-
Notifications
You must be signed in to change notification settings - Fork 387
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
Open
fmeum
wants to merge
1
commit into
main
Choose a base branch
from
fmeum/googleapis-0.0.0-20241220-5e258e33
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+151
−1
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
1 change: 1 addition & 0 deletions
1
modules/googleapis/0.0.0-20241220-5e258e33/overlay/MODULE.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
../MODULE.bazel |
30 changes: 30 additions & 0 deletions
30
modules/googleapis/0.0.0-20241220-5e258e33/overlay/extensions.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
}, | ||
) |
5 changes: 5 additions & 0 deletions
5
modules/googleapis/0.0.0-20241220-5e258e33/overlay/tests/bcr/.bazelrc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
41 changes: 41 additions & 0 deletions
41
modules/googleapis/0.0.0-20241220-5e258e33/overlay/tests/bcr/BUILD.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", | ||
) |
13 changes: 13 additions & 0 deletions
13
modules/googleapis/0.0.0-20241220-5e258e33/overlay/tests/bcr/MODULE.bazel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = "../..", | ||
) |
11 changes: 11 additions & 0 deletions
11
modules/googleapis/0.0.0-20241220-5e258e33/overlay/tests/bcr/failure_test.bzl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | ||
- "//..." |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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=" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
should we increment the compatibility level here? IIUC this is a change that breaks almost everyone who uses the old
googleapis
("almost" because those who only useproto_library
targets should be unaffected), so upping the compatibility level should be a win.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My rule of thumb for this is:
multiple_version_override
.multiple_version_override
will impact maintainability of the root module.In this particular case, the answers to these questions are "yes (and migrating just requires a few
bazel_dep
s, so you won't need to touch files beyondMODULE.bazel
)" and "hell no (a single version of googleapis is already troublesome enough)".There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One thing to keep in mind is that bumping the compatibility level basically requires all (transitive) dependencies to release a new version bumping the dependency version with the new compatibility level before one can use the new dependency in the root module.