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 8load("//bazel:upb_minitable_proto_library.bzl", "upb_minitable_proto_library") 9load("//bazel:upb_proto_library.bzl", "upb_proto_reflection_library") 10load( 11 "//editions:defaults.bzl", 12 "compile_edition_defaults", 13 "embed_edition_defaults", 14) 15load("//upb/bazel:build_defs.bzl", "UPB_DEFAULT_COPTS") 16load( 17 "//upb/cmake:build_defs.bzl", 18 "staleness_test", 19) 20load( 21 "//upb_generator:bootstrap_compiler.bzl", 22 "bootstrap_cc_library", 23 "bootstrap_upb_proto_library", 24) 25 26package(default_applicable_licenses = ["//:license"]) 27 28bootstrap_upb_proto_library( 29 name = "descriptor_upb_proto", 30 bootstrap_hdr = "descriptor_bootstrap.h", 31 google3_src_files = ["net/proto2/proto/descriptor.proto"], 32 google3_src_rules = ["//net/proto2/proto:descriptor_proto_source"], 33 oss_src_files = ["google/protobuf/descriptor.proto"], 34 oss_src_rules = ["//:descriptor_proto_srcs"], 35 oss_strip_prefix = "third_party/protobuf/github/bootstrap/src", 36 proto_lib_deps = ["//:descriptor_proto"], 37) 38 39upb_proto_reflection_library( 40 name = "descriptor_upb_proto_reflection", 41 visibility = ["//upb:friends"], 42 deps = ["//:descriptor_proto"], 43) 44 45upb_minitable_proto_library( 46 name = "descriptor_upb_minitable_proto", 47 visibility = ["//visibility:public"], 48 deps = ["//:descriptor_proto"], 49) 50 51bootstrap_cc_library( 52 name = "reflection", 53 hdrs = [ 54 "def.h", 55 "def.hpp", 56 "message.h", 57 "message.hpp", 58 ], 59 bootstrap_deps = [":internal"], 60 copts = UPB_DEFAULT_COPTS, 61 visibility = ["//visibility:public"], 62 deps = [ 63 "//upb:base", 64 "//upb:mem", 65 "//upb:message", 66 "//upb:mini_descriptor", 67 "//upb:mini_table", 68 "//upb:port", 69 "//upb/message:internal", 70 ], 71) 72 73bootstrap_cc_library( 74 name = "internal", 75 srcs = [ 76 "def_pool.c", 77 "def_type.c", 78 "desc_state.c", 79 "enum_def.c", 80 "enum_reserved_range.c", 81 "enum_value_def.c", 82 "extension_range.c", 83 "field_def.c", 84 "file_def.c", 85 "internal/def_builder.c", 86 "internal/def_builder.h", 87 "internal/strdup2.c", 88 "internal/strdup2.h", 89 "message.c", 90 "message_def.c", 91 "message_reserved_range.c", 92 "method_def.c", 93 "oneof_def.c", 94 "service_def.c", 95 ], 96 hdrs = [ 97 "common.h", 98 "def.h", 99 "def.hpp", 100 "def_pool.h", 101 "def_type.h", 102 "enum_def.h", 103 "enum_reserved_range.h", 104 "enum_value_def.h", 105 "extension_range.h", 106 "field_def.h", 107 "file_def.h", 108 "internal/def_pool.h", 109 "internal/desc_state.h", 110 "internal/enum_def.h", 111 "internal/enum_reserved_range.h", 112 "internal/enum_value_def.h", 113 "internal/extension_range.h", 114 "internal/field_def.h", 115 "internal/file_def.h", 116 "internal/message_def.h", 117 "internal/message_reserved_range.h", 118 "internal/method_def.h", 119 "internal/oneof_def.h", 120 "internal/service_def.h", 121 "internal/upb_edition_defaults.h", 122 "message.h", 123 "message.hpp", 124 "message_def.h", 125 "message_reserved_range.h", 126 "method_def.h", 127 "oneof_def.h", 128 "service_def.h", 129 ], 130 bootstrap_deps = [":descriptor_upb_proto"], 131 copts = UPB_DEFAULT_COPTS, 132 visibility = ["//visibility:public"], 133 deps = [ 134 "//upb:base", 135 "//upb:mem", 136 "//upb:message", 137 "//upb:message_copy", 138 "//upb:mini_descriptor", 139 "//upb:mini_table", 140 "//upb:port", 141 "//upb:wire", 142 "//upb/base:internal", 143 "//upb/hash", 144 "//upb/message:internal", 145 "//upb/mini_descriptor:internal", 146 "//upb/mini_table:internal", 147 ], 148) 149 150cc_library( 151 name = "generated_reflection_support__only_for_generated_code_do_not_use__i_give_permission_to_break_me", 152 hdrs = [ 153 "def.h", 154 "internal/def_pool.h", 155 ], 156 copts = UPB_DEFAULT_COPTS, 157 textual_hdrs = [ 158 "//upb:port_inc", 159 ], 160 visibility = ["//visibility:public"], 161 deps = [ 162 ":internal", 163 "//upb:mem", 164 "//upb:mini_descriptor", 165 ], 166) 167 168cc_test( 169 name = "def_builder_test", 170 srcs = [ 171 "common.h", 172 "def_type.h", 173 "internal/def_builder.h", 174 "internal/def_builder_test.cc", 175 ], 176 deps = [ 177 ":descriptor_upb_proto", 178 ":internal", 179 "//upb:base", 180 "//upb:mem", 181 "//upb:port", 182 "//upb:reflection", 183 "//upb/hash", 184 "@com_google_absl//absl/strings", 185 "@com_google_googletest//:gtest", 186 "@com_google_googletest//:gtest_main", 187 ], 188) 189 190compile_edition_defaults( 191 name = "upb_edition_defaults", 192 srcs = [ 193 "//:descriptor_proto", 194 ], 195 maximum_edition = "2023", 196 minimum_edition = "PROTO2", 197) 198 199embed_edition_defaults( 200 name = "embedded_upb_edition_defaults_generate", 201 defaults = "upb_edition_defaults", 202 output = "generated/internal/upb_edition_defaults.h", 203 placeholder = "DEFAULTS_VALUE", 204 template = "internal/upb_edition_defaults.h.template", 205) 206 207staleness_test( 208 name = "bootstrap_upb_defaults_staleness_test", 209 outs = ["internal/upb_edition_defaults.h"], 210 generated_pattern = "generated/%s", 211 tags = ["manual"], 212 target_files = ["internal/upb_edition_defaults.h"], 213) 214 215filegroup( 216 name = "source_files", 217 srcs = glob( 218 [ 219 "**/*.c", 220 "**/*.h", 221 "**/*.hpp", 222 ], 223 exclude = [ 224 "stage0/**", 225 "cmake/**", 226 ], 227 ), 228 visibility = [ 229 "//python/dist:__pkg__", 230 "//upb/cmake:__pkg__", 231 ], 232) 233