fix(build): compilation on macos when including nim-nat-traversal (#1084)

* fix(build): compilation on macos when including nim-nat-traversal

- removes the `VERSION` rename to `VERSION_temp` in the Makefile
- instead, relies on `-iqoute` to include the `nim-nat-traversal/vendor/libnatpmp-upstream` directory in the search paths. `-iquote` will match the `vendor/libnatpmp-upstream/VERSION` file for `#include "version"` and not `#include <version>`, the latter being what is included by the macos sdk and was causing issues with `-I`. The [gcc 14.2 docs](https://gcc.gnu.org/onlinedocs/gcc-14.2.0/cpp/Invocation.html#index-I) describe how `-iquote` alleviates this issue:
> Directories specified with -iquote apply only to the quote form of the directive, #include "file". Directories specified with -I, -isystem, or -idirafter apply to lookup for both the #include "file" and #include <file> directives.

For more info, please see https://github.com/status-im/nim-nat-traversal/pull/34.

* bump nim-nat-traversal

Now that https://github.com/status-im/nim-nat-traversal/pull/34 has been merged, change back to master commit
This commit is contained in:
Eric 2025-02-06 17:18:00 -08:00 committed by GitHub
parent 17d3f99f45
commit dfa90a9981
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 22 deletions

View File

@ -2,24 +2,8 @@ mode = ScriptMode.Verbose
import std/os except commandLineParams import std/os except commandLineParams
const VendorPath = "vendor/nim-nat-traversal/vendor/libnatpmp-upstream"
let
oldVersionFile = joinPath(VendorPath, "VERSION")
newVersionFile = joinPath(VendorPath, "VERSION_temp")
proc renameFile(oldName, newName: string) =
if fileExists(oldName):
mvFile(oldName, newName)
else:
echo "File ", oldName, " does not exist"
### Helper functions ### Helper functions
proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") = proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
# This is a quick workaround to avoid VERSION file conflict on macOS
# More details here: https://github.com/codex-storage/nim-codex/issues/1059
if defined(macosx):
renameFile(oldVersionFile, newVersionFile)
if not dirExists "build": if not dirExists "build":
mkDir "build" mkDir "build"
@ -37,11 +21,8 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
# Place build output in 'build' folder, even if name includes a longer path. # Place build output in 'build' folder, even if name includes a longer path.
outName = os.lastPathPart(name) outName = os.lastPathPart(name)
cmd = "nim " & lang & " --out:build/" & outName & " " & extra_params & " " & srcDir & name & ".nim" cmd = "nim " & lang & " --out:build/" & outName & " " & extra_params & " " & srcDir & name & ".nim"
try:
exec(cmd) exec(cmd)
finally:
if defined(macosx):
renameFile(newVersionFile, oldVersionFile)
proc test(name: string, srcDir = "tests/", params = "", lang = "c") = proc test(name: string, srcDir = "tests/", params = "", lang = "c") =
buildBinary name, srcDir, params buildBinary name, srcDir, params

@ -1 +1 @@
Subproject commit 5e4059746e9095e1731b02eeaecd62a70fbe664d Subproject commit 6508ce75060878dfcdfa21f94721672c69a1823b