1#!/bin/bash 2 3# This script runs the staleness tests and uses them to update any stale 4# generated files. 5 6set -ex 7 8echo "::group::Regenerate stale files" 9 10# Cd to the repo root. 11cd $(dirname -- "$0") 12 13readonly BazelBin="${BAZEL:-bazel} ${BAZEL_STARTUP_FLAGS}" 14 15STALENESS_TESTS=( 16 "java/core:generated_java_defaults_staleness_test" 17 "upb/reflection:bootstrap_upb_defaults_staleness_test" 18 "src:cmake_lists_staleness_test" 19 "src/google/protobuf:well_known_types_staleness_test" 20 "objectivec:well_known_types_staleness_test" 21 "php:test_amalgamation_staleness" 22 "ruby/ext/google/protobuf_c:test_amalgamation_staleness" 23 "upb/cmake:test_generated_files" 24 "upb/reflection:descriptor_upb_proto_staleness_test" 25 "upb_generator:plugin_upb_proto_staleness_test" 26) 27 28# Run and fix all staleness tests. 29for test in ${STALENESS_TESTS[@]}; do 30 ${BazelBin} test $test "$@" || ./bazel-bin/${test%%:*}/${test#*:} --fix 31done 32 33# Generate C# code. 34# This doesn't currently have Bazel staleness tests, but there's an existing 35# shell script that generates everything required. The output files are stable, 36# so just regenerating in place should be harmless. 37${BazelBin} build src/google/protobuf/compiler:protoc "$@" 38(export PROTOC=$PWD/bazel-bin/protoc && cd csharp && ./generate_protos.sh) 39 40echo "::endgroup::" 41