summaryrefslogtreecommitdiff
path: root/BUILD
diff options
context:
space:
mode:
authorJoshua Haberman <jhaberman@gmail.com>2019-06-02 20:36:42 -0700
committerJoshua Haberman <jhaberman@gmail.com>2019-06-02 20:36:42 -0700
commit583f24fec1f3773b86168db2d2e4f95f36c3324d (patch)
treec15ac3932d77d55269eb19ec72b2887b6571ba35 /BUILD
parent932753d91e183ab25cf1a0f420d9488295002297 (diff)
parent9f49efef6203973931894a4ed9b862b3e3d639f0 (diff)
Merge branch 'master' into rmreflective
Diffstat (limited to 'BUILD')
-rw-r--r--BUILD262
1 files changed, 149 insertions, 113 deletions
diff --git a/BUILD b/BUILD
index b54e0be..11156c8 100644
--- a/BUILD
+++ b/BUILD
@@ -1,5 +1,5 @@
load(
- ":build_defs.bzl",
+ "//bazel:build_defs.bzl",
"generated_file_staleness_test",
"licenses", # copybara:strip_for_google3
"lua_binary",
@@ -7,8 +7,11 @@ load(
"lua_library",
"lua_test",
"make_shell_script",
- "map_dep",
"upb_amalgamation",
+)
+
+load(
+ "//bazel:upb_proto_library.bzl",
"upb_proto_library",
"upb_proto_reflection_library",
)
@@ -45,18 +48,14 @@ config_setting(
cc_library(
name = "upb",
srcs = [
- "google/protobuf/descriptor.upb.c",
"upb/decode.c",
"upb/encode.c",
"upb/msg.c",
- "upb/port_def.inc",
- "upb/port_undef.inc",
"upb/table.c",
"upb/table.int.h",
"upb/upb.c",
],
hdrs = [
- "google/protobuf/descriptor.upb.h",
"upb/decode.h",
"upb/encode.h",
"upb/generated_util.h",
@@ -64,6 +63,17 @@ cc_library(
"upb/upb.h",
],
copts = COPTS,
+ # Internal-only, but we have to make them public for generated code.
+ textual_hdrs = [
+ "upb/port_def.inc",
+ "upb/port_undef.inc",
+ ],
+ visibility = ["//visibility:public"],
+)
+
+upb_proto_library(
+ name = "descriptor_upbproto",
+ deps = ["@com_google_protobuf//:descriptor_proto"],
visibility = ["//visibility:public"],
)
@@ -79,7 +89,11 @@ cc_library(
],
copts = COPTS,
visibility = ["//visibility:public"],
- deps = [":upb"],
+ deps = [
+ ":descriptor_upbproto",
+ ":table",
+ ":upb",
+ ],
)
# Internal C/C++ libraries #####################################################
@@ -98,8 +112,11 @@ cc_library(
"upb/legacy_msg_reflection.c",
],
hdrs = ["upb/legacy_msg_reflection.h"],
- deps = [":upb"],
copts = COPTS,
+ deps = [
+ ":table",
+ ":upb",
+ ],
)
cc_library(
@@ -116,6 +133,7 @@ cc_library(
copts = COPTS,
deps = [
":reflection",
+ ":table",
":upb",
],
)
@@ -138,12 +156,15 @@ cc_library(
],
copts = COPTS,
deps = [
+ ":descriptor_upbproto",
":handlers",
+ ":reflection",
":table",
":upb",
],
)
+# copybara:strip_for_google3_begin
cc_library(
name = "upb_json",
srcs = [
@@ -160,13 +181,18 @@ cc_library(
":upb_pb",
],
)
+# copybara:strip_end
cc_library(
name = "upb_cc_bindings",
hdrs = [
"upb/bindings/stdc++/string.h",
],
- deps = [":upb"],
+ deps = [
+ ":descriptor_upbproto",
+ ":handlers",
+ ":upb",
+ ],
)
# upb compiler #################################################################
@@ -179,30 +205,30 @@ cc_library(
"upbc/message_layout.h",
],
hdrs = ["upbc/generator.h"],
+ copts = CPPOPTS,
deps = [
- map_dep("@absl//absl/base:core_headers"),
- map_dep("@absl//absl/strings"),
- map_dep("@com_google_protobuf//:protobuf"),
- map_dep("@com_google_protobuf//:protoc_lib"),
+ "@absl//absl/base:core_headers",
+ "@absl//absl/container:flat_hash_map",
+ "@absl//absl/strings",
+ "@com_google_protobuf//:protobuf",
+ "@com_google_protobuf//:protoc_lib",
],
- copts = CPPOPTS,
)
cc_binary(
name = "protoc-gen-upb",
srcs = ["upbc/main.cc"],
+ copts = CPPOPTS,
+ visibility = ["//visibility:public"],
deps = [
":upbc_generator",
- map_dep("@com_google_protobuf//:protoc_lib"),
+ "@com_google_protobuf//:protoc_lib",
],
- copts = CPPOPTS,
)
# We strip the tests and remaining rules from google3 until the upb_proto_library()
# and upb_proto_reflection_library() rules are fixed.
-# copybara:strip_for_google3_begin
-
# C/C++ tests ##################################################################
cc_library(
@@ -216,16 +242,24 @@ cc_library(
"tests/upb_test.h",
],
copts = CPPOPTS,
+ deps = [
+ ":handlers",
+ ":upb",
+ ],
)
cc_test(
name = "test_varint",
- srcs = ["tests/pb/test_varint.c"],
+ srcs = [
+ "tests/pb/test_varint.c",
+ "upb/pb/varint.int.h",
+ ],
+ copts = COPTS,
deps = [
+ ":upb",
":upb_pb",
":upb_test",
],
- copts = COPTS,
)
proto_library(
@@ -237,31 +271,23 @@ proto_library(
upb_proto_reflection_library(
name = "test_decoder_upbproto",
- upbc = ":protoc-gen-upb",
- deps = ["test_decoder_proto"],
+ deps = [":test_decoder_proto"],
)
cc_test(
name = "test_decoder",
- srcs = ["tests/pb/test_decoder.cc"],
- deps = [
- ":test_decoder_upbproto",
- ":upb_pb",
- ":upb_test",
+ srcs = [
+ "tests/pb/test_decoder.cc",
+ "upb/pb/varint.int.h",
],
copts = CPPOPTS,
-)
-
-cc_test(
- name = "test_encoder",
- srcs = ["tests/pb/test_encoder.cc"],
- data = ["google/protobuf/descriptor.pb"],
deps = [
- ":upb_cc_bindings",
+ ":handlers",
+ ":test_decoder_upbproto",
+ ":upb",
":upb_pb",
":upb_test",
],
- copts = CPPOPTS,
)
proto_library(
@@ -273,50 +299,78 @@ proto_library(
upb_proto_reflection_library(
name = "test_cpp_upbproto",
- upbc = ":protoc-gen-upb",
deps = ["test_cpp_proto"],
)
cc_test(
name = "test_cpp",
srcs = ["tests/test_cpp.cc"],
+ copts = CPPOPTS,
deps = [
+ ":handlers",
+ ":reflection",
":test_cpp_upbproto",
":upb",
":upb_pb",
":upb_test",
],
- copts = CPPOPTS,
)
cc_test(
name = "test_table",
srcs = ["tests/test_table.cc"],
+ copts = CPPOPTS,
deps = [
+ ":table",
":upb",
":upb_test",
],
+)
+
+# copybara:strip_for_google3_begin
+upb_proto_reflection_library(
+ name = "descriptor_upbreflection",
+ deps = ["@com_google_protobuf//:descriptor_proto"],
+)
+
+cc_test(
+ name = "test_encoder",
+ srcs = ["tests/pb/test_encoder.cc"],
copts = CPPOPTS,
+ deps = [
+ ":descriptor_upbproto",
+ ":descriptor_upbreflection",
+ ":upb",
+ ":upb_cc_bindings",
+ ":upb_pb",
+ ":upb_test",
+ ],
+)
+
+proto_library(
+ name = "test_json_enum_from_separate",
+ srcs = ["tests/json/enum_from_separate_file.proto"],
+ deps = [":test_json_proto"],
)
proto_library(
name = "test_json_proto",
- srcs = [
- "tests/json/test.proto",
- # "tests/json/enum_from_separate_file.proto",
- ],
+ srcs = ["tests/json/test.proto"],
)
upb_proto_reflection_library(
name = "test_json_upbprotoreflection",
- upbc = ":protoc-gen-upb",
deps = ["test_json_proto"],
)
upb_proto_library(
+ name = "test_json_enum_from_separate_upbproto",
+ deps = [":test_json_enum_from_separate"],
+)
+
+upb_proto_library(
name = "test_json_upbproto",
- upbc = ":protoc-gen-upb",
- deps = ["test_json_proto"],
+ deps = [":test_json_proto"],
)
cc_test(
@@ -324,31 +378,38 @@ cc_test(
srcs = [
"tests/json/test_json.cc",
],
+ copts = CPPOPTS,
deps = [
+ ":test_json_upbproto",
":test_json_upbprotoreflection",
":upb_json",
":upb_test",
],
- copts = CPPOPTS,
)
+# copybara:strip_end
upb_proto_library(
name = "conformance_proto_upb",
- upbc = ":protoc-gen-upb",
- deps = [
- "@com_google_protobuf//:conformance_proto",
- "@com_google_protobuf//:test_messages_proto3_proto",
- ],
+ testonly = 1,
+ deps = ["@com_google_protobuf//:conformance_proto"],
+)
+
+upb_proto_library(
+ name = "test_messages_proto3_proto_upb",
+ testonly = 1,
+ deps = ["@com_google_protobuf//:test_messages_proto3_proto"],
)
cc_binary(
name = "conformance_upb",
+ testonly = 1,
srcs = [
"tests/conformance_upb.c",
],
copts = COPTS + ["-Ibazel-out/k8-fastbuild/bin"],
deps = [
":conformance_proto_upb",
+ ":test_messages_proto3_proto_upb",
":upb",
],
)
@@ -356,7 +417,7 @@ cc_binary(
make_shell_script(
name = "gen_test_conformance_upb",
out = "test_conformance_upb.sh",
- contents = "$(rlocation com_google_protobuf/conformance_test_runner) $(rlocation upb/conformance_upb)",
+ contents = "external/com_google_protobuf/conformance_test_runner ./conformance_upb",
)
sh_test(
@@ -365,11 +426,12 @@ sh_test(
data = [
"tests/conformance_upb_failures.txt",
":conformance_upb",
- "@bazel_tools//tools/bash/runfiles",
"@com_google_protobuf//:conformance_test_runner",
],
)
+# copybara:strip_for_google3_begin
+
# Amalgamation #################################################################
py_binary(
@@ -386,6 +448,7 @@ upb_amalgamation(
amalgamator = ":amalgamate",
libs = [
":upb",
+ ":descriptor_upbproto",
":reflection",
":handlers",
":upb_pb",
@@ -459,24 +522,28 @@ lua_test(
# Test the CMake build #########################################################
+filegroup(
+ name = "cmake_files",
+ srcs = glob([
+ "CMakeLists.txt",
+ "generated_for_cmake/**/*",
+ "google/**/*",
+ "upbc/**/*",
+ "upb/**/*",
+ "tests/**/*",
+ ]),
+)
+
make_shell_script(
name = "gen_run_cmake_build",
out = "run_cmake_build.sh",
- contents = "mkdir build && cd build && cmake .. && make -j8 && make test",
+ contents = "find . && mkdir build && cd build && cmake .. && make -j8 && make test",
)
sh_test(
name = "cmake_build",
srcs = ["run_cmake_build.sh"],
- data = glob([
- "CMakeLists.txt",
- "google/**/*",
- "upbc/**/*",
- "upb/**/*",
- "tests/**/*",
- ]) + [
- "@bazel_tools//tools/bash/runfiles",
- ],
+ data = [":cmake_files"],
)
# Generated files ##############################################################
@@ -499,78 +566,47 @@ genrule(
srcs = [
"BUILD",
"WORKSPACE",
+ ":cmake_files",
],
- outs = ["generated/CMakeLists.txt"],
+ outs = ["generated-in/CMakeLists.txt"],
cmd = "$(location :make_cmakelists) $@",
tools = [":make_cmakelists"],
)
-proto_library(
- name = "descriptor_proto",
- srcs = [
- "google/protobuf/descriptor.proto",
- ],
+genrule(
+ name = "generate_json_ragel",
+ srcs = ["upb/json/parser.rl"],
+ outs = ["upb/json/parser.c"],
+ cmd = "$(location @ragel//:ragelc) -C -o upb/json/parser.c $< && mv upb/json/parser.c $@",
+ tools = ["@ragel//:ragelc"],
)
genrule(
- name = "copy_upb_descriptor_pb",
- srcs = [":descriptor_proto"],
- outs = ["generated/google/protobuf/descriptor.pb"],
+ name = "copy_json_ragel",
+ srcs = ["upb/json/parser.c"],
+ outs = ["generated-in/generated_for_cmake/upb/json/parser.c"],
cmd = "cp $< $@",
)
-proto_library(
- name = "google_descriptor_proto",
- srcs = [
- "google/protobuf/descriptor.proto",
- ],
-)
-
genrule(
- name = "generate_descriptor_c",
- srcs = ["google/protobuf/descriptor.proto"],
+ name = "copy_protos",
+ srcs = [":descriptor_upbproto"],
outs = [
- "generated/google/protobuf/descriptor.upb.h",
- "generated/google/protobuf/descriptor.upb.c",
+ "generated-in/generated_for_cmake/google/protobuf/descriptor.upb.c",
+ "generated-in/generated_for_cmake/google/protobuf/descriptor.upb.h",
],
- cmd = "$(location @com_google_protobuf//:protoc) $< --upb_out=$(GENDIR)/generated --plugin=protoc-gen-upb=$(location :protoc-gen-upb)",
- tools = [
- ":protoc-gen-upb",
- "@com_google_protobuf//:protoc",
- ],
-)
-
-proto_library(
- name = "json_test_proto",
- srcs = ["tests/json/test.proto"],
-)
-
-genrule(
- name = "copy_json_test_proto",
- srcs = [":json_test_proto"],
- outs = ["generated/tests/json/test.proto.pb"],
- cmd = "cp $< $@",
-)
-
-genrule(
- name = "generate_json_ragel",
- srcs = ["upb/json/parser.rl"],
- outs = ["generated/upb/json/parser.c"],
- cmd = "$(location @ragel//:ragel) -C -o upb/json/parser.c $< && mv upb/json/parser.c $@",
- tools = ["@ragel"],
+ cmd = "cp $(SRCS) $(@D)/generated-in/generated_for_cmake/google/protobuf",
)
generated_file_staleness_test(
name = "test_generated_files",
outs = [
"CMakeLists.txt",
- "google/protobuf/descriptor.pb",
- "google/protobuf/descriptor.upb.c",
- "google/protobuf/descriptor.upb.h",
- "tests/json/test.proto.pb",
- "upb/json/parser.c",
+ "generated_for_cmake/google/protobuf/descriptor.upb.c",
+ "generated_for_cmake/google/protobuf/descriptor.upb.h",
+ "generated_for_cmake/upb/json/parser.c",
],
- generated_pattern = "generated/%s",
+ generated_pattern = "generated-in/%s",
)
# copybara:strip_end
generated by cgit on debian on lair
contact matthew@masot.net with questions or feedback