Check in upb bootstrap gencode for future cmake usage

PiperOrigin-RevId: 613757614
pull/16102/head
Mike Kruskal 9 months ago committed by Copybara-Service
parent cdb0345d16
commit 58312a6f2e
  1. 20
      regenerate_stale_files.sh
  2. 29
      upb_generator/bootstrap_compiler.bzl

@ -12,13 +12,21 @@ cd $(dirname -- "$0")
readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}" 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. # Run and fix all staleness tests.
${BazelBin} test src:cmake_lists_staleness_test "$@" || ./bazel-bin/src/cmake_lists_staleness_test --fix for test in $STALENESS_TESTS; do
${BazelBin} test src/google/protobuf:well_known_types_staleness_test "$@" || ./bazel-bin/src/google/protobuf/well_known_types_staleness_test --fix ${BazelBin} test $test "$@" || ./bazel-bin/${test%%:*}/${test#*:} --fix
${BazelBin} test objectivec:well_known_types_staleness_test "$@" || ./bazel-bin/objectivec/well_known_types_staleness_test --fix done
${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
# Generate C# code. # Generate C# code.
# This doesn't currently have Bazel staleness tests, but there's an existing # 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): def _generated_srcs_for_generator(prefix, srcs, generator):
ret = _generated_srcs_for_suffix(prefix, srcs, ".{}.h".format(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)) ret += _generated_srcs_for_suffix(prefix, srcs, ".{}.c".format(generator))
return ret return ret
@ -72,7 +72,7 @@ def _stage0_proto_staleness_test(name, base_dir, src_files, src_rules, strip_pre
) )
staleness_test( staleness_test(
name = name + "_staleness_test", name = name + "_stage0_staleness_test",
outs = _generated_srcs(base_dir + "stage0", src_files), outs = _generated_srcs(base_dir + "stage0", src_files),
generated_pattern = "bootstrap_generated_sources/%s", generated_pattern = "bootstrap_generated_sources/%s",
target_files = native.glob([base_dir + "stage0/**"]), 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 **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( def bootstrap_upb_proto_library(
name, name,
base_dir, base_dir,
@ -187,3 +207,8 @@ def bootstrap_upb_proto_library(
visibility = visibility, visibility = visibility,
**kwargs **kwargs
) )
# begin:github_only
_cmake_staleness_test(name, base_dir, src_files)
# end:github_only

Loading…
Cancel
Save