diff --git a/.flutter b/.flutter
new file mode 160000
index 000000000..b8f7f1f98
--- /dev/null
+++ b/.flutter
@@ -0,0 +1 @@
+Subproject commit b8f7f1f9869bb2d116aa6a70dbeac61000b52849
diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml
index c42c62aaa..14a8bc164 100644
--- a/.github/workflows/check.yml
+++ b/.github/workflows/check.yml
@@ -5,34 +5,22 @@ on:
branches:
- develop
-# TODO TLAD run `flutter format -l 1000 .` and fail if any
-
jobs:
build:
name: Check code quality.
runs-on: ubuntu-latest
steps:
- # Flutter SDK is pulled from https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json
- # or, as displayed at https://docs.flutter.dev/development/tools/sdk/releases?tab=linux
- # Available versions may lag behind https://github.com/flutter/flutter.git
- - uses: subosito/flutter-action@v2
- with:
- flutter-version: '3.3.9'
- channel: 'stable'
-
- name: Clone the repository.
uses: actions/checkout@v2
- name: Get packages for the Flutter project.
- working-directory: ${{ github.workspace }}/scripts
- run: ./pub_get_all.sh
+ run: scripts/pub_get_all.sh
- name: Update the flutter version file.
- working-directory: ${{ github.workspace }}/scripts
- run: ./update_flutter_version.sh
+ run: scripts/update_flutter_version.sh
- name: Static analysis.
- run: flutter analyze
+ run: ./flutterw analyze
- name: Unit tests.
- run: flutter test
+ run: ./flutterw test
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 363a3db26..d107a6cd9 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -14,30 +14,20 @@ jobs:
with:
java-version: '11.x'
- # Flutter SDK is pulled from https://storage.googleapis.com/flutter_infra_release/releases/releases_linux.json
- # or, as displayed at https://docs.flutter.dev/development/tools/sdk/releases?tab=linux
- # Available versions may lag behind https://github.com/flutter/flutter.git
- - uses: subosito/flutter-action@v2
- with:
- flutter-version: '3.3.9'
- channel: 'stable'
-
- name: Clone the repository.
uses: actions/checkout@v2
- name: Get packages for the Flutter project.
- working-directory: ${{ github.workspace }}/scripts
- run: ./pub_get_all.sh
+ run: scripts/pub_get_all.sh
- name: Update the flutter version file.
- working-directory: ${{ github.workspace }}/scripts
- run: ./update_flutter_version.sh
+ run: scripts/update_flutter_version.sh
- name: Static analysis.
- run: flutter analyze
+ run: ./flutterw analyze
- name: Unit tests.
- run: flutter test
+ run: ./flutterw test
- name: Build signed artifacts.
# `KEY_JKS` should contain the result of:
@@ -53,19 +43,19 @@ jobs:
gpg -d --passphrase "${{ secrets.KEY_JKS_PASSPHRASE }}" --batch release.keystore.asc > $AVES_STORE_FILE
rm release.keystore.asc
mkdir outputs
- (cd scripts/; ./apply_flavor_play.sh)
- flutter build appbundle -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
+ scripts/apply_flavor_play.sh
+ ./flutterw build appbundle -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
cp build/app/outputs/bundle/playRelease/*.aab outputs
- flutter build apk -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
+ ./flutterw build apk -t lib/main_play.dart --flavor play --bundle-sksl-path shaders.sksl.json
cp build/app/outputs/apk/play/release/*.apk outputs
- (cd scripts/; ./apply_flavor_huawei.sh)
- flutter build apk -t lib/main_huawei.dart --flavor huawei --bundle-sksl-path shaders.sksl.json
+ scripts/apply_flavor_huawei.sh
+ ./flutterw build apk -t lib/main_huawei.dart --flavor huawei --bundle-sksl-path shaders.sksl.json
cp build/app/outputs/apk/huawei/release/*.apk outputs
- (cd scripts/; ./apply_flavor_izzy.sh)
- flutter build apk -t lib/main_izzy.dart --flavor izzy --split-per-abi
+ scripts/apply_flavor_izzy.sh
+ ./flutterw build apk -t lib/main_izzy.dart --flavor izzy --split-per-abi
cp build/app/outputs/apk/izzy/release/*.apk outputs
- (cd scripts/; ./apply_flavor_libre.sh)
- flutter build apk -t lib/main_libre.dart --flavor libre
+ scripts/apply_flavor_libre.sh
+ ./flutterw build apk -t lib/main_libre.dart --flavor libre --split-per-abi
cp build/app/outputs/apk/libre/release/*.apk outputs
rm $AVES_STORE_FILE
env:
diff --git a/.gitmodules b/.gitmodules
new file mode 100644
index 000000000..ee9d7761a
--- /dev/null
+++ b/.gitmodules
@@ -0,0 +1,4 @@
+[submodule ".flutter"]
+ path = .flutter
+ url = https://github.com/flutter/flutter.git
+ branch = stable
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b671491e2..482e10d2a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
## [Unreleased]
+### Changed
+- build: use `flutter-wrapper`, bundle Flutter as submodule
+- build: use split APKs for `libre` flavor
+
## [v1.7.5] - 2022-11-23
### Added
diff --git a/README.md b/README.md
index 36f671091..d18228b8e 100644
--- a/README.md
+++ b/README.md
@@ -118,14 +118,14 @@ Some users have expressed the wish to financially support the project. Thanks!
Before running or building the app, update the dependencies for the desired flavor:
```
-# ./scripts/apply_flavor_play.sh
+# scripts/apply_flavor_play.sh
```
To build the project, create a file named `/android/key.properties`. It should contain a reference to a keystore for app signing, and other necessary credentials. See [key_template.properties](https://github.com/deckerst/aves/blob/develop/android/key_template.properties) for the expected keys.
To run the app:
```
-# flutter run -t lib/main_play.dart --flavor play
+# ./flutterw run -t lib/main_play.dart --flavor play
```
[Version badge]: https://img.shields.io/github/v/release/deckerst/aves?include_prereleases&sort=semver
diff --git a/android/app/build.gradle b/android/app/build.gradle
index f85826a85..fa356b203 100644
--- a/android/app/build.gradle
+++ b/android/app/build.gradle
@@ -33,12 +33,12 @@ if (keystorePropertiesFile.exists()) {
// for release using credentials in environment variables set up by GitHub Actions
// warning: in property file, single quotes should be escaped with a backslash
// but they should not be escaped when stored in env variables
- keystoreProperties['storeFile'] = System.getenv('AVES_STORE_FILE')
- keystoreProperties['storePassword'] = System.getenv('AVES_STORE_PASSWORD')
- keystoreProperties['keyAlias'] = System.getenv('AVES_KEY_ALIAS')
- keystoreProperties['keyPassword'] = System.getenv('AVES_KEY_PASSWORD')
- keystoreProperties['googleApiKey'] = System.getenv('AVES_GOOGLE_API_KEY')
- keystoreProperties['huaweiApiKey'] = System.getenv('AVES_HUAWEI_API_KEY')
+ keystoreProperties['storeFile'] = System.getenv('AVES_STORE_FILE') ?: ''
+ keystoreProperties['storePassword'] = System.getenv('AVES_STORE_PASSWORD') ?: ''
+ keystoreProperties['keyAlias'] = System.getenv('AVES_KEY_ALIAS') ?: ''
+ keystoreProperties['keyPassword'] = System.getenv('AVES_KEY_PASSWORD') ?: ''
+ keystoreProperties['googleApiKey'] = System.getenv('AVES_GOOGLE_API_KEY') ?: ''
+ keystoreProperties['huaweiApiKey'] = System.getenv('AVES_HUAWEI_API_KEY') ?: ''
}
android {
@@ -60,8 +60,8 @@ android {
targetSdkVersion 33
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
- manifestPlaceholders = [googleApiKey: keystoreProperties['googleApiKey'],
- huaweiApiKey: keystoreProperties['huaweiApiKey']]
+ manifestPlaceholders = [googleApiKey: keystoreProperties['googleApiKey'] ?: '',
+ huaweiApiKey: keystoreProperties['huaweiApiKey'] ?: '']
multiDexEnabled true
}
@@ -105,8 +105,8 @@ android {
// check offending libraries with `fdroidserver`
// cf https://f-droid.org/en/docs/Submitting_to_F-Droid_Quick_Start_Guide/
dimension "store"
- // generate a universal APK without x86 native libs
- ext.useNdkAbiFilters = true
+ // generate APK by ABI, but NDK ABI filters are incompatible with split APK generation
+ ext.useNdkAbiFilters = false
applicationIdSuffix ".libre"
}
}
diff --git a/flutterw b/flutterw
new file mode 100755
index 000000000..38928adcd
--- /dev/null
+++ b/flutterw
@@ -0,0 +1,113 @@
+#!/usr/bin/env sh
+
+##############################################################################
+##
+## Flutter start up script for UN*X
+## Version: v1.3.1
+## Date: 2022-11-26 11:30:13
+##
+## Use this flutter wrapper to bundle Flutter within your project to make
+## sure everybody builds with the same version.
+##
+## Read about the install and uninstall process in the README on GitHub
+## https://github.com/passsy/flutter_wrapper
+##
+## Inspired by gradle-wrapper.
+##
+##############################################################################
+
+echoerr() { echo "$@" 1>&2; }
+
+# Attempt to set APP_HOME
+# Resolve links: $0 may be a link
+PRG="$0"
+# Need this for relative symlinks.
+while [ -h "$PRG" ]; do
+ ls=$(ls -ld "$PRG")
+ link=$(expr "$ls" : '.*-> \(.*\)$')
+ if expr "$link" : '/.*' >/dev/null; then
+ PRG="$link"
+ else
+ PRG=$(dirname "$PRG")"/$link"
+ fi
+done
+SAVED="$(pwd)"
+cd "$(dirname "$PRG")/" >/dev/null
+APP_HOME="$(pwd -P)"
+cd "$SAVED" >/dev/null
+
+FLUTTER_SUBMODULE_NAME='.flutter'
+GIT_HOME=$(git -C "${APP_HOME}" rev-parse --show-toplevel)
+FLUTTER_DIR="${GIT_HOME}/${FLUTTER_SUBMODULE_NAME}"
+
+# by default we should be in the correct project dir, but when run from Finder on Mac, the cwd is wrong
+if [ "$(uname)" = "Darwin" ] && [ "$HOME" = "$PWD" ]; then
+ cd "$(dirname "$0")"
+fi
+
+# Fix not initialized flutter submodule
+if [ ! -f "${FLUTTER_DIR}/bin/flutter" ]; then
+ echoerr "$FLUTTER_SUBMODULE_NAME submodule not initialized. Initializing..."
+ git submodule update --init "${FLUTTER_DIR}"
+fi
+
+# Detect detach HEAD and fix it. commands like upgrade expect a valid branch, not a detached HEAD
+FLUTTER_SYMBOLIC_REF=$(git -C "${FLUTTER_DIR}" symbolic-ref -q HEAD)
+if [ -z "${FLUTTER_SYMBOLIC_REF}" ]; then
+ FLUTTER_REV=$(git -C "${FLUTTER_DIR}" rev-parse HEAD)
+ FLUTTER_CHANNEL=$(git -C "${GIT_HOME}" config -f .gitmodules submodule.${FLUTTER_SUBMODULE_NAME}.branch)
+
+ if [ -z "${FLUTTER_CHANNEL}" ]; then
+ echoerr "Warning: Submodule '$FLUTTER_SUBMODULE_NAME' doesn't point to an official Flutter channel \
+(one of stable|beta|dev|master). './flutterw upgrade' will fail without a channel."
+ echoerr "Fix this by adding a specific channel with:"
+ echoerr " - './flutterw channel ' or"
+ echoerr " - Add 'branch = ' to '$FLUTTER_SUBMODULE_NAME' submodule in .gitmodules"
+ else
+ echoerr "Fixing detached HEAD: '$FLUTTER_SUBMODULE_NAME' submodule points to a specific commit $FLUTTER_REV, not channel '$FLUTTER_CHANNEL' (as defined in .gitmodules)."
+ # Make sure channel is fetched
+ # Remove old channel branch because it might be moved to an unrelated commit where fast-forward pull isn't possible
+ git -C "${FLUTTER_DIR}" branch -q -D "${FLUTTER_CHANNEL}" 2> /dev/null || true
+ git -C "${FLUTTER_DIR}" fetch -q origin
+
+ # bind current HEAD to channel defined in .gitmodules
+ git -C "${FLUTTER_DIR}" checkout -q -b "${FLUTTER_CHANNEL}" "${FLUTTER_REV}"
+ git -C "${FLUTTER_DIR}" branch -q -u "origin/${FLUTTER_CHANNEL}" "${FLUTTER_CHANNEL}"
+ echoerr "Fixed! Migrated to channel '$FLUTTER_CHANNEL' while staying at commit $FLUTTER_REV. './flutterw upgrade' now works without problems!"
+ git -C "${FLUTTER_DIR}" status -bs
+ fi
+fi
+
+# Wrapper tasks done, call flutter binary with all args
+set -e
+"$FLUTTER_DIR/bin/flutter" "$@"
+set +e
+
+# Post flutterw tasks. exit code from /bin/flutterw will be used as final exit
+FLUTTER_EXIT_STATUS=$?
+if [ ${FLUTTER_EXIT_STATUS} -eq 0 ]; then
+
+ # ./flutterw channel CHANNEL
+ if echo "$@" | grep -q "channel"; then
+ if [ -n "$2" ]; then
+ # make sure .gitmodules is updated as well
+ CHANNEL=${2} # second arg
+ git config -f "${GIT_HOME}/.gitmodules" "submodule.${FLUTTER_SUBMODULE_NAME}.branch" "${CHANNEL}"
+ # makes sure nobody forgets to do commit all changed files
+ git add "${GIT_HOME}/.gitmodules"
+ git add "${FLUTTER_DIR}"
+ fi
+ fi
+
+ # ./flutterw upgrade
+ if echo "$@" | grep -q "upgrade"; then
+ # makes sure nobody forgets to do commit the changed submodule
+ git add "${FLUTTER_DIR}"
+ # flutter packages get runs automatically. Stage those changes as well
+ if [ -f pubspec.lock ]; then
+ git add pubspec.lock
+ fi
+ fi
+fi
+
+exit ${FLUTTER_EXIT_STATUS}
diff --git a/plugins/aves_services_google/pubspec.lock b/plugins/aves_services_google/pubspec.lock
index 93a58d137..9d60bc455 100644
--- a/plugins/aves_services_google/pubspec.lock
+++ b/plugins/aves_services_google/pubspec.lock
@@ -344,7 +344,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
- version: "3.1.1"
+ version: "3.1.2"
wkt_parser:
dependency: transitive
description:
diff --git a/pubspec.lock b/pubspec.lock
index 72f89724a..14adfc172 100644
--- a/pubspec.lock
+++ b/pubspec.lock
@@ -326,7 +326,7 @@ packages:
name: flex_color_picker
url: "https://pub.dartlang.org"
source: hosted
- version: "2.6.1"
+ version: "3.0.0"
flex_seed_scheme:
dependency: transitive
description:
@@ -1242,7 +1242,7 @@ packages:
name: win32
url: "https://pub.dartlang.org"
source: hosted
- version: "3.1.1"
+ version: "3.1.2"
wkt_parser:
dependency: transitive
description:
diff --git a/pubspec.yaml b/pubspec.yaml
index e388a6e5f..07961f75d 100644
--- a/pubspec.yaml
+++ b/pubspec.yaml
@@ -10,7 +10,8 @@ version: 1.7.5+85
publish_to: none
environment:
- # keep in sync with GitHub workflows
+ # this project bundles Flutter SDK via `flutter_wrapper`
+ # cf https://github.com/passsy/flutter_wrapper
flutter: 3.3.9
sdk: ">=2.18.0 <3.0.0"
diff --git a/scripts/apply_flavor_huawei.sh b/scripts/apply_flavor_huawei.sh
index 666090f87..af65d4c4a 100755
--- a/scripts/apply_flavor_huawei.sh
+++ b/scripts/apply_flavor_huawei.sh
@@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
-flutter clean
+./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_huawei|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_console|g' "$PUBSPEC_PATH"
-flutter pub get
+./flutterw pub get
diff --git a/scripts/apply_flavor_izzy.sh b/scripts/apply_flavor_izzy.sh
index 88ef4ed62..ac86e7398 100755
--- a/scripts/apply_flavor_izzy.sh
+++ b/scripts/apply_flavor_izzy.sh
@@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
-flutter clean
+./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_google|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_console|g' "$PUBSPEC_PATH"
-flutter pub get
+./flutterw pub get
diff --git a/scripts/apply_flavor_libre.sh b/scripts/apply_flavor_libre.sh
index 3e9aa6321..da614cf99 100755
--- a/scripts/apply_flavor_libre.sh
+++ b/scripts/apply_flavor_libre.sh
@@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
-flutter clean
+./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_none|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_console|g' "$PUBSPEC_PATH"
-flutter pub get
+./flutterw pub get
diff --git a/scripts/apply_flavor_play.sh b/scripts/apply_flavor_play.sh
index 3268d5a6d..1775ad361 100755
--- a/scripts/apply_flavor_play.sh
+++ b/scripts/apply_flavor_play.sh
@@ -5,9 +5,9 @@ fi
PUBSPEC_PATH="pubspec.yaml"
-flutter clean
+./flutterw clean
sed -i 's|plugins/aves_services_.*|plugins/aves_services_google|g' "$PUBSPEC_PATH"
sed -i 's|plugins/aves_report_.*|plugins/aves_report_crashlytics|g' "$PUBSPEC_PATH"
-flutter pub get
+./flutterw pub get
diff --git a/scripts/pub_get_all.sh b/scripts/pub_get_all.sh
index 47bc01692..23b780c2c 100755
--- a/scripts/pub_get_all.sh
+++ b/scripts/pub_get_all.sh
@@ -3,12 +3,12 @@ if [ ! -d "scripts" ]; then
cd ..
fi
-flutter pub get
+./flutterw pub get
cd plugins || exit
for plugin in $(ls -d *); do
cd $plugin
- flutter pub get
+ ../../flutterw pub get
cd ..
done
cd ..
diff --git a/scripts/pub_upgrade_all.sh b/scripts/pub_upgrade_all.sh
index 0710b7262..496d7d4da 100755
--- a/scripts/pub_upgrade_all.sh
+++ b/scripts/pub_upgrade_all.sh
@@ -3,12 +3,12 @@ if [ ! -d "scripts" ]; then
cd ..
fi
-flutter pub upgrade
+./flutterw pub upgrade
cd plugins || exit
for plugin in $(ls -d *); do
cd $plugin
- flutter pub upgrade
+ ../../flutterw pub upgrade
cd ..
done
cd ..
diff --git a/scripts/update_flutter_version.sh b/scripts/update_flutter_version.sh
index 55efd68ca..868c464c0 100755
--- a/scripts/update_flutter_version.sh
+++ b/scripts/update_flutter_version.sh
@@ -1,10 +1,15 @@
#!/bin/bash
-FILE_PATH="../lib/flutter_version.dart"
+if [ ! -d "scripts" ]; then
+ cd ..
+fi
+
+FILE_PATH="lib/flutter_version.dart"
+
rm "$FILE_PATH"
echo "Updating flutter_version.dart:"
{
echo "const Map version = "
- flutter --version --machine
+ ./flutterw --version --machine
echo ";"
} >> "$FILE_PATH"
cat "$FILE_PATH"