-
Notifications
You must be signed in to change notification settings - Fork 70
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Design doc: https://docs.google.com/document/d/1L1JFgjpZ7SrBinb24DC_5nTIELeYDacikcme-YcA7xs/edit PiperOrigin-RevId: 606958336
- Loading branch information
A Googler
authored and
Blaze Rules Copybara
committed
Feb 14, 2024
1 parent
dec2b5c
commit d4c3498
Showing
17 changed files
with
232 additions
and
103 deletions.
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
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
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//:bzl_library.bzl", "bzl_library") | ||
|
||
bzl_library( | ||
name = "proto_common", | ||
srcs = [ | ||
"proto_common.bzl", | ||
"proto_info.bzl", | ||
"proto_lang_toolchain_info.bzl", | ||
], | ||
visibility = ["//visibility:public"], | ||
) |
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
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,18 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""ProtoInfo""" | ||
|
||
load("//proto/private:native.bzl", "NativeProtoInfo") | ||
|
||
ProtoInfo = NativeProtoInfo |
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,18 @@ | ||
# Copyright 2024 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""ProtoLangToolchainInfo""" | ||
|
||
load("//proto/private:native.bzl", "native_proto_common") | ||
|
||
ProtoLangToolchainInfo = native_proto_common.ProtoLangToolchainInfo |
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
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
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,18 @@ | ||
# Copyright 2024 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""proto_descriptor_set rule""" | ||
|
||
load("//proto/private/rules:proto_descriptor_set.bzl", _proto_descriptor_set = "proto_descriptor_set") | ||
|
||
proto_descriptor_set = _proto_descriptor_set |
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
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,35 @@ | ||
# Copyright 2024 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""proto_library rule""" | ||
|
||
_MIGRATION_TAG = "__PROTO_RULES_MIGRATION_DO_NOT_USE_WILL_BREAK__" | ||
|
||
def _add_migration_tag(attrs): | ||
if "tags" in attrs and attrs["tags"] != None: | ||
attrs["tags"] = attrs["tags"] + [_MIGRATION_TAG] | ||
else: | ||
attrs["tags"] = [_MIGRATION_TAG] | ||
return attrs | ||
|
||
def proto_library(**attrs): | ||
"""Bazel proto_library rule. | ||
https://docs.bazel.build/versions/master/be/protocol-buffer.html#proto_library | ||
Args: | ||
**attrs: Rule attributes | ||
""" | ||
|
||
# buildifier: disable=native-proto | ||
native.proto_library(**_add_migration_tag(attrs)) |
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
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,23 @@ | ||
load("@bazel_skylib//:bzl_library.bzl", "bzl_library") | ||
|
||
bzl_library( | ||
name = "proto_lang_toolchain", | ||
srcs = [ | ||
"proto_lang_toolchain.bzl", | ||
], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//proto/modules:proto_common", | ||
], | ||
) | ||
|
||
bzl_library( | ||
name = "proto_toolchain", | ||
srcs = [ | ||
"proto_toolchain.bzl", | ||
], | ||
visibility = ["//visibility:public"], | ||
deps = [ | ||
"//proto/private/rules:proto_toolchain_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,47 @@ | ||
# Copyright 2019 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
"""proto_lang_toolchain rule""" | ||
|
||
load("//proto/modules:proto_common.bzl", "proto_common") | ||
|
||
def proto_lang_toolchain(*, name, toolchain_type = None, exec_compatible_with = [], target_compatible_with = [], **attrs): | ||
"""Creates a proto_lang_toolchain and corresponding toolchain target. | ||
Toolchain target is only created when toolchain_type is set. | ||
https://docs.bazel.build/versions/master/be/protocol-buffer.html#proto_lang_toolchain | ||
Args: | ||
name: name of the toolchain | ||
toolchain_type: The toolchain type | ||
exec_compatible_with: ([constraints]) List of constraints the prebuild binaries is compatible with. | ||
target_compatible_with: ([constraints]) List of constraints the target libraries are compatible with. | ||
**attrs: Rule attributes | ||
""" | ||
|
||
if getattr(proto_common, "INCOMPATIBLE_PASS_TOOLCHAIN_TYPE", False): | ||
attrs["toolchain_type"] = toolchain_type | ||
|
||
# buildifier: disable=native-proto | ||
native.proto_lang_toolchain(name = name, **attrs) | ||
|
||
if toolchain_type: | ||
native.toolchain( | ||
name = name + "_toolchain", | ||
toolchain_type = toolchain_type, | ||
exec_compatible_with = exec_compatible_with, | ||
target_compatible_with = target_compatible_with, | ||
toolchain = name, | ||
) |
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,19 @@ | ||
# Copyright 2023 The Bazel Authors. All rights reserved. | ||
# | ||
# Licensed under the Apache License, Version 2.0 (the "License"); | ||
# you may not use this file except in compliance with the License. | ||
# You may obtain a copy of the License at | ||
# | ||
# http://www.apache.org/licenses/LICENSE-2.0 | ||
# | ||
# Unless required by applicable law or agreed to in writing, software | ||
# distributed under the License is distributed on an "AS IS" BASIS, | ||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
# See the License for the specific language governing permissions and | ||
# limitations under the License. | ||
|
||
"""Export for proto_toolchain""" | ||
|
||
load("//proto/private/rules:proto_toolchain.bzl", _proto_toolchain_macro = "proto_toolchain") | ||
|
||
proto_toolchain = _proto_toolchain_macro |
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.
d4c3498
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.
This is a breaking change, and needs some partial reverts in order to let users continue to use rules_proto.
For example, no version of rules_python can work before and after this commit because there's no stable load location for the
proto_common#toolchains
helper: https://github.com/bazelbuild/rules_python/pull/1577/files#diff-9cb07a0e8453ad8b4f429bee2ccf9de818a78cfb6e5d9bb908d8518ea189e2a7R18Asking developers to sort out the version skew themselves in a low-level library like rules_proto is putting far too much burden on them. Bazel Slack is going to be filled with developers tripping over "what version of rules_somelang can I use" due to this.
Alternatively, if proto_common.bzl is a private API, then we need to expose this
toolchains
helper in some other public API, or tell @thesayyn that it may not be used in a language repo to implement the toolchainization?d4c3498
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.
I'm guessing no one is paying attention on this repo, so the answer is not to use that
toolchains
helper and treat it as private API.