getting clang resource dir automagically
weskerfoot opened this issue · 2 comments
weskerfoot commented
Not sure if this is the best method but I did this in order to avoid specifying it manually every time
in yourlib.nim
const clangResourceDir {.strdefine.}: string = "nothing" # defined by config.nims
importc:
sysPath fmt"{clangResourceDir}/include"
path: "/usr/include/libxml2/libxml"
path: "/usr/include/libxml2"
"parser.h"
in config.nims
import system, strformat, strutils
const clangResourceDir = staticExec("clang -print-resource-dir").strip
switch("passL", "/usr/lib/libxml2.so")
switch("d", fmt"clangResourceDir={clangResourceDir}")
Hopefully someone else will find this useful
PMunch commented
PMunch commented
Found a better solution, assuming you have clang in your path callable as clang
you should now be able to simply not have a sysPath
argument.