From 2c96c38339339977f53aa839eae2bac78b68764e Mon Sep 17 00:00:00 2001 From: Siddarth Kumar Date: Thu, 15 Feb 2024 13:48:11 +0530 Subject: [PATCH] chore: disable hermes and cleanup gradle vars (#18832) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- Makefile | 2 +- ci/Jenkinsfile.android | 2 +- ci/Jenkinsfile.combined | 2 +- ci/Jenkinsfile.e2e-nightly | 2 +- ci/Jenkinsfile.ios | 2 +- ci/Jenkinsfile.tests | 2 +- ci/tests/Jenkinsfile.e2e-nightly | 2 +- ci/tests/Jenkinsfile.e2e-prs | 2 +- ci/tests/Jenkinsfile.e2e-upgrade | 2 +- ci/tools/Jenkinsfile.fastlane-clean | 2 +- ci/tools/Jenkinsfile.nix-cache | 4 ++-- ci/tools/Jenkinsfile.playstore-meta | 2 +- ci/tools/Jenkinsfile.xcode-clean | 2 +- nix/DETAILS.md | 6 ++--- nix/README.md | 2 +- nix/deps/gradle/README.md | 2 +- nix/mobile/android/{release.nix => build.nix} | 22 +++++++++---------- nix/mobile/android/default.nix | 4 ++-- nix/scripts/build.sh | 2 +- scripts/build-android.sh | 4 +--- 20 files changed, 33 insertions(+), 37 deletions(-) rename nix/mobile/android/{release.nix => build.nix} (89%) diff --git a/Makefile b/Makefile index 4fe32474e0..11a8d1de95 100644 --- a/Makefile +++ b/Makefile @@ -214,7 +214,7 @@ build-fdroid: ##@build Build release for F-Droid build-android: export BUILD_ENV ?= prod 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_INCLUDE ?= armeabi-v7a;arm64-v8a;x86 build-android: ##@build Build unsigned Android APK diff --git a/ci/Jenkinsfile.android b/ci/Jenkinsfile.android index c4a72bd47c..9385128c5a 100644 --- a/ci/Jenkinsfile.android +++ b/ci/Jenkinsfile.android @@ -1,5 +1,5 @@ #!/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. */ def isPRBuild = utils.isPRBuild() diff --git a/ci/Jenkinsfile.combined b/ci/Jenkinsfile.combined index 02eb9e1b83..c2a2f72d24 100644 --- a/ci/Jenkinsfile.combined +++ b/ci/Jenkinsfile.combined @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { agent { label 'linux' } diff --git a/ci/Jenkinsfile.e2e-nightly b/ci/Jenkinsfile.e2e-nightly index 7495d9eee5..14c8f27b36 100644 --- a/ci/Jenkinsfile.e2e-nightly +++ b/ci/Jenkinsfile.e2e-nightly @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { agent { label 'linux' } diff --git a/ci/Jenkinsfile.ios b/ci/Jenkinsfile.ios index 84305e791c..fd18541eb8 100644 --- a/ci/Jenkinsfile.ios +++ b/ci/Jenkinsfile.ios @@ -1,5 +1,5 @@ #!/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. */ def isPRBuild = utils.isPRBuild() diff --git a/ci/Jenkinsfile.tests b/ci/Jenkinsfile.tests index 02a0825e6c..d41585373b 100644 --- a/ci/Jenkinsfile.tests +++ b/ci/Jenkinsfile.tests @@ -1,5 +1,5 @@ #!/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. */ def isPRBuild = utils.isPRBuild() diff --git a/ci/tests/Jenkinsfile.e2e-nightly b/ci/tests/Jenkinsfile.e2e-nightly index 439135c4f6..071ca89df1 100644 --- a/ci/tests/Jenkinsfile.e2e-nightly +++ b/ci/tests/Jenkinsfile.e2e-nightly @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { diff --git a/ci/tests/Jenkinsfile.e2e-prs b/ci/tests/Jenkinsfile.e2e-prs index a472efe55e..6ecbcc7c68 100644 --- a/ci/tests/Jenkinsfile.e2e-prs +++ b/ci/tests/Jenkinsfile.e2e-prs @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { diff --git a/ci/tests/Jenkinsfile.e2e-upgrade b/ci/tests/Jenkinsfile.e2e-upgrade index 51b3b5c6b4..aea81c2519 100644 --- a/ci/tests/Jenkinsfile.e2e-upgrade +++ b/ci/tests/Jenkinsfile.e2e-upgrade @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { diff --git a/ci/tools/Jenkinsfile.fastlane-clean b/ci/tools/Jenkinsfile.fastlane-clean index 6b4c1dda35..e2b23ddd3a 100644 --- a/ci/tools/Jenkinsfile.fastlane-clean +++ b/ci/tools/Jenkinsfile.fastlane-clean @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { agent { label 'macos' } diff --git a/ci/tools/Jenkinsfile.nix-cache b/ci/tools/Jenkinsfile.nix-cache index e4db22adf3..fbb4bc6be4 100644 --- a/ci/tools/Jenkinsfile.nix-cache +++ b/ci/tools/Jenkinsfile.nix-cache @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { agent { label params.AGENT_LABEL } @@ -82,7 +82,7 @@ pipeline { env.NIXPKGS_SYSTEM_OVERRIDE = nixSysOverride(os, arch, 'android') /* Build/fetch deps required to build android release. */ nix.build( - attr: 'targets.mobile.android.release.buildInputs', + attr: 'targets.mobile.android.build.buildInputs', sandbox: false, pure: false, link: false diff --git a/ci/tools/Jenkinsfile.playstore-meta b/ci/tools/Jenkinsfile.playstore-meta index 80e0e0f49f..be389599f5 100644 --- a/ci/tools/Jenkinsfile.playstore-meta +++ b/ci/tools/Jenkinsfile.playstore-meta @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { agent { label 'linux' } diff --git a/ci/tools/Jenkinsfile.xcode-clean b/ci/tools/Jenkinsfile.xcode-clean index 52f6d58c6a..3a6c32e7ee 100644 --- a/ci/tools/Jenkinsfile.xcode-clean +++ b/ci/tools/Jenkinsfile.xcode-clean @@ -1,5 +1,5 @@ #!/usr/bin/env groovy -library 'status-jenkins-lib@v1.8.5' +library 'status-jenkins-lib@v1.8.7' pipeline { agent { diff --git a/nix/DETAILS.md b/nix/DETAILS.md index 79ff45535c..b295bf97f5 100644 --- a/nix/DETAILS.md +++ b/nix/DETAILS.md @@ -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 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. If you run `make release-android` you'll see the `nix-build` command used: @@ -71,14 +71,14 @@ nix-build \ --fallback \ --no-out-link \ --show-trace \ - --attr targets.mobile.android.release \ + --attr targets.mobile.android.build \ --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' \ default.nix ``` 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. diff --git a/nix/README.md b/nix/README.md index cbcd376136..86057e7188 100644 --- a/nix/README.md +++ b/nix/README.md @@ -28,7 +28,7 @@ export STATUS_GO_IPFS_GATEWAY_URL="https://ipfs.status.im/" ``` You can see the defaults in code: - [`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 diff --git a/nix/deps/gradle/README.md b/nix/deps/gradle/README.md index 138c524de9..4d8a47ec8d 100644 --- a/nix/deps/gradle/README.md +++ b/nix/deps/gradle/README.md @@ -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. -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 diff --git a/nix/mobile/android/release.nix b/nix/mobile/android/build.nix similarity index 89% rename from nix/mobile/android/release.nix rename to nix/mobile/android/build.nix index fcd60d3d8a..a11dba4509 100644 --- a/nix/mobile/android/release.nix +++ b/nix/mobile/android/build.nix @@ -7,15 +7,15 @@ # Path to the file containing secret environment variables secretsFile ? "", # Build type (influences which .env file gets used for feature flags) - # TODO: pr or relase for default? buildType ? lib.getEnvWithDefault "BUILD_TYPE" "release", # Used for versionCode - buildNumber ? lib.getEnvWithDefault "BUILD_NUMBER" 9999, + versionCode ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_versionCode" 9999, # Included in APK Manifest for easier identification. - # TODO: or GIT_COMMIT from Jenkins? - commitHash ? lib.getEnvWithDefault "COMMIT_HASH" "unknown", - # Gradle options passed for Android builds - androidGradleOpts ? lib.getEnvWithDefault "ANDROID_GRADLE_OPTS" null, + commitHash ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_commitHash" "unknown", + # Disabled for debug builds to avoid 'maximum call stack exceeded' errors. + # https://github.com/status-im/status-mobile/issues/18493 + hermesEnabled ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_hermesEnabled" "true", + buildUrl ? lib.getEnvWithDefault "ORG_GRADLE_PROJECT_buildUrl" null, statusGoSrcOverride ? lib.getEnvWithDefault "STATUS_GO_SRC_OVERRIDE" null, # If APKs should be split based on architectures androidAbiSplit ? lib.getEnvWithDefault "ANDROID_ABI_SPLIT" "false", @@ -83,7 +83,10 @@ in stdenv.mkDerivation rec { ANDROID_ABI_INCLUDE = androidAbiInclude; # Disabled for debug builds to avoid 'maximum call stack exceeded' errors. # 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. NODE_OPTIONS = "--openssl-legacy-provider"; @@ -118,8 +121,6 @@ in stdenv.mkDerivation rec { # Symlink React Native entrypoint. cp -Lr ${builtJsBundle} ./result - pwd - find -L result # Copy android/ directory mkdir -p ./android/build @@ -146,7 +147,6 @@ in stdenv.mkDerivation rec { "LD_LIBRARY_PATH=$LD_LIBRARY_PATH:${makeLibraryPath [ pkgs.zlib ]}"; gradleCommand = '' ${pkgs.gradle}/bin/gradle \ - ${toString androidGradleOpts} \ --console=plain \ --offline \ --no-daemon \ @@ -154,8 +154,6 @@ in stdenv.mkDerivation rec { --no-watch-fs \ --no-build-cache \ -Dmaven.repo.local='${deps.gradle}' \ - -PversionCode=${toString buildNumber} \ - -PcommitHash=${commitHash} \ assemble${gradleBuildType} ''; in diff --git a/nix/mobile/android/default.nix b/nix/mobile/android/default.nix index 69fe75016b..371d53859d 100644 --- a/nix/mobile/android/default.nix +++ b/nix/mobile/android/default.nix @@ -2,7 +2,7 @@ , jsbundle, status-go, androidPkgs, androidShell }: rec { - release = callPackage ./release.nix { + build = callPackage ./build.nix { inherit jsbundle status-go; }; @@ -15,7 +15,7 @@ rec { ]; inputsFrom = [ - (release {}) + (build {}) androidShell ]; diff --git a/nix/scripts/build.sh b/nix/scripts/build.sh index d9dd8f656a..d7ad408abb 100755 --- a/nix/scripts/build.sh +++ b/nix/scripts/build.sh @@ -45,7 +45,7 @@ if [[ -z "${TARGET}" ]]; then fi # 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:]') export NIXPKGS_SYSTEM_OVERRIDE="x86_64-${os}" fi diff --git a/scripts/build-android.sh b/scripts/build-android.sh index fdba77923d..eeb3a8e573 100755 --- a/scripts/build-android.sh +++ b/scripts/build-android.sh @@ -21,8 +21,6 @@ function append_env_export() { VAR_VALUE=$(must_get_env "${VAR_NAME}") echo "export ${VAR_NAME}=\"${VAR_VALUE}\";" >> "${SECRETS_FILE_PATH}" } - -export COMMIT_HASH="$(git rev-parse --verify HEAD)" nixOpts=() # We create if now so the trap knows its location @@ -73,4 +71,4 @@ else fi -"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.release "${nixOpts[@]}" +"${GIT_ROOT}/nix/scripts/build.sh" targets.mobile.android.build "${nixOpts[@]}"