Moved reflection codegen to its own directory.

PiperOrigin-RevId: 666132886
pull/17909/head
Joshua Haberman 7 months ago committed by Copybara-Service
parent eca12ff466
commit a2fd240e0e
  1. 2
      bazel/upb_proto_reflection_library.bzl
  2. 2
      pkg/BUILD.bazel
  3. 2
      upb/reflection/BUILD
  4. 43
      upb_generator/BUILD
  5. 48
      upb_generator/reflection/BUILD
  6. 0
      upb_generator/reflection/generator.cc

@ -31,7 +31,7 @@ _upb_proto_reflection_library_aspect = aspect(
default = "//upb:upb_proto_library_copts__for_generated_code_only_do_not_use", default = "//upb:upb_proto_library_copts__for_generated_code_only_do_not_use",
), ),
"_upbdefs_toolchain": attr.label( "_upbdefs_toolchain": attr.label(
default = Label("//upb_generator:protoc-gen-upbdefs_toolchain"), default = Label("//upb_generator/reflection:toolchain"),
cfg = getattr(proto_common, "proto_lang_toolchain_cfg", "target"), cfg = getattr(proto_common, "proto_lang_toolchain_cfg", "target"),
), ),
"_cc_toolchain": attr.label( "_cc_toolchain": attr.label(

@ -243,7 +243,7 @@ cc_dist_library(
], ],
tags = ["manual"], tags = ["manual"],
deps = [ deps = [
"//upb_generator:protoc-gen-upbdefs_lib", "//upb_generator/reflection:generator_with_main",
], ],
) )

@ -40,7 +40,7 @@ bootstrap_upb_proto_library(
upb_proto_reflection_library( upb_proto_reflection_library(
name = "descriptor_upb_proto_reflection", name = "descriptor_upb_proto_reflection",
visibility = ["//visibility:public"], visibility = ["//upb:friends"],
deps = ["//:descriptor_proto"], deps = ["//:descriptor_proto"],
) )

@ -297,46 +297,3 @@ proto_lang_toolchain(
runtime = "//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", runtime = "//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
visibility = ["//visibility:public"], visibility = ["//visibility:public"],
) )
cc_binary(
name = "protoc-gen-upbdefs",
linkopts = ["-lm"],
visibility = ["//visibility:public"],
deps = [
":protoc-gen-upbdefs_lib",
],
)
# TODO: This wrapper lib is a hack that we need because of how CcInfo works in Bazel 6.
# In Bazel 7, our cmake dependency scraping works fine with cc_binary.
cc_library(
name = "protoc-gen-upbdefs_lib",
srcs = [
"protoc-gen-upbdefs.cc",
],
copts = UPB_DEFAULT_CPPOPTS,
visibility = ["//pkg:__pkg__"],
# To work around the following link error from ABSL:
# /usr/bin/x86_64-linux-gnu-ld: bazel-out/k8-opt-exec-2B5CBBC6-ST-c1776f9924ec/bin/external/com_google_absl/absl/time/libtime.a(duration.o): undefined reference to symbol 'floor@@GLIBC_2.2.5'
# /usr/bin/x86_64-linux-gnu-ld: /opt/manylinux/2014/x86_64/lib64/libm.so.6: error adding symbols: DSO missing from command line
# clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
deps = [
":common",
":file_layout",
":plugin",
"//src/google/protobuf:descriptor_upb_c_proto",
"//upb:reflection",
"//upb/util:def_to_proto",
],
)
proto_lang_toolchain(
name = "protoc-gen-upbdefs_toolchain",
command_line = "--upbdefs_out=$(OUT)",
output_files = "multiple",
plugin = ":protoc-gen-upbdefs",
plugin_format_flag = "--plugin=protoc-gen-upbdefs=%s",
progress_message = "Generating upb protos",
runtime = "//upb:generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
visibility = ["//visibility:public"],
)

@ -0,0 +1,48 @@
# Copyright (c) 2009-2024, Google LLC
# All rights reserved.
#
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file or at
# https://developers.google.com/open-source/licenses/bsd
load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_CPPOPTS")
cc_binary(
name = "protoc-gen-upbdefs",
linkopts = ["-lm"],
visibility = ["//net/proto2/contrib/protoc_explorer:__pkg__"],
deps = [":generator_with_main"],
)
# TODO: This wrapper lib is a hack that we need because of how CcInfo works in Bazel 6.
# In Bazel 7, our cmake dependency scraping works fine with cc_binary.
cc_library(
name = "generator_with_main",
srcs = ["generator.cc"],
copts = UPB_DEFAULT_CPPOPTS,
visibility = ["//pkg:__pkg__"],
# To work around the following link error from ABSL:
# /usr/bin/x86_64-linux-gnu-ld: bazel-out/k8-opt-exec-2B5CBBC6-ST-c1776f9924ec/bin/external/com_google_absl/absl/time/libtime.a(duration.o): undefined reference to symbol 'floor@@GLIBC_2.2.5'
# /usr/bin/x86_64-linux-gnu-ld: /opt/manylinux/2014/x86_64/lib64/libm.so.6: error adding symbols: DSO missing from command line
# clang-14: error: linker command failed with exit code 1 (use -v to see invocation)
deps = [
"//src/google/protobuf:descriptor_upb_c_proto",
"//upb:reflection",
"//upb/util:def_to_proto",
"//upb_generator:common",
"//upb_generator:file_layout",
"//upb_generator:plugin",
],
)
proto_lang_toolchain(
name = "toolchain",
command_line = "--upbdefs_out=$(OUT)",
output_files = "multiple",
plugin = ":protoc-gen-upbdefs",
plugin_format_flag = "--plugin=protoc-gen-upbdefs=%s",
progress_message = "Generating upb protos",
runtime = "//upb:generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
# TODO: Restrict to "//bazel:__pkg__" once we are on Bazel >=6.5.
visibility = ["//visibility:public"],
)
Loading…
Cancel
Save