Skip to content

Commit 18666e0

Browse files
Add redirects for proto rules
Redirected rules: proto_library, proto_toolchain, proto_lang_toolchain Modules and providers: proto_common, ProtoInfo, ProtoLangToolchainInfo The structure follows proposal: https://docs.google.com/document/d/1L1JFgjpZ7SrBinb24DC_5nTIELeYDacikcme-YcA7xs/edit?usp=drive_open&ouid=102306600948089647787 PiperOrigin-RevId: 610471985
1 parent d8251eb commit 18666e0

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

54 files changed

+273
-113
lines changed

WORKSPACE

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ ruby_bundle(
135135

136136
http_archive(
137137
name = "lua",
138-
build_file = "//bazel:lua.BUILD",
138+
build_file = "//python/dist:lua.BUILD",
139139
sha256 = "b9e2e4aad6789b3b63a056d442f7b39f0ecfca3ae0f1fc0ae4e9614401b69f4b",
140140
strip_prefix = "lua-5.2.4",
141141
urls = [
@@ -160,7 +160,7 @@ http_archive(
160160
patch_cmds = ["find google -type f -name BUILD.bazel -delete"],
161161
)
162162

163-
load("//bazel:system_python.bzl", "system_python")
163+
load("//python/dist:system_python.bzl", "system_python")
164164

165165
system_python(
166166
name = "system_python",

bazel/BUILD

Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -6,57 +6,13 @@
66
# https://developers.google.com/open-source/licenses/bsd
77

88
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
9-
load("@bazel_skylib//lib:selects.bzl", "selects")
10-
load("@rules_python//python:defs.bzl", "py_binary")
119

1210
# begin:google_only
1311
# package(default_applicable_licenses = ["//upb:license"])
1412
# end:google_only
1513

1614
licenses(["notice"])
1715

18-
# begin:google_only
19-
# selects.config_setting_group(
20-
# name = "android_opt",
21-
# match_all = [
22-
# "//tools/cc_target_os:android",
23-
# "//tools/compilation_mode:opt",
24-
# ],
25-
# )
26-
# end:google_only
27-
28-
py_binary(
29-
name = "amalgamate",
30-
srcs = ["amalgamate.py"],
31-
visibility = ["//upb:__pkg__"],
32-
)
33-
34-
# py_proto_library() is private rule, only intended for internal use by upb.
35-
# Hopefully py_proto_library() will eventually be available in rules_proto or
36-
# another upstream package.
37-
bzl_library(
38-
name = "py_proto_library_bzl",
39-
srcs = ["py_proto_library.bzl"],
40-
deps = [
41-
"@rules_python//python:py_info_bzl",
42-
],
43-
)
44-
45-
bzl_library(
46-
name = "upb_proto_library_internal_bzl",
47-
srcs = [
48-
"upb_proto_library_internal/aspect.bzl",
49-
"upb_proto_library_internal/cc_library_func.bzl",
50-
"upb_proto_library_internal/copts.bzl",
51-
"upb_proto_library_internal/rule.bzl",
52-
],
53-
deps = [
54-
"@bazel_skylib//lib:paths",
55-
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
56-
"@rules_proto//proto:defs",
57-
],
58-
)
59-
6016
bzl_library(
6117
name = "upb_proto_library_bzl",
6218
srcs = [
@@ -67,7 +23,7 @@ bzl_library(
6723
],
6824
visibility = ["//visibility:public"],
6925
deps = [
70-
":upb_proto_library_internal_bzl",
26+
"//bazel/private:upb_proto_library_internal_bzl",
7127
"@rules_proto//proto:defs",
7228
],
7329
)

bazel/common/BUILD.bazel

Whitespace-only changes.

bazel/common/proto_common.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""proto_common"""
2+
3+
load("//bazel/private:native.bzl", "native_proto_common")
4+
5+
proto_common = native_proto_common

bazel/common/proto_info.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""ProtoInfo"""
2+
3+
load("//bazel/private:native.bzl", "NativeProtoInfo")
4+
5+
ProtoInfo = NativeProtoInfo
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""ProtoLangToolchainInfo"""
2+
3+
load("//bazel/common:proto_common.bzl", "proto_common")
4+
5+
ProtoLangToolchainInfo = proto_common.ProtoLangToolchainInfo

bazel/private/BUILD

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Copyright (c) 2009-2021, Google LLC
2+
# All rights reserved.
3+
#
4+
# Use of this source code is governed by a BSD-style
5+
# license that can be found in the LICENSE file or at
6+
# https://developers.google.com/open-source/licenses/bsd
7+
8+
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
9+
10+
# begin:google_only
11+
# package(default_applicable_licenses = ["//upb:license"])
12+
# end:google_only
13+
14+
licenses(["notice"])
15+
16+
bzl_library(
17+
name = "upb_proto_library_internal_bzl",
18+
srcs = [
19+
"upb_proto_library_internal/aspect.bzl",
20+
"upb_proto_library_internal/cc_library_func.bzl",
21+
"upb_proto_library_internal/copts.bzl",
22+
"upb_proto_library_internal/rule.bzl",
23+
],
24+
visibility = ["//bazel:__pkg__"],
25+
deps = [
26+
"@bazel_skylib//lib:paths",
27+
"@bazel_tools//tools/cpp:toolchain_utils.bzl",
28+
"@rules_proto//proto:defs",
29+
],
30+
)

bazel/private/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package(default_applicable_licenses = ["//src/google/protobuf:license"])

bazel/private/native.bzl

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
"""Renames toplevel symbols so they can be exported in Starlark under the same name"""
2+
3+
NativeProtoInfo = ProtoInfo
4+
5+
native_proto_common = proto_common_do_not_use
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
"""A Starlark implementation of the proto_toolchain rule."""
2+
3+
load("//bazel/common:proto_common.bzl", "proto_common")
4+
load("//bazel/common:proto_lang_toolchain_info.bzl", "ProtoLangToolchainInfo")
5+
6+
def _impl(ctx):
7+
kwargs = {}
8+
if getattr(proto_common, "INCOMPATIBLE_PASS_TOOLCHAIN_TYPE", False):
9+
kwargs["toolchain_type"] = "//third_party/bazel_rules/rules_proto/proto:toolchain_type"
10+
11+
return [
12+
DefaultInfo(
13+
files = depset(),
14+
runfiles = ctx.runfiles(),
15+
),
16+
platform_common.ToolchainInfo(
17+
proto = ProtoLangToolchainInfo(
18+
out_replacement_format_flag = ctx.attr.command_line,
19+
output_files = ctx.attr.output_files,
20+
plugin = None,
21+
runtime = None,
22+
proto_compiler = ctx.attr.proto_compiler.files_to_run,
23+
protoc_opts = ctx.fragments.proto.experimental_protoc_opts,
24+
progress_message = ctx.attr.progress_message,
25+
mnemonic = ctx.attr.mnemonic,
26+
**kwargs
27+
),
28+
),
29+
]
30+
31+
proto_toolchain = rule(
32+
_impl,
33+
attrs =
34+
{
35+
"progress_message": attr.string(default = "Generating Descriptor Set proto_library %{label}"),
36+
"mnemonic": attr.string(default = "GenProtoDescriptorSet"),
37+
"command_line": attr.string(default = "--descriptor_set_out=%s"),
38+
"output_files": attr.string(values = ["single", "multiple", "legacy"], default = "single"),
39+
"proto_compiler": attr.label(
40+
cfg = "exec",
41+
executable = True,
42+
allow_files = True, # Used by mocks in tests. Consider fixing tests and removing it.
43+
),
44+
},
45+
provides = [platform_common.ToolchainInfo],
46+
fragments = ["proto"],
47+
)

0 commit comments

Comments
 (0)