From 89fc77727f553b4d6a7384d9b8a2052b9a24ce5b Mon Sep 17 00:00:00 2001 From: Richard van der Hoff <1389908+richvdh@users.noreply.github.com> Date: Thu, 11 Jun 2026 16:02:52 +0100 Subject: [PATCH] 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. --- tools/sdk/build-rust-sdk | 42 ++++++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 14 deletions(-) diff --git a/tools/sdk/build-rust-sdk b/tools/sdk/build-rust-sdk index eddff9f7e4..91c6ed6e02 100755 --- a/tools/sdk/build-rust-sdk +++ b/tools/sdk/build-rust-sdk @@ -27,6 +27,7 @@ set -u buildLocal=0 rustSdkPath="../matrix-rust-sdk/" +kotlinComponentsPath="../matrix-rust-components-kotlin" rustSdkUrl="https://github.com/matrix-org/matrix-rust-sdk.git" rustSdkBranch="main" buildApp=1 @@ -38,6 +39,7 @@ default_arch="${default_arch/arm64/aarch64}" target_arch="${default_arch}" sdkArg="" +update_components=1 ## Argument parsing @@ -48,7 +50,7 @@ else GNU_GETOPT="getopt" 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 echo 'Terminating...' >&2 @@ -85,6 +87,11 @@ while true; do shift 2 continue ;; + '-n'|'--no-update-components') + update_components=0 + shift + continue + ;; '-h'|'--help') cat << END SYNOPSIS @@ -110,6 +117,9 @@ ARGUMENTS -t --target-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 $0 @@ -194,21 +204,25 @@ cd "${elementPwd}" ## Clone matrix-rust-components-kotlin if needed -if [ ! -d "../matrix-rust-components-kotlin" ]; then - printf "\nFolder ../matrix-rust-components-kotlin does not exist." - printf "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 +if [ "$update_components" == "1" ]; then + if [ ! -d "${kotlinComponentsPath}" ]; then + printf "\nFolder ${kotlinComponentsPath} does not exist." + printf "Cloning the repository into ${kotlinComponentsPath}.\n\n" + git clone \ + 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 -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 printf "\n## Building the SDK for ${target_arch}...\n\n"