Add linkLibs and isDefined
This commit is contained in:
parent
c21a334ec1
commit
f2a0d4b0c9
1 changed files with 35 additions and 1 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import macros, osproc, strformat, strutils, tables
|
import macros, osproc, sets, strformat, strutils, tables
|
||||||
|
|
||||||
import os except findExe, sleep
|
import os except findExe, sleep
|
||||||
|
|
||||||
|
|
@ -322,6 +322,28 @@ proc flagBuild*(base: string, flags: openArray[string]): string =
|
||||||
for i in flags:
|
for i in flags:
|
||||||
result &= " " & base % i
|
result &= " " & base % i
|
||||||
|
|
||||||
|
proc linkLibs*(names: openArray[string], staticLink = true): string =
|
||||||
|
## Create linker flags for specified libraries
|
||||||
|
##
|
||||||
|
## Prepends `lib` to the name so you only need `ssl` for `libssl`.
|
||||||
|
var
|
||||||
|
stat = if staticLink: "--static" else: ""
|
||||||
|
resSet: OrderedSet[string]
|
||||||
|
resSet.init()
|
||||||
|
|
||||||
|
for name in names:
|
||||||
|
let
|
||||||
|
cmd = &"pkg-config --libs --silence-errors {stat} lib{name}"
|
||||||
|
libs = gorge(cmd)
|
||||||
|
for lib in libs.split(" "):
|
||||||
|
resSet.incl lib
|
||||||
|
|
||||||
|
if staticLink:
|
||||||
|
resSet.incl "--static"
|
||||||
|
|
||||||
|
for res in resSet:
|
||||||
|
result &= " " & res
|
||||||
|
|
||||||
proc configure*(path, check: string, flags = "") =
|
proc configure*(path, check: string, flags = "") =
|
||||||
## Run the GNU `configure` command to generate all Makefiles or other
|
## Run the GNU `configure` command to generate all Makefiles or other
|
||||||
## build scripts in the specified path
|
## build scripts in the specified path
|
||||||
|
|
@ -737,6 +759,18 @@ macro clearDefines*(): untyped =
|
||||||
## Clear all defines set using `setDefines()`.
|
## Clear all defines set using `setDefines()`.
|
||||||
gDefines.clear()
|
gDefines.clear()
|
||||||
|
|
||||||
|
macro isDefined*(def: untyped): untyped =
|
||||||
|
## Check if `-d:xxx` is set globally or via `setDefines()`
|
||||||
|
let
|
||||||
|
sdef = gDefines.hasKey(def.strVal())
|
||||||
|
result = newNimNode(nnkStmtList)
|
||||||
|
result.add(quote do:
|
||||||
|
when defined(`def`) or `sdef` != 0:
|
||||||
|
true
|
||||||
|
else:
|
||||||
|
false
|
||||||
|
)
|
||||||
|
|
||||||
macro getHeader*(header: static[string], giturl: static[string] = "", dlurl: static[string] = "", outdir: static[string] = "",
|
macro getHeader*(header: static[string], giturl: static[string] = "", dlurl: static[string] = "", outdir: static[string] = "",
|
||||||
conFlags: static[string] = "", cmakeFlags: static[string] = "", makeFlags: static[string] = "",
|
conFlags: static[string] = "", cmakeFlags: static[string] = "", makeFlags: static[string] = "",
|
||||||
altNames: static[string] = ""): untyped =
|
altNames: static[string] = ""): untyped =
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue