Skip to content

Commit 51051f6

Browse files
committed
Add googleapis
1 parent 659b32b commit 51051f6

File tree

5 files changed

+163
-0
lines changed

5 files changed

+163
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
module(
2+
name = "googleapis",
3+
version = "0.0.0-20240326-1c8d509c5",
4+
repo_name = "com_google_googleapis",
5+
)
6+
7+
bazel_dep(name = "grpc", version = "1.56.3.bcr.1", repo_name = "com_github_grpc_grpc")
8+
bazel_dep(name = "grpc-java", repo_name = "io_grpc_grpc_java")
9+
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
10+
bazel_dep(name = "rules_go", version = "0.46.0", repo_name = "io_bazel_rules_go")
11+
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
12+
bazel_dep(name = "rules_python", version = "0.31.0")
13+
14+
switched_rules = use_extension("//:extensions.bzl", "switched_rules")
15+
16+
# TODO: Enable support for other languages with bzlmod
17+
switched_rules.use_languages(
18+
cc = True,
19+
# csharp = True,
20+
# gapic = True,
21+
go = True,
22+
grpc = True,
23+
java = True,
24+
# nodejs = True,
25+
# php = True,
26+
python = True,
27+
# ruby = True,
28+
)
29+
use_repo(switched_rules, "com_google_googleapis_imports")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
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+
+)
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
matrix:
2+
platform: ["debian10", "macos", "ubuntu2004", "windows"]
3+
bazel: ["6.x", "7.x"]
4+
tasks:
5+
verify_targets:
6+
platform: ${{ platform }}
7+
bazel: ${{ bazel }}
8+
build_targets:
9+
- '@googleapis//google/devtools/source/v1:source_proto'
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"integrity": "sha256-uFSuF925M8JJUw90PbjXjfgJBd+0JoElVWSh0ZId/Dw=",
3+
"strip_prefix": "googleapis-1c8d509c574aeab7478be1bfd4f2e8f0931cfead",
4+
"url": "https://github.com/googleapis/googleapis/archive/1c8d509c574aeab7478be1bfd4f2e8f0931cfead.tar.gz",
5+
"patch_strip": 1,
6+
"patches": {
7+
"add_module_bazel.patch": "sha256-fyl8LjxecJdTeeCNtpG4rfZMDiSOPTUi7HvJGDWvP1o="
8+
}
9+
}

modules/googleapis/metadata.json

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{
2+
"homepage": "https://github.com/googleapis/googleapis",
3+
"maintainers": [
4+
{
5+
"email": "[email protected]",
6+
"name": "No Maintainer Specified"
7+
}
8+
],
9+
"repository": [
10+
"github:googleapis/googleapis"
11+
],
12+
"versions": [
13+
"0.0.0-20240326-1c8d509c5"
14+
],
15+
"yanked_versions": {}
16+
}

0 commit comments

Comments
 (0)