diff options
Diffstat (limited to 'BUILD')
-rw-r--r-- | BUILD | 220 |
1 files changed, 87 insertions, 133 deletions
@@ -1,13 +1,19 @@ load( ":build_defs.bzl", + "generated_file_staleness_test", + "lua_binary", "lua_cclibrary", "lua_library", - "lua_binary", "lua_test", - "generated_file_staleness_test", "make_shell_script", "upb_amalgamation", "upb_proto_library", + "upb_proto_reflection_library", +) + +config_setting( + name = "k8", + values = {"cpu": "k8"}, ) # C/C++ rules ################################################################## @@ -25,9 +31,7 @@ cc_library( "upb/msgfactory.c", "upb/port_def.inc", "upb/port_undef.inc", - "upb/refcounted.c", "upb/sink.c", - "upb/structdefs.int.h", "upb/structs.int.h", "upb/table.c", "upb/table.int.h", @@ -42,7 +46,6 @@ cc_library( "upb/handlers.h", "upb/msg.h", "upb/msgfactory.h", - "upb/refcounted.h", "upb/sink.h", "upb/upb.h", ], @@ -55,49 +58,39 @@ cc_library( ) cc_library( - name = "upb_descriptor", - srcs = [ - "upb/descriptor/descriptor.upbdefs.c", - "upb/descriptor/reader.c", - ], - hdrs = [ - "upb/descriptor/descriptor.upbdefs.h", - "upb/descriptor/reader.h", - ], - copts = [ - "-std=c89", - "-pedantic", - "-Wno-long-long", - ], - deps = [":upb"], -) - -cc_library( name = "upb_pb", srcs = [ "upb/pb/compile_decoder.c", "upb/pb/decoder.c", "upb/pb/decoder.int.h", "upb/pb/encoder.c", - "upb/pb/glue.c", "upb/pb/textprinter.c", "upb/pb/varint.c", "upb/pb/varint.int.h", - ], + ] + select({ + ":k8": [ + "upb/pb/compile_decoder_x64.c", + "upb/pb/compile_decoder_x64.h", + "third_party/dynasm/dasm_proto.h", + "third_party/dynasm/dasm_x86.h", + ], + "//conditions:default": [], + }), hdrs = [ "upb/pb/decoder.h", "upb/pb/encoder.h", - "upb/pb/glue.h", "upb/pb/textprinter.h", ], copts = [ "-std=c89", "-pedantic", "-Wno-long-long", - ], + ] + select({ + ":k8": ["-DUPB_USE_JIT_X64"], + "//conditions:default": [], + }), deps = [ ":upb", - ":upb_descriptor", ], ) @@ -146,7 +139,6 @@ upb_amalgamation( amalgamator = ":amalgamate", libs = [ ":upb", - ":upb_descriptor", ":upb_pb", ":upb_json", ], @@ -181,28 +173,30 @@ cc_test( ], ) -cc_test( - name = "test_def", - srcs = ["tests/test_def.c"], - deps = [ - ":upb_pb", - ":upb_test", - ], +upb_proto_reflection_library( + name = "descriptor_upbproto", + upbc = ":protoc-gen-upb", + deps = ["descriptor_proto"], ) -cc_test( - name = "test_handlers", - srcs = ["tests/test_handlers.c"], - deps = [ - ":upb_pb", - ":upb_test", +proto_library( + name = "test_decoder_proto", + srcs = [ + "tests/pb/test_decoder.proto", ], ) +upb_proto_reflection_library( + name = "test_decoder_upbproto", + upbc = ":protoc-gen-upb", + deps = ["test_decoder_proto"], +) + cc_test( name = "test_decoder", srcs = ["tests/pb/test_decoder.cc"], deps = [ + ":test_decoder_upbproto", ":upb_pb", ":upb_test", ], @@ -211,7 +205,7 @@ cc_test( cc_test( name = "test_encoder", srcs = ["tests/pb/test_encoder.cc"], - data = ["upb/descriptor/descriptor.pb"], + data = ["google/protobuf/descriptor.pb"], deps = [ ":upb_cc_bindings", ":upb_pb", @@ -219,12 +213,25 @@ cc_test( ], ) +proto_library( + name = "test_cpp_proto", + srcs = [ + "tests/test_cpp.proto", + ], +) + +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"], deps = [ + ":test_cpp_upbproto", ":upb", - ":upb_descriptor", ":upb_pb", ":upb_test", ], @@ -239,14 +246,24 @@ cc_test( ], ) +proto_library( + name = "test_json_proto", + srcs = ["tests/json/test.proto"], +) + +upb_proto_reflection_library( + name = "test_json_upbproto", + upbc = ":protoc-gen-upb", + deps = ["test_json_proto"], +) + cc_test( name = "test_json", srcs = [ - "tests/json/test.upbdefs.c", - "tests/json/test.upbdefs.h", "tests/json/test_json.cc", ], deps = [ + ":test_json_upbproto", ":upb_json", ":upb_test", ], @@ -266,11 +283,11 @@ cc_binary( srcs = [ "tests/conformance_upb.c", ], + copts = ["-Ibazel-out/k8-fastbuild/bin"], deps = [ ":conformance_proto_upb", ":upb", ], - copts = ["-Ibazel-out/k8-fastbuild/bin"], ) make_shell_script( @@ -316,23 +333,6 @@ lua_library( ) lua_cclibrary( - name = "lua/upb/table_c", - srcs = ["upb/bindings/lua/upb/table.c"], - luadeps = ["lua/upb_c"], - deps = ["upb"], -) - -lua_library( - name = "lua/upb/table", - srcs = ["upb/bindings/lua/upb/table.lua"], - luadeps = [ - "lua/upb", - "lua/upb/table_c", - ], - strip_prefix = "upb/bindings/lua", -) - -lua_cclibrary( name = "lua/upb/pb_c", srcs = ["upb/bindings/lua/upb/pb.c"], luadeps = ["lua/upb_c"], @@ -349,18 +349,6 @@ lua_library( strip_prefix = "upb/bindings/lua", ) -lua_library( - name = "lua/upbc_lib", - srcs = [ - "tools/dump_cinit.lua", - ], - luadeps = [ - "lua/upb", - "lua/upb/table", - ], - strip_prefix = "tools", -) - # Lua tests. ################################################################### lua_test( @@ -377,22 +365,18 @@ lua_test( # upb compiler ################################################################# -lua_binary( - name = "lua_upbc", - luadeps = [ - "lua/upbc_lib", - ], - luamain = "tools/upbc.lua", -) - cc_library( name = "upbc_generator", + srcs = [ + "upbc/generator.cc", + "upbc/message_layout.cc", + "upbc/message_layout.h", + ], hdrs = ["upbc/generator.h"], - srcs = ["upbc/generator.cc", "upbc/message_layout.h", "upbc/message_layout.cc"], deps = [ + "@absl//absl/strings", "@com_google_protobuf//:protobuf", "@com_google_protobuf//:protoc_lib", - "@absl//absl/strings", ], ) @@ -410,7 +394,7 @@ cc_binary( make_shell_script( name = "gen_run_cmake_build", out = "run_cmake_build.sh", - contents = "mkdir build && cd build && cmake .. && make -j8 && make test" + contents = "mkdir build && cd build && cmake .. && make -j8 && make test", ) sh_test( @@ -450,42 +434,34 @@ genrule( tools = ["@lua"], ) -proto_library( - name = "upb_descriptor_proto", - srcs = [ - "upb/descriptor/descriptor.proto", - ], -) - py_binary( name = "make_cmakelists", srcs = ["tools/make_cmakelists.py"], ) -genrule( - name = "gen_cmakelists", - outs = ["generated/CMakeLists.txt"], - srcs = ["BUILD", "WORKSPACE"], - tools = [":make_cmakelists"], - cmd = "$(location :make_cmakelists) $@" +proto_library( + name = "descriptor_proto", + srcs = [ + "google/protobuf/descriptor.proto", + ], ) genrule( name = "copy_upb_descriptor_pb", - srcs = [":upb_descriptor_proto"], - outs = ["generated/upb/descriptor/descriptor.pb"], + srcs = [":descriptor_proto"], + outs = ["generated/google/protobuf/descriptor.pb"], cmd = "cp $< $@", ) genrule( - name = "generate_old_upbdefs", - srcs = ["generated/upb/descriptor/descriptor.pb"], - outs = [ - "generated/upb/descriptor/descriptor.upbdefs.h", - "generated/upb/descriptor/descriptor.upbdefs.c", + name = "gen_cmakelists", + srcs = [ + "BUILD", + "WORKSPACE", ], - cmd = "UPBC=$$PWD/$(location :lua_upbc); INFILE=$$PWD/$<; cd $(GENDIR)/generated && $$UPBC --generate-upbdefs $$INFILE", - tools = [":lua_upbc"], + outs = ["generated/CMakeLists.txt"], + cmd = "$(location :make_cmakelists) $@", + tools = [":make_cmakelists"], ) proto_library( @@ -496,13 +472,6 @@ proto_library( ) genrule( - name = "copy_google_descriptor_pb", - srcs = [":google_descriptor_proto"], - outs = ["generated/google/protobuf/descriptor.pb"], - cmd = "cp $< $@", -) - -genrule( name = "generate_descriptor_c", srcs = ["google/protobuf/descriptor.proto"], outs = [ @@ -511,8 +480,8 @@ genrule( ], 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", - ":protoc-gen-upb" ], ) @@ -529,17 +498,6 @@ genrule( ) genrule( - name = "generated_json_test_proto_upbdefs", - srcs = ["generated/tests/json/test.proto.pb"], - outs = [ - "generated/tests/json/test.upbdefs.h", - "generated/tests/json/test.upbdefs.c", - ], - cmd = "UPBC=$$PWD/$(location :lua_upbc); INFILE=$$PWD/$<; cd $(GENDIR)/generated && $$UPBC --generate-upbdefs $$INFILE", - tools = [":lua_upbc"], -) - -genrule( name = "generate_json_ragel", srcs = ["upb/json/parser.rl"], outs = ["generated/upb/json/parser.c"], @@ -551,14 +509,10 @@ 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", - "tests/json/test.upbdefs.c", - "tests/json/test.upbdefs.h", - "upb/descriptor/descriptor.pb", - "upb/descriptor/descriptor.upbdefs.c", - "upb/descriptor/descriptor.upbdefs.h", "upb/json/parser.c", "upb/pb/compile_decoder_x64.h", ], |