Skip to content

Commit

Permalink
nix: map android arch to status-go builds
Browse files Browse the repository at this point in the history
Fixes partially #15595
In order to build less targets, when not needed we introduce this
mapping logic.
If only specific ABI is required - status-go will have the same
arhitecuture.
  • Loading branch information
yakimant authored and yevh-berdnyk committed Aug 23, 2023
1 parent e0f8338 commit 34f7a48
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 20 deletions.
10 changes: 1 addition & 9 deletions nix/mobile/android/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,11 @@ rec {
];

inputsFrom = [
release
(release {})
androidShell
];

shellHook = ''
export ANDROID_SDK_ROOT="${androidPkgs.sdk}"
export ANDROID_NDK_ROOT="${androidPkgs.ndk}"
export STATUS_NIX_MAVEN_REPO="${deps.gradle}"
# required by some makefile targets
export STATUS_GO_ANDROID_LIBDIR=${status-go}
# check if node modules changed and if so install them
$STATUS_MOBILE_HOME/nix/scripts/node_modules.sh ${deps.nodejs-patched}
'';
Expand Down
24 changes: 16 additions & 8 deletions nix/mobile/android/release.nix
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ let
# Pass secretsFile for POKT_TOKEN to jsbundle build
builtJsBundle = jsbundle { inherit secretsFile; };

# Map ANDROID_ABI_INCLUDE to status-go targets
androidAbiIncludeSplit = lib.splitString ";" androidAbiInclude;


envFileName =
if androidAbiInclude == "x86" then ".env.e2e"
Expand Down Expand Up @@ -77,20 +80,25 @@ in stdenv.mkDerivation rec {
ANDROID_ABI_SPLIT = androidAbiSplit;
ANDROID_ABI_INCLUDE = androidAbiInclude;

# Android SDK/NDK for use by Gradle
ANDROID_SDK_ROOT = "${androidPkgs.sdk}";
ANDROID_NDK_ROOT = "${androidPkgs.ndk}";

# Fix for ERR_OSSL_EVP_UNSUPPORTED error.
NODE_OPTIONS = "--openssl-legacy-provider";

# Used by the Android Gradle build script in android/build.gradle
STATUS_GO_ANDROID_LIBDIR = status-go;

phases = [
"unpackPhase" "secretsPhase" "buildPhase" "checkPhase" "installPhase"
"shellHook" "unpackPhase" "secretsPhase" "buildPhase" "checkPhase" "installPhase"
];

# We use shellHook as a single place to setup env vars for both build derivation and shell
shellHook = ''
# Used by the Android Gradle build script in android/build.gradle
export STATUS_GO_ANDROID_LIBDIR=${ status-go { abis = androidAbiIncludeSplit; } }
# Android SDK/NDK for use by Gradle
export ANDROID_SDK_ROOT="${androidPkgs.sdk}"
export ANDROID_NDK_ROOT="${androidPkgs.ndk}"
export STATUS_NIX_MAVEN_REPO="${deps.gradle}"
'';

unpackPhase = ''
cp -ar $src/. ./
chmod u+w -R ./
Expand Down
2 changes: 1 addition & 1 deletion nix/shells.nix
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ let
# helpers for use with target argument
ios = targets.mobile.ios.shell;
android = targets.mobile.android.shell;
status-go = targets.status-go.mobile.android;
status-go = targets.status-go.mobile.android {};
};

# for merging the default shell with others
Expand Down
12 changes: 10 additions & 2 deletions nix/status-go/mobile/default.nix
Original file line number Diff line number Diff line change
@@ -1,10 +1,18 @@
{ callPackage, meta, source, goBuildLdFlags }:

{
android = callPackage ./build.nix {
android = {abis ? [ "armeabi-v7a" "arm64-v8a" "x86" ]}: callPackage ./build.nix {
platform = "android";
platformVersion = "23";
targets = [ "android/arm" "android/arm64" "android/386" ];
# Hide different arch naming in gomobile from Android builds.
targets = let
abiMap = {
"armeabi-v7a" = "android/arm";
"arm64-v8a" = "android/arm64";
"x86" = "android/386";
"x86_64" = "android/amd64";
};
in map (arch: abiMap."${arch}") abis;
outputFileName = "status-go-${source.shortRev}.aar";
inherit meta source goBuildLdFlags;
};
Expand Down

0 comments on commit 34f7a48

Please sign in to comment.