import std/os
when defined(debug):
const rttDir = currentSourcePath().parentDir()
static:
echo "A: " & currentSourcePath()
echo "B: " & $currentSourcePath().splitPath()
echo "C: " & currentSourcePath().parentDir()
echo "D: " & rttDir
{.localPassC: "-I" & (rttDir / "RTT").}
{.localPassC: "-I" & (rttDir / "Config").}
{.compile: rttDir / "RTT" / "SEGGER_RTT.c".}
{.compile: rttDir / "RTT" / "SEGGER_RTT_printf.c".}
I first tried passing a relative path to the .localPassC pragma. But because the Nim compiler was targeting myproj, a path relative to the submodule was incorrect for the "-I" argument. Now, in the code above you see me trying to build an absolute path to give to -I.
The C files compile successfully, but I'm getting "No such file or directory" for the header files.
The output of the snippet above is:
A: d:\folder\myproj\deps\krnl\src\krnlpkg\debug_rtt.nim
B: (head: "", tail: "d:\\folder\\myproj\\deps\\krnl\\src\\krnlpkg\\debug_rtt.nim")
C:
D: .
This is where I'm stuck. Is this due to os=any? Is it the correct approach to try to build the absolute address for the -I argument? Is there a better way?
thanks,
!!Dean
Yeah likely due to --os:any? There was some discussion on Discord a while back about this sort of issue where the compile time env != runtime env.
If you do --verbosity:3 Nim compiler will print out the C compiler commands it's using as well.
splitPath uses the DirSep const.
Probably the quickest is to do your own "splitPath", but there may be some way to set the os of the compile time VM differently than the runtime.