|
|
|
@ -1,15 +1,32 @@ |
|
|
|
|
load( |
|
|
|
|
":build_defs.bzl", |
|
|
|
|
"licenses", # copybara:strip_for_google3 |
|
|
|
|
"lua_cclibrary", |
|
|
|
|
"lua_library", |
|
|
|
|
"lua_binary", |
|
|
|
|
"lua_test", |
|
|
|
|
"generated_file_staleness_test", |
|
|
|
|
"make_shell_script", |
|
|
|
|
"map_dep", |
|
|
|
|
"upb_amalgamation", |
|
|
|
|
"upb_proto_library", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
licenses(["notice"]) # BSD (Google-authored w/ possible external contributions) |
|
|
|
|
|
|
|
|
|
exports_files([ |
|
|
|
|
"LICENSE", |
|
|
|
|
"build_defs", |
|
|
|
|
]) |
|
|
|
|
|
|
|
|
|
COPTS = [ |
|
|
|
|
# copybara:strip_for_google3_begin |
|
|
|
|
"-std=c89", |
|
|
|
|
"-pedantic", |
|
|
|
|
"-Wno-long-long", |
|
|
|
|
# copybara:strip_end |
|
|
|
|
] |
|
|
|
|
|
|
|
|
|
# C/C++ rules ################################################################## |
|
|
|
|
|
|
|
|
|
cc_library( |
|
|
|
@ -46,11 +63,7 @@ cc_library( |
|
|
|
|
"upb/sink.h", |
|
|
|
|
"upb/upb.h", |
|
|
|
|
], |
|
|
|
|
copts = [ |
|
|
|
|
"-std=c89", |
|
|
|
|
"-pedantic", |
|
|
|
|
"-Wno-long-long", |
|
|
|
|
], |
|
|
|
|
copts = COPTS, |
|
|
|
|
visibility = ["//visibility:public"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -64,11 +77,7 @@ cc_library( |
|
|
|
|
"upb/descriptor/descriptor.upbdefs.h", |
|
|
|
|
"upb/descriptor/reader.h", |
|
|
|
|
], |
|
|
|
|
copts = [ |
|
|
|
|
"-std=c89", |
|
|
|
|
"-pedantic", |
|
|
|
|
"-Wno-long-long", |
|
|
|
|
], |
|
|
|
|
copts = COPTS, |
|
|
|
|
deps = [":upb"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -83,6 +92,7 @@ cc_library( |
|
|
|
|
"upb/pb/textprinter.c", |
|
|
|
|
"upb/pb/varint.c", |
|
|
|
|
"upb/pb/varint.int.h", |
|
|
|
|
"upb/table.int.h", |
|
|
|
|
], |
|
|
|
|
hdrs = [ |
|
|
|
|
"upb/pb/decoder.h", |
|
|
|
@ -90,11 +100,7 @@ cc_library( |
|
|
|
|
"upb/pb/glue.h", |
|
|
|
|
"upb/pb/textprinter.h", |
|
|
|
|
], |
|
|
|
|
copts = [ |
|
|
|
|
"-std=c89", |
|
|
|
|
"-pedantic", |
|
|
|
|
"-Wno-long-long", |
|
|
|
|
], |
|
|
|
|
copts = COPTS, |
|
|
|
|
deps = [ |
|
|
|
|
":upb", |
|
|
|
|
":upb_descriptor", |
|
|
|
@ -111,11 +117,7 @@ cc_library( |
|
|
|
|
"upb/json/parser.h", |
|
|
|
|
"upb/json/printer.h", |
|
|
|
|
], |
|
|
|
|
copts = [ |
|
|
|
|
"-std=c89", |
|
|
|
|
"-pedantic", |
|
|
|
|
"-Wno-long-long", |
|
|
|
|
], |
|
|
|
|
copts = COPTS, |
|
|
|
|
deps = [ |
|
|
|
|
":upb", |
|
|
|
|
":upb_pb", |
|
|
|
@ -130,32 +132,43 @@ cc_library( |
|
|
|
|
deps = [":upb"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Amalgamation ################################################################# |
|
|
|
|
# upb compiler ################################################################# |
|
|
|
|
|
|
|
|
|
py_binary( |
|
|
|
|
name = "amalgamate", |
|
|
|
|
srcs = ["tools/amalgamate.py"], |
|
|
|
|
cc_library( |
|
|
|
|
name = "upbc_generator", |
|
|
|
|
srcs = [ |
|
|
|
|
"upbc/generator.cc", |
|
|
|
|
"upbc/message_layout.cc", |
|
|
|
|
"upbc/message_layout.h", |
|
|
|
|
], |
|
|
|
|
hdrs = ["upbc/generator.h"], |
|
|
|
|
deps = [ |
|
|
|
|
map_dep("@absl//absl/strings"), |
|
|
|
|
map_dep("@com_google_protobuf//:protobuf"), |
|
|
|
|
map_dep("@com_google_protobuf//:protoc_lib"), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
upb_amalgamation( |
|
|
|
|
name = "gen_amalgamation", |
|
|
|
|
outs = [ |
|
|
|
|
"upb.c", |
|
|
|
|
"upb.h", |
|
|
|
|
], |
|
|
|
|
amalgamator = ":amalgamate", |
|
|
|
|
libs = [ |
|
|
|
|
":upb", |
|
|
|
|
":upb_descriptor", |
|
|
|
|
":upb_pb", |
|
|
|
|
":upb_json", |
|
|
|
|
cc_binary( |
|
|
|
|
name = "protoc-gen-upb", |
|
|
|
|
srcs = ["upbc/main.cc"], |
|
|
|
|
deps = [ |
|
|
|
|
":upbc_generator", |
|
|
|
|
map_dep("@com_google_protobuf//:protoc_lib"), |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
cc_library( |
|
|
|
|
name = "amalgamation", |
|
|
|
|
srcs = ["upb.c"], |
|
|
|
|
hdrs = ["upb.h"], |
|
|
|
|
# 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 |
|
|
|
|
|
|
|
|
|
lua_binary( |
|
|
|
|
name = "lua_upbc", |
|
|
|
|
luadeps = [ |
|
|
|
|
"lua/upbc_lib", |
|
|
|
|
], |
|
|
|
|
luamain = "tools/upbc.lua", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# C/C++ tests ################################################################## |
|
|
|
@ -266,11 +279,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( |
|
|
|
@ -290,6 +303,35 @@ sh_test( |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Amalgamation ################################################################# |
|
|
|
|
|
|
|
|
|
py_binary( |
|
|
|
|
name = "amalgamate", |
|
|
|
|
srcs = ["tools/amalgamate.py"], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
upb_amalgamation( |
|
|
|
|
name = "gen_amalgamation", |
|
|
|
|
outs = [ |
|
|
|
|
"upb.c", |
|
|
|
|
"upb.h", |
|
|
|
|
], |
|
|
|
|
amalgamator = ":amalgamate", |
|
|
|
|
libs = [ |
|
|
|
|
":upb", |
|
|
|
|
":upb_descriptor", |
|
|
|
|
":upb_pb", |
|
|
|
|
":upb_json", |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
cc_library( |
|
|
|
|
name = "amalgamation", |
|
|
|
|
srcs = ["upb.c"], |
|
|
|
|
hdrs = ["upb.h"], |
|
|
|
|
copts = COPTS, |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Lua libraries. ############################################################### |
|
|
|
|
|
|
|
|
|
lua_cclibrary( |
|
|
|
@ -375,42 +417,12 @@ lua_test( |
|
|
|
|
luamain = "tests/bindings/lua/test_upb.pb.lua", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# upb compiler ################################################################# |
|
|
|
|
|
|
|
|
|
lua_binary( |
|
|
|
|
name = "lua_upbc", |
|
|
|
|
luadeps = [ |
|
|
|
|
"lua/upbc_lib", |
|
|
|
|
], |
|
|
|
|
luamain = "tools/upbc.lua", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
cc_library( |
|
|
|
|
name = "upbc_generator", |
|
|
|
|
hdrs = ["upbc/generator.h"], |
|
|
|
|
srcs = ["upbc/generator.cc", "upbc/message_layout.h", "upbc/message_layout.cc"], |
|
|
|
|
deps = [ |
|
|
|
|
"@com_google_protobuf//:protobuf", |
|
|
|
|
"@com_google_protobuf//:protoc_lib", |
|
|
|
|
"@absl//absl/strings", |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
cc_binary( |
|
|
|
|
name = "protoc-gen-upb", |
|
|
|
|
srcs = ["upbc/main.cc"], |
|
|
|
|
deps = [ |
|
|
|
|
":upbc_generator", |
|
|
|
|
"@com_google_protobuf//:protoc_lib", |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# Test the CMake build ######################################################### |
|
|
|
|
|
|
|
|
|
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( |
|
|
|
@ -464,10 +476,13 @@ py_binary( |
|
|
|
|
|
|
|
|
|
genrule( |
|
|
|
|
name = "gen_cmakelists", |
|
|
|
|
srcs = [ |
|
|
|
|
"BUILD", |
|
|
|
|
"WORKSPACE", |
|
|
|
|
], |
|
|
|
|
outs = ["generated/CMakeLists.txt"], |
|
|
|
|
srcs = ["BUILD", "WORKSPACE"], |
|
|
|
|
cmd = "$(location :make_cmakelists) $@", |
|
|
|
|
tools = [":make_cmakelists"], |
|
|
|
|
cmd = "$(location :make_cmakelists) $@" |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
genrule( |
|
|
|
@ -511,8 +526,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" |
|
|
|
|
], |
|
|
|
|
) |
|
|
|
|
|
|
|
|
@ -564,3 +579,5 @@ generated_file_staleness_test( |
|
|
|
|
], |
|
|
|
|
generated_pattern = "generated/%s", |
|
|
|
|
) |
|
|
|
|
|
|
|
|
|
# copybara:strip_end |
|
|
|
|