Multiple getHeader, linkLibs name fix

This commit is contained in:
Ganesh Viswanathan 2020-08-02 22:20:04 -05:00
commit 11814811e3
3 changed files with 16 additions and 9 deletions

View file

@ -366,6 +366,7 @@ macro getHeader*(
staticStr = name & "Static" staticStr = name & "Static"
verStr = name & "SetVer" verStr = name & "SetVer"
getPath = name & "GetPath"
# Ident nodes of the -d:xxx to check in when statements # Ident nodes of the -d:xxx to check in when statements
nameStd = newIdentNode(stdStr) nameStd = newIdentNode(stdStr)
@ -375,6 +376,7 @@ macro getHeader*(
nameJBB = newIdentNode(jbbStr) nameJBB = newIdentNode(jbbStr)
nameStatic = newIdentNode(staticStr) nameStatic = newIdentNode(staticStr)
nameGetPath = newIdentNode(getPath)
# Consts to generate # Consts to generate
path = newIdentNode(name & "Path") path = newIdentNode(name & "Path")
@ -421,7 +423,7 @@ macro getHeader*(
`nameStatic`* = when defined(`nameStatic`): true else: `staticVal` == 1 `nameStatic`* = when defined(`nameStatic`): true else: `staticVal` == 1
# Search for header in outdir (after retrieving code) depending on -d:xxx mode # Search for header in outdir (after retrieving code) depending on -d:xxx mode
proc getPath(header, giturl, dlurl, conanuri, conanFlags, jbburi, jbbFlags, proc `nameGetPath`(header, giturl, dlurl, conanuri, conanFlags, jbburi, jbbFlags,
outdir, version: string, shared: bool): string = outdir, version: string, shared: bool): string =
when `nameGit`: when `nameGit`:
getGitPath(header, giturl, outdir, version) getGitPath(header, giturl, outdir, version)
@ -461,7 +463,7 @@ macro getHeader*(
when useStd: when useStd:
stdPath stdPath
else: else:
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `conanFlags`, `jbburi`, `jbbFlags`, `nameGetPath`(`header`, `giturl`, `dlurl`, `conanuri`, `conanFlags`, `jbburi`, `jbbFlags`,
`outdir`, `version`, not `nameStatic`) `outdir`, `version`, not `nameStatic`)
# Run preBuild hook before building library if not Std, Conan or JBB # Run preBuild hook before building library if not Std, Conan or JBB
@ -497,7 +499,7 @@ macro getHeader*(
if prePath.len != 0: if prePath.len != 0:
prePath prePath
else: else:
getPath(`header`, `giturl`, `dlurl`, `conanuri`, `conanFlags`, `jbburi`, `jbbFlags`, `nameGetPath`(`header`, `giturl`, `dlurl`, `conanuri`, `conanFlags`, `jbburi`, `jbbFlags`,
`outdir`, `version`, not `nameStatic`) `outdir`, `version`, not `nameStatic`)
static: static:

View file

@ -481,14 +481,19 @@ proc linkLibs*(names: openArray[string], staticLink = true): string =
var var
stat = if staticLink: "--static" else: "" stat = if staticLink: "--static" else: ""
resSet: OrderedSet[string] resSet: OrderedSet[string]
cmd = &"pkg-config --libs --silence-errors {stat}"
resSet.init() resSet.init()
for name in names: for name in names:
let for n in ["lib" & name, name]:
cmd = &"pkg-config --libs --silence-errors {stat} lib{name}" # Try libname and name - e.g. MagickWand doesn't have lib
(libs, _) = execAction(cmd, die = false) let
for lib in libs.split(" "): cmd = &"{cmd} {n}"
resSet.incl lib (libs, _) = execAction(cmd, die = false)
if libs.len != 0:
for lib in libs.split(" "):
resSet.incl lib
break
if staticLink: if staticLink:
resSet.incl "--static" resSet.incl "--static"

View file

@ -633,7 +633,7 @@ iterator newIdentDefs(gState: State, name: string, node: TSNode, offset: SomeInt
yield result yield result
else: else:
for i in start+1 ..< node.len: for i in start+1 ..< node.len:
if node[i].getName() == "bitfield_clause": if node[i].getName() in ["bitfield_clause", "comment"]:
continue continue
yield gState.newIdentDef(name, node, tname, tinfo, tident, start, i, offset, exported) yield gState.newIdentDef(name, node, tname, tinfo, tident, start, i, offset, exported)