build-rust-sdk: allow skipping git update for kotlin components (#7012)

Updating matrix-rust-components-kotlin from git on every build is
time-consuming, and requires network connectivity. It's useful to be able to
skip it, particularly when working offline.

Add an option to the build script to skip this step.
This commit is contained in:
Richard van der Hoff
2026-06-11 16:02:52 +01:00
committed by GitHub
parent 48e5d1b2f4
commit 89fc77727f
+28 -14
View File
@@ -27,6 +27,7 @@ set -u
buildLocal=0 buildLocal=0
rustSdkPath="../matrix-rust-sdk/" rustSdkPath="../matrix-rust-sdk/"
kotlinComponentsPath="../matrix-rust-components-kotlin"
rustSdkUrl="https://github.com/matrix-org/matrix-rust-sdk.git" rustSdkUrl="https://github.com/matrix-org/matrix-rust-sdk.git"
rustSdkBranch="main" rustSdkBranch="main"
buildApp=1 buildApp=1
@@ -38,6 +39,7 @@ default_arch="${default_arch/arm64/aarch64}"
target_arch="${default_arch}" target_arch="${default_arch}"
sdkArg="" sdkArg=""
update_components=1
## Argument parsing ## Argument parsing
@@ -48,7 +50,7 @@ else
GNU_GETOPT="getopt" GNU_GETOPT="getopt"
fi fi
TEMP=$("$GNU_GETOPT" -o 'rs:b:at:h' --long 'remote,sdk:,branch:,build-app,target-arch:,help' -- "$@") TEMP=$("$GNU_GETOPT" -o 'rs:b:at:nh' --long 'remote,sdk:,branch:,build-app,target-arch:,no-update-components,help' -- "$@")
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo 'Terminating...' >&2 echo 'Terminating...' >&2
@@ -85,6 +87,11 @@ while true; do
shift 2 shift 2
continue continue
;; ;;
'-n'|'--no-update-components')
update_components=0
shift
continue
;;
'-h'|'--help') '-h'|'--help')
cat << END cat << END
SYNOPSIS SYNOPSIS
@@ -110,6 +117,9 @@ ARGUMENTS
-t --target-arch -t --target-arch
The architecture for which to build the app. Defaults to the architecture of this machine (${default_arch}). The architecture for which to build the app. Defaults to the architecture of this machine (${default_arch}).
-n --no-update-components
Do not attempt to update matrix-rust-components-kotlin from git. It must already be cloned and up-to-date.
EXAMPLES EXAMPLES
$0 $0
@@ -194,21 +204,25 @@ cd "${elementPwd}"
## Clone matrix-rust-components-kotlin if needed ## Clone matrix-rust-components-kotlin if needed
if [ ! -d "../matrix-rust-components-kotlin" ]; then if [ "$update_components" == "1" ]; then
printf "\nFolder ../matrix-rust-components-kotlin does not exist." if [ ! -d "${kotlinComponentsPath}" ]; then
printf "Cloning the repository into ../matrix-rust-components-kotlin.\n\n" printf "\nFolder ${kotlinComponentsPath} does not exist."
git clone \ printf "Cloning the repository into ${kotlinComponentsPath}.\n\n"
https://github.com/matrix-org/matrix-rust-components-kotlin.git \ git clone \
../matrix-rust-components-kotlin https://github.com/matrix-org/matrix-rust-components-kotlin.git \
"${kotlinComponentsPath}"
fi
printf "\n## Resetting ${kotlinComponentsPath} to the latest main...\n\n"
cd "${kotlinComponentsPath}"
git reset --hard
git checkout main
git pull
else
cd "${kotlinComponentsPath}"
fi fi
printf "\n## Resetting matrix-rust-components-kotlin to the latest main...\n\n"
cd ../matrix-rust-components-kotlin
git reset --hard
git checkout main
git pull
## Build the SDK ## Build the SDK
printf "\n## Building the SDK for ${target_arch}...\n\n" printf "\n## Building the SDK for ${target_arch}...\n\n"