From 2a99a5235bd334038f0e7fca5b48a03456c2d2ac Mon Sep 17 00:00:00 2001 From: Avently <7953703+avently@users.noreply.github.com> Date: Fri, 13 Dec 2024 19:57:06 +0700 Subject: [PATCH] changes --- packages/simplex-chat-nodejs/binding.gyp | 5 +++-- packages/simplex-chat-nodejs/package.json | 22 +++++++++++++++++----- scripts/desktop/build-lib-linux.sh | 15 ++++++++------- scripts/desktop/build-lib-mac.sh | 5 +++-- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/packages/simplex-chat-nodejs/binding.gyp b/packages/simplex-chat-nodejs/binding.gyp index e24863d7a8..151e4c862a 100644 --- a/packages/simplex-chat-nodejs/binding.gyp +++ b/packages/simplex-chat-nodejs/binding.gyp @@ -4,9 +4,10 @@ "target_name": "addon", "sources": [ "cpp/simplex.cc" ], "libraries": [ + "-Wl,-rpath,libs", + "-L<(module_root_dir)/build/Release/", "-L<(module_root_dir)/libs", - "-lHSsimplex-chat-6.2.0.5-inplace-ghc9.6.3", - "-L<(module_root_dir)/build/Release/" + "-lsimplex" ] } ] diff --git a/packages/simplex-chat-nodejs/package.json b/packages/simplex-chat-nodejs/package.json index 86daf44c1f..17595409cd 100644 --- a/packages/simplex-chat-nodejs/package.json +++ b/packages/simplex-chat-nodejs/package.json @@ -3,17 +3,29 @@ "version": "1.0.0", "main": "src/index.js", "scripts": { + "install-tools": "npm install -g node-gyp", + "configure": "node-gyp configure", + "rebuild": "node-gyp rebuild", + "build": "node-gyp build", + "run": "node src/index.js", + "build-run": "node-gyp build && node src/index.js", "test": "echo \"Error: no test specified\" && exit 1" }, "repository": { "type": "git", - "url": "git+https://github.com/simplex-chat/simplexjs.git" + "url": "git+https://github.com/simplex-chat/simplex-chat.git" }, - "author": "SimpleX team", - "license": "ISC", + "keywords": [ + "messenger", + "chat", + "privacy", + "security" + ], + "author": "SimpleX Chat", + "license": "AGPL-3.0", "bugs": { - "url": "https://github.com/simplex-chat/simplexjs/issues" + "url": "https://github.com/simplex-chat/simplex-chat/issues" }, - "homepage": "https://github.com/simplex-chat/simplexjs#readme", + "homepage": "https://github.com/simplex-chat/simplex-chat/packages/simplex-chat-nodejs#readme", "description": "" } diff --git a/scripts/desktop/build-lib-linux.sh b/scripts/desktop/build-lib-linux.sh index 80ae9fa82e..bdd46afcd2 100755 --- a/scripts/desktop/build-lib-linux.sh +++ b/scripts/desktop/build-lib-linux.sh @@ -24,18 +24,19 @@ exports=( $(sed 's/foreign export ccall "chat_migrate_init_key"//' src/Simplex/C for elem in "${exports[@]}"; do count=$(grep -R "$elem$" libsimplex.dll.def | wc -l); if [ $count -ne 1 ]; then echo Wrong exports in libsimplex.dll.def. Add \"$elem\" to that file; exit 1; fi ; done for elem in "${exports[@]}"; do count=$(grep -R "\"$elem\"" flake.nix | wc -l); if [ $count -ne 2 ]; then echo Wrong exports in flake.nix. Add \"$elem\" in two places of the file; exit 1; fi ; done -rm -rf $BUILD_DIR -cabal build lib:simplex-chat --ghc-options='-optl-Wl,-rpath,$ORIGIN -flink-rts -threaded' --constraint 'simplexmq +client_library' +#rm -rf $BUILD_DIR +cabal build lib:simplex-chat --ghc-options='-optl-Wl,-rpath,$ORIGIN -optl-Wl,-soname,libsimplex.so -flink-rts -threaded' --constraint 'simplexmq +client_library' cd $BUILD_DIR/build -#patchelf --add-needed libHSrts_thr-ghc${GHC_VERSION}.so libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so -#patchelf --add-rpath '$ORIGIN' libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so +mv libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so libsimplex.so 2> /dev/null || true +#patchelf --add-needed libHSrts_thr-ghc${GHC_VERSION}.so libsimplex.so +#patchelf --add-rpath '$ORIGIN' libsimplex.so # GitHub's Ubuntu 20.04 runner started to set libffi.so.7 as a dependency while Ubuntu 20.04 on user's devices may not have it # but libffi.so.8 is shipped as an external library with other libs -patchelf --replace-needed "libffi.so.7" "libffi.so.8" libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so +patchelf --replace-needed "libffi.so.7" "libffi.so.8" libsimplex.so mkdir deps 2> /dev/null || true -ldd libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so | grep "ghc" | cut -d' ' -f 3 | xargs -I {} cp {} ./deps/ +ldd libsimplex.so | grep "ghc" | cut -d' ' -f 3 | xargs -I {} cp {} ./deps/ cd - @@ -44,7 +45,7 @@ rm -rf apps/multiplatform/desktop/build/cmake mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ cp -r $BUILD_DIR/build/deps/* apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ -cp $BUILD_DIR/build/libHSsimplex-chat-*-inplace-ghc${GHC_VERSION}.so apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ +cp $BUILD_DIR/build/libsimplex.so apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ scripts/desktop/prepare-vlc-linux.sh links_dir=apps/multiplatform/build/links diff --git a/scripts/desktop/build-lib-mac.sh b/scripts/desktop/build-lib-mac.sh index 070257ea5f..484d691613 100755 --- a/scripts/desktop/build-lib-mac.sh +++ b/scripts/desktop/build-lib-mac.sh @@ -14,7 +14,7 @@ else fi LIB_EXT=dylib -LIB=libHSsimplex-chat-*-inplace-ghc*.$LIB_EXT +LIB=libsimplex.$LIB_EXT GHC_LIBS_DIR=$(ghc --print-libdir) BUILD_DIR=dist-newstyle/build/$ARCH-*/ghc-*/simplex-chat-* @@ -27,6 +27,7 @@ rm -rf $BUILD_DIR cabal build lib:simplex-chat lib:simplex-chat --ghc-options="-optl-Wl,-rpath,@loader_path -optl-Wl,-L$GHC_LIBS_DIR/$ARCH-osx-ghc-$GHC_VERSION -optl-lHSrts_thr-ghc$GHC_VERSION -optl-lffi" --constraint 'simplexmq +client_library' cd $BUILD_DIR/build +mv libHSsimplex-chat-*-inplace-ghc*.$LIB_EXT libsimplex.dylib 2> /dev/null || true mkdir deps 2> /dev/null || true # It's not included by default for some reason. Compiled lib tries to find system one but it's not always available @@ -95,7 +96,7 @@ rm -rf apps/multiplatform/desktop/build/cmake mkdir -p apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ cp -r $BUILD_DIR/build/deps/* apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ -cp $BUILD_DIR/build/libHSsimplex-chat-*-inplace-ghc*.$LIB_EXT apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ +cp $BUILD_DIR/build/$LIB apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/ cd apps/multiplatform/common/src/commonMain/cpp/desktop/libs/$OS-$ARCH/