[bazel] SkCMS: Android RBE tasks.

Bug: skia:12400
Change-Id: I34160c31cf6d30d484492f2d1e3808e90a03c8b8
Reviewed-on: https://skia-review.googlesource.com/c/skcms/+/471237
Reviewed-by: Joe Gregorio <jcgregorio@google.com>
Commit-Queue: Leandro Lovisolo <lovisolo@google.com>
diff --git a/infra/bots/bazel.py b/infra/bots/bazel.py
index 1e49e9a..99b1e37 100644
--- a/infra/bots/bazel.py
+++ b/infra/bots/bazel.py
@@ -23,11 +23,12 @@
   local_or_rbe = sys.argv[2]
   assert local_or_rbe in ["local", "rbe"]
 
+  target = sys.argv[3]
+  assert target in ["android-arm", "android-arm64", "linux", "windows"]
+
   print("Hello from {platform} in {cwd}!".format(platform=sys.platform,
                                                  cwd=os.getcwd()))
 
-  linux = "linux" in sys.platform  # We assume it's Windows if this is false.
-
   # Create a temporary directory for the Bazel cache.
   #
   # We cannot use the default Bazel cache location ($HOME/.cache/bazel) because:
@@ -50,25 +51,22 @@
   with tempfile.TemporaryDirectory(prefix="bazel-cache-",
                                    dir=os.environ["TMPDIR"]) as cache_dir:
     def bazel(args):
-      cmd = ["bazel", "--output_user_root=" + cache_dir] if linux \
-            else ["C:\\b\\s\\w\\ir\\bazel_win\\bazel.exe"]
+      cmd = ["C:\\b\\s\\w\\ir\\bazel_win\\bazel.exe"] if target == "windows" \
+            else ["bazel", "--output_user_root=" + cache_dir]
       call(cmd + args)
 
     try:
       # Print the Bazel version.
       bazel(["version"])
 
+      # Compute the Bazel configuration to use.
+      config = target
+      if local_or_rbe == "rbe":
+        config += "-rbe"
+
       # Run the requested Bazel command.
       os.chdir("skcms")
-      cmd = [build_or_test, "//..."]
-      if local_or_rbe == "rbe":
-        if linux:
-          cmd += ["--config=linux-rbe"]
-        else: # Windows
-          cmd += ["--config=windows-rbe"]
-        cmd += ["--google_default_credentials"]
-
-      bazel(cmd)
+      bazel([build_or_test, "//...", "--config=" + config, "--google_default_credentials"])
 
     finally:
       # Kill the Bazel server, so as not to leave any children processes
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index ab6aeb5..a7755d6 100644
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -18,7 +18,9 @@
         "skcms-Linux-Bazel-Build-RBE",
         "skcms-Linux-Bazel-Test-RBE",
         "skcms-Win-Bazel-Build-RBE",
-        "skcms-Win-Bazel-Test-RBE"
+        "skcms-Win-Bazel-Test-RBE",
+        "skcms-Android-ARM-Bazel-Build-RBE",
+        "skcms-Android-ARM64-Bazel-Build-RBE"
       ]
     },
     "skcms-Linux": {
@@ -41,6 +43,12 @@
     },
     "skcms-Win-Bazel-Test-RBE": {
       "tasks": ["skcms-Win-Bazel-Test-RBE"]
+    },
+    "skcms-Android-ARM-Bazel-Build-RBE": {
+      "tasks": ["skcms-Android-ARM-Bazel-Build-RBE"]
+    },
+    "skcms-Android-ARM64-Bazel-Build-RBE": {
+      "tasks": ["skcms-Android-ARM64-Bazel-Build-RBE"]
     }
   },
   "tasks": {
@@ -190,7 +198,8 @@
         "cipd_bin_packages/cpython3/bin/python3",
         "skcms/infra/bots/bazel.py",
         "build",
-        "rbe"
+        "rbe",
+        "linux"
       ],
       "dimensions": [
         "pool:Skia",
@@ -237,7 +246,8 @@
         "cipd_bin_packages/cpython3/bin/python3",
         "skcms/infra/bots/bazel.py",
         "test",
-        "rbe"
+        "rbe",
+        "linux"
       ],
       "dimensions": [
         "pool:Skia",
@@ -283,7 +293,8 @@
         "python/bin/python3.exe",
         "skcms/infra/bots/bazel.py",
         "build",
-        "rbe"
+        "rbe",
+        "windows"
       ],
       "env_prefixes": {
         "PATH": ["win_toolchain/sys64"]
@@ -315,7 +326,8 @@
         "python/bin/python3.exe",
         "skcms/infra/bots/bazel.py",
         "test",
-        "rbe"
+        "rbe",
+        "windows"
       ],
       "env_prefixes": {
         "PATH": ["win_toolchain/sys64"]
@@ -323,6 +335,118 @@
       "dimensions": ["os:Windows-Server-17763", "gpu:none", "pool:Skia"],
       "max_attempts": 1,
       "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
+    },
+    "skcms-Android-ARM-Bazel-Build-RBE": {
+      "caches": [
+        {
+          "name": "vpython",
+          "path": "cache/vpython"
+        }
+      ],
+      "casSpec": "whole-repo",
+      "cipd_packages": [
+        {
+          "name": "infra/3pp/tools/cpython3/linux-amd64",
+          "path": "cipd_bin_packages/cpython3",
+          "version": "version:2@3.8.10.chromium.19"
+        },
+        {
+          "name": "skia/bots/android_ndk_linux",
+          "path": "android_ndk_linux",
+          "version": "version:16"
+        },
+        {
+          "name": "skia/bots/bazel",
+          "path": "bazel",
+          "version": "version:3"
+        }
+      ],
+      "command": [
+        "cipd_bin_packages/cpython3/bin/python3",
+        "skcms/infra/bots/bazel.py",
+        "build",
+        "rbe",
+        "android-arm"
+      ],
+      "dimensions": [
+        "pool:Skia",
+        "os:Debian-10.3",
+        "gpu:none",
+        "cpu:x86-64-Haswell_GCE",
+        "machine_type:n1-highcpu-64",
+        "docker_installed:true"
+      ],
+      "env_prefixes": {
+        "ANDROID_NDK_HOME": [
+          "android_ndk_linux"
+        ],
+        "PATH": [
+          "cipd_bin_packages/cpython3",
+          "cipd_bin_packages/cpython3/bin",
+          "bazel/bin"
+        ],
+        "VPYTHON_VIRTUALENV_ROOT": [
+          "cache/vpython"
+        ]
+      },
+      "max_attempts": 1,
+      "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
+    },
+    "skcms-Android-ARM64-Bazel-Build-RBE": {
+      "caches": [
+        {
+          "name": "vpython",
+          "path": "cache/vpython"
+        }
+      ],
+      "casSpec": "whole-repo",
+      "cipd_packages": [
+        {
+          "name": "infra/3pp/tools/cpython3/linux-amd64",
+          "path": "cipd_bin_packages/cpython3",
+          "version": "version:2@3.8.10.chromium.19"
+        },
+        {
+          "name": "skia/bots/android_ndk_linux",
+          "path": "android_ndk_linux",
+          "version": "version:16"
+        },
+        {
+          "name": "skia/bots/bazel",
+          "path": "bazel",
+          "version": "version:3"
+        }
+      ],
+      "command": [
+        "cipd_bin_packages/cpython3/bin/python3",
+        "skcms/infra/bots/bazel.py",
+        "build",
+        "rbe",
+        "android-arm64"
+      ],
+      "dimensions": [
+        "pool:Skia",
+        "os:Debian-10.3",
+        "gpu:none",
+        "cpu:x86-64-Haswell_GCE",
+        "machine_type:n1-highcpu-64",
+        "docker_installed:true"
+      ],
+      "env_prefixes": {
+        "ANDROID_NDK_HOME": [
+          "android_ndk_linux"
+        ],
+        "PATH": [
+          "cipd_bin_packages/cpython3",
+          "cipd_bin_packages/cpython3/bin",
+          "bazel/bin"
+        ],
+        "VPYTHON_VIRTUALENV_ROOT": [
+          "cache/vpython"
+        ]
+      },
+      "max_attempts": 1,
+      "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
     }
   }
 }