Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 1 | # Bazel (http://bazel.io/) BUILD file for Protobuf. |
| 2 | |
| 3 | licenses(["notice"]) |
| 4 | |
Jorge Canizales | d5d7bb3 | 2015-06-28 15:23:02 -0700 | [diff] [blame] | 5 | ################################################################################ |
| 6 | # Protobuf Runtime Library |
| 7 | ################################################################################ |
| 8 | |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 9 | COPTS = [ |
| 10 | "-DHAVE_PTHREAD", |
| 11 | "-Wall", |
| 12 | "-Wwrite-strings", |
| 13 | "-Woverloaded-virtual", |
| 14 | "-Wno-sign-compare", |
| 15 | "-Wno-error=unused-function", |
| 16 | ] |
| 17 | |
| 18 | # Bazel should provide portable link_opts for pthread. |
| 19 | LINK_OPTS = ["-lpthread"] |
| 20 | |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 21 | load( |
| 22 | "protobuf", |
| 23 | "cc_proto_library", |
| 24 | "py_proto_library", |
Jisi Liu | bc4fd15 | 2015-10-20 16:02:58 -0700 | [diff] [blame] | 25 | "internal_copied_filegroup", |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 26 | "internal_protobuf_py_tests", |
| 27 | ) |
Jisi Liu | 39362b3 | 2015-10-14 17:12:11 -0700 | [diff] [blame] | 28 | |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 29 | cc_library( |
| 30 | name = "protobuf_lite", |
| 31 | srcs = [ |
| 32 | # AUTOGEN(protobuf_lite_srcs) |
| 33 | "src/google/protobuf/arena.cc", |
| 34 | "src/google/protobuf/arenastring.cc", |
| 35 | "src/google/protobuf/extension_set.cc", |
| 36 | "src/google/protobuf/generated_message_util.cc", |
| 37 | "src/google/protobuf/io/coded_stream.cc", |
| 38 | "src/google/protobuf/io/zero_copy_stream.cc", |
| 39 | "src/google/protobuf/io/zero_copy_stream_impl_lite.cc", |
| 40 | "src/google/protobuf/message_lite.cc", |
| 41 | "src/google/protobuf/repeated_field.cc", |
| 42 | "src/google/protobuf/stubs/atomicops_internals_x86_gcc.cc", |
| 43 | "src/google/protobuf/stubs/atomicops_internals_x86_msvc.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 44 | "src/google/protobuf/stubs/bytestream.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 45 | "src/google/protobuf/stubs/common.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 46 | "src/google/protobuf/stubs/int128.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 47 | "src/google/protobuf/stubs/once.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 48 | "src/google/protobuf/stubs/status.cc", |
| 49 | "src/google/protobuf/stubs/statusor.cc", |
| 50 | "src/google/protobuf/stubs/stringpiece.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 51 | "src/google/protobuf/stubs/stringprintf.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 52 | "src/google/protobuf/stubs/structurally_valid.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 53 | "src/google/protobuf/stubs/strutil.cc", |
| 54 | "src/google/protobuf/stubs/time.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 55 | "src/google/protobuf/wire_format_lite.cc", |
| 56 | ], |
| 57 | copts = COPTS, |
| 58 | includes = ["src/"], |
| 59 | linkopts = LINK_OPTS, |
| 60 | visibility = ["//visibility:public"], |
| 61 | ) |
| 62 | |
| 63 | cc_library( |
| 64 | name = "protobuf", |
| 65 | srcs = [ |
| 66 | # AUTOGEN(protobuf_srcs) |
| 67 | "src/google/protobuf/any.cc", |
| 68 | "src/google/protobuf/any.pb.cc", |
| 69 | "src/google/protobuf/api.pb.cc", |
| 70 | "src/google/protobuf/compiler/importer.cc", |
| 71 | "src/google/protobuf/compiler/parser.cc", |
| 72 | "src/google/protobuf/descriptor.cc", |
| 73 | "src/google/protobuf/descriptor.pb.cc", |
| 74 | "src/google/protobuf/descriptor_database.cc", |
| 75 | "src/google/protobuf/duration.pb.cc", |
| 76 | "src/google/protobuf/dynamic_message.cc", |
| 77 | "src/google/protobuf/empty.pb.cc", |
| 78 | "src/google/protobuf/extension_set_heavy.cc", |
| 79 | "src/google/protobuf/field_mask.pb.cc", |
| 80 | "src/google/protobuf/generated_message_reflection.cc", |
| 81 | "src/google/protobuf/io/gzip_stream.cc", |
| 82 | "src/google/protobuf/io/printer.cc", |
| 83 | "src/google/protobuf/io/strtod.cc", |
| 84 | "src/google/protobuf/io/tokenizer.cc", |
| 85 | "src/google/protobuf/io/zero_copy_stream_impl.cc", |
| 86 | "src/google/protobuf/map_field.cc", |
| 87 | "src/google/protobuf/message.cc", |
| 88 | "src/google/protobuf/reflection_ops.cc", |
| 89 | "src/google/protobuf/service.cc", |
| 90 | "src/google/protobuf/source_context.pb.cc", |
| 91 | "src/google/protobuf/struct.pb.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 92 | "src/google/protobuf/stubs/mathlimits.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 93 | "src/google/protobuf/stubs/substitute.cc", |
| 94 | "src/google/protobuf/text_format.cc", |
| 95 | "src/google/protobuf/timestamp.pb.cc", |
| 96 | "src/google/protobuf/type.pb.cc", |
| 97 | "src/google/protobuf/unknown_field_set.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 98 | "src/google/protobuf/util/field_comparator.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 99 | "src/google/protobuf/util/field_mask_util.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 100 | "src/google/protobuf/util/internal/datapiece.cc", |
| 101 | "src/google/protobuf/util/internal/default_value_objectwriter.cc", |
| 102 | "src/google/protobuf/util/internal/error_listener.cc", |
| 103 | "src/google/protobuf/util/internal/field_mask_utility.cc", |
| 104 | "src/google/protobuf/util/internal/json_escaping.cc", |
| 105 | "src/google/protobuf/util/internal/json_objectwriter.cc", |
| 106 | "src/google/protobuf/util/internal/json_stream_parser.cc", |
| 107 | "src/google/protobuf/util/internal/object_writer.cc", |
| 108 | "src/google/protobuf/util/internal/protostream_objectsource.cc", |
| 109 | "src/google/protobuf/util/internal/protostream_objectwriter.cc", |
| 110 | "src/google/protobuf/util/internal/type_info.cc", |
| 111 | "src/google/protobuf/util/internal/type_info_test_helper.cc", |
| 112 | "src/google/protobuf/util/internal/utility.cc", |
| 113 | "src/google/protobuf/util/json_util.cc", |
| 114 | "src/google/protobuf/util/message_differencer.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 115 | "src/google/protobuf/util/time_util.cc", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 116 | "src/google/protobuf/util/type_resolver_util.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 117 | "src/google/protobuf/wire_format.cc", |
| 118 | "src/google/protobuf/wrappers.pb.cc", |
| 119 | ], |
| 120 | copts = COPTS, |
| 121 | includes = ["src/"], |
| 122 | linkopts = LINK_OPTS, |
| 123 | visibility = ["//visibility:public"], |
| 124 | deps = [":protobuf_lite"], |
| 125 | ) |
| 126 | |
Jisi Liu | 14c8f8a | 2015-10-20 15:36:22 -0700 | [diff] [blame] | 127 | objc_library( |
| 128 | name = "protobuf_objc", |
| 129 | hdrs = ["objectivec/GPBProtocolBuffers.h"], |
| 130 | includes = ["objectivec"], |
| 131 | non_arc_srcs = ["objectivec/GPBProtocolBuffers.m"], |
| 132 | visibility = ["//visibility:public"], |
| 133 | ) |
Jorge Canizales | d5d7bb3 | 2015-06-28 15:23:02 -0700 | [diff] [blame] | 134 | |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 135 | RELATIVE_WELL_KNOWN_PROTOS = [ |
Jorge Canizales | d5d7bb3 | 2015-06-28 15:23:02 -0700 | [diff] [blame] | 136 | # AUTOGEN(well_known_protos) |
| 137 | "google/protobuf/any.proto", |
| 138 | "google/protobuf/api.proto", |
| 139 | "google/protobuf/compiler/plugin.proto", |
| 140 | "google/protobuf/descriptor.proto", |
| 141 | "google/protobuf/duration.proto", |
| 142 | "google/protobuf/empty.proto", |
| 143 | "google/protobuf/field_mask.proto", |
| 144 | "google/protobuf/source_context.proto", |
| 145 | "google/protobuf/struct.proto", |
| 146 | "google/protobuf/timestamp.proto", |
| 147 | "google/protobuf/type.proto", |
| 148 | "google/protobuf/wrappers.proto", |
| 149 | ] |
| 150 | |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 151 | WELL_KNOWN_PROTOS = ["src/" + s for s in RELATIVE_WELL_KNOWN_PROTOS] |
| 152 | |
Jisi Liu | 39362b3 | 2015-10-14 17:12:11 -0700 | [diff] [blame] | 153 | cc_proto_library( |
| 154 | name = "cc_wkt_protos", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 155 | srcs = WELL_KNOWN_PROTOS, |
Jisi Liu | 3101e73 | 2015-10-16 12:46:26 -0700 | [diff] [blame] | 156 | include = "src", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 157 | internal_bootstrap_hack = 1, |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 158 | protoc = ":protoc", |
Jisi Liu | be92ffb | 2015-10-27 15:11:38 -0700 | [diff] [blame] | 159 | default_runtime = ":protobuf", |
Jisi Liu | 6a40bf8 | 2015-11-17 12:36:21 -0800 | [diff] [blame] | 160 | visibility = ["//visibility:public"], |
Jisi Liu | 39362b3 | 2015-10-14 17:12:11 -0700 | [diff] [blame] | 161 | ) |
| 162 | |
Jorge Canizales | d5d7bb3 | 2015-06-28 15:23:02 -0700 | [diff] [blame] | 163 | ################################################################################ |
| 164 | # Protocol Buffers Compiler |
| 165 | ################################################################################ |
| 166 | |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 167 | cc_library( |
| 168 | name = "protoc_lib", |
| 169 | srcs = [ |
| 170 | # AUTOGEN(protoc_lib_srcs) |
| 171 | "src/google/protobuf/compiler/code_generator.cc", |
| 172 | "src/google/protobuf/compiler/command_line_interface.cc", |
| 173 | "src/google/protobuf/compiler/cpp/cpp_enum.cc", |
| 174 | "src/google/protobuf/compiler/cpp/cpp_enum_field.cc", |
| 175 | "src/google/protobuf/compiler/cpp/cpp_extension.cc", |
| 176 | "src/google/protobuf/compiler/cpp/cpp_field.cc", |
| 177 | "src/google/protobuf/compiler/cpp/cpp_file.cc", |
| 178 | "src/google/protobuf/compiler/cpp/cpp_generator.cc", |
| 179 | "src/google/protobuf/compiler/cpp/cpp_helpers.cc", |
| 180 | "src/google/protobuf/compiler/cpp/cpp_map_field.cc", |
| 181 | "src/google/protobuf/compiler/cpp/cpp_message.cc", |
| 182 | "src/google/protobuf/compiler/cpp/cpp_message_field.cc", |
| 183 | "src/google/protobuf/compiler/cpp/cpp_primitive_field.cc", |
| 184 | "src/google/protobuf/compiler/cpp/cpp_service.cc", |
| 185 | "src/google/protobuf/compiler/cpp/cpp_string_field.cc", |
Ming Zhao | 5cdd936 | 2015-10-05 14:37:21 -0700 | [diff] [blame] | 186 | "src/google/protobuf/compiler/csharp/csharp_doc_comment.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 187 | "src/google/protobuf/compiler/csharp/csharp_enum.cc", |
| 188 | "src/google/protobuf/compiler/csharp/csharp_enum_field.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 189 | "src/google/protobuf/compiler/csharp/csharp_field_base.cc", |
| 190 | "src/google/protobuf/compiler/csharp/csharp_generator.cc", |
| 191 | "src/google/protobuf/compiler/csharp/csharp_helpers.cc", |
Jon Skeet | b2ac868 | 2015-07-15 13:17:42 +0100 | [diff] [blame] | 192 | "src/google/protobuf/compiler/csharp/csharp_map_field.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 193 | "src/google/protobuf/compiler/csharp/csharp_message.cc", |
| 194 | "src/google/protobuf/compiler/csharp/csharp_message_field.cc", |
| 195 | "src/google/protobuf/compiler/csharp/csharp_primitive_field.cc", |
| 196 | "src/google/protobuf/compiler/csharp/csharp_repeated_enum_field.cc", |
| 197 | "src/google/protobuf/compiler/csharp/csharp_repeated_message_field.cc", |
| 198 | "src/google/protobuf/compiler/csharp/csharp_repeated_primitive_field.cc", |
| 199 | "src/google/protobuf/compiler/csharp/csharp_source_generator_base.cc", |
| 200 | "src/google/protobuf/compiler/csharp/csharp_umbrella_class.cc", |
Jon Skeet | b2ac868 | 2015-07-15 13:17:42 +0100 | [diff] [blame] | 201 | "src/google/protobuf/compiler/csharp/csharp_wrapper_field.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 202 | "src/google/protobuf/compiler/java/java_context.cc", |
| 203 | "src/google/protobuf/compiler/java/java_doc_comment.cc", |
| 204 | "src/google/protobuf/compiler/java/java_enum.cc", |
| 205 | "src/google/protobuf/compiler/java/java_enum_field.cc", |
| 206 | "src/google/protobuf/compiler/java/java_enum_field_lite.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 207 | "src/google/protobuf/compiler/java/java_enum_lite.cc", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 208 | "src/google/protobuf/compiler/java/java_extension.cc", |
| 209 | "src/google/protobuf/compiler/java/java_field.cc", |
| 210 | "src/google/protobuf/compiler/java/java_file.cc", |
| 211 | "src/google/protobuf/compiler/java/java_generator.cc", |
| 212 | "src/google/protobuf/compiler/java/java_generator_factory.cc", |
| 213 | "src/google/protobuf/compiler/java/java_helpers.cc", |
| 214 | "src/google/protobuf/compiler/java/java_lazy_message_field.cc", |
| 215 | "src/google/protobuf/compiler/java/java_lazy_message_field_lite.cc", |
| 216 | "src/google/protobuf/compiler/java/java_map_field.cc", |
| 217 | "src/google/protobuf/compiler/java/java_map_field_lite.cc", |
| 218 | "src/google/protobuf/compiler/java/java_message.cc", |
| 219 | "src/google/protobuf/compiler/java/java_message_builder.cc", |
| 220 | "src/google/protobuf/compiler/java/java_message_builder_lite.cc", |
| 221 | "src/google/protobuf/compiler/java/java_message_field.cc", |
| 222 | "src/google/protobuf/compiler/java/java_message_field_lite.cc", |
| 223 | "src/google/protobuf/compiler/java/java_message_lite.cc", |
| 224 | "src/google/protobuf/compiler/java/java_name_resolver.cc", |
| 225 | "src/google/protobuf/compiler/java/java_primitive_field.cc", |
| 226 | "src/google/protobuf/compiler/java/java_primitive_field_lite.cc", |
| 227 | "src/google/protobuf/compiler/java/java_service.cc", |
| 228 | "src/google/protobuf/compiler/java/java_shared_code_generator.cc", |
| 229 | "src/google/protobuf/compiler/java/java_string_field.cc", |
| 230 | "src/google/protobuf/compiler/java/java_string_field_lite.cc", |
| 231 | "src/google/protobuf/compiler/javanano/javanano_enum.cc", |
| 232 | "src/google/protobuf/compiler/javanano/javanano_enum_field.cc", |
| 233 | "src/google/protobuf/compiler/javanano/javanano_extension.cc", |
| 234 | "src/google/protobuf/compiler/javanano/javanano_field.cc", |
| 235 | "src/google/protobuf/compiler/javanano/javanano_file.cc", |
| 236 | "src/google/protobuf/compiler/javanano/javanano_generator.cc", |
| 237 | "src/google/protobuf/compiler/javanano/javanano_helpers.cc", |
| 238 | "src/google/protobuf/compiler/javanano/javanano_map_field.cc", |
| 239 | "src/google/protobuf/compiler/javanano/javanano_message.cc", |
| 240 | "src/google/protobuf/compiler/javanano/javanano_message_field.cc", |
| 241 | "src/google/protobuf/compiler/javanano/javanano_primitive_field.cc", |
| 242 | "src/google/protobuf/compiler/objectivec/objectivec_enum.cc", |
| 243 | "src/google/protobuf/compiler/objectivec/objectivec_enum_field.cc", |
| 244 | "src/google/protobuf/compiler/objectivec/objectivec_extension.cc", |
| 245 | "src/google/protobuf/compiler/objectivec/objectivec_field.cc", |
| 246 | "src/google/protobuf/compiler/objectivec/objectivec_file.cc", |
| 247 | "src/google/protobuf/compiler/objectivec/objectivec_generator.cc", |
| 248 | "src/google/protobuf/compiler/objectivec/objectivec_helpers.cc", |
| 249 | "src/google/protobuf/compiler/objectivec/objectivec_map_field.cc", |
| 250 | "src/google/protobuf/compiler/objectivec/objectivec_message.cc", |
| 251 | "src/google/protobuf/compiler/objectivec/objectivec_message_field.cc", |
| 252 | "src/google/protobuf/compiler/objectivec/objectivec_oneof.cc", |
| 253 | "src/google/protobuf/compiler/objectivec/objectivec_primitive_field.cc", |
| 254 | "src/google/protobuf/compiler/plugin.cc", |
| 255 | "src/google/protobuf/compiler/plugin.pb.cc", |
| 256 | "src/google/protobuf/compiler/python/python_generator.cc", |
| 257 | "src/google/protobuf/compiler/ruby/ruby_generator.cc", |
| 258 | "src/google/protobuf/compiler/subprocess.cc", |
| 259 | "src/google/protobuf/compiler/zip_writer.cc", |
| 260 | ], |
| 261 | copts = COPTS, |
| 262 | includes = ["src/"], |
| 263 | linkopts = LINK_OPTS, |
| 264 | visibility = ["//visibility:public"], |
| 265 | deps = [":protobuf"], |
| 266 | ) |
| 267 | |
| 268 | cc_binary( |
| 269 | name = "protoc", |
| 270 | srcs = ["src/google/protobuf/compiler/main.cc"], |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 271 | linkopts = LINK_OPTS, |
| 272 | visibility = ["//visibility:public"], |
| 273 | deps = [":protoc_lib"], |
| 274 | ) |
| 275 | |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 276 | ################################################################################ |
| 277 | # Tests |
| 278 | ################################################################################ |
| 279 | |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 280 | RELATIVE_LITE_TEST_PROTOS = [ |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 281 | # AUTOGEN(lite_test_protos) |
| 282 | "google/protobuf/map_lite_unittest.proto", |
| 283 | "google/protobuf/unittest_import_lite.proto", |
| 284 | "google/protobuf/unittest_import_public_lite.proto", |
| 285 | "google/protobuf/unittest_lite.proto", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 286 | "google/protobuf/unittest_no_arena_lite.proto", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 287 | ] |
| 288 | |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 289 | LITE_TEST_PROTOS = ["src/" + s for s in RELATIVE_LITE_TEST_PROTOS] |
| 290 | |
| 291 | RELATIVE_TEST_PROTOS = [ |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 292 | # AUTOGEN(test_protos) |
| 293 | "google/protobuf/any_test.proto", |
| 294 | "google/protobuf/compiler/cpp/cpp_test_bad_identifiers.proto", |
| 295 | "google/protobuf/compiler/cpp/cpp_test_large_enum_value.proto", |
| 296 | "google/protobuf/map_proto2_unittest.proto", |
| 297 | "google/protobuf/map_unittest.proto", |
| 298 | "google/protobuf/unittest.proto", |
| 299 | "google/protobuf/unittest_arena.proto", |
| 300 | "google/protobuf/unittest_custom_options.proto", |
| 301 | "google/protobuf/unittest_drop_unknown_fields.proto", |
| 302 | "google/protobuf/unittest_embed_optimize_for.proto", |
| 303 | "google/protobuf/unittest_empty.proto", |
| 304 | "google/protobuf/unittest_enormous_descriptor.proto", |
| 305 | "google/protobuf/unittest_import.proto", |
| 306 | "google/protobuf/unittest_import_public.proto", |
| 307 | "google/protobuf/unittest_lite_imports_nonlite.proto", |
| 308 | "google/protobuf/unittest_mset.proto", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 309 | "google/protobuf/unittest_mset_wire_format.proto", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 310 | "google/protobuf/unittest_no_arena.proto", |
| 311 | "google/protobuf/unittest_no_arena_import.proto", |
| 312 | "google/protobuf/unittest_no_field_presence.proto", |
| 313 | "google/protobuf/unittest_no_generic_services.proto", |
| 314 | "google/protobuf/unittest_optimize_for.proto", |
| 315 | "google/protobuf/unittest_preserve_unknown_enum.proto", |
| 316 | "google/protobuf/unittest_preserve_unknown_enum2.proto", |
| 317 | "google/protobuf/unittest_proto3_arena.proto", |
| 318 | "google/protobuf/unittest_well_known_types.proto", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 319 | "google/protobuf/util/internal/testdata/anys.proto", |
| 320 | "google/protobuf/util/internal/testdata/books.proto", |
| 321 | "google/protobuf/util/internal/testdata/default_value.proto", |
| 322 | "google/protobuf/util/internal/testdata/default_value_test.proto", |
| 323 | "google/protobuf/util/internal/testdata/field_mask.proto", |
| 324 | "google/protobuf/util/internal/testdata/maps.proto", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 325 | "google/protobuf/util/internal/testdata/oneofs.proto", |
Jisi Liu | af3eafd | 2015-06-18 13:38:36 -0700 | [diff] [blame] | 326 | "google/protobuf/util/internal/testdata/struct.proto", |
| 327 | "google/protobuf/util/internal/testdata/timestamp_duration.proto", |
| 328 | "google/protobuf/util/json_format_proto3.proto", |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 329 | ] |
| 330 | |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 331 | TEST_PROTOS = ["src/" + s for s in RELATIVE_TEST_PROTOS] |
| 332 | |
Jisi Liu | 39362b3 | 2015-10-14 17:12:11 -0700 | [diff] [blame] | 333 | cc_proto_library( |
| 334 | name = "cc_test_protos", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 335 | srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
Jisi Liu | 3101e73 | 2015-10-16 12:46:26 -0700 | [diff] [blame] | 336 | include = "src", |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 337 | protoc = ":protoc", |
Jisi Liu | be92ffb | 2015-10-27 15:11:38 -0700 | [diff] [blame] | 338 | default_runtime = ":protobuf", |
Jisi Liu | d8701b5 | 2015-10-16 11:44:21 -0700 | [diff] [blame] | 339 | deps = [":cc_wkt_protos"], |
Jisi Liu | d19604f | 2015-06-17 17:37:58 -0700 | [diff] [blame] | 340 | ) |
| 341 | |
| 342 | COMMON_TEST_SRCS = [ |
| 343 | # AUTOGEN(common_test_srcs) |
| 344 | "src/google/protobuf/arena_test_util.cc", |
| 345 | "src/google/protobuf/map_test_util.cc", |
| 346 | "src/google/protobuf/test_util.cc", |
| 347 | "src/google/protobuf/testing/file.cc", |
| 348 | "src/google/protobuf/testing/googletest.cc", |
| 349 | ] |
| 350 | |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 351 | cc_binary( |
| 352 | name = "test_plugin", |
| 353 | srcs = [ |
| 354 | # AUTOGEN(test_plugin_srcs) |
| 355 | "src/google/protobuf/compiler/mock_code_generator.cc", |
| 356 | "src/google/protobuf/compiler/test_plugin.cc", |
| 357 | "src/google/protobuf/testing/file.cc", |
| 358 | ], |
| 359 | deps = [ |
| 360 | ":protobuf", |
| 361 | ":protoc_lib", |
| 362 | "//external:gtest", |
| 363 | ], |
| 364 | ) |
| 365 | |
| 366 | cc_test( |
| 367 | name = "protobuf_test", |
Jisi Liu | 39362b3 | 2015-10-14 17:12:11 -0700 | [diff] [blame] | 368 | srcs = COMMON_TEST_SRCS + [ |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 369 | # AUTOGEN(test_srcs) |
| 370 | "src/google/protobuf/any_test.cc", |
| 371 | "src/google/protobuf/arena_unittest.cc", |
| 372 | "src/google/protobuf/arenastring_unittest.cc", |
| 373 | "src/google/protobuf/compiler/command_line_interface_unittest.cc", |
| 374 | "src/google/protobuf/compiler/cpp/cpp_bootstrap_unittest.cc", |
| 375 | "src/google/protobuf/compiler/cpp/cpp_plugin_unittest.cc", |
| 376 | "src/google/protobuf/compiler/cpp/cpp_unittest.cc", |
| 377 | "src/google/protobuf/compiler/csharp/csharp_generator_unittest.cc", |
| 378 | "src/google/protobuf/compiler/importer_unittest.cc", |
| 379 | "src/google/protobuf/compiler/java/java_doc_comment_unittest.cc", |
| 380 | "src/google/protobuf/compiler/java/java_plugin_unittest.cc", |
| 381 | "src/google/protobuf/compiler/mock_code_generator.cc", |
| 382 | "src/google/protobuf/compiler/objectivec/objectivec_helpers_unittest.cc", |
| 383 | "src/google/protobuf/compiler/parser_unittest.cc", |
| 384 | "src/google/protobuf/compiler/python/python_plugin_unittest.cc", |
| 385 | "src/google/protobuf/compiler/ruby/ruby_generator_unittest.cc", |
| 386 | "src/google/protobuf/descriptor_database_unittest.cc", |
| 387 | "src/google/protobuf/descriptor_unittest.cc", |
| 388 | "src/google/protobuf/drop_unknown_fields_test.cc", |
| 389 | "src/google/protobuf/dynamic_message_unittest.cc", |
| 390 | "src/google/protobuf/extension_set_unittest.cc", |
| 391 | "src/google/protobuf/generated_message_reflection_unittest.cc", |
| 392 | "src/google/protobuf/io/coded_stream_unittest.cc", |
| 393 | "src/google/protobuf/io/printer_unittest.cc", |
| 394 | "src/google/protobuf/io/tokenizer_unittest.cc", |
| 395 | "src/google/protobuf/io/zero_copy_stream_unittest.cc", |
| 396 | "src/google/protobuf/map_field_test.cc", |
| 397 | "src/google/protobuf/map_test.cc", |
| 398 | "src/google/protobuf/message_unittest.cc", |
| 399 | "src/google/protobuf/no_field_presence_test.cc", |
| 400 | "src/google/protobuf/preserve_unknown_enum_test.cc", |
| 401 | "src/google/protobuf/proto3_arena_unittest.cc", |
| 402 | "src/google/protobuf/reflection_ops_unittest.cc", |
| 403 | "src/google/protobuf/repeated_field_reflection_unittest.cc", |
| 404 | "src/google/protobuf/repeated_field_unittest.cc", |
| 405 | "src/google/protobuf/stubs/bytestream_unittest.cc", |
| 406 | "src/google/protobuf/stubs/common_unittest.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 407 | "src/google/protobuf/stubs/int128_unittest.cc", |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 408 | "src/google/protobuf/stubs/once_unittest.cc", |
| 409 | "src/google/protobuf/stubs/status_test.cc", |
| 410 | "src/google/protobuf/stubs/statusor_test.cc", |
| 411 | "src/google/protobuf/stubs/stringpiece_unittest.cc", |
| 412 | "src/google/protobuf/stubs/stringprintf_unittest.cc", |
| 413 | "src/google/protobuf/stubs/structurally_valid_unittest.cc", |
| 414 | "src/google/protobuf/stubs/strutil_unittest.cc", |
| 415 | "src/google/protobuf/stubs/template_util_unittest.cc", |
| 416 | "src/google/protobuf/stubs/time_test.cc", |
| 417 | "src/google/protobuf/stubs/type_traits_unittest.cc", |
| 418 | "src/google/protobuf/text_format_unittest.cc", |
| 419 | "src/google/protobuf/unknown_field_set_unittest.cc", |
| 420 | "src/google/protobuf/util/field_comparator_test.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 421 | "src/google/protobuf/util/field_mask_util_test.cc", |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 422 | "src/google/protobuf/util/internal/default_value_objectwriter_test.cc", |
| 423 | "src/google/protobuf/util/internal/json_objectwriter_test.cc", |
| 424 | "src/google/protobuf/util/internal/json_stream_parser_test.cc", |
| 425 | "src/google/protobuf/util/internal/protostream_objectsource_test.cc", |
| 426 | "src/google/protobuf/util/internal/protostream_objectwriter_test.cc", |
| 427 | "src/google/protobuf/util/internal/type_info_test_helper.cc", |
| 428 | "src/google/protobuf/util/json_util_test.cc", |
Jisi Liu | b90f9f8 | 2015-08-25 17:06:33 -0700 | [diff] [blame] | 429 | "src/google/protobuf/util/time_util_test.cc", |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 430 | "src/google/protobuf/util/type_resolver_util_test.cc", |
| 431 | "src/google/protobuf/well_known_types_unittest.cc", |
| 432 | "src/google/protobuf/wire_format_unittest.cc", |
| 433 | ], |
| 434 | copts = COPTS, |
| 435 | data = [ |
| 436 | ":test_plugin", |
Jisi Liu | 598480d | 2015-10-21 11:19:16 -0700 | [diff] [blame] | 437 | ] + glob([ |
| 438 | "src/google/protobuf/**/*", |
| 439 | ]), |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 440 | includes = [ |
| 441 | "src/", |
| 442 | ], |
| 443 | linkopts = LINK_OPTS, |
| 444 | deps = [ |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 445 | ":cc_test_protos", |
Jisi Liu | 7a0c431 | 2015-06-18 16:45:27 -0700 | [diff] [blame] | 446 | ":protobuf", |
| 447 | ":protoc_lib", |
| 448 | "//external:gtest_main", |
| 449 | ], |
| 450 | ) |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 451 | |
| 452 | ################################################################################ |
| 453 | # Java support |
| 454 | ################################################################################ |
| 455 | genrule( |
| 456 | name = "generate_java_descriptor_proto", |
| 457 | srcs = ["src/google/protobuf/descriptor.proto"], |
| 458 | outs = ["com/google/protobuf/DescriptorProtos.java"], |
| 459 | cmd = "$(location :protoc) --java_out=$(@D)/../../.. $<", |
| 460 | tools = [":protoc"], |
| 461 | ) |
| 462 | |
| 463 | java_library( |
Jisi Liu | 166e9bb | 2015-10-21 10:56:38 -0700 | [diff] [blame] | 464 | name = "protobuf_java", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 465 | srcs = glob([ |
| 466 | "java/src/main/java/com/google/protobuf/*.java", |
| 467 | ]) + [ |
| 468 | ":generate_java_descriptor_proto", |
| 469 | ], |
| 470 | visibility = ["//visibility:public"], |
| 471 | ) |
| 472 | |
| 473 | ################################################################################ |
| 474 | # Python support |
| 475 | ################################################################################ |
| 476 | |
Jisi Liu | 7b948cc | 2015-10-19 17:56:27 -0700 | [diff] [blame] | 477 | # Hack: |
| 478 | # protoc generated files contain imports like: |
| 479 | # "from google.protobuf.xxx import yyy" |
| 480 | # However, the sources files of the python runtime are not directly under |
| 481 | # "google/protobuf" (they are under python/google/protobuf). We workaround |
| 482 | # this by copying runtime source files into the desired location to workaround |
| 483 | # the import issue. Ideally py_library should support something similiar to the |
| 484 | # "include" attribute in cc_library to inject the PYTHON_PATH for all libraries |
| 485 | # that depend on the target. |
| 486 | # |
| 487 | # If you use python protobuf as a third_party library in your bazel managed |
Jisi Liu | e1f60f5 | 2015-10-22 13:55:37 -0700 | [diff] [blame] | 488 | # project: |
| 489 | # 1) Please import the whole package to //google/protobuf in your |
Jisi Liu | 7b948cc | 2015-10-19 17:56:27 -0700 | [diff] [blame] | 490 | # project. Otherwise, bazel disallows generated files out of the current |
| 491 | # package, thus we won't be able to copy protobuf runtime files into |
| 492 | # //google/protobuf/. |
Jisi Liu | e1f60f5 | 2015-10-22 13:55:37 -0700 | [diff] [blame] | 493 | # 2) The runtime also requires "six" for Python2/3 compatibility, please see the |
| 494 | # WORKSPACE file and bind "six" to your workspace as well. |
Jisi Liu | bc4fd15 | 2015-10-20 16:02:58 -0700 | [diff] [blame] | 495 | internal_copied_filegroup( |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 496 | name = "python_srcs", |
| 497 | srcs = glob( |
| 498 | [ |
| 499 | "python/google/protobuf/*.py", |
| 500 | "python/google/protobuf/**/*.py", |
| 501 | ], |
| 502 | exclude = [ |
| 503 | "python/google/protobuf/internal/*_test.py", |
| 504 | "python/google/protobuf/internal/test_util.py", |
| 505 | ], |
| 506 | ), |
| 507 | include = "python", |
| 508 | ) |
| 509 | |
| 510 | py_proto_library( |
Jisi Liu | 166e9bb | 2015-10-21 10:56:38 -0700 | [diff] [blame] | 511 | name = "protobuf_python", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 512 | srcs = WELL_KNOWN_PROTOS, |
| 513 | include = "src", |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 514 | protoc = ":protoc", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 515 | py_extra_srcs = [":python_srcs"], |
Jisi Liu | fbc51b7 | 2015-10-22 13:38:17 -0700 | [diff] [blame] | 516 | py_libs = ["//external:six"], |
Jisi Liu | be92ffb | 2015-10-27 15:11:38 -0700 | [diff] [blame] | 517 | default_runtime = "", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 518 | visibility = ["//visibility:public"], |
| 519 | ) |
| 520 | |
Jisi Liu | bc4fd15 | 2015-10-20 16:02:58 -0700 | [diff] [blame] | 521 | internal_copied_filegroup( |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 522 | name = "python_test_srcs", |
| 523 | srcs = glob( |
| 524 | [ |
| 525 | "python/google/protobuf/internal/*_test.py", |
| 526 | "python/google/protobuf/internal/test_util.py", |
| 527 | ], |
| 528 | ), |
| 529 | include = "python", |
| 530 | ) |
| 531 | |
| 532 | py_proto_library( |
| 533 | name = "python_common_test_protos", |
| 534 | srcs = LITE_TEST_PROTOS + TEST_PROTOS, |
| 535 | include = "src", |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 536 | protoc = ":protoc", |
Jisi Liu | 166e9bb | 2015-10-21 10:56:38 -0700 | [diff] [blame] | 537 | deps = [":protobuf_python"], |
Jisi Liu | be92ffb | 2015-10-27 15:11:38 -0700 | [diff] [blame] | 538 | default_runtime = "", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 539 | ) |
| 540 | |
| 541 | py_proto_library( |
| 542 | name = "python_specific_test_protos", |
Jisi Liu | 68e13f4 | 2015-10-22 11:13:14 -0700 | [diff] [blame] | 543 | srcs = glob([ |
| 544 | "python/google/protobuf/internal/*.proto", |
| 545 | "python/google/protobuf/internal/import_test_package/*.proto", |
| 546 | ]), |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 547 | include = "python", |
Jisi Liu | 04658a3 | 2015-10-20 15:00:13 -0700 | [diff] [blame] | 548 | protoc = ":protoc", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 549 | deps = [":python_common_test_protos"], |
Jisi Liu | be92ffb | 2015-10-27 15:11:38 -0700 | [diff] [blame] | 550 | default_runtime = ":protobuf_python", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 551 | ) |
| 552 | |
| 553 | py_library( |
| 554 | name = "python_tests", |
| 555 | srcs = [":python_test_srcs"], |
| 556 | deps = [ |
Jisi Liu | 166e9bb | 2015-10-21 10:56:38 -0700 | [diff] [blame] | 557 | ":protobuf_python", |
Jisi Liu | 598480d | 2015-10-21 11:19:16 -0700 | [diff] [blame] | 558 | ":python_common_test_protos", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 559 | ":python_specific_test_protos", |
| 560 | ], |
| 561 | ) |
| 562 | |
| 563 | internal_protobuf_py_tests( |
Jisi Liu | 8f54026 | 2015-10-20 16:21:41 -0700 | [diff] [blame] | 564 | name = "python_tests_batch", |
Jisi Liu | 68e13f4 | 2015-10-22 11:13:14 -0700 | [diff] [blame] | 565 | data = glob([ |
| 566 | "src/google/protobuf/**/*", |
| 567 | ]), |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 568 | modules = [ |
| 569 | "descriptor_database_test", |
| 570 | "descriptor_pool_test", |
| 571 | "descriptor_test", |
| 572 | "generator_test", |
| 573 | "json_format_test", |
| 574 | "message_factory_test", |
Jisi Liu | 68e13f4 | 2015-10-22 11:13:14 -0700 | [diff] [blame] | 575 | "message_test", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 576 | "proto_builder_test", |
Jisi Liu | 68e13f4 | 2015-10-22 11:13:14 -0700 | [diff] [blame] | 577 | "reflection_test", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 578 | "service_reflection_test", |
| 579 | "symbol_database_test", |
| 580 | "text_encoding_test", |
Jisi Liu | 68e13f4 | 2015-10-22 11:13:14 -0700 | [diff] [blame] | 581 | "text_format_test", |
Jisi Liu | 993fb70 | 2015-10-19 17:19:49 -0700 | [diff] [blame] | 582 | "unknown_fields_test", |
| 583 | "wire_format_test", |
| 584 | ], |
| 585 | deps = [":python_tests"], |
| 586 | ) |