Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 1 | # Bazel (http://bazel.io/) BUILD file for Protobuf. |
| 2 | |
| 3 | licenses(["notice"]) |
| 4 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 5 | exports_files(["LICENSE"]) |
| 6 | |
| 7 | ################################################################################ |
| 8 | # Java 9 configuration |
| 9 | ################################################################################ |
| 10 | |
| 11 | config_setting( |
| 12 | name = "jdk9", |
| 13 | values = { |
| 14 | "java_toolchain": "@bazel_tools//tools/jdk:toolchain_jdk9", |
| 15 | }, |
| 16 | ) |
Brian Silverman | 3fca9d7 | 2016-02-20 02:32:51 -0500 | [diff] [blame] | 17 | |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 18 | ################################################################################ |
| 19 | # Protobuf Runtime Library |
| 20 | ################################################################################ |
| 21 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 22 | config_setting( |
| 23 | name = "msvc", |
| 24 | values = {"compiler": "msvc-cl"}, |
| 25 | visibility = ["//visibility:public"], |
| 26 | ) |
| 27 | |
| 28 | config_setting( |
| 29 | name = "android", |
| 30 | values = { |
| 31 | "crosstool_top": "//external:android/crosstool", |
| 32 | }, |
| 33 | ) |
| 34 | |
| 35 | # Android and MSVC builds do not need to link in a separate pthread library. |
| 36 | LINK_OPTS = select({ |
| 37 | ":android": [], |
| 38 | ":msvc": [], |
| 39 | "//conditions:default": [ |
| 40 | "-lpthread", |
| 41 | "-lm", |
Brian Silverman | 3fca9d7 | 2016-02-20 02:32:51 -0500 | [diff] [blame] | 42 | ], |
| 43 | }) |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 44 | |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 45 | load( |
Austin Schuh | 4f85729 | 2018-02-15 23:42:04 -0800 | [diff] [blame] | 46 | ":protobuf.bzl", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 47 | "cc_proto_library", |
| 48 | "py_proto_library", |
| 49 | "internal_copied_filegroup", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 50 | "internal_gen_well_known_protos_java", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 51 | "internal_protobuf_py_tests", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 52 | "COPTS", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 53 | ) |
| 54 | |
| 55 | cc_library( |
| 56 | name = "protobuf_lite", |
| 57 | srcs = [ |
| 58 | # AUTOGEN(protobuf_lite_srcs) |
| 59 | "src/google/protobuf/arena.cc", |
| 60 | "src/google/protobuf/arenastring.cc", |
| 61 | "src/google/protobuf/extension_set.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 62 | "src/google/protobuf/generated_message_table_driven_lite.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 63 | "src/google/protobuf/generated_message_util.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 64 | "src/google/protobuf/implicit_weak_message.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 65 | "src/google/protobuf/io/coded_stream.cc", |
| 66 | "src/google/protobuf/io/zero_copy_stream.cc", |
| 67 | "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", |
| 68 | "src/google/protobuf/message_lite.cc", |
| 69 | "src/google/protobuf/repeated_field.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 70 | "src/google/protobuf/stubs/bytestream.cc", |
| 71 | "src/google/protobuf/stubs/common.cc", |
| 72 | "src/google/protobuf/stubs/int128.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 73 | "src/google/protobuf/stubs/io_win32.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 74 | "src/google/protobuf/stubs/status.cc", |
| 75 | "src/google/protobuf/stubs/statusor.cc", |
| 76 | "src/google/protobuf/stubs/stringpiece.cc", |
| 77 | "src/google/protobuf/stubs/stringprintf.cc", |
| 78 | "src/google/protobuf/stubs/structurally_valid.cc", |
| 79 | "src/google/protobuf/stubs/strutil.cc", |
| 80 | "src/google/protobuf/stubs/time.cc", |
| 81 | "src/google/protobuf/wire_format_lite.cc", |
| 82 | ], |
| 83 | hdrs = glob(["src/google/protobuf/**/*.h"]), |
Brian Silverman | 7a7c24d | 2018-09-01 17:49:09 -0700 | [diff] [blame] | 84 | compatible_with = [ |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 85 | "@//tools:armhf-debian", |
Brian Silverman | 7a7c24d | 2018-09-01 17:49:09 -0700 | [diff] [blame] | 86 | ], |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 87 | copts = COPTS, |
| 88 | includes = ["src/"], |
| 89 | linkopts = LINK_OPTS, |
| 90 | visibility = ["//visibility:public"], |
| 91 | ) |
| 92 | |
| 93 | cc_library( |
| 94 | name = "protobuf", |
| 95 | srcs = [ |
| 96 | # AUTOGEN(protobuf_srcs) |
| 97 | "src/google/protobuf/any.cc", |
| 98 | "src/google/protobuf/any.pb.cc", |
| 99 | "src/google/protobuf/api.pb.cc", |
| 100 | "src/google/protobuf/compiler/importer.cc", |
| 101 | "src/google/protobuf/compiler/parser.cc", |
| 102 | "src/google/protobuf/descriptor.cc", |
| 103 | "src/google/protobuf/descriptor.pb.cc", |
| 104 | "src/google/protobuf/descriptor_database.cc", |
| 105 | "src/google/protobuf/duration.pb.cc", |
| 106 | "src/google/protobuf/dynamic_message.cc", |
| 107 | "src/google/protobuf/empty.pb.cc", |
| 108 | "src/google/protobuf/extension_set_heavy.cc", |
| 109 | "src/google/protobuf/field_mask.pb.cc", |
| 110 | "src/google/protobuf/generated_message_reflection.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 111 | "src/google/protobuf/generated_message_table_driven.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 112 | "src/google/protobuf/io/gzip_stream.cc", |
| 113 | "src/google/protobuf/io/printer.cc", |
| 114 | "src/google/protobuf/io/strtod.cc", |
| 115 | "src/google/protobuf/io/tokenizer.cc", |
| 116 | "src/google/protobuf/io/zero_copy_stream_impl.cc", |
| 117 | "src/google/protobuf/map_field.cc", |
| 118 | "src/google/protobuf/message.cc", |
| 119 | "src/google/protobuf/reflection_ops.cc", |
| 120 | "src/google/protobuf/service.cc", |
| 121 | "src/google/protobuf/source_context.pb.cc", |
| 122 | "src/google/protobuf/struct.pb.cc", |
| 123 | "src/google/protobuf/stubs/mathlimits.cc", |
| 124 | "src/google/protobuf/stubs/substitute.cc", |
| 125 | "src/google/protobuf/text_format.cc", |
| 126 | "src/google/protobuf/timestamp.pb.cc", |
| 127 | "src/google/protobuf/type.pb.cc", |
| 128 | "src/google/protobuf/unknown_field_set.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 129 | "src/google/protobuf/util/delimited_message_util.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 130 | "src/google/protobuf/util/field_comparator.cc", |
| 131 | "src/google/protobuf/util/field_mask_util.cc", |
| 132 | "src/google/protobuf/util/internal/datapiece.cc", |
| 133 | "src/google/protobuf/util/internal/default_value_objectwriter.cc", |
| 134 | "src/google/protobuf/util/internal/error_listener.cc", |
| 135 | "src/google/protobuf/util/internal/field_mask_utility.cc", |
| 136 | "src/google/protobuf/util/internal/json_escaping.cc", |
| 137 | "src/google/protobuf/util/internal/json_objectwriter.cc", |
| 138 | "src/google/protobuf/util/internal/json_stream_parser.cc", |
| 139 | "src/google/protobuf/util/internal/object_writer.cc", |
| 140 | "src/google/protobuf/util/internal/proto_writer.cc", |
| 141 | "src/google/protobuf/util/internal/protostream_objectsource.cc", |
| 142 | "src/google/protobuf/util/internal/protostream_objectwriter.cc", |
| 143 | "src/google/protobuf/util/internal/type_info.cc", |
| 144 | "src/google/protobuf/util/internal/type_info_test_helper.cc", |
| 145 | "src/google/protobuf/util/internal/utility.cc", |
| 146 | "src/google/protobuf/util/json_util.cc", |
| 147 | "src/google/protobuf/util/message_differencer.cc", |
| 148 | "src/google/protobuf/util/time_util.cc", |
| 149 | "src/google/protobuf/util/type_resolver_util.cc", |
| 150 | "src/google/protobuf/wire_format.cc", |
| 151 | "src/google/protobuf/wrappers.pb.cc", |
| 152 | ], |
| 153 | hdrs = glob(["src/**/*.h"]), |
Brian Silverman | 7a7c24d | 2018-09-01 17:49:09 -0700 | [diff] [blame] | 154 | compatible_with = [ |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 155 | "@//tools:armhf-debian", |
Brian Silverman | 7a7c24d | 2018-09-01 17:49:09 -0700 | [diff] [blame] | 156 | ], |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 157 | copts = COPTS, |
| 158 | includes = ["src/"], |
| 159 | linkopts = LINK_OPTS, |
| 160 | visibility = ["//visibility:public"], |
| 161 | deps = [":protobuf_lite"], |
| 162 | ) |
| 163 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 164 | # This provides just the header files for use in projects that need to build |
| 165 | # shared libraries for dynamic loading. This target is available until Bazel |
| 166 | # adds native support for such use cases. |
| 167 | # TODO(keveman): Remove this target once the support gets added to Bazel. |
| 168 | cc_library( |
| 169 | name = "protobuf_headers", |
| 170 | hdrs = glob(["src/**/*.h"]), |
| 171 | includes = ["src/"], |
| 172 | visibility = ["//visibility:public"], |
| 173 | ) |
| 174 | |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 175 | objc_library( |
| 176 | name = "protobuf_objc", |
| 177 | hdrs = ["objectivec/GPBProtocolBuffers.h"], |
| 178 | includes = ["objectivec"], |
| 179 | non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"], |
| 180 | visibility = ["//visibility:public"], |
| 181 | ) |
| 182 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 183 | # Map of all well known protos. |
| 184 | # name => (include path, imports) |
| 185 | WELL_KNOWN_PROTO_MAP = { |
| 186 | "any": ("google/protobuf/any.proto", []), |
| 187 | "api": ( |
| 188 | "google/protobuf/api.proto", |
| 189 | [ |
| 190 | "source_context", |
| 191 | "type", |
| 192 | ], |
| 193 | ), |
| 194 | "compiler_plugin": ( |
| 195 | "google/protobuf/compiler/plugin.proto", |
| 196 | ["descriptor"], |
| 197 | ), |
| 198 | "descriptor": ("google/protobuf/descriptor.proto", []), |
| 199 | "duration": ("google/protobuf/duration.proto", []), |
| 200 | "empty": ("google/protobuf/empty.proto", []), |
| 201 | "field_mask": ("google/protobuf/field_mask.proto", []), |
| 202 | "source_context": ("google/protobuf/source_context.proto", []), |
| 203 | "struct": ("google/protobuf/struct.proto", []), |
| 204 | "timestamp": ("google/protobuf/timestamp.proto", []), |
| 205 | "type": ( |
| 206 | "google/protobuf/type.proto", |
| 207 | [ |
| 208 | "any", |
| 209 | "source_context", |
| 210 | ], |
| 211 | ), |
| 212 | "wrappers": ("google/protobuf/wrappers.proto", []), |
| 213 | } |
| 214 | |
| 215 | RELATIVE_WELL_KNOWN_PROTOS = [proto[1][0] for proto in WELL_KNOWN_PROTO_MAP.items()] |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 216 | |
| 217 | WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] |
| 218 | |
Brian Silverman | eb16fa4 | 2016-02-20 15:29:56 -0500 | [diff] [blame] | 219 | filegroup( |
| 220 | name = "well_known_protos", |
| 221 | srcs = WELL_KNOWN_PROTOS, |
| 222 | visibility = ["//visibility:public"], |
| 223 | ) |
| 224 | |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 225 | cc_proto_library( |
| 226 | name = "cc_wkt_protos", |
| 227 | srcs = WELL_KNOWN_PROTOS, |
| 228 | include = "src", |
| 229 | default_runtime = ":protobuf", |
| 230 | internal_bootstrap_hack = 1, |
| 231 | protoc = ":protoc", |
| 232 | visibility = ["//visibility:public"], |
| 233 | ) |
| 234 | |
| 235 | ################################################################################ |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 236 | # Well Known Types Proto Library Rules |
| 237 | # |
| 238 | # These proto_library rules can be used with one of the language specific proto |
| 239 | # library rules i.e. java_proto_library: |
| 240 | # |
| 241 | # java_proto_library( |
| 242 | # name = "any_java_proto", |
| 243 | # deps = ["@com_google_protobuf//:any_proto], |
| 244 | # ) |
| 245 | ################################################################################ |
| 246 | |
| 247 | internal_copied_filegroup( |
| 248 | name = "_internal_wkt_protos", |
| 249 | srcs = WELL_KNOWN_PROTOS, |
| 250 | dest = "", |
| 251 | strip_prefix = "src", |
| 252 | visibility = ["//visibility:private"], |
| 253 | ) |
| 254 | |
| 255 | [proto_library( |
| 256 | name = proto[0] + "_proto", |
| 257 | srcs = [proto[1][0]], |
| 258 | visibility = ["//visibility:public"], |
| 259 | deps = [dep + "_proto" for dep in proto[1][1]], |
| 260 | ) for proto in WELL_KNOWN_PROTO_MAP.items()] |
| 261 | |
| 262 | ################################################################################ |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 263 | # Protocol Buffers Compiler |
| 264 | ################################################################################ |
| 265 | |
| 266 | cc_library( |
| 267 | name = "protoc_lib", |
| 268 | srcs = [ |
| 269 | # AUTOGEN(protoc_lib_srcs) |
| 270 | "src/google/protobuf/compiler/code_generator.cc", |
| 271 | "src/google/protobuf/compiler/command_line_interface.cc", |
| 272 | "src/google/protobuf/compiler/cpp/cpp_enum.cc", |
| 273 | "src/google/protobuf/compiler/cpp/cpp_enum_field.cc", |
| 274 | "src/google/protobuf/compiler/cpp/cpp_extension.cc", |
| 275 | "src/google/protobuf/compiler/cpp/cpp_field.cc", |
| 276 | "src/google/protobuf/compiler/cpp/cpp_file.cc", |
| 277 | "src/google/protobuf/compiler/cpp/cpp_generator.cc", |
| 278 | "src/google/protobuf/compiler/cpp/cpp_helpers.cc", |
| 279 | "src/google/protobuf/compiler/cpp/cpp_map_field.cc", |
| 280 | "src/google/protobuf/compiler/cpp/cpp_message.cc", |
| 281 | "src/google/protobuf/compiler/cpp/cpp_message_field.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 282 | "src/google/protobuf/compiler/cpp/cpp_padding_optimizer.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 283 | "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", |
| 284 | "src/google/protobuf/compiler/cpp/cpp_service.cc", |
| 285 | "src/google/protobuf/compiler/cpp/cpp_string_field.cc", |
| 286 | "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc", |
| 287 | "src/google/protobuf/compiler/csharp/csharp_enum.cc", |
| 288 | "src/google/protobuf/compiler/csharp/csharp_enum_field.cc", |
| 289 | "src/google/protobuf/compiler/csharp/csharp_field_base.cc", |
| 290 | "src/google/protobuf/compiler/csharp/csharp_generator.cc", |
| 291 | "src/google/protobuf/compiler/csharp/csharp_helpers.cc", |
| 292 | "src/google/protobuf/compiler/csharp/csharp_map_field.cc", |
| 293 | "src/google/protobuf/compiler/csharp/csharp_message.cc", |
| 294 | "src/google/protobuf/compiler/csharp/csharp_message_field.cc", |
| 295 | "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc", |
| 296 | "src/google/protobuf/compiler/csharp/csharp_reflection_class.cc", |
| 297 | "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc", |
| 298 | "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc", |
| 299 | "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc", |
| 300 | "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", |
| 301 | "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc", |
| 302 | "src/google/protobuf/compiler/java/java_context.cc", |
| 303 | "src/google/protobuf/compiler/java/java_doc_comment.cc", |
| 304 | "src/google/protobuf/compiler/java/java_enum.cc", |
| 305 | "src/google/protobuf/compiler/java/java_enum_field.cc", |
| 306 | "src/google/protobuf/compiler/java/java_enum_field_lite.cc", |
| 307 | "src/google/protobuf/compiler/java/java_enum_lite.cc", |
| 308 | "src/google/protobuf/compiler/java/java_extension.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 309 | "src/google/protobuf/compiler/java/java_extension_lite.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 310 | "src/google/protobuf/compiler/java/java_field.cc", |
| 311 | "src/google/protobuf/compiler/java/java_file.cc", |
| 312 | "src/google/protobuf/compiler/java/java_generator.cc", |
| 313 | "src/google/protobuf/compiler/java/java_generator_factory.cc", |
| 314 | "src/google/protobuf/compiler/java/java_helpers.cc", |
| 315 | "src/google/protobuf/compiler/java/java_lazy_message_field.cc", |
| 316 | "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", |
| 317 | "src/google/protobuf/compiler/java/java_map_field.cc", |
| 318 | "src/google/protobuf/compiler/java/java_map_field_lite.cc", |
| 319 | "src/google/protobuf/compiler/java/java_message.cc", |
| 320 | "src/google/protobuf/compiler/java/java_message_builder.cc", |
| 321 | "src/google/protobuf/compiler/java/java_message_builder_lite.cc", |
| 322 | "src/google/protobuf/compiler/java/java_message_field.cc", |
| 323 | "src/google/protobuf/compiler/java/java_message_field_lite.cc", |
| 324 | "src/google/protobuf/compiler/java/java_message_lite.cc", |
| 325 | "src/google/protobuf/compiler/java/java_name_resolver.cc", |
| 326 | "src/google/protobuf/compiler/java/java_primitive_field.cc", |
| 327 | "src/google/protobuf/compiler/java/java_primitive_field_lite.cc", |
| 328 | "src/google/protobuf/compiler/java/java_service.cc", |
| 329 | "src/google/protobuf/compiler/java/java_shared_code_generator.cc", |
| 330 | "src/google/protobuf/compiler/java/java_string_field.cc", |
| 331 | "src/google/protobuf/compiler/java/java_string_field_lite.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 332 | "src/google/protobuf/compiler/js/js_generator.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 333 | "src/google/protobuf/compiler/js/well_known_types_embed.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 334 | "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", |
| 335 | "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", |
| 336 | "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", |
| 337 | "src/google/protobuf/compiler/objectivec/objectivec_field.cc", |
| 338 | "src/google/protobuf/compiler/objectivec/objectivec_file.cc", |
| 339 | "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", |
| 340 | "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", |
| 341 | "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", |
| 342 | "src/google/protobuf/compiler/objectivec/objectivec_message.cc", |
| 343 | "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", |
| 344 | "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", |
| 345 | "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 346 | "src/google/protobuf/compiler/php/php_generator.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 347 | "src/google/protobuf/compiler/plugin.cc", |
| 348 | "src/google/protobuf/compiler/plugin.pb.cc", |
| 349 | "src/google/protobuf/compiler/python/python_generator.cc", |
| 350 | "src/google/protobuf/compiler/ruby/ruby_generator.cc", |
| 351 | "src/google/protobuf/compiler/subprocess.cc", |
| 352 | "src/google/protobuf/compiler/zip_writer.cc", |
| 353 | ], |
| 354 | copts = COPTS, |
| 355 | includes = ["src/"], |
| 356 | linkopts = LINK_OPTS, |
| 357 | visibility = ["//visibility:public"], |
| 358 | deps = [":protobuf"], |
| 359 | ) |
| 360 | |
| 361 | cc_binary( |
| 362 | name = "protoc", |
| 363 | srcs = ["src/google/protobuf/compiler/main.cc"], |
| 364 | linkopts = LINK_OPTS, |
| 365 | visibility = ["//visibility:public"], |
| 366 | deps = [":protoc_lib"], |
| 367 | ) |
| 368 | |
| 369 | ################################################################################ |
| 370 | # Tests |
| 371 | ################################################################################ |
| 372 | |
| 373 | RELATIVE_LITE_TEST_PROTOS = [ |
| 374 | # AUTOGEN(lite_test_protos) |
| 375 | "google/protobuf/map_lite_unittest.proto", |
| 376 | "google/protobuf/unittest_import_lite.proto", |
| 377 | "google/protobuf/unittest_import_public_lite.proto", |
| 378 | "google/protobuf/unittest_lite.proto", |
| 379 | "google/protobuf/unittest_no_arena_lite.proto", |
| 380 | ] |
| 381 | |
| 382 | LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS] |
| 383 | |
| 384 | RELATIVE_TEST_PROTOS = [ |
| 385 | # AUTOGEN(test_protos) |
| 386 | "google/protobuf/any_test.proto", |
| 387 | "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto", |
| 388 | "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto", |
| 389 | "google/protobuf/map_proto2_unittest.proto", |
| 390 | "google/protobuf/map_unittest.proto", |
| 391 | "google/protobuf/unittest.proto", |
| 392 | "google/protobuf/unittest_arena.proto", |
| 393 | "google/protobuf/unittest_custom_options.proto", |
| 394 | "google/protobuf/unittest_drop_unknown_fields.proto", |
| 395 | "google/protobuf/unittest_embed_optimize_for.proto", |
| 396 | "google/protobuf/unittest_empty.proto", |
| 397 | "google/protobuf/unittest_enormous_descriptor.proto", |
| 398 | "google/protobuf/unittest_import.proto", |
| 399 | "google/protobuf/unittest_import_public.proto", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 400 | "google/protobuf/unittest_lazy_dependencies.proto", |
| 401 | "google/protobuf/unittest_lazy_dependencies_custom_option.proto", |
| 402 | "google/protobuf/unittest_lazy_dependencies_enum.proto", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 403 | "google/protobuf/unittest_lite_imports_nonlite.proto", |
| 404 | "google/protobuf/unittest_mset.proto", |
| 405 | "google/protobuf/unittest_mset_wire_format.proto", |
| 406 | "google/protobuf/unittest_no_arena.proto", |
| 407 | "google/protobuf/unittest_no_arena_import.proto", |
| 408 | "google/protobuf/unittest_no_field_presence.proto", |
| 409 | "google/protobuf/unittest_no_generic_services.proto", |
| 410 | "google/protobuf/unittest_optimize_for.proto", |
| 411 | "google/protobuf/unittest_preserve_unknown_enum.proto", |
| 412 | "google/protobuf/unittest_preserve_unknown_enum2.proto", |
| 413 | "google/protobuf/unittest_proto3_arena.proto", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 414 | "google/protobuf/unittest_proto3_arena_lite.proto", |
| 415 | "google/protobuf/unittest_proto3_lite.proto", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 416 | "google/protobuf/unittest_well_known_types.proto", |
| 417 | "google/protobuf/util/internal/testdata/anys.proto", |
| 418 | "google/protobuf/util/internal/testdata/books.proto", |
| 419 | "google/protobuf/util/internal/testdata/default_value.proto", |
| 420 | "google/protobuf/util/internal/testdata/default_value_test.proto", |
| 421 | "google/protobuf/util/internal/testdata/field_mask.proto", |
| 422 | "google/protobuf/util/internal/testdata/maps.proto", |
| 423 | "google/protobuf/util/internal/testdata/oneofs.proto", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 424 | "google/protobuf/util/internal/testdata/proto3.proto", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 425 | "google/protobuf/util/internal/testdata/struct.proto", |
| 426 | "google/protobuf/util/internal/testdata/timestamp_duration.proto", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 427 | "google/protobuf/util/internal/testdata/wrappers.proto", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 428 | "google/protobuf/util/json_format_proto3.proto", |
| 429 | "google/protobuf/util/message_differencer_unittest.proto", |
| 430 | ] |
| 431 | |
| 432 | TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] |
| 433 | |
| 434 | cc_proto_library( |
| 435 | name = "cc_test_protos", |
| 436 | srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
| 437 | include = "src", |
| 438 | default_runtime = ":protobuf", |
| 439 | protoc = ":protoc", |
| 440 | deps = [":cc_wkt_protos"], |
| 441 | ) |
| 442 | |
| 443 | COMMON_TEST_SRCS = [ |
| 444 | # AUTOGEN(common_test_srcs) |
| 445 | "src/google/protobuf/arena_test_util.cc", |
| 446 | "src/google/protobuf/map_test_util.cc", |
| 447 | "src/google/protobuf/test_util.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 448 | "src/google/protobuf/test_util.inc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 449 | "src/google/protobuf/testing/file.cc", |
| 450 | "src/google/protobuf/testing/googletest.cc", |
| 451 | ] |
| 452 | |
| 453 | cc_binary( |
| 454 | name = "test_plugin", |
| 455 | srcs = [ |
| 456 | # AUTOGEN(test_plugin_srcs) |
| 457 | "src/google/protobuf/compiler/mock_code_generator.cc", |
| 458 | "src/google/protobuf/compiler/test_plugin.cc", |
| 459 | "src/google/protobuf/testing/file.cc", |
| 460 | ], |
Brian Silverman | 7b8899e | 2018-06-30 19:19:24 -0700 | [diff] [blame] | 461 | copts = COPTS, |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 462 | deps = [ |
| 463 | ":protobuf", |
| 464 | ":protoc_lib", |
| 465 | "//external:gtest", |
| 466 | ], |
| 467 | ) |
| 468 | |
| 469 | cc_test( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 470 | name = "win32_test", |
| 471 | srcs = ["src/google/protobuf/stubs/io_win32_unittest.cc"], |
| 472 | tags = [ |
| 473 | "manual", |
| 474 | "windows", |
| 475 | ], |
| 476 | deps = [ |
| 477 | ":protobuf_lite", |
| 478 | "//external:gtest_main", |
| 479 | ], |
| 480 | ) |
| 481 | |
| 482 | cc_test( |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 483 | name = "protobuf_test", |
| 484 | srcs = COMMON_TEST_SRCS + [ |
| 485 | # AUTOGEN(test_srcs) |
| 486 | "src/google/protobuf/any_test.cc", |
| 487 | "src/google/protobuf/arena_unittest.cc", |
| 488 | "src/google/protobuf/arenastring_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 489 | "src/google/protobuf/compiler/annotation_test_util.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 490 | "src/google/protobuf/compiler/command_line_interface_unittest.cc", |
| 491 | "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 492 | "src/google/protobuf/compiler/cpp/cpp_move_unittest.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 493 | "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", |
| 494 | "src/google/protobuf/compiler/cpp/cpp_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 495 | "src/google/protobuf/compiler/cpp/cpp_unittest.inc", |
| 496 | "src/google/protobuf/compiler/cpp/metadata_test.cc", |
| 497 | "src/google/protobuf/compiler/csharp/csharp_bootstrap_unittest.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 498 | "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", |
| 499 | "src/google/protobuf/compiler/importer_unittest.cc", |
| 500 | "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", |
| 501 | "src/google/protobuf/compiler/java/java_plugin_unittest.cc", |
| 502 | "src/google/protobuf/compiler/mock_code_generator.cc", |
| 503 | "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc", |
| 504 | "src/google/protobuf/compiler/parser_unittest.cc", |
| 505 | "src/google/protobuf/compiler/python/python_plugin_unittest.cc", |
| 506 | "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", |
| 507 | "src/google/protobuf/descriptor_database_unittest.cc", |
| 508 | "src/google/protobuf/descriptor_unittest.cc", |
| 509 | "src/google/protobuf/drop_unknown_fields_test.cc", |
| 510 | "src/google/protobuf/dynamic_message_unittest.cc", |
| 511 | "src/google/protobuf/extension_set_unittest.cc", |
| 512 | "src/google/protobuf/generated_message_reflection_unittest.cc", |
| 513 | "src/google/protobuf/io/coded_stream_unittest.cc", |
| 514 | "src/google/protobuf/io/printer_unittest.cc", |
| 515 | "src/google/protobuf/io/tokenizer_unittest.cc", |
| 516 | "src/google/protobuf/io/zero_copy_stream_unittest.cc", |
| 517 | "src/google/protobuf/map_field_test.cc", |
| 518 | "src/google/protobuf/map_test.cc", |
| 519 | "src/google/protobuf/message_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 520 | "src/google/protobuf/message_unittest.inc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 521 | "src/google/protobuf/no_field_presence_test.cc", |
| 522 | "src/google/protobuf/preserve_unknown_enum_test.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 523 | "src/google/protobuf/proto3_arena_lite_unittest.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 524 | "src/google/protobuf/proto3_arena_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 525 | "src/google/protobuf/proto3_lite_unittest.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 526 | "src/google/protobuf/reflection_ops_unittest.cc", |
| 527 | "src/google/protobuf/repeated_field_reflection_unittest.cc", |
| 528 | "src/google/protobuf/repeated_field_unittest.cc", |
| 529 | "src/google/protobuf/stubs/bytestream_unittest.cc", |
| 530 | "src/google/protobuf/stubs/common_unittest.cc", |
| 531 | "src/google/protobuf/stubs/int128_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 532 | "src/google/protobuf/stubs/io_win32_unittest.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 533 | "src/google/protobuf/stubs/status_test.cc", |
| 534 | "src/google/protobuf/stubs/statusor_test.cc", |
| 535 | "src/google/protobuf/stubs/stringpiece_unittest.cc", |
| 536 | "src/google/protobuf/stubs/stringprintf_unittest.cc", |
| 537 | "src/google/protobuf/stubs/structurally_valid_unittest.cc", |
| 538 | "src/google/protobuf/stubs/strutil_unittest.cc", |
| 539 | "src/google/protobuf/stubs/template_util_unittest.cc", |
| 540 | "src/google/protobuf/stubs/time_test.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 541 | "src/google/protobuf/text_format_unittest.cc", |
| 542 | "src/google/protobuf/unknown_field_set_unittest.cc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 543 | "src/google/protobuf/util/delimited_message_util_test.cc", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 544 | "src/google/protobuf/util/field_comparator_test.cc", |
| 545 | "src/google/protobuf/util/field_mask_util_test.cc", |
| 546 | "src/google/protobuf/util/internal/default_value_objectwriter_test.cc", |
| 547 | "src/google/protobuf/util/internal/json_objectwriter_test.cc", |
| 548 | "src/google/protobuf/util/internal/json_stream_parser_test.cc", |
| 549 | "src/google/protobuf/util/internal/protostream_objectsource_test.cc", |
| 550 | "src/google/protobuf/util/internal/protostream_objectwriter_test.cc", |
| 551 | "src/google/protobuf/util/internal/type_info_test_helper.cc", |
| 552 | "src/google/protobuf/util/json_util_test.cc", |
| 553 | "src/google/protobuf/util/message_differencer_unittest.cc", |
| 554 | "src/google/protobuf/util/time_util_test.cc", |
| 555 | "src/google/protobuf/util/type_resolver_util_test.cc", |
| 556 | "src/google/protobuf/well_known_types_unittest.cc", |
| 557 | "src/google/protobuf/wire_format_unittest.cc", |
| 558 | ], |
| 559 | copts = COPTS, |
| 560 | data = [ |
| 561 | ":test_plugin", |
| 562 | ] + glob([ |
| 563 | "src/google/protobuf/**/*", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 564 | # Files for csharp_bootstrap_unittest.cc. |
| 565 | "conformance/**/*", |
| 566 | "csharp/src/**/*", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 567 | ]), |
| 568 | includes = [ |
| 569 | "src/", |
| 570 | ], |
| 571 | linkopts = LINK_OPTS, |
| 572 | deps = [ |
| 573 | ":cc_test_protos", |
| 574 | ":protobuf", |
| 575 | ":protoc_lib", |
| 576 | "//external:gtest_main", |
| 577 | ], |
| 578 | ) |
| 579 | |
| 580 | ################################################################################ |
| 581 | # Java support |
| 582 | ################################################################################ |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 583 | internal_gen_well_known_protos_java( |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 584 | srcs = WELL_KNOWN_PROTOS, |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 585 | ) |
| 586 | |
| 587 | java_library( |
| 588 | name = "protobuf_java", |
| 589 | srcs = glob([ |
| 590 | "java/core/src/main/java/com/google/protobuf/*.java", |
| 591 | ]) + [ |
| 592 | ":gen_well_known_protos_java", |
| 593 | ], |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 594 | javacopts = select({ |
| 595 | "//:jdk9": ["--add-modules=jdk.unsupported"], |
| 596 | "//conditions:default": [ |
| 597 | "-source 7", |
| 598 | "-target 7", |
| 599 | ], |
| 600 | }), |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 601 | visibility = ["//visibility:public"], |
| 602 | ) |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 603 | |
| 604 | java_library( |
| 605 | name = "protobuf_java_util", |
| 606 | srcs = glob([ |
| 607 | "java/util/src/main/java/com/google/protobuf/util/*.java", |
| 608 | ]), |
| 609 | javacopts = [ |
| 610 | "-source 7", |
| 611 | "-target 7", |
| 612 | ], |
| 613 | visibility = ["//visibility:public"], |
| 614 | deps = [ |
| 615 | "protobuf_java", |
| 616 | "//external:gson", |
| 617 | "//external:guava", |
| 618 | ], |
| 619 | ) |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 620 | |
| 621 | ################################################################################ |
| 622 | # Python support |
| 623 | ################################################################################ |
| 624 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 625 | py_library( |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 626 | name = "python_srcs", |
| 627 | srcs = glob( |
| 628 | [ |
| 629 | "python/google/protobuf/*.py", |
| 630 | "python/google/protobuf/**/*.py", |
| 631 | ], |
| 632 | exclude = [ |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 633 | "python/google/protobuf/__init__.py", |
| 634 | "python/google/protobuf/**/__init__.py", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 635 | "python/google/protobuf/internal/*_test.py", |
| 636 | "python/google/protobuf/internal/test_util.py", |
| 637 | ], |
| 638 | ), |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 639 | imports = ["python"], |
| 640 | srcs_version = "PY2AND3", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 641 | ) |
| 642 | |
Brian Silverman | 7b8899e | 2018-06-30 19:19:24 -0700 | [diff] [blame] | 643 | """ |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 644 | cc_binary( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 645 | name = "python/google/protobuf/internal/_api_implementation.so", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 646 | srcs = ["python/google/protobuf/internal/api_implementation.cc"], |
| 647 | copts = COPTS + [ |
| 648 | "-DPYTHON_PROTO2_CPP_IMPL_V2", |
| 649 | ], |
| 650 | linkshared = 1, |
| 651 | linkstatic = 1, |
| 652 | deps = select({ |
| 653 | "//conditions:default": [], |
Brian Silverman | 3fca9d7 | 2016-02-20 02:32:51 -0500 | [diff] [blame] | 654 | ":use_fast_cpp_protos": ["//third_party/protobuf/util/python:python_headers"], |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 655 | }), |
| 656 | ) |
| 657 | |
| 658 | cc_binary( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 659 | name = "python/google/protobuf/pyext/_message.so", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 660 | srcs = glob([ |
| 661 | "python/google/protobuf/pyext/*.cc", |
| 662 | "python/google/protobuf/pyext/*.h", |
| 663 | ]), |
| 664 | copts = COPTS + [ |
| 665 | "-DGOOGLE_PROTOBUF_HAS_ONEOF=1", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 666 | ] + select({ |
| 667 | "//conditions:default": [], |
| 668 | ":allow_oversize_protos": ["-DPROTOBUF_PYTHON_ALLOW_OVERSIZE_PROTOS=1"], |
| 669 | }), |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 670 | includes = [ |
| 671 | "python/", |
| 672 | "src/", |
| 673 | ], |
| 674 | linkshared = 1, |
| 675 | linkstatic = 1, |
| 676 | deps = [ |
| 677 | ":protobuf", |
| 678 | ] + select({ |
| 679 | "//conditions:default": [], |
Brian Silverman | 3fca9d7 | 2016-02-20 02:32:51 -0500 | [diff] [blame] | 680 | ":use_fast_cpp_protos": ["//third_party/protobuf/util/python:python_headers"], |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 681 | }), |
| 682 | ) |
Brian Silverman | 7b8899e | 2018-06-30 19:19:24 -0700 | [diff] [blame] | 683 | """ |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 684 | |
| 685 | config_setting( |
| 686 | name = "use_fast_cpp_protos", |
| 687 | values = { |
| 688 | "define": "use_fast_cpp_protos=true", |
| 689 | }, |
| 690 | ) |
| 691 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 692 | config_setting( |
| 693 | name = "allow_oversize_protos", |
| 694 | values = { |
| 695 | "define": "allow_oversize_protos=true", |
| 696 | }, |
| 697 | ) |
| 698 | |
| 699 | # Copy the builtin proto files from src/google/protobuf to |
| 700 | # python/google/protobuf. This way, the generated Python sources will be in the |
| 701 | # same directory as the Python runtime sources. This is necessary for the |
| 702 | # modules to be imported correctly since they are all part of the same Python |
| 703 | # package. |
| 704 | internal_copied_filegroup( |
| 705 | name = "protos_python", |
| 706 | srcs = WELL_KNOWN_PROTOS, |
| 707 | dest = "python", |
| 708 | strip_prefix = "src", |
| 709 | ) |
| 710 | |
| 711 | # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in |
| 712 | # which case we can simply add :protos_python in srcs. |
| 713 | COPIED_WELL_KNOWN_PROTOS = ["python/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] |
| 714 | |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 715 | py_proto_library( |
| 716 | name = "protobuf_python", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 717 | srcs = COPIED_WELL_KNOWN_PROTOS, |
| 718 | include = "python", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 719 | data = select({ |
| 720 | "//conditions:default": [], |
| 721 | ":use_fast_cpp_protos": [ |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 722 | ":python/google/protobuf/internal/_api_implementation.so", |
| 723 | ":python/google/protobuf/pyext/_message.so", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 724 | ], |
| 725 | }), |
| 726 | default_runtime = "", |
| 727 | protoc = ":protoc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 728 | py_extra_srcs = glob(["python/**/__init__.py"]), |
| 729 | py_libs = [ |
| 730 | ":python_srcs", |
| 731 | "//external:six", |
| 732 | ], |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 733 | srcs_version = "PY2AND3", |
| 734 | visibility = ["//visibility:public"], |
| 735 | ) |
| 736 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 737 | # Copy the test proto files from src/google/protobuf to |
| 738 | # python/google/protobuf. This way, the generated Python sources will be in the |
| 739 | # same directory as the Python runtime sources. This is necessary for the |
| 740 | # modules to be imported correctly by the tests since they are all part of the |
| 741 | # same Python package. |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 742 | internal_copied_filegroup( |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 743 | name = "protos_python_test", |
| 744 | srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
| 745 | dest = "python", |
| 746 | strip_prefix = "src", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 747 | ) |
| 748 | |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 749 | # TODO(dzc): Remove this once py_proto_library can have labels in srcs, in |
| 750 | # which case we can simply add :protos_python_test in srcs. |
| 751 | COPIED_LITE_TEST_PROTOS = ["python/" + s for s in RELATIVE_LITE_TEST_PROTOS] |
| 752 | |
| 753 | COPIED_TEST_PROTOS = ["python/" + s for s in RELATIVE_TEST_PROTOS] |
| 754 | |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 755 | py_proto_library( |
| 756 | name = "python_common_test_protos", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 757 | srcs = COPIED_LITE_TEST_PROTOS + COPIED_TEST_PROTOS, |
| 758 | include = "python", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 759 | default_runtime = "", |
| 760 | protoc = ":protoc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 761 | srcs_version = "PY2AND3", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 762 | deps = [":protobuf_python"], |
| 763 | ) |
| 764 | |
| 765 | py_proto_library( |
| 766 | name = "python_specific_test_protos", |
| 767 | srcs = glob([ |
| 768 | "python/google/protobuf/internal/*.proto", |
| 769 | "python/google/protobuf/internal/import_test_package/*.proto", |
| 770 | ]), |
| 771 | include = "python", |
| 772 | default_runtime = ":protobuf_python", |
| 773 | protoc = ":protoc", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 774 | srcs_version = "PY2AND3", |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 775 | deps = [":python_common_test_protos"], |
| 776 | ) |
| 777 | |
| 778 | py_library( |
| 779 | name = "python_tests", |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 780 | srcs = glob( |
| 781 | [ |
| 782 | "python/google/protobuf/internal/*_test.py", |
| 783 | "python/google/protobuf/internal/test_util.py", |
| 784 | "python/google/protobuf/internal/import_test_package/__init__.py", |
| 785 | ], |
| 786 | ), |
| 787 | imports = ["python"], |
Brian Silverman | 9c614bc | 2016-02-15 20:20:02 -0500 | [diff] [blame] | 788 | srcs_version = "PY2AND3", |
| 789 | deps = [ |
| 790 | ":protobuf_python", |
| 791 | ":python_common_test_protos", |
| 792 | ":python_specific_test_protos", |
| 793 | ], |
| 794 | ) |
| 795 | |
| 796 | internal_protobuf_py_tests( |
| 797 | name = "python_tests_batch", |
| 798 | data = glob([ |
| 799 | "src/google/protobuf/**/*", |
| 800 | ]), |
| 801 | modules = [ |
| 802 | "descriptor_database_test", |
| 803 | "descriptor_pool_test", |
| 804 | "descriptor_test", |
| 805 | "generator_test", |
| 806 | "json_format_test", |
| 807 | "message_factory_test", |
| 808 | "message_test", |
| 809 | "proto_builder_test", |
| 810 | "reflection_test", |
| 811 | "service_reflection_test", |
| 812 | "symbol_database_test", |
| 813 | "text_encoding_test", |
| 814 | "text_format_test", |
| 815 | "unknown_fields_test", |
| 816 | "wire_format_test", |
| 817 | ], |
| 818 | deps = [":python_tests"], |
| 819 | ) |
Austin Schuh | f972444 | 2018-10-28 20:30:21 -0700 | [diff] [blame^] | 820 | |
| 821 | proto_lang_toolchain( |
| 822 | name = "cc_toolchain", |
| 823 | blacklisted_protos = [":_internal_wkt_protos_genrule"], |
| 824 | command_line = "--cpp_out=$(OUT)", |
| 825 | runtime = ":protobuf", |
| 826 | visibility = ["//visibility:public"], |
| 827 | ) |
| 828 | |
| 829 | proto_lang_toolchain( |
| 830 | name = "java_toolchain", |
| 831 | command_line = "--java_out=$(OUT)", |
| 832 | runtime = ":protobuf_java", |
| 833 | visibility = ["//visibility:public"], |
| 834 | ) |
| 835 | |
| 836 | OBJC_HDRS = [ |
| 837 | "objectivec/GPBArray.h", |
| 838 | "objectivec/GPBBootstrap.h", |
| 839 | "objectivec/GPBCodedInputStream.h", |
| 840 | "objectivec/GPBCodedOutputStream.h", |
| 841 | "objectivec/GPBDescriptor.h", |
| 842 | "objectivec/GPBDictionary.h", |
| 843 | "objectivec/GPBExtensionInternals.h", |
| 844 | "objectivec/GPBExtensionRegistry.h", |
| 845 | "objectivec/GPBMessage.h", |
| 846 | "objectivec/GPBProtocolBuffers.h", |
| 847 | "objectivec/GPBProtocolBuffers_RuntimeSupport.h", |
| 848 | "objectivec/GPBRootObject.h", |
| 849 | "objectivec/GPBRuntimeTypes.h", |
| 850 | "objectivec/GPBUnknownField.h", |
| 851 | "objectivec/GPBUnknownFieldSet.h", |
| 852 | "objectivec/GPBUtilities.h", |
| 853 | "objectivec/GPBWellKnownTypes.h", |
| 854 | "objectivec/GPBWireFormat.h", |
| 855 | "objectivec/google/protobuf/Any.pbobjc.h", |
| 856 | "objectivec/google/protobuf/Api.pbobjc.h", |
| 857 | "objectivec/google/protobuf/Duration.pbobjc.h", |
| 858 | "objectivec/google/protobuf/Empty.pbobjc.h", |
| 859 | "objectivec/google/protobuf/FieldMask.pbobjc.h", |
| 860 | "objectivec/google/protobuf/SourceContext.pbobjc.h", |
| 861 | "objectivec/google/protobuf/Struct.pbobjc.h", |
| 862 | "objectivec/google/protobuf/Timestamp.pbobjc.h", |
| 863 | "objectivec/google/protobuf/Type.pbobjc.h", |
| 864 | "objectivec/google/protobuf/Wrappers.pbobjc.h", |
| 865 | ] |
| 866 | |
| 867 | OBJC_PRIVATE_HDRS = [ |
| 868 | "objectivec/GPBArray_PackagePrivate.h", |
| 869 | "objectivec/GPBCodedInputStream_PackagePrivate.h", |
| 870 | "objectivec/GPBCodedOutputStream_PackagePrivate.h", |
| 871 | "objectivec/GPBDescriptor_PackagePrivate.h", |
| 872 | "objectivec/GPBDictionary_PackagePrivate.h", |
| 873 | "objectivec/GPBMessage_PackagePrivate.h", |
| 874 | "objectivec/GPBRootObject_PackagePrivate.h", |
| 875 | "objectivec/GPBUnknownFieldSet_PackagePrivate.h", |
| 876 | "objectivec/GPBUnknownField_PackagePrivate.h", |
| 877 | "objectivec/GPBUtilities_PackagePrivate.h", |
| 878 | ] |
| 879 | |
| 880 | OBJC_SRCS = [ |
| 881 | "objectivec/GPBArray.m", |
| 882 | "objectivec/GPBCodedInputStream.m", |
| 883 | "objectivec/GPBCodedOutputStream.m", |
| 884 | "objectivec/GPBDescriptor.m", |
| 885 | "objectivec/GPBDictionary.m", |
| 886 | "objectivec/GPBExtensionInternals.m", |
| 887 | "objectivec/GPBExtensionRegistry.m", |
| 888 | "objectivec/GPBMessage.m", |
| 889 | "objectivec/GPBRootObject.m", |
| 890 | "objectivec/GPBUnknownField.m", |
| 891 | "objectivec/GPBUnknownFieldSet.m", |
| 892 | "objectivec/GPBUtilities.m", |
| 893 | "objectivec/GPBWellKnownTypes.m", |
| 894 | "objectivec/GPBWireFormat.m", |
| 895 | "objectivec/google/protobuf/Any.pbobjc.m", |
| 896 | "objectivec/google/protobuf/Api.pbobjc.m", |
| 897 | "objectivec/google/protobuf/Duration.pbobjc.m", |
| 898 | "objectivec/google/protobuf/Empty.pbobjc.m", |
| 899 | "objectivec/google/protobuf/FieldMask.pbobjc.m", |
| 900 | "objectivec/google/protobuf/SourceContext.pbobjc.m", |
| 901 | "objectivec/google/protobuf/Struct.pbobjc.m", |
| 902 | "objectivec/google/protobuf/Timestamp.pbobjc.m", |
| 903 | "objectivec/google/protobuf/Type.pbobjc.m", |
| 904 | "objectivec/google/protobuf/Wrappers.pbobjc.m", |
| 905 | ] |
| 906 | |
| 907 | objc_library( |
| 908 | name = "objectivec", |
| 909 | hdrs = OBJC_HDRS + OBJC_PRIVATE_HDRS, |
| 910 | includes = [ |
| 911 | "objectivec", |
| 912 | ], |
| 913 | non_arc_srcs = OBJC_SRCS, |
| 914 | visibility = ["//visibility:public"], |
| 915 | ) |