Automated rollback of commit 694d7935747a5b4eac351b757ad8ff22599c8077.
[google-protobuf.git] / upb_generator / minitable / BUILD
blob83e75b0d7d7c27d2c52bdcc5c4d233943fd8dbed
1 # Copyright (c) 2009-2024, Google LLC
2 # All rights reserved.
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
8 load("//bazel/toolchains:proto_lang_toolchain.bzl", "proto_lang_toolchain")
9 load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_CPPOPTS")
10 load(
11     "//upb_generator:bootstrap_compiler.bzl",
12     "bootstrap_cc_binary",
13     "bootstrap_cc_library",
16 package(default_applicable_licenses = ["//:license"])
18 licenses(["notice"])
20 bootstrap_cc_library(
21     name = "generator",
22     srcs = [
23         "fasttable.cc",
24         "fasttable.h",
25         "generator.cc",
26     ],
27     hdrs = ["generator.h"],
28     bootstrap_deps = [
29         "//upb_generator:common",
30         "//upb_generator:file_layout",
31         "//upb_generator:plugin",
32         "//upb_generator:plugin_upb_proto",
33         "//upb/reflection:descriptor_upb_proto",
34         "//upb/reflection:reflection",
35     ],
36     copts = UPB_DEFAULT_CPPOPTS,
37     deps = [
38         ":names",
39         ":names_internal",
40         "//src/google/protobuf/compiler:code_generator_lite",
41         "//upb:base",
42         "//upb:mem",
43         "//upb:mini_table",
44         "//upb:port",
45         "//upb:wire_reader",
46         "//upb/mini_table:internal",
47         "//upb_generator/common:names",
48         "@com_google_absl//absl/container:flat_hash_map",
49         "@com_google_absl//absl/container:flat_hash_set",
50         "@com_google_absl//absl/log:absl_check",
51         "@com_google_absl//absl/log:absl_log",
52         "@com_google_absl//absl/strings",
53     ],
56 cc_library(
57     name = "names",
58     srcs = ["names.cc"],
59     hdrs = ["names.h"],
60     visibility = [
61         "//src/google/protobuf/compiler/hpb:__pkg__",
62         "//src/google/protobuf/compiler/rust:__pkg__",
63         "//third_party/kotlin/protobuf/generator/native:__pkg__",
64         "//upb_generator:__subpackages__",
65     ],
66     deps = [
67         ":names_internal",
68         "//upb:port",
69         "@com_google_absl//absl/strings",
70     ],
73 cc_library(
74     name = "names_internal",
75     srcs = ["names_internal.cc"],
76     hdrs = ["names_internal.h"],
77     visibility = [
78         # For bootstrapping.
79         "//upb_generator/c:__pkg__",
80     ],
81     deps = [
82         "//upb_generator/common:names",
83         "@com_google_absl//absl/strings",
84     ],
87 bootstrap_cc_binary(
88     name = "protoc-gen-upb_minitable",
89     bootstrap_deps = [
90         ":generator_with_main",
91     ],
92     copts = UPB_DEFAULT_CPPOPTS,
93     visibility = [
94         "//editions/codegen_tests:__pkg__",
95         "//net/proto2/contrib/protoc_explorer:__pkg__",
96         "//rust:__subpackages__",
97         "//third_party/prototiller/transformer:__pkg__",
98     ],
101 # TODO: This wrapper lib is a hack that we need because of how CcInfo works in Bazel 6.
102 # In Bazel 7, our cmake dependency scraping works fine with cc_binary.
103 bootstrap_cc_library(
104     name = "generator_with_main",
105     srcs = ["main.cc"],
106     bootstrap_deps = [
107         ":generator",
108         "//upb_generator:file_layout",
109         "//upb_generator:common",
110         "//upb_generator:plugin",
111         "//upb/reflection:reflection",
112     ],
113     copts = UPB_DEFAULT_CPPOPTS,
114     visibility = ["//pkg:__pkg__"],
115     deps = [
116         ":names",
117         ":names_internal",
118         "//src/google/protobuf/compiler:code_generator_lite",
119         "//upb:base",
120         "//upb:port",
121         "//upb_generator/common:names",
122         "@com_google_absl//absl/log:absl_check",
123         "@com_google_absl//absl/log:absl_log",
124         "@com_google_absl//absl/strings",
125     ],
128 proto_lang_toolchain(
129     name = "toolchain",
130     command_line = "--upb_minitable_out=$(OUT)",
131     output_files = "multiple",
132     plugin = ":protoc-gen-upb_minitable_stage1",
133     plugin_format_flag = "--plugin=protoc-gen-upb_minitable=%s",
134     progress_message = "Generating upb minitables",
135     runtime = "//upb:generated_code_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me",
136     # TODO: Restrict to "//bazel:__pkg__" once we are on Bazel >=6.5.
137     visibility = ["//visibility:public"],