|
| 1 | +diff --git a/MODULE.bazel b/MODULE.bazel |
| 2 | +new file mode 100644 |
| 3 | +index 000000000..169133e43 |
| 4 | +--- /dev/null |
| 5 | ++++ b/MODULE.bazel |
| 6 | +@@ -0,0 +1,29 @@ |
| 7 | ++module( |
| 8 | ++ name = "googleapis", |
| 9 | ++ version = "0.0.0-20240326-1c8d509c5", |
| 10 | ++ repo_name = "com_google_googleapis", |
| 11 | ++) |
| 12 | ++ |
| 13 | ++bazel_dep(name = "grpc", version = "1.56.3.bcr.1", repo_name = "com_github_grpc_grpc") |
| 14 | ++bazel_dep(name = "grpc-java", version = "1.62.2", repo_name = "io_grpc_grpc_java") |
| 15 | ++bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf") |
| 16 | ++bazel_dep(name = "rules_go", version = "0.46.0", repo_name = "io_bazel_rules_go") |
| 17 | ++bazel_dep(name = "rules_proto", version = "5.3.0-21.7") |
| 18 | ++bazel_dep(name = "rules_python", version = "0.31.0") |
| 19 | ++ |
| 20 | ++switched_rules = use_extension("//:extensions.bzl", "switched_rules") |
| 21 | ++ |
| 22 | ++# TODO: Enable support for other languages with bzlmod |
| 23 | ++switched_rules.use_languages( |
| 24 | ++ cc = True, |
| 25 | ++ # csharp = True, |
| 26 | ++ # gapic = True, |
| 27 | ++ go = True, |
| 28 | ++ grpc = True, |
| 29 | ++ java = True, |
| 30 | ++ # nodejs = True, |
| 31 | ++ # php = True, |
| 32 | ++ python = True, |
| 33 | ++ # ruby = True, |
| 34 | ++) |
| 35 | ++use_repo(switched_rules, "com_google_googleapis_imports") |
| 36 | +diff --git a/extensions.bzl b/extensions.bzl |
| 37 | +new file mode 100644 |
| 38 | +index 000000000..9aa161841 |
| 39 | +--- /dev/null |
| 40 | ++++ b/extensions.bzl |
| 41 | +@@ -0,0 +1,59 @@ |
| 42 | ++load(":repository_rules.bzl", "switched_rules_by_language") |
| 43 | ++ |
| 44 | ++_use_languages_tag = tag_class( |
| 45 | ++ attrs = { |
| 46 | ++ "cc": attr.bool(default = False), |
| 47 | ++ "csharp": attr.bool(default = False), |
| 48 | ++ "gapic": attr.bool(default = False), |
| 49 | ++ "go": attr.bool(default = False), |
| 50 | ++ "go_test": attr.bool(default = False), |
| 51 | ++ "grpc": attr.bool(default = False), |
| 52 | ++ "java": attr.bool(default = False), |
| 53 | ++ "nodejs": attr.bool(default = False), |
| 54 | ++ "php": attr.bool(default = False), |
| 55 | ++ "python": attr.bool(default = False), |
| 56 | ++ "ruby": attr.bool(default = False), |
| 57 | ++ }, |
| 58 | ++) |
| 59 | ++ |
| 60 | ++def _switched_rules_impl(ctx): |
| 61 | ++ attrs = {} |
| 62 | ++ for module in ctx.modules: |
| 63 | ++ if not module.is_root: |
| 64 | ++ continue |
| 65 | ++ |
| 66 | ++ is_tag_set = False |
| 67 | ++ set_tag_name = "" |
| 68 | ++ |
| 69 | ++ for t in module.tags.use_languages: |
| 70 | ++ if is_tag_set: |
| 71 | ++ fail("Multiple use_language tags are set in the root module: '{}' and '{}'. Only one is allowed.".format(set_tag_name, module.name)) |
| 72 | ++ |
| 73 | ++ is_tag_set = True |
| 74 | ++ set_tag_name = module.name |
| 75 | ++ |
| 76 | ++ attrs = { |
| 77 | ++ "cc": t.cc, |
| 78 | ++ "csharp": t.csharp, |
| 79 | ++ "gapic": t.gapic, |
| 80 | ++ "go": t.go, |
| 81 | ++ "go_test": t.go_test, |
| 82 | ++ "grpc": t.grpc, |
| 83 | ++ "java": t.java, |
| 84 | ++ "nodejs": t.nodejs, |
| 85 | ++ "php": t.php, |
| 86 | ++ "python": t.python, |
| 87 | ++ "ruby": t.ruby, |
| 88 | ++ } |
| 89 | ++ |
| 90 | ++ switched_rules_by_language( |
| 91 | ++ name = "com_google_googleapis_imports", |
| 92 | ++ **attrs |
| 93 | ++ ) |
| 94 | ++ |
| 95 | ++switched_rules = module_extension( |
| 96 | ++ implementation = _switched_rules_impl, |
| 97 | ++ tag_classes = { |
| 98 | ++ "use_languages": _use_languages_tag, |
| 99 | ++ }, |
| 100 | ++) |
0 commit comments