chore: disable hermes and cleanup gradle vars (#18832)

fixes #18831

We update the nix derivation to build android by passing `hermesEnabled` flag which checks the environment variable and if the environment variable is not set we default `hermesEnabled` to `true`.
This ensures that `hermes` is disabled for debug builds and enabled for release builds.

In this commit we also
- rename `nix/mobile/android/release.nix` → `nix/mobile/android/build.nix` since that nix file no longer generates release only builds.
- cleanup 2 other env vars and use the `gradle` project format
- replace `BUILD_NUMBER` with `verisonCode` for consistency
- replace `androidGradleOpts ` with `buildUrl ` 
- bump `status-jenkins-lib` to v1.8.7
This commit is contained in:
Siddarth Kumar 2024-02-15 13:48:11 +05:30 committed by GitHub
parent 1d2c01c16b
commit 2c96c38339
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
20 changed files with 33 additions and 37 deletions

View File

@ -214,7 +214,7 @@ build-fdroid: ##@build Build release for F-Droid
build-android: export BUILD_ENV ?= prod build-android: export BUILD_ENV ?= prod
build-android: export BUILD_TYPE ?= nightly build-android: export BUILD_TYPE ?= nightly
build-android: export BUILD_NUMBER ?= $(TMP_BUILD_NUMBER) build-android: export ORG_GRADLE_PROJECT_versionCode ?= $(TMP_BUILD_NUMBER)
build-android: export ANDROID_ABI_SPLIT ?= false build-android: export ANDROID_ABI_SPLIT ?= false
build-android: export ANDROID_ABI_INCLUDE ?= armeabi-v7a;arm64-v8a;x86 build-android: export ANDROID_ABI_INCLUDE ?= armeabi-v7a;arm64-v8a;x86
build-android: ##@build Build unsigned Android APK build-android: ##@build Build unsigned Android APK

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
/* Options section can't access functions in objects. */ /* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild() def isPRBuild = utils.isPRBuild()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
/* Options section can't access functions in objects. */ /* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild() def isPRBuild = utils.isPRBuild()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
/* Options section can't access functions in objects. */ /* Options section can't access functions in objects. */
def isPRBuild = utils.isPRBuild() def isPRBuild = utils.isPRBuild()

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {
agent { label 'macos' } agent { label 'macos' }

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {
agent { label params.AGENT_LABEL } agent { label params.AGENT_LABEL }
@ -82,7 +82,7 @@ pipeline {
env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, 'android') env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, 'android')
/* Build/fetch deps required to build android release. */ /* Build/fetch deps required to build android release. */
nix.build( nix.build(
attr: 'targets.mobile.android.release.buildInputs', attr: 'targets.mobile.android.build.buildInputs',
sandbox: false, sandbox: false,
pure: false, pure: false,
link: false link: false

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {
agent { label 'linux' } agent { label 'linux' }

View File

@ -1,5 +1,5 @@
#!/usr/bin/env groovy #!/usr/bin/env groovy
library 'status-jenkins-lib@v1.8.5' library 'status-jenkins-lib@v1.8.7'
pipeline { pipeline {
agent { agent {

View File

@ -61,7 +61,7 @@ We will use the `make jsbundle` target as an example of a derivation you can bui
3. [`build.sh`](/nix/scripts/build.sh) calls `nix-build --attr targets.mobile.jsbundle` with extra arguments 3. [`build.sh`](/nix/scripts/build.sh) calls `nix-build --attr targets.mobile.jsbundle` with extra arguments
4. `nix-build` builds the derivation from [`nix/mobile/jsbundle/default.nix`](/nix/mobile/jsbundle/default.nix) 4. `nix-build` builds the derivation from [`nix/mobile/jsbundle/default.nix`](/nix/mobile/jsbundle/default.nix)
The same can be done for other targets like `targets.mobile.android.release`. The same can be done for other targets like `targets.mobile.android.build`.
Except in that case extra arguments are required which is why the [`scripts/release-android.sh`](/scripts/release-android.sh) is used in the `make release-android` target. Except in that case extra arguments are required which is why the [`scripts/release-android.sh`](/scripts/release-android.sh) is used in the `make release-android` target.
If you run `make release-android` you'll see the `nix-build` command used: If you run `make release-android` you'll see the `nix-build` command used:
@ -71,14 +71,14 @@ nix-build \
--fallback \ --fallback \
--no-out-link \ --no-out-link \
--show-trace \ --show-trace \
--attr targets.mobile.android.release \ --attr targets.mobile.android.build \
--argstr secrets-file '/tmp/tmp-status-mobile-559a3a441/tmp.xAnrPuNtAP' \ --argstr secrets-file '/tmp/tmp-status-mobile-559a3a441/tmp.xAnrPuNtAP' \
--option extra-sandbox-paths '/home/joe/.gradle/status-im.keystore /tmp/tmp-status-mobile-559a3a441/tmp.xAnrPuNtAP' \ --option extra-sandbox-paths '/home/joe/.gradle/status-im.keystore /tmp/tmp-status-mobile-559a3a441/tmp.xAnrPuNtAP' \
default.nix default.nix
``` ```
Some of those are required which is why just calling: Some of those are required which is why just calling:
``` ```
nix-build --attr targets.mobile.android.release nix-build --attr targets.mobile.android.build
``` ```
Would fail. Would fail.

View File

@ -28,7 +28,7 @@ export STATUS_GO_IPFS_GATEWAY_URL="https://ipfs.status.im/"
``` ```
You can see the defaults in code: You can see the defaults in code:
- [`nix/status-go/default.nix`](./status-go/default.nix) - [`nix/status-go/default.nix`](./status-go/default.nix)
- [`nix/mobile/android/release.nix`](./mobile/android/release.nix) - [`nix/mobile/android/release.nix`](./mobile/android/build.nix)
## Shell ## Shell

View File

@ -6,7 +6,7 @@ This directory contains the tools and the data that allows Nix to manage Gradle
Simply calling `generate.sh` should result in a `deps.json` file which is used in the derivation that provides Gradle dependencies when building the Android app. Simply calling `generate.sh` should result in a `deps.json` file which is used in the derivation that provides Gradle dependencies when building the Android app.
You can see in [`nix/mobile/android/release.nix`](../../mobile/android/release.nix) that it's used via the `-Dmaven.repo.local='${deps.gradle}'` Gradle flag. You can see in [`nix/mobile/android/release.nix`](../../mobile/android/build.nix) that it's used via the `-Dmaven.repo.local='${deps.gradle}'` Gradle flag.
# Files # Files

View File

@ -7,15 +7,15 @@
# Path to the file containing secret environment variables # Path to the file containing secret environment variables
secretsFile ? "", secretsFile ? "",
# Build type (influences which .env file gets used for feature flags) # Build type (influences which .env file gets used for feature flags)
# TODO: pr or relase for default?
buildType ? lib.getEnvWithDefault "BUILD_TYPE" "release", buildType ? lib.getEnvWithDefault "BUILD_TYPE" "release",
# Used for versionCode # Used for versionCode
buildNumber ? lib.getEnvWithDefault "BUILD_NUMBER" 9999, versionCode ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_versionCode" 9999,
# Included in APK Manifest for easier identification. # Included in APK Manifest for easier identification.
# TODO: or GIT_COMMIT from Jenkins? commitHash ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_commitHash" "unknown",
commitHash ? lib.getEnvWithDefault "COMMIT_HASH" "unknown", # Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
# Gradle options passed for Android builds # https://github.com/status-im/status-mobile/issues/18493
androidGradleOpts ? lib.getEnvWithDefault "ANDROID_GRADLE_OPTS" null, hermesEnabled ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_hermesEnabled" "true",
buildUrl ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_buildUrl" null,
statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null, statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null,
# If APKs should be split based on architectures # If APKs should be split based on architectures
androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "false", androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "false",
@ -83,7 +83,10 @@ in stdenv.mkDerivation rec {
ANDROID_ABI_INCLUDE = androidAbiInclude; ANDROID_ABI_INCLUDE = androidAbiInclude;
# Disabled for debug builds to avoid 'maximum call stack exceeded' errors. # Disabled for debug builds to avoid 'maximum call stack exceeded' errors.
# https://github.com/status-im/status-mobile/issues/18493 # https://github.com/status-im/status-mobile/issues/18493
ORG_GRADLE_PROJECT_hermesEnabled = true; ORG_GRADLE_PROJECT_versionCode = versionCode;
ORG_GRADLE_PROJECT_commitHash = commitHash;
ORG_GRADLE_PROJECT_buildUrl = buildUrl;
ORG_GRADLE_PROJECT_hermesEnabled = hermesEnabled;
# Fix for ERR_OSSL_EVP_UNSUPPORTED error. # Fix for ERR_OSSL_EVP_UNSUPPORTED error.
NODE_OPTIONS = "--openssl-legacy-provider"; NODE_OPTIONS = "--openssl-legacy-provider";
@ -118,8 +121,6 @@ in stdenv.mkDerivation rec {
# Symlink React Native entrypoint. # Symlink React Native entrypoint.
cp -Lr ${builtJsBundle} ./result cp -Lr ${builtJsBundle} ./result
pwd
find -L result
# Copy android/ directory # Copy android/ directory
mkdir -p ./android/build mkdir -p ./android/build
@ -146,7 +147,6 @@ in stdenv.mkDerivation rec {
"LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${makeLibraryPath [ pkgs.zlib ]}"; "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${makeLibraryPath [ pkgs.zlib ]}";
gradleCommand = '' gradleCommand = ''
${pkgs.gradle}/bin/gradle \ ${pkgs.gradle}/bin/gradle \
${toString androidGradleOpts} \
--console=plain \ --console=plain \
--offline \ --offline \
--no-daemon \ --no-daemon \
@ -154,8 +154,6 @@ in stdenv.mkDerivation rec {
--no-watch-fs \ --no-watch-fs \
--no-build-cache \ --no-build-cache \
-Dmaven.repo.local='${deps.gradle}' \ -Dmaven.repo.local='${deps.gradle}' \
-PversionCode=${toString buildNumber} \
-PcommitHash=${commitHash} \
assemble${gradleBuildType} assemble${gradleBuildType}
''; '';
in in

View File

@ -2,7 +2,7 @@
, jsbundle, status-go, androidPkgs, androidShell }: , jsbundle, status-go, androidPkgs, androidShell }:
rec { rec {
release = callPackage ./release.nix { build = callPackage ./build.nix {
inherit jsbundle status-go; inherit jsbundle status-go;
}; };
@ -15,7 +15,7 @@ rec {
]; ];
inputsFrom = [ inputsFrom = [
(release {}) (build {})
androidShell androidShell
]; ];

View File

@ -45,7 +45,7 @@ if [[ -z "${TARGET}" ]]; then
fi fi
# Hack fix for missing Android SDK for aarch64 on Darwin. See systemOverride in `nix/pkgs.nix`. # Hack fix for missing Android SDK for aarch64 on Darwin. See systemOverride in `nix/pkgs.nix`.
if [[ "${TARGET}" =~ ^(targets.status-go.mobile.android|targets.mobile.android.release)$ ]]; then if [[ "${TARGET}" =~ ^(targets.status-go.mobile.android|targets.mobile.android.build)$ ]]; then
os=$(uname -s | tr '[:upper:]' '[:lower:]') os=$(uname -s | tr '[:upper:]' '[:lower:]')
export NIXPKGS_SYSTEM_OVERRIDE="x86_64-${os}" export NIXPKGS_SYSTEM_OVERRIDE="x86_64-${os}"
fi fi

View File

@ -21,8 +21,6 @@ function append_env_export() {
VAR_VALUE=$(must_get_env "${VAR_NAME}") VAR_VALUE=$(must_get_env "${VAR_NAME}")
echo "export ${VAR_NAME}=\"${VAR_VALUE}\";" >> "${SECRETS_FILE_PATH}" echo "export ${VAR_NAME}=\"${VAR_VALUE}\";" >> "${SECRETS_FILE_PATH}"
} }
export COMMIT_HASH="$(git rev-parse --verify HEAD)"
nixOpts=() nixOpts=()
# We create if now so the trap knows its location # We create if now so the trap knows its location
@ -73,4 +71,4 @@ else
fi fi
"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.release "${nixOpts[@]}" "${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.build "${nixOpts[@]}"