Skip to content

Commit 5404420

Browse files
mkruskal-googlecopybara-github
authored andcommitted
Make protoc use upb_generator stage1 (#21317)
Closes #21317 COPYBARA_INTEGRATE_REVIEW=#21317 from mkruskal-google:protoc_stage1 8106568 PiperOrigin-RevId: 748751321
1 parent 01b154c commit 5404420

File tree

4 files changed

+24
-8
lines changed

4 files changed

+24
-8
lines changed

BUILD.bazel

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,15 @@ cc_binary(
350350
copts = COPTS,
351351
linkopts = LINK_OPTS,
352352
visibility = ["//visibility:public"],
353-
deps = ["//src/google/protobuf/compiler:protoc_lib"],
353+
deps = ["//src/google/protobuf/compiler:protoc_lib_stage1"],
354+
)
355+
356+
cc_binary(
357+
name = "protoc_stage0",
358+
copts = COPTS,
359+
linkopts = LINK_OPTS,
360+
visibility = ["//:__subpackages__"],
361+
deps = ["//src/google/protobuf/compiler:protoc_lib_stage0"],
354362
)
355363

356364
cc_binary(
@@ -365,7 +373,7 @@ cc_binary(
365373
}),
366374
linkopts = LINK_OPTS,
367375
visibility = ["//visibility:public"],
368-
deps = ["//src/google/protobuf/compiler:protoc_lib"],
376+
deps = ["//src/google/protobuf/compiler:protoc_lib_stage1"],
369377
)
370378

371379
################################################################################

src/google/protobuf/compiler/BUILD.bazel

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ load("//bazel:upb_c_proto_library.bzl", "upb_c_proto_library")
1515
load("//bazel:upb_proto_reflection_library.bzl", "upb_proto_reflection_library")
1616
load("//build_defs:arch_tests.bzl", "aarch64_test", "x86_64_test")
1717
load("//build_defs:cpp_opts.bzl", "COPTS")
18+
load(
19+
"//upb_generator:bootstrap_compiler.bzl",
20+
"bootstrap_cc_library",
21+
)
1822
load("test_plugin_injection.bzl", "inject_plugin_paths")
1923

2024
proto_library(
@@ -213,13 +217,13 @@ cc_library(
213217
],
214218
)
215219

216-
cc_library(
220+
bootstrap_cc_library(
217221
name = "protoc_lib",
218222
srcs = [
219223
"main.cc",
220224
],
225+
bootstrap_deps = ["//upb_generator/minitable:generator"],
221226
copts = COPTS,
222-
strip_include_prefix = "/src",
223227
visibility = [
224228
"//:__pkg__",
225229
"//pkg:__pkg__",
@@ -239,7 +243,6 @@ cc_library(
239243
"//src/google/protobuf/compiler/python",
240244
"//src/google/protobuf/compiler/ruby",
241245
"//src/google/protobuf/compiler/rust",
242-
"//upb_generator/minitable:generator_stage0",
243246
"@abseil-cpp//absl/log:initialize",
244247
],
245248
)

upb_generator/bootstrap_compiler.bzl

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,10 @@ load(
1414
)
1515

1616
_stages = ["_stage0", "_stage1", ""]
17-
_protoc = "//:protoc"
1817

19-
_extra_proto_path = "-I$$(dirname $(location @com_google_protobuf//:descriptor_proto_srcs))/../.. "
18+
_protoc = "//:protoc_stage0"
19+
20+
_extra_proto_path = "-I$$(dirname $(location //:descriptor_proto_srcs))/../.. "
2021

2122
# This visibility is used automatically for anything used by the bootstrapping process.
2223
_bootstrap_visibility = [
@@ -26,6 +27,7 @@ _bootstrap_visibility = [
2627
"//upb/reflection:__pkg__",
2728
"//upb:__pkg__", # For the amalgamations.
2829
"//python/dist:__pkg__", # For the Python source package.
30+
"//:__pkg__", # For protoc
2931
]
3032

3133
def _stage_visibility(stage, visibility):

upb_generator/minitable/BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ bootstrap_cc_library(
3333
"//upb_generator:plugin",
3434
],
3535
copts = UPB_DEFAULT_CPPOPTS,
36-
visibility = ["//pkg:__pkg__"],
36+
visibility = [
37+
"//pkg:__pkg__",
38+
"//src/google/protobuf/compiler:__pkg__",
39+
],
3740
deps = [
3841
":names",
3942
":names_internal",

0 commit comments

Comments
 (0)