diff options
| author | Ganesh Viswanathan <dev@genotrance.com> | 2019-10-15 23:04:23 -0500 |
|---|---|---|
| committer | Ganesh Viswanathan <dev@genotrance.com> | 2019-10-15 23:04:23 -0500 |
| commit | c40b25d2a29c467121b515739b5f67f9c7774927 (patch) | |
| tree | 2e7b2f0b33ffa8a5717e9747fc5d78efc3d235a7 | |
| parent | f4d863d3ddb8ac8b6295476d33351e8db0e4d90a (diff) | |
| download | nimterop-c40b25d2a29c467121b515739b5f67f9c7774927.tar.gz nimterop-c40b25d2a29c467121b515739b5f67f9c7774927.zip | |
Fix altNames behavior
| -rw-r--r-- | nimterop/build.nim | 13 | ||||
| -rw-r--r-- | tests/zlib.nim | 2 |
2 files changed, 9 insertions, 6 deletions
diff --git a/nimterop/build.nim b/nimterop/build.nim index 49bc15d..72f80b9 100644 --- a/nimterop/build.nim +++ b/nimterop/build.nim @@ -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 diff --git a/tests/zlib.nim b/tests/zlib.nim index 572580c..036b50c 100644 --- a/tests/zlib.nim +++ b/tests/zlib.nim @@ -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: |
