|
|
@ -1,15 +1,32 @@ |
|
|
|
load( |
|
|
|
load( |
|
|
|
":build_defs.bzl", |
|
|
|
":build_defs.bzl", |
|
|
|
|
|
|
|
"licenses", # copybara:strip_for_google3 |
|
|
|
"lua_cclibrary", |
|
|
|
"lua_cclibrary", |
|
|
|
"lua_library", |
|
|
|
"lua_library", |
|
|
|
"lua_binary", |
|
|
|
"lua_binary", |
|
|
|
"lua_test", |
|
|
|
"lua_test", |
|
|
|
"generated_file_staleness_test", |
|
|
|
"generated_file_staleness_test", |
|
|
|
"make_shell_script", |
|
|
|
"make_shell_script", |
|
|
|
|
|
|
|
"map_dep", |
|
|
|
"upb_amalgamation", |
|
|
|
"upb_amalgamation", |
|
|
|
"upb_proto_library", |
|
|
|
"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 ################################################################## |
|
|
|
# C/C++ rules ################################################################## |
|
|
|
|
|
|
|
|
|
|
|
cc_library( |
|
|
|
cc_library( |
|
|
@ -46,11 +63,7 @@ cc_library( |
|
|
|
"upb/sink.h", |
|
|
|
"upb/sink.h", |
|
|
|
"upb/upb.h", |
|
|
|
"upb/upb.h", |
|
|
|
], |
|
|
|
], |
|
|
|
copts = [ |
|
|
|
copts = COPTS, |
|
|
|
"-std=c89", |
|
|
|
|
|
|
|
"-pedantic", |
|
|
|
|
|
|
|
"-Wno-long-long", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
visibility = ["//visibility:public"], |
|
|
|
visibility = ["//visibility:public"], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -64,11 +77,7 @@ cc_library( |
|
|
|
"upb/descriptor/descriptor.upbdefs.h", |
|
|
|
"upb/descriptor/descriptor.upbdefs.h", |
|
|
|
"upb/descriptor/reader.h", |
|
|
|
"upb/descriptor/reader.h", |
|
|
|
], |
|
|
|
], |
|
|
|
copts = [ |
|
|
|
copts = COPTS, |
|
|
|
"-std=c89", |
|
|
|
|
|
|
|
"-pedantic", |
|
|
|
|
|
|
|
"-Wno-long-long", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
deps = [":upb"], |
|
|
|
deps = [":upb"], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -83,6 +92,7 @@ cc_library( |
|
|
|
"upb/pb/textprinter.c", |
|
|
|
"upb/pb/textprinter.c", |
|
|
|
"upb/pb/varint.c", |
|
|
|
"upb/pb/varint.c", |
|
|
|
"upb/pb/varint.int.h", |
|
|
|
"upb/pb/varint.int.h", |
|
|
|
|
|
|
|
"upb/table.int.h", |
|
|
|
], |
|
|
|
], |
|
|
|
hdrs = [ |
|
|
|
hdrs = [ |
|
|
|
"upb/pb/decoder.h", |
|
|
|
"upb/pb/decoder.h", |
|
|
@ -90,11 +100,7 @@ cc_library( |
|
|
|
"upb/pb/glue.h", |
|
|
|
"upb/pb/glue.h", |
|
|
|
"upb/pb/textprinter.h", |
|
|
|
"upb/pb/textprinter.h", |
|
|
|
], |
|
|
|
], |
|
|
|
copts = [ |
|
|
|
copts = COPTS, |
|
|
|
"-std=c89", |
|
|
|
|
|
|
|
"-pedantic", |
|
|
|
|
|
|
|
"-Wno-long-long", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
deps = [ |
|
|
|
deps = [ |
|
|
|
":upb", |
|
|
|
":upb", |
|
|
|
":upb_descriptor", |
|
|
|
":upb_descriptor", |
|
|
@ -111,11 +117,7 @@ cc_library( |
|
|
|
"upb/json/parser.h", |
|
|
|
"upb/json/parser.h", |
|
|
|
"upb/json/printer.h", |
|
|
|
"upb/json/printer.h", |
|
|
|
], |
|
|
|
], |
|
|
|
copts = [ |
|
|
|
copts = COPTS, |
|
|
|
"-std=c89", |
|
|
|
|
|
|
|
"-pedantic", |
|
|
|
|
|
|
|
"-Wno-long-long", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
deps = [ |
|
|
|
deps = [ |
|
|
|
":upb", |
|
|
|
":upb", |
|
|
|
":upb_pb", |
|
|
|
":upb_pb", |
|
|
@ -130,32 +132,43 @@ cc_library( |
|
|
|
deps = [":upb"], |
|
|
|
deps = [":upb"], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# Amalgamation ################################################################# |
|
|
|
# upb compiler ################################################################# |
|
|
|
|
|
|
|
|
|
|
|
py_binary( |
|
|
|
cc_library( |
|
|
|
name = "amalgamate", |
|
|
|
name = "upbc_generator", |
|
|
|
srcs = ["tools/amalgamate.py"], |
|
|
|
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( |
|
|
|
cc_binary( |
|
|
|
name = "gen_amalgamation", |
|
|
|
name = "protoc-gen-upb", |
|
|
|
outs = [ |
|
|
|
srcs = ["upbc/main.cc"], |
|
|
|
"upb.c", |
|
|
|
deps = [ |
|
|
|
"upb.h", |
|
|
|
":upbc_generator", |
|
|
|
], |
|
|
|
map_dep("@com_google_protobuf//:protoc_lib"), |
|
|
|
amalgamator = ":amalgamate", |
|
|
|
|
|
|
|
libs = [ |
|
|
|
|
|
|
|
":upb", |
|
|
|
|
|
|
|
":upb_descriptor", |
|
|
|
|
|
|
|
":upb_pb", |
|
|
|
|
|
|
|
":upb_json", |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
cc_library( |
|
|
|
# We strip the tests and remaining rules from google3 until the upb_proto_library() |
|
|
|
name = "amalgamation", |
|
|
|
# and upb_proto_reflection_library() rules are fixed. |
|
|
|
srcs = ["upb.c"], |
|
|
|
|
|
|
|
hdrs = ["upb.h"], |
|
|
|
# copybara:strip_for_google3_begin |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
lua_binary( |
|
|
|
|
|
|
|
name = "lua_upbc", |
|
|
|
|
|
|
|
luadeps = [ |
|
|
|
|
|
|
|
"lua/upbc_lib", |
|
|
|
|
|
|
|
], |
|
|
|
|
|
|
|
luamain = "tools/upbc.lua", |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
# C/C++ tests ################################################################## |
|
|
|
# C/C++ tests ################################################################## |
|
|
@ -266,11 +279,11 @@ cc_binary( |
|
|
|
srcs = [ |
|
|
|
srcs = [ |
|
|
|
"tests/conformance_upb.c", |
|
|
|
"tests/conformance_upb.c", |
|
|
|
], |
|
|
|
], |
|
|
|
|
|
|
|
copts = ["-Ibazel-out/k8-fastbuild/bin"], |
|
|
|
deps = [ |
|
|
|
deps = [ |
|
|
|
":conformance_proto_upb", |
|
|
|
":conformance_proto_upb", |
|
|
|
":upb", |
|
|
|
":upb", |
|
|
|
], |
|
|
|
], |
|
|
|
copts = ["-Ibazel-out/k8-fastbuild/bin"], |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
make_shell_script( |
|
|
|
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 libraries. ############################################################### |
|
|
|
|
|
|
|
|
|
|
|
lua_cclibrary( |
|
|
|
lua_cclibrary( |
|
|
@ -375,42 +417,12 @@ lua_test( |
|
|
|
luamain = "tests/bindings/lua/test_upb.pb.lua", |
|
|
|
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 ######################################################### |
|
|
|
# Test the CMake build ######################################################### |
|
|
|
|
|
|
|
|
|
|
|
make_shell_script( |
|
|
|
make_shell_script( |
|
|
|
name = "gen_run_cmake_build", |
|
|
|
name = "gen_run_cmake_build", |
|
|
|
out = "run_cmake_build.sh", |
|
|
|
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( |
|
|
|
sh_test( |
|
|
@ -464,10 +476,13 @@ py_binary( |
|
|
|
|
|
|
|
|
|
|
|
genrule( |
|
|
|
genrule( |
|
|
|
name = "gen_cmakelists", |
|
|
|
name = "gen_cmakelists", |
|
|
|
|
|
|
|
srcs = [ |
|
|
|
|
|
|
|
"BUILD", |
|
|
|
|
|
|
|
"WORKSPACE", |
|
|
|
|
|
|
|
], |
|
|
|
outs = ["generated/CMakeLists.txt"], |
|
|
|
outs = ["generated/CMakeLists.txt"], |
|
|
|
srcs = ["BUILD", "WORKSPACE"], |
|
|
|
cmd = "$(location :make_cmakelists) $@", |
|
|
|
tools = [":make_cmakelists"], |
|
|
|
tools = [":make_cmakelists"], |
|
|
|
cmd = "$(location :make_cmakelists) $@" |
|
|
|
|
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
genrule( |
|
|
|
genrule( |
|
|
@ -511,8 +526,8 @@ genrule( |
|
|
|
], |
|
|
|
], |
|
|
|
cmd = "$(location @com_google_protobuf//:protoc) $< --upb_out=$(GENDIR)/generated --plugin=protoc-gen-upb=$(location :protoc-gen-upb)", |
|
|
|
cmd = "$(location @com_google_protobuf//:protoc) $< --upb_out=$(GENDIR)/generated --plugin=protoc-gen-upb=$(location :protoc-gen-upb)", |
|
|
|
tools = [ |
|
|
|
tools = [ |
|
|
|
|
|
|
|
":protoc-gen-upb", |
|
|
|
"@com_google_protobuf//:protoc", |
|
|
|
"@com_google_protobuf//:protoc", |
|
|
|
":protoc-gen-upb" |
|
|
|
|
|
|
|
], |
|
|
|
], |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
@ -564,3 +579,5 @@ generated_file_staleness_test( |
|
|
|
], |
|
|
|
], |
|
|
|
generated_pattern = "generated/%s", |
|
|
|
generated_pattern = "generated/%s", |
|
|
|
) |
|
|
|
) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# copybara:strip_end |
|
|
|