-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
wasm followup: fix release workflows (#1146)
* fix cross_build.sh * fix gen_kotlin * fix swift * fix android workflow
- Loading branch information
Showing
5 changed files
with
66 additions
and
70 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,34 +1,44 @@ | ||
#!/bin/bash | ||
|
||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
main() { | ||
set -ex | ||
# Dev+Debug is better for debugging Rust crashes, but generates much larger libraries (100's of MB) | ||
# PROFILE="dev" | ||
# BINARY_PROFILE="debug" | ||
PROFILE="release" | ||
BINARY_PROFILE="release" | ||
|
||
WORKSPACE_MANIFEST="$(cargo locate-project --workspace --message-format=plain)" | ||
WORKSPACE_PATH="$(dirname $WORKSPACE_MANIFEST)" | ||
TARGET_DIR="$WORKSPACE_PATH/target" | ||
BINDINGS_MANIFEST="$WORKSPACE_PATH/bindings_ffi/Cargo.toml" | ||
# Go to the workspace root so that the workspace config can be found by cross | ||
cd .. | ||
cd $WORKSPACE_PATH | ||
if ! cross &>/dev/null; then | ||
echo -e "${RED} `cargo-cross` not detected. install cargo-cross to continue${NC}"; | ||
exit | ||
fi | ||
# Uncomment to build for all targets. aarch64-linux-android is the default target for an emulator on Android Studio on an M1 mac. | ||
cross build --manifest-path ./bindings_ffi/Cargo.toml --target x86_64-linux-android --target-dir ./bindings_ffi/target --profile $PROFILE && \ | ||
cross build --manifest-path ./bindings_ffi/Cargo.toml --target i686-linux-android --target-dir ./bindings_ffi/target --profile $PROFILE && \ | ||
cross build --manifest-path ./bindings_ffi/Cargo.toml --target armv7-linux-androideabi --target-dir ./bindings_ffi/target --profile $PROFILE && \ | ||
cross build --manifest-path ./bindings_ffi/Cargo.toml --target aarch64-linux-android --target-dir ./bindings_ffi/target --profile $PROFILE | ||
cross build --manifest-path $BINDINGS_MANIFEST --target x86_64-linux-android --target-dir $TARGET_DIR --profile $PROFILE && \ | ||
cross build --manifest-path $BINDINGS_MANIFEST --target i686-linux-android --target-dir $TARGET_DIR --profile $PROFILE && \ | ||
cross build --manifest-path $BINDINGS_MANIFEST --target armv7-linux-androideabi --target-dir $TARGET_DIR --profile $PROFILE && \ | ||
cross build --manifest-path $BINDINGS_MANIFEST --target aarch64-linux-android --target-dir $TARGET_DIR --profile $PROFILE | ||
|
||
# Move everything to jniLibs folder and rename | ||
LIBRARY_NAME="libxmtpv3" | ||
TARGET_NAME="libuniffi_xmtpv3" | ||
cd bindings_ffi | ||
cd $(dirname $BINDINGS_MANIFEST) # cd bindings_ffi | ||
rm -rf jniLibs/ | ||
mkdir -p jniLibs/armeabi-v7a/ && \ | ||
cp target/armv7-linux-androideabi/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/armeabi-v7a/$TARGET_NAME.so && \ | ||
cp $WORKSPACE_PATH/target/armv7-linux-androideabi/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/armeabi-v7a/$TARGET_NAME.so && \ | ||
mkdir -p jniLibs/x86/ && \ | ||
cp target/i686-linux-android/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/x86/$TARGET_NAME.so && \ | ||
cp $WORKSPACE_PATH/target/i686-linux-android/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/x86/$TARGET_NAME.so && \ | ||
mkdir -p jniLibs/x86_64/ && \ | ||
cp target/x86_64-linux-android/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/x86_64/$TARGET_NAME.so && \ | ||
cp $WORKSPACE_PATH/target/x86_64-linux-android/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/x86_64/$TARGET_NAME.so && \ | ||
mkdir -p jniLibs/arm64-v8a/ && \ | ||
cp target/aarch64-linux-android/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/arm64-v8a/$TARGET_NAME.so | ||
cp $WORKSPACE_PATH/target/aarch64-linux-android/$BINARY_PROFILE/$LIBRARY_NAME.so jniLibs/arm64-v8a/$TARGET_NAME.so | ||
} | ||
|
||
time main |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,34 @@ | ||
CRATE_NAME="bindings_ffi" | ||
PROJECT_NAME="xmtpv3" | ||
|
||
cargo build --release | ||
pushd .. > /dev/null | ||
rm -f $CRATE_NAME/src/uniffi/$PROJECT_NAME/$PROJECT_NAME.kt | ||
bindings_ffi/target/release/ffi-uniffi-bindgen generate \ | ||
--lib-file bindings_ffi/target/release/libxmtpv3.dylib \ | ||
$CRATE_NAME/src/$PROJECT_NAME.udl \ | ||
RED='\033[0;31m' | ||
NC='\033[0m' # No Color | ||
|
||
WORKSPACE_MANIFEST="$(cargo locate-project --workspace --message-format=plain)" | ||
WORKSPACE_PATH="$(dirname $WORKSPACE_MANIFEST)" | ||
BINDINGS_MANIFEST="$WORKSPACE_PATH/bindings_ffi/Cargo.toml" | ||
BINDINGS_PATH="$(dirname $BINDINGS_MANIFEST)" | ||
TARGET_DIR="$WORKSPACE_PATH/target" | ||
XMTP_ANDROID="${1:-../xmtp_android}" | ||
|
||
if [ ! -d $XMTP_ANDROID ]; then | ||
echo "${RED}xmtp-android directory not detected${NC}" | ||
echo "${RED}Ensure \`github.com/xmtp/xmtp_android\` is cloned as a sibling directory or passed as the first argument to this script.${NC}" | ||
exit | ||
fi | ||
echo "Android Directory: $XMTP_ANDROID" | ||
|
||
cd $WORKSPACE_PATH | ||
cargo build --release --manifest-path $BINDINGS_MANIFEST | ||
rm -f $BINDINGS_PATH/src/uniffi/$PROJECT_NAME/$PROJECT_NAME.kt | ||
$TARGET_DIR/release/ffi-uniffi-bindgen generate \ | ||
--lib-file $TARGET_DIR/release/libxmtpv3.dylib \ | ||
$BINDINGS_PATH/src/$PROJECT_NAME.udl \ | ||
--language kotlin | ||
popd > /dev/null | ||
cd $BINDINGS_PATH | ||
make libxmtp-version | ||
cp libxmtp-version.txt src/uniffi/$PROJECT_NAME/ | ||
|
||
# Assumes libxmtp is in a peer directory of xmtp-android | ||
cp src/uniffi/xmtpv3/xmtpv3.kt ../../xmtp-android/library/src/main/java/xmtpv3.kt | ||
cp src/uniffi/xmtpv3/libxmtp-version.txt ../../xmtp-android/library/src/main/java/libxmtp-version.txt | ||
cd $WORKSPACE_PATH | ||
|
||
cp $BINDINGS_PATH/src/uniffi/xmtpv3/xmtpv3.kt $XMTP_ANDROID/library/src/main/java/xmtpv3.kt | ||
cp $BINDINGS_PATH/src/uniffi/xmtpv3/libxmtp-version.txt $XMTP_ANDROID/library/src/main/java/libxmtp-version.txt |