mirror of
https://github.com/logos-messaging/nim-sds.git
synced 2026-01-08 00:53:13 +00:00
Makefile and sds.nimble adaptation to ensure all lib ext are covered
This commit is contained in:
parent
c82dad828a
commit
5a577a4d5c
25
Makefile
25
Makefile
@ -65,27 +65,20 @@ detected_OS := $(shell uname -s)
|
|||||||
endif
|
endif
|
||||||
|
|
||||||
BUILD_COMMAND ?= libsdsDynamic
|
BUILD_COMMAND ?= libsdsDynamic
|
||||||
|
|
||||||
ifeq ($(detected_OS),Windows)
|
|
||||||
LIB_EXT_DYNAMIC = dll
|
|
||||||
LIB_EXT_STATIC = lib
|
|
||||||
else ifeq ($(detected_OS),Darwin)
|
|
||||||
LIB_EXT_DYNAMIC = dylib
|
|
||||||
LIB_EXT_STATIC = a
|
|
||||||
else ifeq ($(detected_OS),Linux)
|
|
||||||
LIB_EXT_DYNAMIC = so
|
|
||||||
LIB_EXT_STATIC = a
|
|
||||||
endif
|
|
||||||
|
|
||||||
LIB_EXT := $(LIB_EXT_DYNAMIC)
|
|
||||||
|
|
||||||
ifeq ($(STATIC), 1)
|
ifeq ($(STATIC), 1)
|
||||||
LIB_EXT = $(LIB_EXT_STATIC)
|
|
||||||
BUILD_COMMAND = libsdsStatic
|
BUILD_COMMAND = libsdsStatic
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(detected_OS),Windows)
|
||||||
|
BUILD_COMMAND := $(BUILD_COMMAND)Windows
|
||||||
|
else ifeq ($(detected_OS),Darwin)
|
||||||
|
BUILD_COMMAND := $(BUILD_COMMAND)Mac
|
||||||
|
else ifeq ($(detected_OS),Linux)
|
||||||
|
BUILD_COMMAND := $(BUILD_COMMAND)Linux
|
||||||
|
endif
|
||||||
|
|
||||||
libsds: | deps
|
libsds: | deps
|
||||||
echo -e $(BUILD_MSG) "build/$@.$(LIB_EXT)" && $(ENV_SCRIPT) nim $(BUILD_COMMAND) $(NIM_PARAMS) sds.nims
|
$(ENV_SCRIPT) nim $(BUILD_COMMAND) $(NIM_PARAMS) sds.nims
|
||||||
|
|
||||||
#####################
|
#####################
|
||||||
## Mobile Bindings ##
|
## Mobile Bindings ##
|
||||||
|
|||||||
64
sds.nimble
64
sds.nimble
@ -11,7 +11,13 @@ srcDir = "src"
|
|||||||
requires "nim >= 2.2.4",
|
requires "nim >= 2.2.4",
|
||||||
"chronicles", "chronos", "stew", "stint", "metrics", "libp2p", "results"
|
"chronicles", "chronos", "stew", "stint", "metrics", "libp2p", "results"
|
||||||
|
|
||||||
proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
|
proc buildLibrary(
|
||||||
|
outLibNameAndExt: string,
|
||||||
|
name: string,
|
||||||
|
srcDir = "./",
|
||||||
|
params = "",
|
||||||
|
`type` = "static",
|
||||||
|
) =
|
||||||
if not dirExists "build":
|
if not dirExists "build":
|
||||||
mkDir "build"
|
mkDir "build"
|
||||||
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
||||||
@ -19,17 +25,16 @@ proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
|
|||||||
for i in 2 ..< paramCount():
|
for i in 2 ..< paramCount():
|
||||||
extra_params &= " " & paramStr(i)
|
extra_params &= " " & paramStr(i)
|
||||||
if `type` == "static":
|
if `type` == "static":
|
||||||
exec "nim c" & " --out:build/" & name &
|
exec "nim c" & " --out:build/" & outLibNameAndExt &
|
||||||
".a --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " &
|
" --threads:on --app:staticlib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " &
|
||||||
extra_params & " " & srcDir & name & ".nim"
|
extra_params & " " & srcDir & name & ".nim"
|
||||||
else:
|
else:
|
||||||
let lib_name = (when defined(windows): toDll(name) else: name & ".so")
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
exec "nim c" & " --out:build/" & lib_name &
|
exec "nim c" & " --out:build/" & outLibNameAndExt &
|
||||||
" --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:off " &
|
" --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:off " &
|
||||||
extra_params & " " & srcDir & name & ".nim"
|
extra_params & " " & srcDir & name & ".nim"
|
||||||
else:
|
else:
|
||||||
exec "nim c" & " --out:build/" & lib_name &
|
exec "nim c" & " --out:build/" & outLibNameAndExt &
|
||||||
" --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " &
|
" --threads:on --app:lib --opt:size --noMain --mm:refc --header --nimMainPrefix:libsds --skipParentCfg:on " &
|
||||||
extra_params & " " & srcDir & name & ".nim"
|
extra_params & " " & srcDir & name & ".nim"
|
||||||
|
|
||||||
@ -38,13 +43,54 @@ task test, "Run the test suite":
|
|||||||
exec "nim c -r tests/test_bloom.nim"
|
exec "nim c -r tests/test_bloom.nim"
|
||||||
exec "nim c -r tests/test_reliability.nim"
|
exec "nim c -r tests/test_reliability.nim"
|
||||||
|
|
||||||
task libsdsDynamic, "Generate bindings":
|
task libsdsDynamicWindows, "Generate bindings":
|
||||||
|
let outLibNameAndExt = "libsds.dll"
|
||||||
let name = "libsds"
|
let name = "libsds"
|
||||||
buildLibrary name,
|
buildLibrary outLibNameAndExt,
|
||||||
"library/",
|
name, "library/",
|
||||||
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
"dynamic"
|
"dynamic"
|
||||||
|
|
||||||
|
task libsdsDynamicLinux, "Generate bindings":
|
||||||
|
let outLibNameAndExt = "libsds.so"
|
||||||
|
let name = "libsds"
|
||||||
|
buildLibrary outLibNameAndExt,
|
||||||
|
name, "library/",
|
||||||
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
|
"dynamic"
|
||||||
|
|
||||||
|
task libsdsDynamicMac, "Generate bindings":
|
||||||
|
let outLibNameAndExt = "libsds.dylib"
|
||||||
|
let name = "libsds"
|
||||||
|
buildLibrary outLibNameAndExt,
|
||||||
|
name, "library/",
|
||||||
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
|
"dynamic"
|
||||||
|
|
||||||
|
task libsdsStaticWindows, "Generate bindings":
|
||||||
|
let outLibNameAndExt = "libsds.lib"
|
||||||
|
let name = "libsds"
|
||||||
|
buildLibrary outLibNameAndExt,
|
||||||
|
name, "library/",
|
||||||
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
|
"static"
|
||||||
|
|
||||||
|
task libsdsStaticLinux, "Generate bindings":
|
||||||
|
let outLibNameAndExt = "libsds.a"
|
||||||
|
let name = "libsds"
|
||||||
|
buildLibrary outLibNameAndExt,
|
||||||
|
name, "library/",
|
||||||
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
|
"static"
|
||||||
|
|
||||||
|
task libsdsStaticMac, "Generate bindings":
|
||||||
|
let outLibNameAndExt = "libsds.a"
|
||||||
|
let name = "libsds"
|
||||||
|
buildLibrary outLibNameAndExt,
|
||||||
|
name, "library/",
|
||||||
|
"""-d:chronicles_line_numbers --warning:Deprecated:off --warning:UnusedImport:on -d:chronicles_log_level=TRACE """,
|
||||||
|
"static"
|
||||||
|
|
||||||
### Mobile Android
|
### Mobile Android
|
||||||
proc buildMobileAndroid(srcDir = ".", params = "") =
|
proc buildMobileAndroid(srcDir = ".", params = "") =
|
||||||
let cpu = getEnv("CPU")
|
let cpu = getEnv("CPU")
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user