From 79d9da82855fc49bb03bdf8d8a856bd2b931748a Mon Sep 17 00:00:00 2001 From: Hyperling Date: Mon, 28 Sep 2026 10:34:52 -0700 Subject: [PATCH] compile, further enhance the script as well as add space-saving options and platform specific APKs. --- compile.sh | 60 ++++++++++++++++++++++++++++++++++++++++++++---------- 1 file changed, 49 insertions(+), 11 deletions(-) diff --git a/compile.sh b/compile.sh index e041847..e6f23de 100755 --- a/compile.sh +++ b/compile.sh @@ -15,6 +15,7 @@ function log { function clean_flutter { log "Cleaning..." flutter clean + echo "Done!" } ## Variables ## @@ -41,12 +42,23 @@ fi RELEASE="release/$name-$version" echo "Running for '$RELEASE'." +BUILD_OPTIONS=( + --release + --obfuscate + --split-debug-info=./debug-info/ + --extra-gen-snapshot-options="--strip" +) + ## Main ## clean_flutter +# Linux + log "Building Linux Bundle..." -flutter build linux +set -x +flutter build linux ${BUILD_OPTIONS[@]} +set +x log "Saving Linux Bundle..." filename=$RELEASE.linux-bundle.zip @@ -56,15 +68,41 @@ fi zip -r $filename build/linux/x64/release/bundle/* ls -sh $filename -clean_flutter +# Android -log "Building APK..." -flutter build apk +log "Building Universal APK..." +# Creates a generic (and large) app-release.apk +set -x +flutter build apk ${BUILD_OPTIONS[@]} +set +x -log "Saving APK..." -filename=$RELEASE.apk -if [[ -e $filename ]]; then - rm -v $filename -fi -cp -v build/app/outputs/flutter-apk/app-release.apk $filename -ls -sh $filename +#log "Saving Universal APK..." +#apk="build/app/outputs/flutter-apk/app-release.apk" +#filename=`basename $apk` +#filename=${filename//app/${RELEASE}} +#if [[ -e $filename ]]; then +# rm -v $filename +#fi +#cp -v "$apk" "$filename" +#ls -sh "$filename" + +log "Building Individual APKs..." +# Creates files such as build/app/outputs/flutter-apk/app-arm64-v8a-release.apk +set -x +flutter build apk ${BUILD_OPTIONS[@]} --split-per-abi +set +x + +log "Saving APKs..." +for apk in `ls build/app/outputs/flutter-apk/app*release.apk`; do + #if [[ "$apk" == *"x86"* ]]; then echo "Skipping $apk" continue; fi + #log "APK: $apk" + filename=`basename $apk` + filename=${filename//app/${RELEASE}} + cp -v "$apk" "$filename" + ls -sh "$filename" + echo " " +done + +# Finish + +exit 0