Skip to content

Commit d7dd1e1

Browse files
habermantonyliaoss
authored andcommitted
Refactored and rearranged Bazel rules.
- OSS-specific rule implementations are now located in `bazel/private/oss/`. - Shared rule logic remains in `bazel/` and its subdirectories. - This change clarifies which files are part of the OSS release and simplifies the build structure. PiperOrigin-RevId: 862007024
1 parent 7efbfe1 commit d7dd1e1

25 files changed

Lines changed: 608 additions & 510 deletions

MODULE.bazel

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,11 +136,11 @@ use_repo(
136136

137137
# However this registration only matters if the config_setting for prefer_prebuilt_protoc is true,
138138
# using --@protobuf//bazel/toolchains:prefer_prebuilt_protoc
139-
register_toolchains("//bazel/private/toolchains/prebuilt:all")
139+
register_toolchains("//bazel/private/oss/toolchains/prebuilt:all")
140140

141141
# From-source protobuf toolchains
142142
# Fallback if nothing is already registered
143-
register_toolchains("//bazel/private/toolchains:all")
143+
register_toolchains("//bazel/private/oss/toolchains:all")
144144

145145
SUPPORTED_PYTHON_VERSIONS = [
146146
"3.10",
Lines changed: 13 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,32 @@
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-
81
load("@bazel_skylib//:bzl_library.bzl", "bzl_library")
92

10-
licenses(["notice"])
3+
package(default_applicable_licenses = ["//:license"])
114

125
bzl_library(
136
name = "proto_library_bzl",
147
srcs = ["proto_library.bzl"],
158
visibility = ["//visibility:public"],
169
deps = [
1710
"//bazel/private:proto_library_rule_bzl",
18-
"@proto_bazel_features//:features",
1911
],
2012
)
2113

2214
bzl_library(
2315
name = "cc_proto_library_bzl",
2416
srcs = ["cc_proto_library.bzl"],
2517
visibility = ["//visibility:public"],
26-
deps = ["//bazel/private:bazel_cc_proto_library_bzl"],
18+
deps = [
19+
"//bazel/private/oss:cc_proto_library_bzl",
20+
],
2721
)
2822

2923
bzl_library(
3024
name = "java_proto_library_bzl",
3125
srcs = ["java_proto_library.bzl"],
3226
visibility = ["//visibility:public"],
33-
deps = ["//bazel/private:bazel_java_proto_library_rule_bzl"],
27+
deps = [
28+
"//bazel/private:java_proto_library_bzl",
29+
],
3430
)
3531

3632
bzl_library(
@@ -45,10 +41,7 @@ bzl_library(
4541
srcs = ["py_proto_library.bzl"],
4642
visibility = ["//visibility:public"],
4743
deps = [
48-
"//bazel/common:proto_common_bzl",
49-
"//bazel/common:proto_info_bzl",
50-
"//bazel/private:toolchain_helpers_bzl",
51-
"@rules_python//python:py_info_bzl",
44+
"//bazel/private/oss:py_proto_library_bzl",
5245
],
5346
)
5447

@@ -63,13 +56,16 @@ filegroup(
6356
name = "for_bazel_tests",
6457
testonly = True,
6558
srcs = [
66-
"BUILD.bazel",
59+
"BUILD",
6760
":cc_proto_library_bzl",
6861
":java_lite_proto_library_bzl",
6962
":proto_library_bzl",
7063
":py_proto_library_bzl",
7164
"//bazel/common:for_bazel_tests",
65+
"//bazel/flags:for_bazel_tests",
7266
"//bazel/toolchains:for_bazel_tests",
7367
],
74-
visibility = ["//bazel/private:__pkg__"],
68+
visibility = [
69+
"//bazel/private:__pkg__",
70+
],
7571
)

bazel/cc_proto_library.bzl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
1+
# Copyright (c) 2009-2024, 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+
18
"""cc_proto_library rule"""
29

3-
load("//bazel/private:bazel_cc_proto_library.bzl", _cc_proto_library = "cc_proto_library") # buildifier: disable=bzl-visibility
10+
load("//bazel/private/oss:cc_proto_library.bzl", _cc_proto_library = "cc_proto_library")
411

512
def cc_proto_library(**kwattrs):
613
# Only use Starlark rules when they are removed from Bazel

bazel/flags/flags.bzl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ load("@bazel_skylib//rules:common_settings.bzl", "BuildSettingInfo")
44

55
visibility([
66
"//third_party/grpc/bazel",
7-
"//bazel/private",
7+
"//bazel/private/...",
88
"//bazel/flags",
99
])
1010

bazel/java_lite_proto_library.bzl

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# Use of this source code is governed by a BSD-style
55
# license that can be found in the LICENSE file or at
66
# https://developers.google.com/open-source/licenses/bsd
7+
78
"""java_lite_proto_library rule"""
89

9-
load("//bazel/private:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library") # buildifier: disable=bzl-visibility
10+
load("//bazel/private:java_lite_proto_library.bzl", _java_lite_proto_library = "java_lite_proto_library")
1011

1112
def java_lite_proto_library(**kwattrs):
1213
# Only use Starlark rules when they are removed from Bazel

bazel/java_proto_library.bzl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
# Use of this source code is governed by a BSD-style
55
# license that can be found in the LICENSE file or at
66
# https://developers.google.com/open-source/licenses/bsd
7-
"""java_proto_library rule"""
87

9-
load("//bazel/private:bazel_java_proto_library_rule.bzl", _java_proto_library = "java_proto_library") # buildifier: disable=bzl-visibility
8+
"""java_proto_library rule."""
9+
10+
load("//bazel/private:java_proto_library.bzl", _java_proto_library = "java_proto_library")
1011

1112
def java_proto_library(**kwattrs):
1213
# Only use Starlark rules when they are removed from Bazel

bazel/private/BUILD

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -59,9 +59,9 @@ bzl_library(
5959
)
6060

6161
bzl_library(
62-
name = "bazel_java_proto_library_rule_bzl",
62+
name = "java_proto_library_bzl",
6363
srcs = [
64-
"bazel_java_proto_library_rule.bzl",
64+
"java_proto_library.bzl",
6565
"java_proto_support.bzl",
6666
],
6767
visibility = [
@@ -93,18 +93,13 @@ bzl_library(
9393
)
9494

9595
bzl_library(
96-
name = "bazel_cc_proto_library_bzl",
97-
srcs = [
98-
"bazel_cc_proto_library.bzl",
99-
"cc_proto_support.bzl",
100-
],
101-
visibility = ["//bazel:__subpackages__"],
96+
name = "cc_proto_support_bzl",
97+
srcs = ["cc_proto_support.bzl"],
98+
visibility = ["//bazel/private:__subpackages__"],
10299
deps = [
103-
":toolchain_helpers_bzl",
104-
"//bazel/common:proto_common_bzl",
105-
"//bazel/common:proto_info_bzl",
106100
"@proto_bazel_features//:features",
107101
"@rules_cc//cc:find_cc_toolchain_bzl",
102+
"@rules_cc//cc/common",
108103
],
109104
)
110105

@@ -145,8 +140,11 @@ bzl_library(
145140
bzl_library(
146141
name = "cc_proto_aspect_bzl",
147142
srcs = ["cc_proto_aspect.bzl"],
143+
visibility = [
144+
"//rust/bazel:__pkg__",
145+
],
148146
deps = [
149-
":bazel_cc_proto_library_bzl",
147+
"//bazel/private/oss:cc_proto_library_bzl",
150148
],
151149
)
152150

@@ -205,9 +203,11 @@ filegroup(
205203
testonly = True,
206204
srcs = [
207205
"BUILD",
206+
":java_proto_library_bzl",
208207
":native_bool_flag_bzl",
208+
":toolchain_helpers_bzl",
209209
"//bazel:for_bazel_tests",
210-
"//bazel/private/toolchains:for_bazel_tests",
210+
"//bazel/private/oss/toolchains:for_bazel_tests",
211211
],
212212
visibility = ["//visibility:public"],
213213
)

0 commit comments

Comments
 (0)