mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-20 05:16:01 +00:00
perf(lab): compile with the Kotlin daemon, since in-process Kotlin compiles always redo the whole app
This commit is contained in:
1 parent
9d73ff75bc
commit
f638979507
2 files changed
+16
-5
No files matched your search
@@ -96,15 +96,24 @@ if [ ! -d "$ANDROID_HOME/platforms/android-34" ]; then
|
||||
"$ANDROID_HOME/cmdline-tools/latest/bin/sdkmanager" "platforms;android-34" "build-tools;35.0.0" >/dev/null
|
||||
fi
|
||||
|
||||
# A full Kotlin compile of the app needs about 3 GB of heap; smaller devices get what they can spare.
|
||||
# A full Kotlin compile of the app needs about 2.5 GB of heap and Gradle about 1 GB; smaller devices get
|
||||
# what they can spare. Both daemons end with this script's process when the build is done.
|
||||
total_mb=$(awk '/^MemTotal:/ {print int($2 / 1024)}' /proc/meminfo)
|
||||
heap=$(( total_mb * 2 / 5 )); [ $heap -gt 3072 ] && heap=3072; [ $heap -lt 1536 ] && heap=1536
|
||||
heap=$(( total_mb / 2 )); [ $heap -gt 4096 ] && heap=4096; [ $heap -lt 2048 ] && heap=2048
|
||||
heap=${DD_LAB_HEAP_MB:-$heap}
|
||||
kotlin_heap=$(( heap * 2 / 3 )); gradle_heap=$(( heap - kotlin_heap ))
|
||||
|
||||
# Only the Kotlin daemon compiles incrementally; in-process compiles always redo the whole app, and the
|
||||
# caches they leave behind make the daemon's first incremental compile fail.
|
||||
if [ "$(cat "$cache/dd-lab-build-strategy" 2>/dev/null)" != daemon ]; then
|
||||
rm -rf app/build/kotlin/compileReleaseKotlin
|
||||
echo daemon > "$cache/dd-lab-build-strategy"
|
||||
fi
|
||||
|
||||
# Google publishes aapt2 for x86-64 Linux only; setup wraps it in qemu-user at ~/aapt2/aapt2.
|
||||
gradle=(./gradlew :app:processReleaseResources :app:mergeDexRelease --max-workers=2 -PskipRust=true -x buildVkBridgeServer
|
||||
-Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=in-process
|
||||
-Dorg.gradle.jvmargs=-Xmx${heap}m --console=plain)
|
||||
-Pandroid.aapt2FromMavenOverride=$HOME/aapt2/aapt2 -Pkotlin.compiler.execution.strategy=daemon
|
||||
-Pkotlin.daemon.jvmargs=-Xmx${kotlin_heap}m -Dorg.gradle.jvmargs=-Xmx${gradle_heap}m --console=plain)
|
||||
progress planning
|
||||
mapfile -t plan < <("${gradle[@]}" --dry-run -q 2>/dev/null | awk '/^:/ {print $1}' || true)
|
||||
total=${#plan[@]}
|
||||
|
||||
Reference in new issue
Block a user