mirror of
https://github.com/logos-messaging/logos-chat.git
synced 2026-05-05 20:19:32 +00:00
feat: statically link libchat
liblogoschat.so now embeds liblibchat.a directly. Library paths moved out of nimble tasks into Makefile / Nix, and librln renamed to librlnDrv for consistency.
This commit is contained in:
parent
6fc4c2200a
commit
d9ec677820
22
Makefile
22
Makefile
@ -28,6 +28,13 @@ ifneq (,$(findstring MINGW,$(detected_OS)))
|
||||
detected_OS := Windows
|
||||
endif
|
||||
|
||||
# liblibchat and librln are both Rust staticlibs that embed Rust std,
|
||||
# resulting in duplicate symbol errors at link time. To mitigate that,
|
||||
# --allow-multiple-definition is added.
|
||||
ifeq ($(detected_OS),Linux)
|
||||
LDFLAGS := --passL:-Wl,--allow-multiple-definition
|
||||
endif
|
||||
|
||||
##########
|
||||
## Main ##
|
||||
##########
|
||||
@ -104,7 +111,10 @@ build-libchat:
|
||||
.PHONY: tests
|
||||
tests: | build-waku-librln build-waku-nat build-libchat logos_chat.nims
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim tests $(NIM_PARAMS) logos_chat.nims
|
||||
$(ENV_SCRIPT) nim tests $(NIM_PARAMS) \
|
||||
--passL:vendor/libchat/target/release/liblibchat.a \
|
||||
$(LDFLAGS) \
|
||||
logos_chat.nims
|
||||
|
||||
|
||||
##########
|
||||
@ -114,7 +124,10 @@ tests: | build-waku-librln build-waku-nat build-libchat logos_chat.nims
|
||||
# Ensure there is a nimble task with a name that matches the target
|
||||
tui bot_echo pingpong: | build-waku-librln build-waku-nat build-libchat logos_chat.nims
|
||||
echo -e $(BUILD_MSG) "build/$@" && \
|
||||
$(ENV_SCRIPT) nim $@ $(NIM_PARAMS) --path:src logos_chat.nims
|
||||
$(ENV_SCRIPT) nim $@ $(NIM_PARAMS) \
|
||||
--passL:vendor/libchat/target/release/liblibchat.a \
|
||||
$(LDFLAGS) \
|
||||
--path:src logos_chat.nims
|
||||
|
||||
###########
|
||||
## Library ##
|
||||
@ -134,7 +147,10 @@ LIBLOGOSCHAT := build/liblogoschat.$(LIBLOGOSCHAT_EXT)
|
||||
.PHONY: liblogoschat
|
||||
liblogoschat: | build-waku-librln build-waku-nat build-libchat logos_chat.nims
|
||||
echo -e $(BUILD_MSG) "$(LIBLOGOSCHAT)" && \
|
||||
$(ENV_SCRIPT) nim liblogoschat $(NIM_PARAMS) --path:src logos_chat.nims && \
|
||||
$(ENV_SCRIPT) nim liblogoschat $(NIM_PARAMS) \
|
||||
--passL:vendor/libchat/target/release/liblibchat.a \
|
||||
$(LDFLAGS) \
|
||||
--path:src logos_chat.nims && \
|
||||
echo -e "\n\x1B[92mLibrary built successfully:\x1B[39m" && \
|
||||
echo " $(shell pwd)/$(LIBLOGOSCHAT)"
|
||||
|
||||
|
||||
@ -25,11 +25,11 @@
|
||||
overlays = [ rust-overlay.overlays.default ];
|
||||
};
|
||||
libchatDrv = pkgs.callPackage ./nix/libchat.nix {};
|
||||
librln = pkgs.callPackage ./nix/librln.nix {};
|
||||
librlnDrv = pkgs.callPackage ./nix/librln.nix {};
|
||||
in {
|
||||
packages.default = pkgs.callPackage ./nix/default.nix {
|
||||
src = self;
|
||||
inherit libchatDrv librln;
|
||||
inherit libchatDrv librlnDrv;
|
||||
};
|
||||
devShells.default = pkgs.callPackage ./nix/shell.nix {
|
||||
inherit libchatDrv;
|
||||
|
||||
@ -2,7 +2,7 @@
|
||||
openssl, miniupnpc, libnatpmp,
|
||||
src, # logos-chat source (self from flake, with submodules=1)
|
||||
libchatDrv, # result of libchat.nix
|
||||
librln }: # result of librln.nix
|
||||
librlnDrv }: # result of librln.nix
|
||||
|
||||
# NOTE: this build requires git submodules to be present in src.
|
||||
# When fetching from GitHub use '?submodules=1#', e.g.:
|
||||
@ -14,21 +14,20 @@ assert lib.assertMsg ((src.submodules or false) == true)
|
||||
|
||||
let
|
||||
revision = lib.substring 0 8 (src.rev or "dirty");
|
||||
libExt = if stdenv.isDarwin then "dylib" else "so";
|
||||
libchatPath = "${libchatDrv}/lib/liblibchat.${libExt}";
|
||||
in stdenv.mkDerivation {
|
||||
pname = "liblogoschat";
|
||||
version = "0.1.0";
|
||||
inherit src;
|
||||
|
||||
NIMFLAGS = lib.concatStringsSep " " [
|
||||
"--passL:vendor/nwaku/librln_v0.7.0.a"
|
||||
"--passL:${libchatDrv}/lib/liblibchat.a"
|
||||
"--passL:${librlnDrv}/lib/librln_v0.7.0.a"
|
||||
"--passL:-lm"
|
||||
"-d:miniupnpcUseSystemLibs"
|
||||
"-d:libnatpmpUseSystemLibs"
|
||||
"--passL:-lminiupnpc"
|
||||
"--passL:-lnatpmp"
|
||||
"-d:CONVERSATIONS_LIB:${libchatPath}"
|
||||
(lib.optionalString (!stdenv.isDarwin) "--passL:-Wl,--allow-multiple-definition")
|
||||
"-d:git_version=${revision}"
|
||||
];
|
||||
|
||||
@ -62,8 +61,6 @@ in stdenv.mkDerivation {
|
||||
'';
|
||||
|
||||
preBuild = ''
|
||||
# Place pre-built librln where the Nim linker expects it
|
||||
cp ${librln}/lib/librln_v0.7.0.a vendor/nwaku/librln_v0.7.0.a
|
||||
mkdir -p build
|
||||
'';
|
||||
|
||||
|
||||
@ -10,8 +10,7 @@ in pkgs.mkShell {
|
||||
];
|
||||
|
||||
shellHook = ''
|
||||
export CONVERSATIONS_LIB="${libchatDrv}/lib/liblibchat.${libExt}"
|
||||
echo "logos-chat dev shell. CONVERSATIONS_LIB=$CONVERSATIONS_LIB"
|
||||
echo "logos-chat dev shell."
|
||||
echo "Build: make liblogoschat"
|
||||
echo "Nix build: nix build '.?submodules=1#'"
|
||||
'';
|
||||
|
||||
2
vendor/libchat
vendored
2
vendor/libchat
vendored
@ -1 +1 @@
|
||||
Subproject commit 960bb195a13657a09fa2df66262b3b2ced738f30
|
||||
Subproject commit 681c17ccaecd7a171c46cc96ff61d1d3db7fd7a9
|
||||
Loading…
x
Reference in New Issue
Block a user