Add Bazel task to build on Intel Macs This makes sure our toolchain works on hosts which are older Macs. Previous mac builds had accidentally been working because they'd run on machines which had previously run with recipes that used the "install xcode" [1] step. This means when we start running task drivers on Macs that only use the task driver (e.g. the Intel macs I targeted for this new task), it would fail with: Error in fail: Error Getting SDK path: xcode-select: note: No developer tools were found, requesting install. If developer tools are located at a non-default location on disk, use `sudo xcode-select --switch path/to/Xcode.app` to specify the Xcode that you wish to use for command line developer tools, and cancel the installation dialog. This ports that command to our mac task drivers. Unlike the task drivers, we don't use sudo to switch to the xcode, instead we use DEVELOPER_DIR to achieve that. I chose the MacBookPro15.1 machines (cpu:x86-64-i9-8950HK) because we have the most of those. We have those on Mac 14 and 15 and I don't really care which of those we run on (we are just compiling), so I didn't specify. [1] https://github.com/google/skia/blob/2c4e3993fd1c68ee7f1561a0fca782623ec6f1b0/infra/bots/recipe_modules/xcode/api.py#L56 Change-Id: I97bccf88498814554600ef0eb978a47ed8729971 Bug: 256863909 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/1288656 Reviewed-by: Eric Boren <borenet@google.com> Commit-Queue: Kaylee Lubick <kjlubick@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 214e7a9..55a8ca8 100644 --- a/infra/bots/gen_tasks_logic/gen_tasks_logic.go +++ b/infra/bots/gen_tasks_logic/gen_tasks_logic.go
@@ -2195,6 +2195,7 @@ // We only run builds in GCE. "linux_x64": bazelCacheDirOnGCELinux, "mac_arm64": bazelCacheDirOnMac, + "mac_x64": bazelCacheDirOnMac, "windows_x64": bazelCacheDirOnWindows, }[host] if !ok { @@ -2209,7 +2210,7 @@ cmd := []string{ "luci-auth", "context", - b.taskDriver("bazel_build", host != "windows_x64"), + b.taskDriver("bazel_build", false), "--project_id=skia-swarming-bots", "--task_id=" + specs.PLACEHOLDER_TASK_ID, "--task_name=" + b.Name, @@ -2240,6 +2241,14 @@ b.usesBazel("mac_arm64") b.dimension("cpu:arm64-64-Apple_M4", "pool:Skia") b.usesXCode() + } else if host == "mac_x64" { + b.usesBazel("mac_x64") + b.dimension( + "cpu:x86-64-i9-8950HK", + "cipd_platform:mac-amd64", + "pool:Skia", + ) + b.usesXCode() } else { panic("unsupported Bazel host " + host) }
diff --git a/infra/bots/gen_tasks_logic/schema.go b/infra/bots/gen_tasks_logic/schema.go index 4d335b9..8132ce9 100644 --- a/infra/bots/gen_tasks_logic/schema.go +++ b/infra/bots/gen_tasks_logic/schema.go
@@ -269,7 +269,7 @@ // IsMac returns true if the task runs on Mac. func (p Parts) IsMac() bool { - return !p.Role("Upload") && (p.MatchOs("Mac") || p.MatchExtraConfig("Mac") || p.MatchBazelHost("darwin")) + return !p.Role("Upload") && (p.MatchOs("Mac") || p.MatchExtraConfig("Mac") || p.MatchBazelHost("darwin", "mac")) } // BazelBuildParts returns all parts from the BazelBuild schema. All parts are required.
diff --git a/infra/bots/gen_tasks_logic/task_builder.go b/infra/bots/gen_tasks_logic/task_builder.go index 6cfc15f..548c8b5 100644 --- a/infra/bots/gen_tasks_logic/task_builder.go +++ b/infra/bots/gen_tasks_logic/task_builder.go
@@ -470,7 +470,7 @@ arch := "amd64" if b.Role("Upload") { arch = "amd64" - } else if b.MatchArch("Arm64") || b.MatchBazelHost("on_rpi") || b.MatchOs("Android", "ChromeOS", "iOS") { + } else if b.MatchArch("Arm64") || b.MatchBazelHost("on_rpi", "arm64") || b.MatchOs("Android", "ChromeOS", "iOS") { // Tests on Android/ChromeOS/iOS are hosted on RPI. // WARNING: This assumption is not necessarily true with Android devices // hosted in other environments.
diff --git a/infra/bots/jobs.json b/infra/bots/jobs.json index e8dd659..1fe08e4 100644 --- a/infra/bots/jobs.json +++ b/infra/bots/jobs.json
@@ -32,6 +32,9 @@ "name": "BazelBuild-viewer-release-mac_arm64" }, { + "name": "BazelBuild-viewer-release-mac_x64" + }, + { "name": "BazelTest-cpu_tests-all_go_tests-linux_rbe-linux_x64" }, {
diff --git a/infra/bots/task_drivers/bazel_build/BUILD.bazel b/infra/bots/task_drivers/bazel_build/BUILD.bazel index 2092675..95335452 100644 --- a/infra/bots/task_drivers/bazel_build/BUILD.bazel +++ b/infra/bots/task_drivers/bazel_build/BUILD.bazel
@@ -14,6 +14,7 @@ deps = [ "//infra/bots/task_drivers/common", "@org_skia_go_infra//go/common", + "@org_skia_go_infra//go/exec", "@org_skia_go_infra//go/skerr", "@org_skia_go_infra//task_driver/go/lib/bazel", "@org_skia_go_infra//task_driver/go/lib/os_steps",
diff --git a/infra/bots/task_drivers/bazel_build/bazel_build.go b/infra/bots/task_drivers/bazel_build/bazel_build.go index bcebae6..05a17ba 100644 --- a/infra/bots/task_drivers/bazel_build/bazel_build.go +++ b/infra/bots/task_drivers/bazel_build/bazel_build.go
@@ -14,9 +14,12 @@ "flag" "fmt" "io/fs" + "os" "path/filepath" + "runtime" infra_common "go.skia.org/infra/go/common" + sk_exec "go.skia.org/infra/go/exec" "go.skia.org/infra/go/skerr" "go.skia.org/infra/task_driver/go/lib/bazel" "go.skia.org/infra/task_driver/go/lib/os_steps" @@ -59,6 +62,44 @@ if err != nil { td.Fatal(ctx, err) } + + // For Mac builds, ensure Xcode is downloaded/installed via mac_toolchain before we build. + if runtime.GOOS == "darwin" { + parentDir := filepath.Dir(checkoutPath) + macToolchainBin := filepath.Join(parentDir, "mac_toolchain", "mac_toolchain") + xcodeAppPath := filepath.Join(parentDir, "cache", "Xcode.app") + + if _, err := os.Stat(macToolchainBin); err == nil { + err = td.Do(ctx, td.Props("Ensure Xcode via mac_toolchain"), func(ctx context.Context) error { + runCmd := &sk_exec.Command{ + Name: macToolchainBin, + Args: []string{ + "install", + "-kind", "ios", + "-xcode-version", "16a242d", // Xcode 16.0 + "-output-dir", xcodeAppPath, + }, + InheritEnv: true, + LogStdout: true, + LogStderr: true, + } + _, runErr := sk_exec.RunCommand(ctx, runCmd) + return runErr + }) + if err != nil { + td.Fatal(ctx, err) + } + } + + cachedXcodeDevDir := filepath.Join(xcodeAppPath, "Contents", "Developer") + if _, err := os.Stat(cachedXcodeDevDir); err == nil { + // We set DEVELOPER_DIR to the absolute path of the cached Xcode to bypass + // the global system-wide 'xcode-select' pointer. This is similar to + // 'sudo xcode-select -switch' but doesn't affect the global state. + os.Setenv("DEVELOPER_DIR", cachedXcodeDevDir) + } + } + var outputPath string if *outPath != "" { outputPath, err = os_steps.Abs(ctx, *outPath) @@ -93,6 +134,9 @@ // Perform the build. args := append([]string{*bazelFlags.Label, fmt.Sprintf("--config=%s", *bazelFlags.Config)}, *bazelFlags.AdditionalArgs...) + if os.Getenv("DEVELOPER_DIR") != "" { + args = append(args, "--repo_env=DEVELOPER_DIR") + } if _, err := bzl.Do(ctx, "build", args...); err != nil { td.Fatal(ctx, err) }
diff --git a/infra/bots/tasks.json b/infra/bots/tasks.json index 5d0bca6..6c6752f 100644 --- a/infra/bots/tasks.json +++ b/infra/bots/tasks.json
@@ -50,6 +50,11 @@ "BazelBuild-viewer-release-mac_arm64" ] }, + "BazelBuild-viewer-release-mac_x64": { + "tasks": [ + "BazelBuild-viewer-release-mac_x64" + ] + }, "BazelTest-cpu_tests-all_go_tests-linux_rbe-linux_x64": { "tasks": [ "BazelTest-cpu_tests-all_go_tests-linux_rbe-linux_x64" @@ -3862,17 +3867,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-core-release-linux_x64", @@ -3884,6 +3884,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -3942,17 +3945,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-fontations-release-linux_x64", @@ -3964,6 +3962,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -4098,17 +4099,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-full_library-release-linux_x64", @@ -4120,6 +4116,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -4178,17 +4177,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-ganesh_gl-release-linux_x64", @@ -4200,6 +4194,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -4258,17 +4255,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-modules_canvaskit-ck_full_webgl2_debug-linux_x64", @@ -4280,6 +4272,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -4414,17 +4409,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-viewer-debug-linux_x64", @@ -4436,6 +4426,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -4494,17 +4487,12 @@ "name": "skia/bots/bazelisk_linux_amd64", "path": "bazelisk_linux_amd64", "version": "version:1" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-viewer-release-linux_x64", @@ -4516,6 +4504,9 @@ "--bazel_arg=--jobs=100", "--bazel_arg=--remote_download_minimal" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64" + ], "dimensions": [ "cpu:x86-64-Haswell_GCE", "gpu:none", @@ -4583,17 +4574,12 @@ "name": "skia/bots/bazelisk_mac_arm64", "path": "bazelisk_mac_arm64", "version": "version:2" - }, - { - "name": "skia/tools/bazel_build/${platform}", - "path": "task_drivers", - "version": "git_revision:b5d31abb7bc772a69f800de45783768768437675" } ], "command": [ "luci-auth", "context", - "task_drivers/bazel_build", + "./bazel_build", "--project_id=skia-swarming-bots", "--task_id=<(TASK_ID)", "--task_name=BazelBuild-viewer-release-mac_arm64", @@ -4602,6 +4588,9 @@ "--bazel_cache_dir=/Volumes/Work/s/w/bazel_cache", "--workdir=./skia" ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_darwin_arm64" + ], "dimensions": [ "cpu:arm64-64-Apple_M4", "pool:Skia" @@ -4620,6 +4609,88 @@ "max_attempts": 1, "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com" }, + "BazelBuild-viewer-release-mac_x64": { + "caches": [ + { + "name": "git", + "path": "cache/git" + }, + { + "name": "git_cache", + "path": "cache/git_cache" + }, + { + "name": "xcode", + "path": "cache/Xcode.app" + } + ], + "casSpec": "bazel", + "cipd_packages": [ + { + "name": "infra/3pp/tools/git/${platform}", + "path": "cipd_bin_packages", + "version": "version:3@2.51.2.chromium.11" + }, + { + "name": "infra/tools/git/${platform}", + "path": "cipd_bin_packages", + "version": "git_revision:b2fad5ab18774b86d84aa867287bfb4f2394893b" + }, + { + "name": "infra/tools/luci-auth/${platform}", + "path": "cipd_bin_packages", + "version": "git_revision:36402eaf928c7ca7db41448371af1891776d115a" + }, + { + "name": "infra/tools/luci/git-credential-luci/${platform}", + "path": "cipd_bin_packages", + "version": "git_revision:b2fad5ab18774b86d84aa867287bfb4f2394893b" + }, + { + "name": "infra/tools/mac_toolchain/${platform}", + "path": "mac_toolchain", + "version": "git_revision:0cb1e51344de158f72524c384f324465aebbcef2" + }, + { + "name": "skia/bots/bazelisk_mac_amd64", + "path": "bazelisk_mac_amd64", + "version": "version:1" + } + ], + "command": [ + "luci-auth", + "context", + "./bazel_build", + "--project_id=skia-swarming-bots", + "--task_id=<(TASK_ID)", + "--task_name=BazelBuild-viewer-release-mac_x64", + "--bazel_label=//tools/viewer:viewer", + "--bazel_config=release", + "--bazel_cache_dir=/Volumes/Work/s/w/bazel_cache", + "--workdir=./skia" + ], + "dependencies": [ + "Housekeeper-PerCommit-BuildTaskDrivers_darwin_amd64" + ], + "dimensions": [ + "cpu:x86-64-i9-8950HK", + "cipd_platform:mac-amd64", + "pool:Skia" + ], + "environment": { + "USE_BAZEL_FALLBACK_VERSION": "error" + }, + "env_prefixes": { + "PATH": [ + "cipd_bin_packages", + "cipd_bin_packages/bin", + "bazelisk_mac_amd64" + ] + }, + "idempotent": true, + "max_attempts": 1, + "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com" + }, "BazelTest-cpu_tests-all_go_tests-linux_rbe-linux_x64": { "casSpec": "bazel", "cipd_packages": [ @@ -26700,6 +26771,48 @@ "idempotent": true, "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com" }, + "Housekeeper-PerCommit-BuildTaskDrivers_darwin_arm64": { + "casSpec": "task-drivers", + "cipd_packages": [ + { + "name": "infra/tools/luci-auth/${platform}", + "path": "cipd_bin_packages", + "version": "git_revision:36402eaf928c7ca7db41448371af1891776d115a" + }, + { + "name": "skia/bots/bazelisk_linux_amd64", + "path": "bazelisk_linux_amd64", + "version": "version:1" + } + ], + "command": [ + "luci-auth", + "context", + "/bin/bash", + "skia/infra/bots/build_task_drivers.sh", + "${ISOLATED_OUTDIR}", + "darwin_arm64" + ], + "dimensions": [ + "cpu:x86-64-Haswell_GCE", + "gpu:none", + "machine_type:n1-standard-16", + "os:Ubuntu-24.04", + "pool:Skia" + ], + "environment": { + "USE_BAZEL_FALLBACK_VERSION": "error" + }, + "env_prefixes": { + "PATH": [ + "bazelisk_linux_amd64", + "cipd_bin_packages", + "cipd_bin_packages/bin" + ] + }, + "idempotent": true, + "service_account": "skia-external-compile-tasks@skia-swarming-bots.iam.gserviceaccount.com" + }, "Housekeeper-PerCommit-BuildTaskDrivers_linux_amd64": { "casSpec": "task-drivers", "cipd_packages": [