-
Notifications
You must be signed in to change notification settings - Fork 2.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(bazel): make googleapis a Bzlmod module #855
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
@@ -0,0 +1,16 @@ | ||||||||
module( | ||||||||
name = "com_google_googleapis", | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
this is what most modules are doing, folks can use the fully qualified name if they need to |
||||||||
version = "0.0.0", | ||||||||
) | ||||||||
|
||||||||
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf") | ||||||||
bazel_dep(name = "rules_proto", version = "5.3.0-21.7") | ||||||||
|
||||||||
switched_rules = use_extension("//:extensions.bzl", "switched_rules") | ||||||||
switched_rules.use_languages( | ||||||||
cc = True, | ||||||||
tyler-french marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||||
go = True, | ||||||||
java = True, | ||||||||
python = True, | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
It looks to me if you add this some other deps are missing There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. maybe blocked on bazelbuild/bazel-central-registry#353 |
||||||||
) | ||||||||
use_repo(switched_rules, "com_google_googleapis_imports") |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# When Bzlmod is enabled, this file replaces the content of the original WORKSPACE | ||
# and makes sure no WORKSPACE prefix or suffix are added when Bzlmod is enabled. |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,59 @@ | ||||||
load(":repository_rules.bzl", "switched_rules_by_language") | ||||||
|
||||||
_use_languages_tag = tag_class( | ||||||
attrs = { | ||||||
"cc": attr.bool(default = False), | ||||||
"csharp": attr.bool(default = False), | ||||||
"gapic": attr.bool(default = False), | ||||||
"go": attr.bool(default = False), | ||||||
"go_test": attr.bool(default = False), | ||||||
"grpc": attr.bool(default = False), | ||||||
"java": attr.bool(default = False), | ||||||
"nodejs": attr.bool(default = False), | ||||||
"php": attr.bool(default = False), | ||||||
"python": attr.bool(default = False), | ||||||
"ruby": attr.bool(default = False), | ||||||
}, | ||||||
) | ||||||
|
||||||
def _switched_rules_impl(ctx): | ||||||
attrs = {} | ||||||
for module in ctx.modules: | ||||||
if not module.is_root: | ||||||
continue | ||||||
|
||||||
is_tag_set = False | ||||||
set_tag_name = "" | ||||||
|
||||||
for t in module.tags.use_languages: | ||||||
if is_tag_set: | ||||||
fail("Multiple use_language tags are set in the root module: '{}' and '{}'. Only one is allowed.".format(set_tag_name, t.name)) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
is_tag_set = True | ||||||
set_tag_name = t.name | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
|
||||||
attrs = { | ||||||
tyler-french marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
"cc": t.cc, | ||||||
"csharp": t.csharp, | ||||||
"gapic": t.gapic, | ||||||
"go": t.go, | ||||||
"go_test": t.go_test, | ||||||
"grpc": t.grpc, | ||||||
"java": t.java, | ||||||
"nodejs": t.nodejs, | ||||||
"php": t.php, | ||||||
"python": t.python, | ||||||
"ruby": t.ruby, | ||||||
} | ||||||
|
||||||
switched_rules_by_language( | ||||||
name = "com_google_googleapis_imports", | ||||||
**attrs | ||||||
) | ||||||
|
||||||
switched_rules = module_extension( | ||||||
implementation = _switched_rules_impl, | ||||||
tag_classes = { | ||||||
"use_languages": _use_languages_tag, | ||||||
}, | ||||||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should enable a CI run with Bzlmod (only the default in the not yet released Bazel 7).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not sure CI is running in this repo. I will try to set up a BCR presubmit also.