Loading cmd/soong_build/main.go +8 −7 Original line number Diff line number Diff line Loading @@ -443,10 +443,16 @@ func main() { } writeMetrics(configuration, ctx.EventHandler, metricsDir) } writeUsedEnvironmentFile(configuration, finalOutputFile) writeUsedEnvironmentFile(configuration) // Touch the output file so that it's the newest file created by soong_build. // This is necessary because, if soong_build generated any files which // are ninja inputs to the main output file, then ninja would superfluously // rebuild this output file on the next build invocation. touch(shared.JoinPath(topDir, finalOutputFile)) } func writeUsedEnvironmentFile(configuration android.Config, finalOutputFile string) { func writeUsedEnvironmentFile(configuration android.Config) { if usedEnvFile == "" { return } Loading @@ -465,11 +471,6 @@ func writeUsedEnvironmentFile(configuration android.Config, finalOutputFile stri } err = os.WriteFile(path, data, 0666) maybeQuit(err, "error writing used environment file '%s'", usedEnvFile) // Touch the output file so that it's not older than the file we just // wrote. We can't write the environment file earlier because one an access // new environment variables while writing it. touch(shared.JoinPath(topDir, finalOutputFile)) } func touch(path string) { Loading tests/bootstrap_test.sh +33 −0 Original line number Diff line number Diff line Loading @@ -885,4 +885,37 @@ function test_queryview_null_build() { fi } # This test verifies that adding a new glob to a blueprint file only # causes build.ninja to be regenerated on the *next* build, and *not* # the build after. (This is a regression test for a bug where globs # resulted in two successive regenerations.) function test_new_glob_incrementality { setup run_soong nothing local -r mtime1=$(stat -c "%y" out/soong/build.ninja) mkdir -p globdefpkg/ cat > globdefpkg/Android.bp <<'EOF' filegroup { name: "fg_with_glob", srcs: ["*.txt"], } EOF run_soong nothing local -r mtime2=$(stat -c "%y" out/soong/build.ninja) if [[ "$mtime1" == "$mtime2" ]]; then fail "Ninja file was not regenerated, despite a new bp file" fi run_soong nothing local -r mtime3=$(stat -c "%y" out/soong/build.ninja) if [[ "$mtime2" != "$mtime3" ]]; then fail "Ninja file was regenerated despite no previous bp changes" fi } scan_and_run_tests Loading
cmd/soong_build/main.go +8 −7 Original line number Diff line number Diff line Loading @@ -443,10 +443,16 @@ func main() { } writeMetrics(configuration, ctx.EventHandler, metricsDir) } writeUsedEnvironmentFile(configuration, finalOutputFile) writeUsedEnvironmentFile(configuration) // Touch the output file so that it's the newest file created by soong_build. // This is necessary because, if soong_build generated any files which // are ninja inputs to the main output file, then ninja would superfluously // rebuild this output file on the next build invocation. touch(shared.JoinPath(topDir, finalOutputFile)) } func writeUsedEnvironmentFile(configuration android.Config, finalOutputFile string) { func writeUsedEnvironmentFile(configuration android.Config) { if usedEnvFile == "" { return } Loading @@ -465,11 +471,6 @@ func writeUsedEnvironmentFile(configuration android.Config, finalOutputFile stri } err = os.WriteFile(path, data, 0666) maybeQuit(err, "error writing used environment file '%s'", usedEnvFile) // Touch the output file so that it's not older than the file we just // wrote. We can't write the environment file earlier because one an access // new environment variables while writing it. touch(shared.JoinPath(topDir, finalOutputFile)) } func touch(path string) { Loading
tests/bootstrap_test.sh +33 −0 Original line number Diff line number Diff line Loading @@ -885,4 +885,37 @@ function test_queryview_null_build() { fi } # This test verifies that adding a new glob to a blueprint file only # causes build.ninja to be regenerated on the *next* build, and *not* # the build after. (This is a regression test for a bug where globs # resulted in two successive regenerations.) function test_new_glob_incrementality { setup run_soong nothing local -r mtime1=$(stat -c "%y" out/soong/build.ninja) mkdir -p globdefpkg/ cat > globdefpkg/Android.bp <<'EOF' filegroup { name: "fg_with_glob", srcs: ["*.txt"], } EOF run_soong nothing local -r mtime2=$(stat -c "%y" out/soong/build.ninja) if [[ "$mtime1" == "$mtime2" ]]; then fail "Ninja file was not regenerated, despite a new bp file" fi run_soong nothing local -r mtime3=$(stat -c "%y" out/soong/build.ninja) if [[ "$mtime2" != "$mtime3" ]]; then fail "Ninja file was regenerated despite no previous bp changes" fi } scan_and_run_tests