-
-
Notifications
You must be signed in to change notification settings - Fork 673
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
how to upgrade to 0.41.0 via bzlmod only #3685
Comments
Try this:
GOOGLE_APIS_VERSION = "64926d52febbf298cb82a8f472ade4a3969ba922"
bazel_dep(name = "com_google_googleapis", version = GOOGLE_APIS_VERSION)
archive_override(
module_name = "com_google_googleapis",
integrity = "sha256-nRqTDnZ8k8glOYuPhpLso/41O5qq3t+88fyiKCyF34g=",
patch_strip = 1,
patches = [
"add_bzlmod_support.patch"
],
strip_prefix = "googleapis-" + GOOGLE_APIS_VERSION,
urls = [
"https://github.com/googleapis/googleapis/archive/%s.zip" % GOOGLE_APIS_VERSION
],
)
switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages()
use_repo(switched_rules, "com_google_googleapis_imports")
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 000000000..c26575773
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,22 @@
+module(
+ name = "com_google_googleapis",
+ version = "64926d52febbf298cb82a8f472ade4a3969ba922",
+)
+
+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,
+ csharp = True,
+ gapic = True,
+ go = True,
+ grpc = True,
+ java = True,
+ nodejs = True,
+ php = True,
+ python = True,
+ ruby = True,
+)
+use_repo(switched_rules, "com_google_googleapis_imports")
diff --git a/WORKSPACE.bzlmod b/WORKSPACE.bzlmod
new file mode 100644
index 000000000..fafa28da3
--- /dev/null
+++ b/WORKSPACE.bzlmod
@@ -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.
diff --git a/extensions.bzl b/extensions.bzl
new file mode 100644
index 000000000..d8f04cf6c
--- /dev/null
+++ b/extensions.bzl
@@ -0,0 +1,50 @@
+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
+
+ for t in module.tags.use_languages:
+ attrs = {
+ "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,
+ },
+) |
@fmeum or @pdeva Did you get this to work? I can't see the go build rules when I query using this:
|
Note to anybody trying this at home: if you see an error like this:
then you need to patch Gazelle to pull in In your
Now all the Go deps that Gazelle pulls in will be able to find |
Trying this with latest versions but i get this:
Bazel: 7.3.0 |
the upgrade instruction for 0.41.0 mention this as step 1:
this seems to be for users of
WORKSPACE
file.What is the equivalent to the above for those looking to use
bzlmod
only?The text was updated successfully, but these errors were encountered: