Skip to content
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

Split googleapis into per-language modules #3472

Merged
merged 1 commit into from
Feb 19, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions modules/googleapis/0.0.0-20241220-5e258e33/MODULE.bazel
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module(
name = "googleapis",
version = "0.0.0-20241220-5e258e33",
repo_name = "com_google_googleapis",
bazel_compatibility = [">=7.2.1"],
)

# Only needed for well-known protos.
bazel_dep(name = "protobuf", version = "21.7", repo_name = "com_google_protobuf")

# Only needed for proto_library.
bazel_dep(name = "rules_proto", version = "5.3.0-21.7")

bazel_dep(name = "googleapis-rules-registry", version = "1.0.0")

rules_registry = use_extension("@googleapis-rules-registry//private/extensions:rules_registry.bzl", "rules_registry")
use_repo(
rules_registry,
"com_google_googleapis_imports",
"io_bazel_rules_go",
)
30 changes: 30 additions & 0 deletions modules/googleapis/0.0.0-20241220-5e258e33/overlay/extensions.bzl
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
_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):
fail("""
The 'switched_rules' extension is no longer supported due to problems inherent to its design.
Instead, add 'bazel_dep(name = "googleapis-<lang>", version = "1.0.0")' to your MODULE.bazel file to use '<lang>_proto_library' targets in 'googleapis'.
To see error messages with the exact 'bazel_dep's to add, remove the 'switched_rules' usage and build your project.
The available individual modules can be found at https://registry.bazel.build/search?q=googleapis.
""")

switched_rules = module_extension(
implementation = _switched_rules_impl,
tag_classes = {
"use_languages": _use_languages_tag,
},
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
common --java_runtime_version=remotejdk_11

# Disable warnings for external dependencies.
common --per_file_copt=external/.*@-w
common --host_per_file_copt=external/.*@-w
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
load(":failure_test.bzl", "php_proto_library_fails_with_message_test")

alias(
name = "bytestream_proto",
actual = "@googleapis//google/bytestream:bytestream_proto",
)

alias(
name = "bytestream_cc_proto",
actual = "@googleapis//google/bytestream:bytestream_cc_proto",
)

alias(
name = "bytestream_go_proto",
actual = "@googleapis//google/bytestream:bytestream_go_proto",
)

alias(
name = "bytestream_java_proto",
actual = "@googleapis//google/bytestream:bytestream_java_proto",
)

alias(
name = "date_py_proto",
actual = "@googleapis//google/type:date_py_proto",
)

alias(
name = "spanner_cc_grpc",
actual = "@googleapis//google/spanner/v1:spanner_cc_grpc",
)

alias(
name = "spanner_java_grpc",
actual = "@googleapis//google/spanner/v1:spanner_java_grpc",
)

php_proto_library_fails_with_message_test(
name = "php_proto_library_fails_with_message_test",
target_under_test = "@googleapis//google/bytestream:bytestream_php_proto",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
bazel_dep(name = "bazel_skylib", version = "1.7.1")
bazel_dep(name = "googleapis")
bazel_dep(name = "googleapis-cc", version = "1.0.0")
bazel_dep(name = "googleapis-go", version = "1.0.0")
bazel_dep(name = "googleapis-java", version = "1.0.0")
bazel_dep(name = "googleapis-python", version = "1.0.0")
bazel_dep(name = "googleapis-grpc-cc", version = "1.0.0")
bazel_dep(name = "googleapis-grpc-java", version = "1.0.0")

local_path_override(
module_name = "googleapis",
path = "../..",
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
load("@bazel_skylib//lib:unittest.bzl", "analysistest", "asserts")

def _php_proto_library_fails_with_message_test_impl(ctx):
env = analysistest.begin(ctx)
asserts.expect_failure(env, """php_proto_library targets in googleapis are not supported with Bzlmod. If you need them, please file an issue at https://github.com/bazelbuild/bazel-central-registry.""")
return analysistest.end(env)

php_proto_library_fails_with_message_test = analysistest.make(
_php_proto_library_fails_with_message_test_impl,
expect_failure = True,
)
14 changes: 14 additions & 0 deletions modules/googleapis/0.0.0-20241220-5e258e33/presubmit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
bcr_test_module:
module_path: "tests/bcr"
matrix:
platform: ["debian10", "macos", "ubuntu2004", "windows"]
bazel: ["7.x", "8.x"]
tasks:
run_tests:
name: "Run test module"
bazel: ${{ bazel }}
platform: ${{ platform }}
build_targets:
- "//..."
test_targets:
- "//..."
13 changes: 13 additions & 0 deletions modules/googleapis/0.0.0-20241220-5e258e33/source.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"integrity": "sha256-ftfNAEA+XKYX5I+kRRNhXnnfyBert9Rgq1WQ6sJ0Pvk=",
"strip_prefix": "googleapis-5e258e334154da04dcd0a567a61ac21518cac81b",
"url": "https://github.com/googleapis/googleapis/archive/5e258e334154da04dcd0a567a61ac21518cac81b.tar.gz",
"overlay": {
"MODULE.bazel": "sha256-VxsBhkSSAwL1ppUguR2uGJwX1WbnMKG4fJ2+7+Ob1qU=",
"extensions.bzl": "sha256-7C/04C9c7meY0eqFSdgSm6i1MTCAd5QarXTsBRJ4aN4=",
"tests/bcr/.bazelrc": "sha256-hFZT+gits3VtXcUkKuh3NCEC9FgBNGuNxaOVCuOiFPk=",
"tests/bcr/BUILD.bazel": "sha256-KZzDURLUNDOiMsurUHrnuWYogHPFs7W+Ar9ZrilPLuE=",
"tests/bcr/MODULE.bazel": "sha256-4zmBG1uAn7W3ExjUMQChBcrJVSNCE6K8PhIs9SfKy1U=",
"tests/bcr/failure_test.bzl": "sha256-pKImfWiY7m3EB1w0n4C66/LABDBwTYr/2nqxoC+gvBc="
}
}
3 changes: 2 additions & 1 deletion modules/googleapis/metadata.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
],
"versions": [
"0.0.0-20240326-1c8d509c5",
"0.0.0-20240819-fe8ba054a"
"0.0.0-20240819-fe8ba054a",
"0.0.0-20241220-5e258e33"
],
"yanked_versions": {}
}
Loading