Skip to content

Commit

Permalink
Add googleapis and grpc-java (bazelbuild#1699)
Browse files Browse the repository at this point in the history
These are in the same PR since they have a circular dependency on each
other

Fixes: bazelbuild#353
Fixes: bazelbuild#1113
  • Loading branch information
keith authored and aiuto committed Jun 3, 2024
1 parent b0091cc commit fabb8ae
Show file tree
Hide file tree
Showing 12 changed files with 2,424 additions and 0 deletions.
29 changes: 29 additions & 0 deletions modules/googleapis/0.0.0-20240326-1c8d509c5/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
module(
name = "googleapis",
version = "0.0.0-20240326-1c8d509c5",
repo_name = "com_google_googleapis",
)

bazel_dep(name = "grpc", version = "1.56.3.bcr.1", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "grpc-java", version = "1.62.2", repo_name = "io_grpc_grpc_java")
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_go", version = "0.46.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
bazel_dep(name = "rules_python", version = "0.31.0")

switched_rules = use_extension("//:extensions.bzl", "switched_rules")

# TODO: Enable support for other languages with bzlmod
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")
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
diff --git a/MODULE.bazel b/MODULE.bazel
new file mode 100644
index 000000000..169133e43
--- /dev/null
+++ b/MODULE.bazel
@@ -0,0 +1,29 @@
+module(
+ name = "googleapis",
+ version = "0.0.0-20240326-1c8d509c5",
+ repo_name = "com_google_googleapis",
+)
+
+bazel_dep(name = "grpc", version = "1.56.3.bcr.1", repo_name = "com_github_grpc_grpc")
+bazel_dep(name = "grpc-java", version = "1.62.2", repo_name = "io_grpc_grpc_java")
+bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")
+bazel_dep(name = "rules_go", version = "0.46.0", repo_name = "io_bazel_rules_go")
+bazel_dep(name = "rules_proto", version = "5.3.0-21.7")
+bazel_dep(name = "rules_python", version = "0.31.0")
+
+switched_rules = use_extension("//:extensions.bzl", "switched_rules")
+
+# TODO: Enable support for other languages with bzlmod
+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/extensions.bzl b/extensions.bzl
new file mode 100644
index 000000000..9aa161841
--- /dev/null
+++ b/extensions.bzl
@@ -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, module.name))
+
+ is_tag_set = True
+ set_tag_name = module.name
+
+ 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,
+ },
+)
9 changes: 9 additions & 0 deletions modules/googleapis/0.0.0-20240326-1c8d509c5/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
bazel: ["7.x"]
tasks:
verify_targets:
platform: ${{ platform }}
bazel: ${{ bazel }}
build_targets:
- '@googleapis//google/devtools/source/v1:source_proto'
9 changes: 9 additions & 0 deletions modules/googleapis/0.0.0-20240326-1c8d509c5/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"integrity": "sha256-uFSuF925M8JJUw90PbjXjfgJBd+0JoElVWSh0ZId/Dw=",
"strip_prefix": "googleapis-1c8d509c574aeab7478be1bfd4f2e8f0931cfead",
"url": "https://github.com/googleapis/googleapis/archive/1c8d509c574aeab7478be1bfd4f2e8f0931cfead.tar.gz",
"patch_strip": 1,
"patches": {
"add_module_bazel.patch": "sha256-fyl8LjxecJdTeeCNtpG4rfZMDiSOPTUi7HvJGDWvP1o="
}
}
16 changes: 16 additions & 0 deletions modules/googleapis/metadata.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
"homepage": "https://github.com/googleapis/googleapis",
"maintainers": [
{
"email": "bcr-maintainers@bazel.build",
"name": "No Maintainer Specified"
}
],
"repository": [
"github:googleapis/googleapis"
],
"versions": [
"0.0.0-20240326-1c8d509c5"
],
"yanked_versions": {}
}
197 changes: 197 additions & 0 deletions modules/grpc-java/1.62.2/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,197 @@
module(
name = "grpc-java",
version = "1.62.2",
compatibility_level = 0,
repo_name = "io_grpc_grpc_java",
)

bazel_dep(name = "googleapis", version = "0.0.0-20240326-1c8d509c5", repo_name = "com_google_googleapis")
bazel_dep(name = "grpc", version = "1.56.3.bcr.1", repo_name = "com_github_grpc_grpc")
bazel_dep(name = "protobuf", version = "23.1", repo_name = "com_google_protobuf")
bazel_dep(name = "rules_cc", version = "0.0.9")
bazel_dep(name = "rules_go", version = "0.46.0", repo_name = "io_bazel_rules_go")
bazel_dep(name = "rules_jvm_external", version = "6.0")
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

non_module_deps = use_extension("//:repositories.bzl", "grpc_java_repositories_extension")
use_repo(
non_module_deps,
"com_github_cncf_xds",
"envoy_api",
"io_grpc_grpc_proto",
)

grpc_repo_deps_ext = use_extension("@com_github_grpc_grpc//bazel:grpc_deps.bzl", "grpc_repo_deps_ext")
use_repo(
grpc_repo_deps_ext,
"com_envoyproxy_protoc_gen_validate",
"com_github_cncf_udpa",
"opencensus_proto",
)

maven = use_extension("@rules_jvm_external//:extensions.bzl", "maven")
maven.install(
name = "grpc_java_maven",
artifacts = [
"com.google.android:annotations:4.1.1.4",
"com.google.api.grpc:proto-google-common-protos:2.29.0",
"com.google.auth:google-auth-library-credentials:1.4.0",
"com.google.auth:google-auth-library-oauth2-http:1.4.0",
"com.google.auto.value:auto-value-annotations:1.10.4",
"com.google.auto.value:auto-value:1.10.4",
"com.google.code.findbugs:jsr305:3.0.2",
"com.google.code.gson:gson:2.10.1",
"com.google.errorprone:error_prone_annotations:2.23.0",
"com.google.guava:failureaccess:1.0.1",
"com.google.guava:guava:32.1.3-android",
"com.google.re2j:re2j:1.7",
"com.google.truth:truth:1.1.5",
"com.squareup.okhttp:okhttp:2.7.5",
"com.squareup.okio:okio:2.10.0", # 3.0+ needs swapping to -jvm; need work to avoid flag-day
"io.netty:netty-buffer:4.1.100.Final",
"io.netty:netty-codec-http2:4.1.100.Final",
"io.netty:netty-codec-http:4.1.100.Final",
"io.netty:netty-codec-socks:4.1.100.Final",
"io.netty:netty-codec:4.1.100.Final",
"io.netty:netty-common:4.1.100.Final",
"io.netty:netty-handler-proxy:4.1.100.Final",
"io.netty:netty-handler:4.1.100.Final",
"io.netty:netty-resolver:4.1.100.Final",
"io.netty:netty-tcnative-boringssl-static:2.0.61.Final",
"io.netty:netty-tcnative-classes:2.0.61.Final",
"io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.100.Final",
"io.netty:netty-transport-native-unix-common:4.1.100.Final",
"io.netty:netty-transport:4.1.100.Final",
"io.opencensus:opencensus-api:0.31.0",
"io.opencensus:opencensus-contrib-grpc-metrics:0.31.0",
"io.perfmark:perfmark-api:0.26.0",
"junit:junit:4.13.2",
"org.apache.tomcat:annotations-api:6.0.53",
"org.codehaus.mojo:animal-sniffer-annotations:1.23",
],
lock_file = "//:maven_install.json",
repositories = [
"https://repo1.maven.org/maven2",
"https://maven.google.com",
],
)
use_repo(maven, "grpc_java_maven", "unpinned_grpc_java_maven")
maven.override(
name = "grpc_java_maven",
coordinates = "com.google.protobuf:protobuf-java",
target = "@com_google_protobuf//:protobuf_java",
)
maven.override(
name = "grpc_java_maven",
coordinates = "com.google.protobuf:protobuf-java-util",
target = "@com_google_protobuf//:protobuf_java_util",
)
maven.override(
name = "grpc_java_maven",
coordinates = "com.google.protobuf:protobuf-javalite",
target = "@com_google_protobuf_javalite//:protobuf_javalite",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-alts",
target = "@io_grpc_grpc_java//alts",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-api",
target = "@io_grpc_grpc_java//api",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-auth",
target = "@io_grpc_grpc_java//auth",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-census",
target = "@io_grpc_grpc_java//census",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-context",
target = "@io_grpc_grpc_java//context",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-core",
target = "@io_grpc_grpc_java//core:core_maven",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-googleapis",
target = "@io_grpc_grpc_java//googleapis",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-grpclb",
target = "@io_grpc_grpc_java//grpclb",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-inprocess",
target = "@io_grpc_grpc_java//inprocess",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-netty",
target = "@io_grpc_grpc_java//netty",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-netty-shaded",
target = "@io_grpc_grpc_java//netty:shaded_maven",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-okhttp",
target = "@io_grpc_grpc_java//okhttp",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-protobuf",
target = "@io_grpc_grpc_java//protobuf",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-protobuf-lite",
target = "@io_grpc_grpc_java//protobuf-lite",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-rls",
target = "@io_grpc_grpc_java//rls",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-services",
target = "@io_grpc_grpc_java//services:services_maven",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-stub",
target = "@io_grpc_grpc_java//stub",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-testing",
target = "@io_grpc_grpc_java//testing",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-xds",
target = "@io_grpc_grpc_java//xds:xds_maven",
)
maven.override(
name = "grpc_java_maven",
coordinates = "io.grpc:grpc-util",
target = "@io_grpc_grpc_java//util",
)

switched_rules = use_extension("@com_google_googleapis//:extensions.bzl", "switched_rules")
switched_rules.use_languages(java = True)
use_repo(switched_rules, "com_google_googleapis_imports")
Loading

0 comments on commit fabb8ae

Please sign in to comment.