[bazel] Add BazelBuild job for //example/external_client:use_ganesh_gl

Bug: b/256860862
Change-Id: I25b02eb0c3997b3e6e116a29d39cd59931a90b82
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/896461
Reviewed-by: Kaylee Lubick <kjlubick@google.com>
Auto-Submit: Eric Boren <borenet@google.com>
Commit-Queue: Eric Boren <borenet@google.com>
diff --git a/infra/bots/gen_tasks_logic/gen_tasks_logic.go b/infra/bots/gen_tasks_logic/gen_tasks_logic.go
index 70be808..f7d3227 100644
--- a/infra/bots/gen_tasks_logic/gen_tasks_logic.go
+++ b/infra/bots/gen_tasks_logic/gen_tasks_logic.go
@@ -2140,6 +2140,7 @@
 // Maps a shorthand version of a label (which can be an arbitrary string) to an absolute Bazel
 // label or "target pattern" https://bazel.build/docs/build#specifying-build-targets
 // The reason we need this mapping is because Buildbucket build names cannot have / or : in them.
+// TODO(borenet/kjlubick): Is there a way to generate a mapping using `bazel query`?
 var shorthandToLabel = map[string]labelAndSavedOutputDir{
 	"all_tests":                  {"//tests:linux_rbe_tests", ""},
 	"core":                       {"//:core", ""},
@@ -2152,20 +2153,18 @@
 	"modules_canvaskit_js_tests": {"//modules/canvaskit:canvaskit_js_tests", ""},
 	"skottie_tool_gpu":           {"//modules/skottie:skottie_tool_gpu", ""},
 	"viewer":                     {"//tools/viewer:viewer", ""},
-
-	// Note: these paths are relative to the WORKSPACE in //example/external_client
-	"decode_everything":          {"//:decode_everything", ""},
-	"path_combiner":              {"//:path_combiner", ""},
-	"png_decoder":                {"//:png_decoder", ""},
-	"shape_text":                 {"//:shape_text", ""},
-	"svg_with_harfbuzz":          {"//:svg_with_harfbuzz", ""},
-	"svg_with_primitive":         {"//:svg_with_primitive", ""},
-	"use_ganesh_gl":              {"//:use_ganesh_gl", ""},
-	"use_ganesh_vulkan":          {"//:use_ganesh_vulkan", ""},
-	"use_graphite_native_vulkan": {"//:use_graphite_native_vulkan", ""},
-	"use_skresources":            {"//:use_skresources", ""},
-	"write_text_to_png":          {"//:write_text_to_png", ""},
-	"write_to_pdf":               {"//:write_to_pdf", ""},
+	"decode_everything":          {"//example/external_client:decode_everything", ""},
+	"path_combiner":              {"//example/external_client:path_combiner", ""},
+	"png_decoder":                {"//example/external_client:png_decoder", ""},
+	"shape_text":                 {"//example/external_client:shape_text", ""},
+	"svg_with_harfbuzz":          {"//example/external_client:svg_with_harfbuzz", ""},
+	"svg_with_primitive":         {"//example/external_client:svg_with_primitive", ""},
+	"use_ganesh_gl":              {"//example/external_client:use_ganesh_gl", ""},
+	"use_ganesh_vulkan":          {"//example/external_client:use_ganesh_vulkan", ""},
+	"use_graphite_native_vulkan": {"//example/external_client:use_graphite_native_vulkan", ""},
+	"use_skresources":            {"//example/external_client:use_skresources", ""},
+	"write_text_to_png":          {"//example/external_client:write_text_to_png", ""},
+	"write_to_pdf":               {"//example/external_client:write_to_pdf", ""},
 
 	// Currently there is no way to tell Bazel "only test go_test targets", so we must group them
 	// under a test_suite.
@@ -2443,9 +2442,14 @@
 				"--patchset_order="+specs.PLACEHOLDER_PATCHSET)
 
 		case "external_client":
+			// For external_client, we want to test how an external user would
+			// build using Skia. Therefore, we change to the workspace in that
+			// directory and use labels relative to it.
+			pathInSkia := "example/external_client"
+			label := strings.Replace(labelAndSavedOutputDir.label, pathInSkia, "", -1)
 			cmd = append(cmd,
-				"--bazel_label="+labelAndSavedOutputDir.label,
-				"--path_in_skia=example/external_client",
+				"--bazel_label="+label,
+				"--path_in_skia="+pathInSkia,
 				"--bazel_cache_dir="+bazelCacheDir)
 			b.usesDocker()
 
diff --git a/infra/bots/jobs.json b/infra/bots/jobs.json
index 2f85cd6..66ca8f9 100644
--- a/infra/bots/jobs.json
+++ b/infra/bots/jobs.json
@@ -21,6 +21,7 @@
   {"name": "BazelBuild-cpu_8888_benchmark_android_test-for_android_arm64_release-linux_x64"},
   {"name": "BazelBuild-hello_bazel_world_android_test-for_android_arm64_release-linux_x64"},
   {"name": "BazelBuild-android_math_test-for_android_arm64_release-linux_x64"},
+  {"name": "BazelBuild-use_ganesh_gl-for_windows_x64_release-windows_x64"},
   {"name": "BazelBuild-viewer-debug-linux_x64",
     "cq_config": {}
   },
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json
index f0f24f3..f70ede2 100644
--- a/infra/bots/tasks.json
+++ b/infra/bots/tasks.json
@@ -60,6 +60,11 @@
         "BazelBuild-skottie_tool_gpu-enforce_iwyu-linux_x64"
       ]
     },
+    "BazelBuild-use_ganesh_gl-for_windows_x64_release-windows_x64": {
+      "tasks": [
+        "BazelBuild-use_ganesh_gl-for_windows_x64_release-windows_x64"
+      ]
+    },
     "BazelBuild-viewer-debug-linux_x64": {
       "tasks": [
         "BazelBuild-viewer-debug-linux_x64"
@@ -4538,6 +4543,72 @@
       "max_attempts": 1,
       "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
     },
+    "BazelBuild-use_ganesh_gl-for_windows_x64_release-windows_x64": {
+      "caches": [
+        {
+          "name": "git",
+          "path": "cache/git"
+        },
+        {
+          "name": "git_cache",
+          "path": "cache/git_cache"
+        }
+      ],
+      "casSpec": "bazel",
+      "cipd_packages": [
+        {
+          "name": "infra/3pp/tools/git/windows-amd64",
+          "path": "cipd_bin_packages",
+          "version": "version:3@2.46.0.chromium.11"
+        },
+        {
+          "name": "infra/tools/git/${platform}",
+          "path": "cipd_bin_packages",
+          "version": "git_revision:e02b085286a3baf3ab1194941cdb6c196c4c0802"
+        },
+        {
+          "name": "infra/tools/luci/git-credential-luci/${platform}",
+          "path": "cipd_bin_packages",
+          "version": "git_revision:e02b085286a3baf3ab1194941cdb6c196c4c0802"
+        },
+        {
+          "name": "skia/bots/bazelisk_win_amd64",
+          "path": "bazelisk_win_amd64",
+          "version": "version:1"
+        }
+      ],
+      "command": [
+        "./bazel_build",
+        "--project_id=skia-swarming-bots",
+        "--task_id=<(TASK_ID)",
+        "--task_name=BazelBuild-use_ganesh_gl-for_windows_x64_release-windows_x64",
+        "--bazel_label=//example/external_client:use_ganesh_gl",
+        "--bazel_config=for_windows_x64_release",
+        "--bazel_cache_dir=C:\\\\Users\\\\chrome-bot\\\\bazel_cache",
+        "--workdir=./skia",
+        "--bazel_arg=--experimental_scale_timeouts=2.0"
+      ],
+      "dependencies": [
+        "Housekeeper-PerCommit-BuildTaskDrivers_windows_amd64"
+      ],
+      "dimensions": [
+        "cpu:x86-64-Haswell_GCE",
+        "gpu:none",
+        "machine_type:n1-highcpu-64",
+        "os:Windows-Server-17763",
+        "pool:Skia"
+      ],
+      "env_prefixes": {
+        "PATH": [
+          "cipd_bin_packages",
+          "cipd_bin_packages/bin",
+          "bazelisk_win_amd64"
+        ]
+      },
+      "idempotent": true,
+      "max_attempts": 1,
+      "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com"
+    },
     "BazelBuild-viewer-debug-linux_x64": {
       "caches": [
         {
diff --git a/toolchain/windows_toolchain_config.bzl b/toolchain/windows_toolchain_config.bzl
index 826e065..b4b914e 100644
--- a/toolchain/windows_toolchain_config.bzl
+++ b/toolchain/windows_toolchain_config.bzl
@@ -279,6 +279,7 @@
                     "-std=c++17",
                     "-L" + FULL_MSVC_LIB + "/x64",
                     "-L" + FULL_WIN_SDK_LIB + "/ucrt/x64",
+                    "-L" + FULL_WIN_SDK_LIB + "/um/x64",
                 ],
             ),
         ],