Skip to content

Commit dd22b78

Browse files
erock2112SkCQ
authored andcommitted
[bazel] Move google_cloud_sdk to MODULE.bazel
This just wraps the existing repository_rule into a module_extension and fixes the resulting path. Bug: b/458681039 Change-Id: I0f8d824f5dc2a551208b056551ea01562946068f Reviewed-on: https://skia-review.googlesource.com/c/buildbot/+/1122262 Reviewed-by: Kaylee Lubick <[email protected]> Auto-Submit: Eric Boren <[email protected]> Commit-Queue: Kaylee Lubick <[email protected]> Commit-Queue: Eric Boren <[email protected]>
1 parent 6686849 commit dd22b78

File tree

5 files changed

+44
-10
lines changed

5 files changed

+44
-10
lines changed

MODULE.bazel

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -642,3 +642,11 @@ http_file(
642642
sha256 = "1206e8a79b41cb22524f73afa4f4ee648478f46ef6990d78e7cc953665a1db89",
643643
url = "https://github.com/bazelbuild/bazel-toolchains/releases/download/v5.1.2/rbe_configs_gen_linux_amd64",
644644
)
645+
646+
####################################################################################################
647+
# Google Cloud SDK (needed for the Google Cloud Emulators).
648+
####################################################################################################
649+
650+
google_cloud_sdk = use_extension("//bazel/external:google_cloud_sdk.bzl", "google_cloud_sdk")
651+
google_cloud_sdk.download(name = "google_cloud_sdk")
652+
use_repo(google_cloud_sdk, "google_cloud_sdk")

MODULE.bazel.lock

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

WORKSPACE

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,6 @@ rbe_exec_properties(
3333
name = "exec_properties",
3434
)
3535

36-
#############################################################
37-
# Google Cloud SDK (needed for the Google Cloud Emulators). #
38-
#############################################################
39-
40-
load("//bazel/external:google_cloud_sdk.bzl", "google_cloud_sdk")
41-
42-
google_cloud_sdk(name = "google_cloud_sdk")
43-
4436
# #################################################################################
4537
# # Google Chrome and Fonts (needed for Karma and Puppeteer tests, respectively). #
4638
# #################################################################################

bazel/external/google_cloud_sdk.bzl

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ filegroup(
8787
)
8888
fail_if_nonzero_status(exec_result, "Failed to install Cloud Emulators.")
8989

90-
google_cloud_sdk = repository_rule(
90+
_google_cloud_sdk = repository_rule(
9191
implementation = _google_cloud_sdk_impl,
9292
attrs = {
9393
"quiet": attr.bool(
@@ -102,3 +102,20 @@ This rule hermetically downloads the Google Cloud SDK, then installs the Cloud E
102102
at the same exact revision. Therefore, this rule cannot be considered to be fully hermetic.
103103
""",
104104
)
105+
106+
_download = tag_class(attrs = {
107+
"name": attr.string(mandatory = True),
108+
})
109+
110+
def _gcloud_sdk_impl(ctx):
111+
for module in ctx.modules:
112+
for tag in module.tags.download:
113+
_google_cloud_sdk(name = tag.name)
114+
115+
google_cloud_sdk = module_extension(
116+
doc = "Bzlmod extension used to download the Google Cloud SDK and emulators.",
117+
implementation = _gcloud_sdk_impl,
118+
tag_classes = {
119+
"download": _download,
120+
},
121+
)

bazel/external/google_cloud_sdk/google_cloud_sdk.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ func FindGcloud() (string, error) {
1818
return exec.LookPath("gcloud")
1919
}
2020
if runtime.GOOS == "linux" {
21-
return filepath.Join(bazel.RunfilesDir(), "external", "google_cloud_sdk", "google-cloud-sdk", "bin", "gcloud"), nil
21+
return filepath.Join(bazel.RunfilesDir(), "external", "_main~google_cloud_sdk~google_cloud_sdk", "google-cloud-sdk", "bin", "gcloud"), nil
2222
}
2323
return "", skerr.Fmt("unsupported runtime.GOOS: %q", runtime.GOOS)
2424
}

0 commit comments

Comments
 (0)