44 lines
1.5 KiB
Bash
Executable File
44 lines
1.5 KiB
Bash
Executable File
#!/bin/sh
|
|
# Builds the app from the read-only source at /src into /out.
|
|
# Usage: pipelines-app-build web|apk [flutter build arguments...]
|
|
set -eu
|
|
kind="$1"
|
|
shift
|
|
rm -rf /tmp/work && mkdir -p /tmp/work
|
|
# A private copy: the host checkout's build outputs and machine paths stay out.
|
|
(cd /src && tar --exclude=./build --exclude=./.dart_tool --exclude=./android/.gradle \
|
|
--exclude=./android/local.properties --exclude=./android/app/.cxx --exclude=./ios/Pods \
|
|
--exclude=./macos/Pods --exclude=./macos/Flutter/ephemeral --exclude=./linux/flutter/ephemeral \
|
|
-cf - .) | tar -C /tmp/work -xf -
|
|
cd /tmp/work
|
|
flutter pub get
|
|
case "$kind" in
|
|
web)
|
|
flutter build web --release --no-web-resources-cdn "$@"
|
|
cp -R build/web/. /out/
|
|
;;
|
|
apk)
|
|
# Flutter's template permits an 8 GiB Gradle heap plus separate Kotlin
|
|
# daemons. That exceeds a typical Docker Desktop VM before APK packaging.
|
|
# Limit only this private build copy, not native developers' settings.
|
|
cat >> android/gradle.properties <<'PROPERTIES'
|
|
|
|
org.gradle.jvmargs=-Xmx3G -XX:MaxMetaspaceSize=1G -XX:ReservedCodeCacheSize=256m -XX:+HeapDumpOnOutOfMemoryError
|
|
org.gradle.workers.max=2
|
|
org.gradle.parallel=false
|
|
org.gradle.vfs.watch=false
|
|
kotlin.compiler.execution.strategy=in-process
|
|
PROPERTIES
|
|
flutter build apk --release "$@"
|
|
cp build/app/outputs/flutter-apk/app-release.apk /out/pipelines.apk
|
|
;;
|
|
linux)
|
|
flutter build linux --release "$@"
|
|
cp -a build/linux/x64/release/bundle/. /out/
|
|
;;
|
|
*)
|
|
echo "unknown build: $kind" >&2
|
|
exit 2
|
|
;;
|
|
esac
|