mirror of
https://github.com/logos-storage/nim-libplum.git
synced 2026-07-24 00:03:11 +00:00
Use {.compile.} to compile libplum as part of tha package; remove separate build task.
This commit is contained in:
parent
270ff7157d
commit
2d2c48714c
@ -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()
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user