Skip to content

Commit

Permalink
ffi: strip libraries after foreign language generation
Browse files Browse the repository at this point in the history
Signed-off-by: Yuki Kishimoto <[email protected]>
  • Loading branch information
yukibtc committed Nov 5, 2024
1 parent 5f3c24a commit cbf0125
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 1 deletion.
9 changes: 8 additions & 1 deletion bindings/nostr-sdk-ffi/justfile
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,10 @@ x86_64-linux-android: ndk
[private]
android: aarch64-linux-android armv7-linux-androideabi i686-linux-android x86_64-linux-android

[private]
strip-jni-libs:
strip ffi/kotlin/jniLibs/*/*.so

kotlin: clean-android android
find ./ffi/kotlin/jniLibs -name libnostr_ffi.so -type f -delete
cargo run -p uniffi-bindgen generate --library ../../target/x86_64-linux-android/release/libnostr_sdk_ffi.so --language kotlin --no-format -o ffi/kotlin
Expand All @@ -72,7 +76,7 @@ assemble-aar:
cp android/lib/build/outputs/aar/lib-release.aar ffi/android

# Compile and build Android Archive (AAR)
aar: sdk-root kotlin assemble-aar
aar: sdk-root kotlin strip-jni-libs assemble-aar

# Publish android bindings
[confirm]
Expand Down Expand Up @@ -132,6 +136,7 @@ python:
cargo build --release
cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.so --language python --no-format -o python/src/nostr-sdk/
cp ../../target/release/libnostr_sdk_ffi.so python/src/nostr-sdk/
strip python/src/nostr-sdk/libnostr_sdk_ffi.so
cd python && python setup.py --verbose bdist_wheel
pip install ./python/dist/nostr_sdk*.whl --force-reinstall

Expand All @@ -142,6 +147,7 @@ python:
cargo build --release
cargo run -p uniffi-bindgen generate --library ../../target/release/libnostr_sdk_ffi.dylib --language python --no-format -o python/src/nostr-sdk/
cp ../../target/release/libnostr_sdk_ffi.dylib python/src/nostr-sdk/
strip python/src/nostr-sdk/libnostr_sdk_ffi.dylib
cd python && python setup.py --verbose bdist_wheel
pip install ./python/dist/nostr_sdk*.whl --force-reinstall

Expand All @@ -151,6 +157,7 @@ python:
cargo build --release
cargo run -p uniffi-bindgen generate --library ..\..\target\release\nostr_sdk_ffi.dll --language python --no-format -o python\src\nostr-sdk\
copy ..\..\target\release\nostr_sdk_ffi.dll python\src\nostr-sdk
strip python\src\nostr-sdk\nostr_sdk_ffi.dll
del /F /Q python\dist\* 2>nul || exit /b 0
cd python && python setup.py --verbose bdist_wheel
FOR %%i in (.\python\dist\*.whl) DO pip install %i --force-reinstall
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cargo run -p uniffi-bindgen generate --library ../../target/aarch64-unknown-linu
echo "Copying linux libnostr_sdk_ffi.so..."
cp ../../target/aarch64-unknown-linux-gnu/release/libnostr_sdk_ffi.so python/src/nostr-sdk/

echo "Stripping libnostr_sdk_ffi.so..."
strip python/src/nostr-sdk/libnostr_sdk_ffi.so

echo "All done!"
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cargo run -p uniffi-bindgen generate --library ../../target/x86_64-unknown-linux
echo "Copying linux libnostr_sdk_ffi.so..."
cp ../../target/x86_64-unknown-linux-gnu/release/libnostr_sdk_ffi.so python/src/nostr-sdk/

echo "Stripping libnostr_sdk_ffi.so..."
strip python/src/nostr-sdk/libnostr_sdk_ffi.so

echo "All done!"
3 changes: 3 additions & 0 deletions bindings/nostr-sdk-ffi/python/scripts/generate-macos-arm64.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cargo run -p uniffi-bindgen generate --library ../../target/aarch64-apple-darwin
echo "Copying libraries libnostr_sdk_ffi.dylib..."
cp ../../target/aarch64-apple-darwin/release/libnostr_sdk_ffi.dylib python/src/nostr-sdk/

echo "Stripping libnostr_sdk_ffi.dylib..."
strip -k python/src/nostr-sdk/libnostr_sdk_ffi.dylib

echo "All done!"
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cargo run -p uniffi-bindgen generate --library ../../target/x86_64-apple-darwin/
echo "Copying libraries libnostr_sdk_ffi.dylib..."
cp ../../target/x86_64-apple-darwin/release/libnostr_sdk_ffi.dylib python/src/nostr-sdk/

echo "Stripping libnostr_sdk_ffi.dylib..."
strip -k python/src/nostr-sdk/libnostr_sdk_ffi.dylib

echo "All done!"
3 changes: 3 additions & 0 deletions bindings/nostr-sdk-ffi/python/scripts/generate-windows.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,7 @@ cargo run -p uniffi-bindgen generate --library ../../target/x86_64-pc-windows-ms
echo "Copying libraries nostr_sdk_ffi.dll..."
cp ../../target/x86_64-pc-windows-msvc/release/nostr_sdk_ffi.dll python/src/nostr-sdk/

echo "Stripping nostr_sdk_ffi.dll..."
strip python/src/nostr-sdk/nostr_sdk_ffi.dll

echo "All done!"

0 comments on commit cbf0125

Please sign in to comment.