mirror of
https://github.com/protocolbuffers/protobuf
synced 2026-08-26 02:23:14 -04:00
Check in upb bootstrap gencode for future cmake usage
PiperOrigin-RevId: 613757614
This commit is contained in:
parent
cdb0345d16
commit
58312a6f2e
2 changed files with 41 additions and 8 deletions
|
|
@ -12,13 +12,21 @@ cd $(dirname -- "$0")
|
|||
|
||||
readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}"
|
||||
|
||||
STALENESS_TESTS=(
|
||||
"src:cmake_lists_staleness_test"
|
||||
"src/google/protobuf:well_known_types_staleness_test"
|
||||
"objectivec:well_known_types_staleness_test"
|
||||
"php:test_amalgamation_staleness"
|
||||
"ruby/ext/google/protobuf_c:test_amalgamation_staleness"
|
||||
"upb/cmake:test_generated_files"
|
||||
"upb/upb_generator:plugin_upb_proto_staleness_test"
|
||||
"upb/reflection:descriptor_upb_proto_staleness_test"
|
||||
)
|
||||
|
||||
# Run and fix all staleness tests.
|
||||
${BazelBin} test src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix
|
||||
${BazelBin} test src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix
|
||||
${BazelBin} test objectivec:well_known_types_staleness_test "$@" || ./bazel-bin/objectivec/well_known_types_staleness_test --fix
|
||||
${BazelBin} test php:test_amalgamation_staleness "$@" || ./bazel-bin/php/test_amalgamation_staleness --fix
|
||||
${BazelBin} test ruby/ext/google/protobuf_c:test_amalgamation_staleness "$@" || ./bazel-bin/ruby/ext/google/protobuf_c/test_amalgamation_staleness --fix
|
||||
${BazelBin} test upb/cmake:test_generated_files "$@" || ./bazel-bin/upb/cmake/test_generated_files --fix
|
||||
for test in $STALENESS_TESTS; do
|
||||
${BazelBin} test $test "$@" || ./bazel-bin/${test%%:*}/${test#*:} --fix
|
||||
done
|
||||
|
||||
# Generate C# code.
|
||||
# This doesn't currently have Bazel staleness tests, but there's an existing
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ def _generated_srcs_for_suffix(prefix, srcs, suffix):
|
|||
def _generated_srcs_for_generator(prefix, srcs, generator):
|
||||
ret = _generated_srcs_for_suffix(prefix, srcs, ".{}.h".format(generator))
|
||||
|
||||
if not (generator == "upb" and prefix.endswith("stage1")):
|
||||
if generator != "upb" or prefix.endswith("stage0"):
|
||||
ret += _generated_srcs_for_suffix(prefix, srcs, ".{}.c".format(generator))
|
||||
return ret
|
||||
|
||||
|
|
@ -72,7 +72,7 @@ def _stage0_proto_staleness_test(name, base_dir, src_files, src_rules, strip_pre
|
|||
)
|
||||
|
||||
staleness_test(
|
||||
name = name + "_staleness_test",
|
||||
name = name + "_stage0_staleness_test",
|
||||
outs = _generated_srcs(base_dir + "stage0", src_files),
|
||||
generated_pattern = "bootstrap_generated_sources/%s",
|
||||
target_files = native.glob([base_dir + "stage0/**"]),
|
||||
|
|
@ -101,6 +101,26 @@ def _generate_stage1_proto(name, base_dir, src_files, src_rules, generator, kwar
|
|||
**kwargs
|
||||
)
|
||||
|
||||
# begin:github_only
|
||||
def _cmake_staleness_test(name, base_dir, src_files):
|
||||
# Copy the final gencode for staleness comparison
|
||||
native.genrule(
|
||||
name = name + "_copy_gencode",
|
||||
outs = _generated_srcs("generated_sources/cmake" + base_dir, src_files),
|
||||
srcs = [name],
|
||||
cmd = "for src in $(SRCS); do cp -f $$src $(@D); done",
|
||||
)
|
||||
|
||||
# Keep bazel gencode in sync with our checked-in sources needed for cmake builds.
|
||||
staleness_test(
|
||||
name = name + "_staleness_test",
|
||||
outs = _generated_srcs("cmake" + base_dir, src_files),
|
||||
generated_pattern = "generated_sources/%s",
|
||||
tags = ["manual"],
|
||||
)
|
||||
|
||||
# end:github_only
|
||||
|
||||
def bootstrap_upb_proto_library(
|
||||
name,
|
||||
base_dir,
|
||||
|
|
@ -187,3 +207,8 @@ def bootstrap_upb_proto_library(
|
|||
visibility = visibility,
|
||||
**kwargs
|
||||
)
|
||||
|
||||
# begin:github_only
|
||||
_cmake_staleness_test(name, base_dir, src_files)
|
||||
|
||||
# end:github_only
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue