-
Notifications
You must be signed in to change notification settings - Fork 155
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add script to build the rust sdk locally and from different repo / branch #1582
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,80 @@ | ||
#!/usr/bin/env bash | ||
|
||
# Exit on error | ||
set -e | ||
|
||
# Ask to build from local source or to clone the repository | ||
read -p "Do you want to build the Rust SDK from local source (yes/no) default to yes? " buildLocal | ||
buildLocal=${buildLocal:-yes} | ||
|
||
date=$(gdate +%Y%m%d%H%M%S) | ||
|
||
# Ask for the Rust SDK local source path | ||
# if folder rustSdk/ exists, use it as default | ||
if [ ${buildLocal} == "yes" ]; then | ||
read -p "Please enter the path to the Rust SDK local source, default to ../matrix-rust-sdk" rustSdkPath | ||
rustSdkPath=${rustSdkPath:-../matrix-rust-sdk/} | ||
if [ ! -d "${rustSdkPath}" ]; then | ||
printf "\nFolder ${rustSdkPath} does not exist. Please clone the matrix-rust-sdk repository in the folder ../matrix-rust-sdk.\n\n" | ||
exit 0 | ||
fi | ||
else | ||
read -p "Please enter the Rust SDK repository url, default to https://github.com/matrix-org/matrix-rust-sdk.git " rustSdkUrl | ||
rustSdkUrl=${rustSdkUrl:-https://github.com/matrix-org/matrix-rust-sdk.git} | ||
read -p "Please enter the Rust SDK branch, default to main " rustSdkBranch | ||
rustSdkBranch=${rustSdkBranch:-main} | ||
cd .. | ||
git clone ${rustSdkUrl} matrix-rust-sdk-$date | ||
cd matrix-rust-sdk-$date | ||
git checkout ${rustSdkBranch} | ||
rustSdkPath=$(pwd) | ||
cd ../element-x-android | ||
fi | ||
|
||
|
||
cd ${rustSdkPath} | ||
git status | ||
|
||
read -p "Will build with this version of the Rust SDK ^. Is it correct (yes/no) default to yes? " sdkCorrect | ||
sdkCorrect=${sdkCorrect:-yes} | ||
|
||
if [ ${sdkCorrect} != "yes" ]; then | ||
exit 0 | ||
fi | ||
|
||
# Ask if the user wants to build the app after | ||
read -p "Do you want to build the app after (yes/no) default to yes? " buildApp | ||
buildApp=${buildApp:-yes} | ||
|
||
# If folder ../matrix-rust-components-kotlin does not exist, clone the repo | ||
if [ ! -d "../matrix-rust-components-kotlin" ]; then | ||
printf "\nFolder ../matrix-rust-components-kotlin does not exist. Cloning the repository into ../matrix-rust-components-kotlin.\n\n" | ||
git clone https://github.com/matrix-org/matrix-rust-components-kotlin.git ../matrix-rust-components-kotlin | ||
fi | ||
|
||
printf "\nResetting matrix-rust-components-kotlin to the latest main branch...\n\n" | ||
cd ../matrix-rust-components-kotlin | ||
git reset --hard | ||
git checkout main | ||
git pull | ||
|
||
printf "\nBuilding the SDK for aarch64-linux-android...\n\n" | ||
./scripts/build.sh -p ${rustSdkPath} -m sdk -t aarch64-linux-android -o ../element-x-android/libraries/rustsdk | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Won't this only work for ARM64 emulators/devices? Maybe the user who builds this wants to use an x86-64 emulator in Linux/Windows. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, I'll take this as a limitation of the script, but i will update the message so that it will be clearer. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You could use So if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
|
||
cd ../element-x-android | ||
mv ./libraries/rustsdk/sdk-android-debug.aar ./libraries/rustsdk/matrix-rust-sdk.aar | ||
mkdir -p ./libraries/rustsdk/sdks | ||
cp ./libraries/rustsdk/matrix-rust-sdk.aar ./libraries/rustsdk/matrix-rust-sdk-${date}.aar | ||
|
||
|
||
if [ ${buildApp} == "yes" ]; then | ||
printf "\nBuilding the application...\n\n" | ||
./gradlew assembleDebug | ||
fi | ||
|
||
if [ ${buildLocal} == "no" ]; then | ||
printf "\nCleaning up...\n\n" | ||
rm -rf ../matrix-rust-sdk-$date | ||
fi | ||
|
||
printf "\nDone!\n" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just for safety, could we make it so that this
if
works only for debug builds? (i.e. release builds will always useimplementation(libs.matrix.sdk)
no matter what?)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. It's not possible to commit the sdk: *.aar file are git ignored, so I think it's fine. The idea is to avoid editing this file (and so committing it by mistake)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah but adding a
releaseImplementation()
and haveing the if using onlydebugImplementation
could be an additional layer of safetyThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You mean having something like:
?
I am wondering now if we may want to test the release build with a local SDK :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. That's what I had in mind. In the rare case we'd like to test a release build with a local sdk we'll have to manually change the gradle file.
This seems to me an added level of safety. But if you feel I'm being paranoid don't be afraid to say it, sometimes I am.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Works for me. Better safe than sorry!