mirror of
https://github.com/waku-org/nwaku.git
synced 2025-02-24 12:58:35 +00:00
Makefile, waku.nimble: allow the creation of dynamic library, libwaku.so (#1730)
This commit is contained in:
parent
ceb54b1821
commit
d0aa388b39
26
Makefile
26
Makefile
@ -283,25 +283,27 @@ docker-push:
|
||||
################
|
||||
## C Bindings ##
|
||||
################
|
||||
.PHONY: cbindings cwaku_example libwaku.a
|
||||
.PHONY: cbindings cwaku_example libwaku
|
||||
|
||||
libwaku.a: | build deps
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim libwaku $(NIM_PARAMS) $(EXPERIMENTAL_PARAMS) waku.nims
|
||||
STATIC ?= false
|
||||
|
||||
libwaku.so: | build deps
|
||||
# TODO: pending to enhance this part. Kindly use the static approach.
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim c --app:lib --opt:size --noMain --header -o:build/$@ library/cwakunode.nim
|
||||
libwaku: | build deps
|
||||
rm -f build/libwaku*
|
||||
ifeq ($(STATIC), true)
|
||||
echo -e $(BUILD_MSG) "build/$@.a" && \
|
||||
$(ENV_SCRIPT) nim libwakuStatic $(NIM_PARAMS) $(EXPERIMENTAL_PARAMS) waku.nims
|
||||
else
|
||||
echo -e $(BUILD_MSG) "build/$@.so" && \
|
||||
$(ENV_SCRIPT) nim libwakuDynamic $(NIM_PARAMS) $(EXPERIMENTAL_PARAMS) waku.nims
|
||||
endif
|
||||
|
||||
cbindings: | build libwaku.a
|
||||
|
||||
cwaku_example: | build cbindings
|
||||
cwaku_example: | build libwaku
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
cp nimcache/release/libwaku/libwaku.h ./examples/cbindings/ && \
|
||||
cc -o "build/$@" \
|
||||
./examples/cbindings/waku_example.c \
|
||||
-lwaku -Lbuild/ -pthread -ldl -lm \
|
||||
-lwaku -Lbuild/ \
|
||||
-pthread -ldl -lm \
|
||||
-lminiupnpc -Lvendor/nim-nat-traversal/vendor/miniupnp/miniupnpc/build/ \
|
||||
-lnatpmp -Lvendor/nim-nat-traversal/vendor/libnatpmp-upstream/ \
|
||||
vendor/nim-libbacktrace/libbacktrace_wrapper.o \
|
||||
|
16
waku.nimble
16
waku.nimble
@ -34,17 +34,17 @@ proc buildBinary(name: string, srcDir = "./", params = "", lang = "c") =
|
||||
extra_params &= " " & paramStr(i)
|
||||
exec "nim " & lang & " --out:build/" & name & " " & extra_params & " " & srcDir & name & ".nim"
|
||||
|
||||
proc buildLibrary(name: string, srcDir = "./", params = "", lang = "c", isStatic = true) =
|
||||
proc buildLibrary(name: string, srcDir = "./", params = "", `type` = "static") =
|
||||
if not dirExists "build":
|
||||
mkDir "build"
|
||||
# allow something like "nim nimbus --verbosity:0 --hints:off nimbus.nims"
|
||||
var extra_params = params
|
||||
for i in 2..<paramCount():
|
||||
extra_params &= " " & paramStr(i)
|
||||
if isStatic:
|
||||
exec "nim " & lang & " --out:build/" & name & ".a --app:staticlib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
|
||||
if `type` == "static":
|
||||
exec "nim c" & " --out:build/" & name & ".a --app:staticlib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
|
||||
else:
|
||||
exec "nim " & lang & " --out:build/" & name & ".a --app:lib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
|
||||
exec "nim c" & " --out:build/" & name & ".so --app:lib --opt:size --noMain --header " & extra_params & " " & srcDir & name & ".nim"
|
||||
|
||||
proc test(name: string, params = "-d:chronicles_log_level=DEBUG", lang = "c") =
|
||||
# XXX: When running `> NIM_PARAMS="-d:chronicles_log_level=INFO" make test2`
|
||||
@ -100,9 +100,13 @@ task chat2bridge, "Build chat2bridge":
|
||||
buildBinary name, "apps/chat2bridge/", "-d:chronicles_log_level=TRACE"
|
||||
|
||||
### C Bindings
|
||||
task libwaku, "Build the cbindings waku node library":
|
||||
task libwakuStatic, "Build the cbindings waku node library":
|
||||
let name = "libwaku"
|
||||
buildLibrary name, "library/", "-d:chronicles_log_level=ERROR"
|
||||
buildLibrary name, "library/", "-d:chronicles_log_level=ERROR", "static"
|
||||
|
||||
task libwakuDynamic, "Build the cbindings waku node library":
|
||||
let name = "libwaku"
|
||||
buildLibrary name, "library/", "-d:chronicles_log_level=ERROR", "dynamic"
|
||||
|
||||
### Legacy: Whisper & Waku v1 tasks
|
||||
task testwhisper, "Build & run Whisper tests":
|
||||
|
Loading…
x
Reference in New Issue
Block a user