diff --git a/libplum.nimble b/libplum.nimble index e5c81f6..6744764 100644 --- a/libplum.nimble +++ b/libplum.nimble @@ -1,5 +1,3 @@ -import std/[os, strutils] - mode = ScriptMode.Verbose packageName = "libplum" @@ -15,33 +13,10 @@ requires "nim >= 1.6.0", "chronos >= 4.2.0 & < 5.0.0", "unittest2" -proc compileStaticLibraries() = - let - cflags = "-std=c11 -O2 -pthread -fPIC -fvisibility=hidden -DPLUM_EXPORTS -DPLUM_STATIC -DRELEASE=1 -D_GNU_SOURCE" - includes = "-Iinclude/plum -Isrc" - - withDir "vendor/libplum": - let winFlags = - if defined(windows): " -DWIN32_LEAN_AND_MEAN" - else: "" - var oFiles: seq[string] - - for srcFile in listFiles("src"): - if srcFile.endsWith(".c"): - let oFile = srcFile.changeFileExt("o") - exec "gcc " & cflags & winFlags & " " & includes & " -c " & srcFile & " -o " & oFile - oFiles.add(oFile) - - exec "ar rcs libplum.a " & oFiles.join(" ") - task format, "format Nim code using nph": exec "nph libplum/ tests/" -task buildBundledLibs, "build bundled libraries": - compileStaticLibraries() - task test, "run tests": - compileStaticLibraries() exec("nimble setup") exec("nim c -o:tests/test_plum tests/test_plum.nim") exec("./tests/test_plum") @@ -55,6 +30,3 @@ task testIntegration, "run miniupnpd integration tests in Docker / Podman": exec(docker & " run --rm --cap-add=NET_ADMIN -e TEST_MINIUPNP_PCP=1" & flags & " " & packageName) exec(docker & " run --rm --cap-add=NET_ADMIN -e TEST_MINIUPNP_UPNP=1" & flags & " " & packageName) exec(docker & " run --rm --cap-add=NET_ADMIN -e TEST_MINIUPNP_NATPMP=1" & flags & " " & packageName) - -before install: - compileStaticLibraries() diff --git a/libplum/libplum.nim b/libplum/libplum.nim index 9c3457e..3b5fcb8 100644 --- a/libplum/libplum.nim +++ b/libplum/libplum.nim @@ -12,15 +12,34 @@ const rootPath = currentSourcePath.parentDir().parentDir().replace('\\', '/') libplumPath = rootPath & "/vendor/libplum" includePath = libplumPath & "/include/plum" - libraryPath = libplumPath & "/libplum.a" -{.passc: "-I" & includePath & " -DPLUM_STATIC".} -{.passl: libraryPath.} + srcPath = libplumPath & "/src" + +{.passc: "-I" & quoteShell(includePath) & " -I" & quoteShell(srcPath) & + " -DPLUM_STATIC -DPLUM_EXPORTS -DRELEASE=1 -D_GNU_SOURCE".} when defined(windows): + {.passc: "-DWIN32_LEAN_AND_MEAN".} {.passl: "-lws2_32 -liphlpapi -lbcrypt".} else: {.passl: "-lpthread".} +{.compile: srcPath & "/addr.c".} +{.compile: srcPath & "/client.c".} +{.compile: srcPath & "/dummytls.c".} +{.compile: srcPath & "/http.c".} +{.compile: srcPath & "/log.c".} +{.compile: srcPath & "/natpmp.c".} +{.compile: srcPath & "/net.c".} +{.compile: srcPath & "/noprotocol.c".} +{.compile: srcPath & "/pcp.c".} +{.compile: srcPath & "/plum.c".} +{.compile: srcPath & "/random.c".} +{.compile: srcPath & "/tcp.c".} +{.compile: srcPath & "/timestamp.c".} +{.compile: srcPath & "/udp.c".} +{.compile: srcPath & "/upnp.c".} +{.compile: srcPath & "/util.c".} + const PLUM_ERR_SUCCESS* = cint(0) PLUM_ERR_INVALID* = cint(-1)