Skip to content

Commit

Permalink
speed up android debug builds (#19335)
Browse files Browse the repository at this point in the history
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 )
  • Loading branch information
siddarthkay authored Mar 23, 2024
1 parent ebc12c3 commit 399da79
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 6 deletions.
4 changes: 0 additions & 4 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -199,10 +199,6 @@ android {
doNotStrip '*/mips/*.so'
doNotStrip '*/mips64/*.so'
}
dexOptions {
jumboMode true
javaMaxHeapSize "8g"
}
splits {
abi {
reset()
Expand Down
17 changes: 17 additions & 0 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,23 @@ subprojects {
defaultConfig {
targetSdkVersion rootProject.ext.targetSdkVersion
}

// Speed up Tests Stage
tasks.withType(Test).configureEach {
// https://docs.gradle.org/current/userguide/performance.html#execute_tests_in_parallel
maxParallelForks = Runtime.runtime.availableProcessors().intdiv(2) ?: 1
// https://docs.gradle.org/current/userguide/performance.html#fork_tests_into_multiple_processes
forkEvery = 100
// https://docs.gradle.org/current/userguide/performance.html#disable_reports
reports.html.required = false
reports.junitXml.required = false
}
// Speed up Java Compile Stage
// https://docs.gradle.org/current/userguide/performance.html#run_the_compiler_as_a_separate_process
tasks.withType(JavaCompile).configureEach {
options.fork = true
}

}
}
}
Expand Down
2 changes: 1 addition & 1 deletion android/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ ANDROID_ABI_SPLIT=false
# Some platforms are excluded though
ANDROID_ABI_INCLUDE=armeabi-v7a;arm64-v8a;x86;x86_64

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

versionCode=9999
commitHash=unknown
Expand Down
6 changes: 5 additions & 1 deletion nix/mobile/android/build.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,10 @@

let
inherit (lib) toLower optionalString stringLength makeLibraryPath elem;
notDebug = (buildType != "debug");

# Pass secretsFile for POKT_TOKEN to jsbundle build
builtJsBundle = jsbundle { inherit secretsFile; };
builtJsBundle = lib.optionals notDebug jsbundle { inherit secretsFile; };

# Map ANDROID_ABI_INCLUDE to status-go targets
androidAbiIncludeSplit = lib.splitString ";" androidAbiInclude;
Expand Down Expand Up @@ -119,8 +120,10 @@ in stdenv.mkDerivation rec {
# Export all vars from .env file
export $(cut -d= -f1 .env)
${lib.optionalString notDebug ''
# Symlink React Native entrypoint.
cp -Lr ${builtJsBundle} ./result
''}
# Copy android/ directory
mkdir -p ./android/build
Expand Down Expand Up @@ -153,6 +156,7 @@ in stdenv.mkDerivation rec {
--no-scan \
--no-watch-fs \
--no-build-cache \
--parallel \
-Dmaven.repo.local='${deps.gradle}' \
assemble${gradleBuildType}
'';
Expand Down

0 comments on commit 399da79

Please sign in to comment.