Comments (7)
Also adding --passC:-I/cad/adi/apps/cadence/xlm/linux/current/tools/include
directly to the nim c ..
command doesn't make any difference. But the needed .h files are definitely in that directory, albeit as symlinks.
from nimterop.
Try setting the search path to the include path using cAddSearchDir
, then use cImport(cSearchPath("svdpi.h"))
to import
from nimterop.
cIncludeDir() only forwards to gcc, it isn't used by nimterop itself.
See #7 for some details.
Please confirm that @zestyr's solution works.
from nimterop.
@zestyr thank you!
This worked:
import nimterop/cimport
import os
# cDebug()
# Below manual definition of s_vpi_vecval is a workaround for
# https://github.com/genotrance/nimterop/issues/47.
type
s_vpi_vecval* {.importc: "s_vpi_vecval".} = object
aval: uint32
bval: uint32
const
xlmIncludePath = getEnv("XCELIUM_ROOT") / ".." / "include"
static:
doAssert fileExists(xlmIncludePath / "svdpi.h")
doAssert fileExists(xlmIncludePath / "svdpi_compatibility.h")
# Below works
cAddSearchDir(xlmIncludePath)
cImport(cSearchPath("svdpi.h"))
# https://github.com/genotrance/nimterop/issues/48
# Below doesn't work
# cIncludeDir(xlmIncludePath)
# cImport("svdpi.h")
Any idea why cIncludeDir
wouldn't work? i.e. why wouldn't gcc find the svdpi.h at that path even though those doAsserts pass?
from nimterop.
I think that the issue is probably that the assert
in the findPath
in cimport causes the fail because the gcc
command runs:
proc findPath(path: string, fail = true): string =
# Relative to project path
result = joinPathIfRel(getProjectPath(), path).replace("\\", "/")
echo "debug = " & result # I added this debug
if not fileExists(result) and not dirExists(result):
doAssert (not fail), "File or directory not found: " & path
result = ""
Above debug statement prints:
debug = /home/kmodi/sandbox/systemverilog/dpi_c/nim_svdpi_import_export/svdpi.h
The svdpi.h
of course is not in the current directory .. it's in the directory I set using cIncludePath
.
From cDebug()
, I get:
{.passC: "-I"/cad/adi/apps/cadence/xlm/linux/18.03-s06/tools/include"".}
.. and svdpi.h
does exist in that path.
So looks like the assertion is kicking too soon? .. not sure ..
from nimterop.
Again - cIncludeDir()
is only used to send -Ixyz
directives to gcc
. It is not used by nimterop to find files. Even gcc
only uses -I
to search for files included in the file being processed but expects a full path to the file.
You need to use cAddSearchDir()
and cSearchPath()
lik you have to do this. This was explicitly requested by @timotheecour where originally cIncludeDir()
was shared.
We can think about it again but it was separated out so that you don't confuse nimterop paths with gcc.
from nimterop.
You need to use cAddSearchDir() and cSearchPath() lik you have to do this. This was explicitly requested by @timotheecour where originally cIncludeDir() was shared.
Thanks! Closing this issue then.
from nimterop.
Related Issues (20)
- Parsing a global variable that's a pointer to an array of functions
- Structs mapped from C header need completeStruct pragma, otherwise sizeof doesn't work on those
- VM does not support 'cast' from tyFloat to tyFloat HOT 2
- [Question] Change build directory HOT 1
- Toast parsing comment as var HOT 4
- Inject code to process `#define`? HOT 8
- Building Failed with nimble. HOT 2
- [Question] Binding to OpenCV HOT 2
- Using nimterop in MSYS2 Bash environment on Windows HOT 3
- Header path handling on Windows HOT 3
- βuint16_t β What happened?
- Typedef function with an enum return type
- Support OpenBSD
- The nimterop good this reference documentation to convert small C project
- [Question] Nimterop, libnx and DevKitPro | sys/lock.h : No such file or directory HOT 1
- "cmd: not found" when building using mingw building a windows executable in linux
- ssing comma in the example
- Toast segfault with comment after define
- Build fails due to `macro getHeader` Implementation
- Documentation
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nimterop.