Commit 81ac8a76 authored by Morgan Jones's avatar Morgan Jones Committed by Masum Reza
Browse files

androidenv: support 5 years of Android APIs with images; test 10 without

Cut down on the number of system images that need to be fetched by just
supporting packages from the last 5 years. Still test the last 10 years
of APIs without images.
parent c75818be
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -88,6 +88,9 @@ The following parameters are supported:
  have an aarch64-linux compile).
* `platformVersions` specifies which platform SDK versions should be included.
  It defaults to including only the latest API level, though you can add more.
* `numLatestPlatformVersions` specifies how many of the latest API levels to include,
  if you are using the default for `platformVersions`. It defaults to 1, though you can
  increase this to, for example, 5 to get the last 5 years of Android API packages.
* `minPlatformVersion` and `maxPlatformVersion` take priority over `platformVersions`
  if both are provided. Note that `maxPlatformVersion` always defaults to the latest
  Android SDK platform version, allowing you to specify `minPlatformVersion` to describe
+9 −1
Original line number Diff line number Diff line
@@ -82,6 +82,7 @@ in
  emulatorVersion ? repo.latest.emulator,
  minPlatformVersion ? null,
  maxPlatformVersion ? coerceInt repo.latest.platforms,
  numLatestPlatformVersions ? 1,
  platformVersions ?
    if minPlatformVersion != null && maxPlatformVersion != null then
      let
@@ -92,7 +93,14 @@ in
        lib.max minPlatformVersionInt maxPlatformVersionInt
      )
    else
      map coerceInt [ repo.latest.platforms ],
      let
        minPlatformVersionInt = if minPlatformVersion == null then 1 else coerceInt minPlatformVersion;
        latestPlatformVersionInt = lib.max minPlatformVersionInt (coerceInt repo.latest.platforms);
        firstPlatformVersionInt = lib.max minPlatformVersionInt (
          latestPlatformVersionInt - (lib.max 1 numLatestPlatformVersions) + 1
        );
      in
      lib.range firstPlatformVersionInt latestPlatformVersionInt,
  includeSources ? false,
  includeSystemImages ? false,
  systemImageTypes ? [
+2 −1
Original line number Diff line number Diff line
@@ -18,7 +18,8 @@ lib.recurseIntoAttrs rec {
  };

  androidPkgs = composeAndroidPackages {
    minPlatformVersion = 28;
    # Support roughly the last 5 years of Android packages and system images by default in nixpkgs.
    numLatestPlatformVersions = 5;
    includeEmulator = "if-supported";
    includeSystemImages = "if-supported";
    includeNDK = "if-supported";
+5 −10
Original line number Diff line number Diff line
@@ -47,12 +47,13 @@ let

  androidComposition = androidEnv.composeAndroidPackages {
    includeSources = true;
    includeSystemImages = true;
    includeSystemImages = false;
    includeEmulator = "if-supported";
    includeNDK = "if-supported";
    useGoogleAPIs = true;

    minPlatformVersion = 23;
    # Make sure everything from the last decade works since we are not using system images.
    numLatestPlatformVersions = 10;

    # If you want to use a custom repo JSON:
    # repoJson = ../repo.json;
@@ -100,6 +101,7 @@ let

  androidSdk = androidComposition.androidsdk;
  platformTools = androidComposition.platform-tools;
  firstSdk = pkgs.lib.foldl' pkgs.lib.min 100 androidComposition.platformVersions;
  latestSdk = pkgs.lib.foldl' pkgs.lib.max 0 androidComposition.platformVersions;
  jdk = pkgs.jdk;
in
@@ -171,19 +173,12 @@ pkgs.mkShell rec {
            "extras;google;gcm"
          )

          for x in $(seq 23 ${toString latestSdk}); do
          for x in $(seq ${toString firstSdk} ${toString latestSdk}); do
            if [ $x -ne 34 ]; then
              # FIXME couldn't find platforms;android-34, even though it's in the correct directory!! sdkmanager's bug?!
              packages+=("platforms;android-$x")
            fi
            packages+=("sources;android-$x")
            if [ $x -ge 28 ]; then
              if [ $x -lt 34 ]; then
                packages+=("system-images;android-$x;google_apis_playstore;x86_64")
              else
                packages+=("system-images;android-$x;google_apis;x86_64")
              fi
            fi
          done

          ${pkgs.lib.optionalString includeAuto ''packages+=("extras;google;auto")''}