Skip to content

Commit

Permalink
feat: update build_fdroid.sh (rustdesk#10040)
Browse files Browse the repository at this point in the history
Signed-off-by: fufesou <[email protected]>
  • Loading branch information
fufesou authored Nov 25, 2024
1 parent 34b93c6 commit 9d2bdfe
Showing 1 changed file with 56 additions and 54 deletions.
110 changes: 56 additions & 54 deletions flutter/build_fdroid.sh
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,21 @@ export PATH="${PATH}:${HOME}/flutter/bin:${HOME}/depot_tools"

export VCPKG_ROOT="${HOME}/vcpkg"

prepare_Flutter() {
version="${1}"

pushd "${HOME}"
if [ ! -f "${HOME}/flutter/bin/flutter" ]; then
git clone https://github.com/flutter/flutter
fi
pushd flutter
git restore .
git checkout "${version}"
flutter config --no-analytics
popd # flutter
popd # ${HOME}
}

# Now act depending on build step

# NOTE: F-Droid maintainers require explicit declaration of dependencies
Expand Down Expand Up @@ -110,9 +125,13 @@ prebuild)
.github/workflows/flutter-build.yml)"
fi

FLUTTER_BRIDGE_VERSION="$(yq -r \
.env.FLUTTER_VERSION \
.github/workflows/bridge.yml)"

FLUTTER_RUST_BRIDGE_VERSION="$(yq -r \
.env.FLUTTER_RUST_BRIDGE_VERSION \
.github/workflows/flutter-build.yml)"
.github/workflows/bridge.yml)"

NDK_VERSION="$(yq -r \
.env.NDK_VERSION \
Expand All @@ -127,6 +146,7 @@ prebuild)
.github/workflows/flutter-build.yml)"

if [ -z "${CARGO_NDK_VERSION}" ] || [ -z "${FLUTTER_VERSION}" ] ||
[ -z "${FLUTTER_BRIDGE_VERSION}" ] ||
[ -z "${FLUTTER_RUST_BRIDGE_VERSION}" ] ||
[ -z "${NDK_VERSION}" ] || [ -z "${RUST_VERSION}" ] ||
[ -z "${VCPKG_COMMIT_ID}" ]; then
Expand Down Expand Up @@ -163,24 +183,6 @@ prebuild)
sdkmanager --install "ndk;${NDK_VERSION}"
fi

# Install Flutter

if [ ! -f "${HOME}/flutter/bin/flutter" ]; then
pushd "${HOME}"

git clone https://github.com/flutter/flutter

pushd flutter

git reset --hard "${FLUTTER_VERSION}"

flutter config --no-analytics

popd # flutter

popd # ${HOME}
fi

# Install Rust

if [ ! -f "${HOME}/rustup/rustup-init.sh" ]; then
Expand Down Expand Up @@ -275,12 +277,46 @@ prebuild)

git apply res/fdroid/patches/*.patch

# Backup .gclient file, for later restore

cp flutter-sdk/.gclient flutter-sdk/.gclient.bak

# For FLUTTER_BRIDGE_VERSION
sed \
-i \
-e 's/extended_text: 14.0.0/extended_text: 13.0.0/g' \
flutter/pubspec.yaml

# Install Flutter bridge version
prepare_Flutter "${FLUTTER_BRIDGE_VERSION}"
cp flutter-sdk/.gclient.bak flutter-sdk/.gclient
sed -i "s/FLUTTER_VERSION_PLACEHOLDER/${FLUTTER_BRIDGE_VERSION}/" flutter-sdk/.gclient

# Download Flutter dependencies
pushd flutter
flutter clean && flutter packages pub get
popd # flutter

# Generate FFI bindings
flutter_rust_bridge_codegen \
--rust-input ./src/flutter_ffi.rs \
--dart-output ./flutter/lib/generated_bridge.dart

git restore flutter/pubspec.*

# Install Flutter
prepare_Flutter "${FLUTTER_VERSION}"
cp flutter-sdk/.gclient.bak flutter-sdk/.gclient
sed -i "s/FLUTTER_VERSION_PLACEHOLDER/${FLUTTER_VERSION}/" flutter-sdk/.gclient

# gms is not in thoes files now, but we still keep the following line for future reference(maybe).
sed \
-i \
-e '/gms/d' \
flutter/android/build.gradle \
flutter/android/app/build.gradle

# `firebase_analytics`` is not in thoes files now, but we still keep the following lines.
sed \
-i \
-e '/firebase_analytics/d' \
Expand All @@ -296,34 +332,6 @@ prebuild)
-e '/firebase/Id' \
flutter/lib/main.dart

if [ "${FLUTTER_VERSION}" = "3.13.9" ]; then
# Fix for android 3.13.9
# https://github.com/rustdesk/rustdesk/blob/285e974d1a52c891d5fcc28e963d724e085558bc/.github/workflows/flutter-build.yml#L862

sed \
-i \
-e 's/extended_text: .*/extended_text: 11.1.0/' \
-e 's/uni_links_desktop/#uni_links_desktop/g' \
flutter/pubspec.yaml

set --

while read -r _1; do
set -- "$@" "${_1}"
done 0<<.a
$(find flutter/lib/ -type f -name "*dart*")
.a

sed \
-i \
-e 's/textScaler: TextScaler.linear(\(.*\)),/textScaleFactor: \1,/g' \
"$@"

set --
fi

sed -i "s/FLUTTER_VERSION_PLACEHOLDER/${FLUTTER_VERSION}/" flutter-sdk/.gclient

;;
build)
# build: perform actual build of APK file
Expand Down Expand Up @@ -373,16 +381,10 @@ build)

pushd flutter

flutter packages pub get
flutter clean && flutter packages pub get

popd # flutter

# Generate FFI bindings

flutter_rust_bridge_codegen \
--rust-input ./src/flutter_ffi.rs \
--dart-output ./flutter/lib/generated_bridge.dart

# Build host android deps

bash flutter/build_android_deps.sh "${ANDROID_ABI}"
Expand Down

0 comments on commit 9d2bdfe

Please sign in to comment.