Giter Club home page Giter Club logo

Comments (7)

kaushalmodi avatar kaushalmodi commented on May 23, 2024

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.

zedeus avatar zedeus commented on May 23, 2024

Try setting the search path to the include path using cAddSearchDir, then use cImport(cSearchPath("svdpi.h")) to import

from nimterop.

genotrance avatar genotrance commented on May 23, 2024

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.

kaushalmodi avatar kaushalmodi commented on May 23, 2024

@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.

kaushalmodi avatar kaushalmodi commented on May 23, 2024

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.

genotrance avatar genotrance commented on May 23, 2024

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.

kaushalmodi avatar kaushalmodi commented on May 23, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.