Fix altNames behavior

This commit is contained in:
Ganesh Viswanathan 2019-10-15 23:04:23 -05:00
commit c40b25d2a2
2 changed files with 9 additions and 6 deletions

View file

@ -855,8 +855,13 @@ macro getHeader*(header: static[string], giturl: static[string] = "", dlurl: sta
## `cmake` and `make` in case additional configuration is required as part of the build process.
##
## `altNames` is a list of alternate names for the library - e.g. zlib uses `zlib.h` for the header but
## the typical lib name is `libz.so` and not `libzlib.so`. In this case, `altNames = "z"`. Comma
## separate for multiple alternate names.
## the typical lib name is `libz.so` and not `libzlib.so`. However, it is libzlib.dll on Windows if built
## with cmake. In this case, `altNames = "z,zlib"`. Comma separate for multiple alternate names without
## spaces.
##
## The original header name is not included by default if `altNames` is set since it could cause the
## wrong lib to be selected. E.g. `SDL2/SDL.h` could pick `libSDL.so` even if `altNames = "SDL2"`.
## Explicitly include it in `altNames` like the `zlib` example when required.
##
## `xxxPreBuild` is a hook that is called after the source code is pulled from Git or downloaded but
## before the library is built. This might be needed if some initial prep needs to be done before
@ -902,9 +907,7 @@ macro getHeader*(header: static[string], giturl: static[string] = "", dlurl: sta
""
if altNames.len != 0:
let
names = "(" & name & "|" & altNames.replace(",", "|") & ")"
lre = lre % names
lre = lre % ("(" & altNames.replace(",", "|") & ")")
else:
lre = lre % name

View file

@ -29,7 +29,7 @@ getHeader(
giturl = "https://github.com/madler/zlib",
dlurl = "http://zlib.net/zlib-$1.tar.gz",
outdir = baseDir,
altNames = "z"
altNames = "z,zlib"
)
cPlugin: