Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
  • Apr 04 2021 12:26
    @dom96 banned @acroobat
  • Mar 03 2017 15:52
    @dom96 banned @Octopoda7
  • Feb 12 2017 23:57
    @dom96 banned @zzz125
  • Dec 23 2016 19:43
    @dom96 banned @Izrab
Kaushal Modi
@kaushalmodi
ok, here's a real example
Timothee Cour
@timotheecour
ok then definitely consider sending a PR to help the next guy, since u got confused :)
Kaushal Modi
@kaushalmodi
# draw/EGGX/eggx.nim
import nimterop/cimport
import macros

# cDisableCaching()
cDebug()

const
  # hDir = currentSourcePath.parentDir()
  hDir = getProjectPath()

cIncludeDir(hDir)
cAddSearchDir(hDir)
cImport(cSearchPath("eggx.h"))
# draw/draw.nim
import EGGX/eggx
the cDebug() from nimterop prints:
{.passC: "-I\"/home/kmodi/sandbox/systemverilog/dpi_c/systemverilog_dpi_now/user-interface/draw\"".}
and I got that same value when I tried getCurrentDir()
Timothee Cour
@timotheecour
getCurrentDir is just current dir (more or less $PWD); getProjectPath is just parentDir(abspath(foo)) where foo is the module in cmd line nim c foo
Kaushal Modi
@kaushalmodi
hmm, thanks, so as I was doing nim c draw.nim while in the draw/ dir, they ended up being the same
need to note this down
Timothee Cour
@timotheecour
(Or, PR :) )
Kaushal Modi
@kaushalmodi
PR where?
Timothee Cour
@timotheecour
under getProjectPath in macros.nim
Kaushal Modi
@kaushalmodi
I need to find a concise way to articulate this
I was unable to explain myself without that dummy /a/b example
Timothee Cour
@timotheecour
best is 1 example where currentdir, getProjectPath and currentSourcePath are all different. then it’s crystal clear.
(WITH the dummy example is best)
Kaushal Modi
@kaushalmodi
ok, will work on it
Timothee Cour
@timotheecour
(or u can help w nimterop :) )
From IRC (bridge bot)
@FromIRC
<shashlick> sorry missed the conversation
<shashlick> so you are having trouble pointing to the source?
Kaushal Modi
@kaushalmodi
shashlick: @timotheecour helped me sort it out
the problem was that I needed that include/search path to stay static to the dir containing that nim file regardless of from where I imported it
From IRC (bridge bot)
@FromIRC
<shashlick> i don't know why you need that cause my tsoloud.nim works fine with relative paths
<shashlick> okay i see - if you import the nim wrapper, it stops working cause you are now elsewhere
Kaushal Modi
@kaushalmodi
that eggx.h has include with <foo.h>
so I need to add the same path to cInclude too
Timothee Cour
@timotheecour
i’m now using abs paths and makes code simpler
From IRC (bridge bot)
@FromIRC
<shashlick> @kaushalmodi - i used sourcepath in the tree-sitter wrapper too - https://github.com/genotrance/nimterop/blob/master/nimterop/treesitter/runtime.nim
Kaushal Modi
@kaushalmodi
shashlick: It's just that I discovered currentSourcePath() today :)
From IRC (bridge bot)
@FromIRC
<shashlick> ya that was a big one even in nimgen days
<shashlick> feel free to join https://gitter.im/nimgen/Lobby to chat about nimterop
Kaushal Modi
@kaushalmodi
will do, thanks
btw can someone point out why that second import line doesn't work? https://ptpb.pw/ObL6/nim
b/bar.nim(2, 31) Error: undeclared identifier: 'currentSourcePath'
Timothee Cour
@timotheecour
because of this:
[0 ] lib/system.nim:3978:10 |template currentSourcePath*: string = instantiationInfo(-1, true).filename
it’s defined in system.nim :)
Kaushal Modi
@kaushalmodi
sorry, I need to sleep it seems
I visited the manual like 5 times, but didn't spot that I was opening system.html
and thank you
Timothee Cour
@timotheecour
np
From IRC (bridge bot)
@FromIRC
<shashlick> how's the actual nim render
<shashlick> with nimterop? is the wrapper working?
Kaushal Modi
@kaushalmodi
@timotheecour a minimal example showing the path differences:
km²~/sandbox/:nim/paths> ls --tree                                                   01/27 11:18pm
./
└── a/
   ├── b/
   │  └── bar.nim
   └── foo.nim
km²~/sandbox/:nim/paths> cat a/foo.nim                                               01/27 11:18pm
import b/bar
km²~/sandbox/:nim/paths> cat a/b/bar.nim                                             01/27 11:18pm
from macros import getProjectPath
from os import getCurrentDir, parentDir # doesn't work

const
  sDir = currentSourcePath.parentDir()
  pDir = getProjectPath()
let
  cDir = getCurrentDir()

echo "Source path = ", sDir
echo "Project path = ", pDir
echo "Current path = ", cDir
shashlick: if that question was for me, I just got that wrapper to compile
now working on translating some C code to Nim in that wrapper
Timothee Cour
@timotheecour
@kaushalmodi please report all issues u encounter in the bug tracker (after checking they’re not dups :)
Kaushal Modi
@kaushalmodi
will send a PR for this to an appropriate place in the manual
(that "doesn't work" in the comment is old, doesn't apply any more)