diff --git a/regenerate_stale_files.sh b/regenerate_stale_files.sh index c96693ac10..eaff025e8d 100755 --- a/regenerate_stale_files.sh +++ b/regenerate_stale_files.sh @@ -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 diff --git a/upb_generator/bootstrap_compiler.bzl b/upb_generator/bootstrap_compiler.bzl index a1d8671153..1c3f3ee7b4 100644 --- a/upb_generator/bootstrap_compiler.bzl +++ b/upb_generator/bootstrap_compiler.bzl @@ -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