Unverified Commit 14b427a7 authored by John Ericson's avatar John Ericson Committed by GitHub
Browse files

Merge pull request #119092 from numinit/update-androidenv

androidenv: Allow multiple ndkVersions to be specified
parents 4ac8826b a7e5b070
Loading
Loading
Loading
Loading
+6 −2
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ let
    abiVersions = [ "armeabi-v7a" "arm64-v8a" ];
    cmakeVersions = [ "3.10.2" ];
    includeNDK = true;
    ndkVersion = "22.0.7026061";
    ndkVersions = ["22.0.7026061"];
    useGoogleAPIs = false;
    useGoogleTVAddOns = false;
    includeExtras = [
@@ -52,7 +52,11 @@ The following parameters are supported:
* `cmakeVersions` specifies which CMake versions should be deployed.
* `includeNDK` specifies that the Android NDK bundle should be included.
  Defaults to: `false`.
* `ndkVersion` specifies the NDK version that we want to use.
* `ndkVersions` specifies the NDK versions that we want to use. These are linked
  under the `ndk` directory of the SDK root, and the first is linked under the
  `ndk-bundle` directory.
* `ndkVersion` is equivalent to specifying one entry in `ndkVersions`, and
  `ndkVersions` overrides this parameter if provided.
* `includeExtras` is an array of identifier strings referring to arbitrary
  add-on packages that should be installed.
* `platformVersions` specifies which platform SDK versions should be included.
+26 −8
Original line number Diff line number Diff line
@@ -3,10 +3,10 @@
}:

{ toolsVersion ? "26.1.1"
, platformToolsVersion ? "30.0.5"
, platformToolsVersion ? "31.0.2"
, buildToolsVersions ? [ "30.0.3" ]
, includeEmulator ? false
, emulatorVersion ? "30.3.4"
, emulatorVersion ? "30.6.3"
, platformVersions ? []
, includeSources ? false
, includeSystemImages ? false
@@ -14,7 +14,8 @@
, abiVersions ? [ "armeabi-v7a" ]
, cmakeVersions ? [ ]
, includeNDK ? false
, ndkVersion ? "22.0.7026061"
, ndkVersion ? "22.1.7171670"
, ndkVersions ? [ndkVersion]
, useGoogleAPIs ? false
, useGoogleTVAddOns ? false
, includeExtras ? []
@@ -175,11 +176,19 @@ rec {
    }
  ) cmakeVersions;

  ndk-bundle = import ./ndk-bundle {
  # Creates a NDK bundle.
  makeNdkBundle = ndkVersion:
    import ./ndk-bundle {
      inherit deployAndroidPackage os autoPatchelfHook makeWrapper pkgs pkgsHostHost lib platform-tools;
      package = packages.ndk-bundle.${ndkVersion};
    };

  # All NDK bundles.
  ndk-bundles = if includeNDK then map makeNdkBundle ndkVersions else [];

  # The "default" NDK bundle.
  ndk-bundle = if includeNDK then lib.findFirst (x: x != null) null ndk-bundles else null;

  google-apis = map (version:
    deployAndroidPackage {
      inherit os;
@@ -203,6 +212,15 @@ rec {
      '') plugins}
    '';

  # Function that automatically links all NDK plugins.
  linkNdkPlugins = {name, plugins, rootName ? name}:
    lib.optionalString (plugins != []) ''
      mkdir -p ${rootName}
      ${lib.concatMapStrings (plugin: ''
        ln -s ${plugin}/libexec/android-sdk/${name} ${rootName}/${plugin.version}
      '') plugins}
    '';

  # Function that automatically links a plugin for which only one version exists
  linkPlugin = {name, plugin, check ? true}:
    lib.optionalString check ''
@@ -233,13 +251,13 @@ rec {

    postInstall = ''
      # Symlink all requested plugins

      ${linkPlugin { name = "platform-tools"; plugin = platform-tools; }}
      ${linkPlugins { name = "build-tools"; plugins = build-tools; }}
      ${linkPlugin { name = "emulator"; plugin = emulator; check = includeEmulator; }}
      ${linkPlugins { name = "platforms"; plugins = platforms; }}
      ${linkPlatformPlugins { name = "sources"; plugins = sources; check = includeSources; }}
      ${linkPlugins { name = "cmake"; plugins = cmake; }}
      ${linkNdkPlugins { name = "ndk-bundle"; rootName = "ndk"; plugins = ndk-bundles; }}
      ${linkPlugin { name = "ndk-bundle"; plugin = ndk-bundle; check = includeNDK; }}

      ${lib.optionalString includeSystemImages ''
+9 −9
Original line number Diff line number Diff line
@@ -23,14 +23,14 @@ let
  android = {
    versions = {
      tools = "26.1.1";
      platformTools = "30.0.5";
      platformTools = "31.0.2";
      buildTools = "30.0.3";
      ndk = "22.0.7026061";

      # or the LTS NDK:
      # ndk = "21.3.6528147";
      cmake = "3.10.2";
      emulator = "30.3.4";
      ndk = [
        "22.1.7171670"
        "21.3.6528147" # LTS NDK
      ];
      cmake = "3.18.1";
      emulator = "30.6.3";
    };

    platforms = ["23" "24" "25" "26" "27" "28" "29" "30"];
@@ -69,7 +69,7 @@ let
    emulatorVersion = android.versions.emulator;

    includeNDK = true;
    ndkVersion = android.versions.ndk;
    ndkVersions = android.versions.ndk;
    cmakeVersions = [android.versions.cmake];

    useGoogleAPIs = true;
@@ -130,7 +130,7 @@ pkgs.mkShell rec {

  shellHook = ''
    # Add cmake to the path.
    cmake_root="$(echo "$ANDROID_SDK_ROOT/cmake/${android.versions.cmake}".*/)"
    cmake_root="$(echo "$ANDROID_SDK_ROOT/cmake/${android.versions.cmake}"*/)"
    export PATH="$cmake_root/bin:$PATH"

    # Write out local.properties for Android Studio.
+455 −106

File changed.

Preview size limit exceeded, changes collapsed.