Skip to content

Commit 399da79

Browse files
authored
speed up android debug builds (#19335)
fixes #19081 ## Summary This PR aims to improve android build step for debug variants by ensuring we do not rebuild the android derivation for any change made to `clojurescript` code. We also do the following things : - enable `JVM` parallel garbage collector. - get rid of `dexOptions` which was deprecated in `gradle 8`. - add additional `parallel` flag to `gradle` to speed up builds. ## Review notes - `make run-clojure` - `make run-android` - ctrl + C on android terminal and edit any `cljs` file - `make run-android` ( should build almost instantly )
1 parent ebc12c3 commit 399da79

File tree

4 files changed

+23
-6
lines changed

4 files changed

+23
-6
lines changed

android/app/build.gradle

-4
Original file line numberDiff line numberDiff line change
@@ -199,10 +199,6 @@ android {
199199
doNotStrip '*/mips/*.so'
200200
doNotStrip '*/mips64/*.so'
201201
}
202-
dexOptions {
203-
jumboMode true
204-
javaMaxHeapSize "8g"
205-
}
206202
splits {
207203
abi {
208204
reset()

android/build.gradle

+17
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,23 @@ subprojects {
4444
defaultConfig {
4545
targetSdkVersion rootProject.ext.targetSdkVersion
4646
}
47+
48+
// Speed up Tests Stage
49+
tasks.withType(Test).configureEach {
50+
// https://docs.gradle.org/current/userguide/performance.html#execute_tests_in_parallel
51+
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
52+
// https://docs.gradle.org/current/userguide/performance.html#fork_tests_into_multiple_processes
53+
forkEvery = 100
54+
// https://docs.gradle.org/current/userguide/performance.html#disable_reports
55+
reports.html.required = false
56+
reports.junitXml.required = false
57+
}
58+
// Speed up Java Compile Stage
59+
// https://docs.gradle.org/current/userguide/performance.html#run_the_compiler_as_a_separate_process
60+
tasks.withType(JavaCompile).configureEach {
61+
options.fork = true
62+
}
63+
4764
}
4865
}
4966
}

android/gradle.properties

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ ANDROID_ABI_SPLIT=false
4343
# Some platforms are excluded though
4444
ANDROID_ABI_INCLUDE=armeabi-v7a;arm64-v8a;x86;x86_64
4545

46-
org.gradle.jvmargs=-Xmx8704M
46+
org.gradle.jvmargs=-Xmx8704M -XX:+UseParallelGC
4747

4848
versionCode=9999
4949
commitHash=unknown

nix/mobile/android/build.nix

+5-1
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,10 @@
2626

2727
let
2828
inherit (lib) toLower optionalString stringLength makeLibraryPath elem;
29+
notDebug = (buildType != "debug");
2930

3031
# Pass secretsFile for POKT_TOKEN to jsbundle build
31-
builtJsBundle = jsbundle { inherit secretsFile; };
32+
builtJsBundle = lib.optionals notDebug jsbundle { inherit secretsFile; };
3233

3334
# Map ANDROID_ABI_INCLUDE to status-go targets
3435
androidAbiIncludeSplit = lib.splitString ";" androidAbiInclude;
@@ -119,8 +120,10 @@ in stdenv.mkDerivation rec {
119120
# Export all vars from .env file
120121
export $(cut -d= -f1 .env)
121122
123+
${lib.optionalString notDebug ''
122124
# Symlink React Native entrypoint.
123125
cp -Lr ${builtJsBundle} ./result
126+
''}
124127
125128
# Copy android/ directory
126129
mkdir -p ./android/build
@@ -153,6 +156,7 @@ in stdenv.mkDerivation rec {
153156
--no-scan \
154157
--no-watch-fs \
155158
--no-build-cache \
159+
--parallel \
156160
-Dmaven.repo.local='${deps.gradle}' \
157161
assemble${gradleBuildType}
158162
'';

0 commit comments

Comments
 (0)