Make globs compatible with hash-based ninja semantics
Previously, globs worked by having soong_build rewrite a ninja file that ran the globs, and then dependended on the results of that ninja file. soong_build also pre-filled their outputs so that it wouldn't be immediately rerun on the 2nd build. However, the pre-filling of outputs worked for ninja, because although it updated their timestamps, the soong ninja file was then touched by soong_build after that, so the soong_build ninja file was newer and ninja wouldn't rerun soong. But N2 reruns actions if their inputs' mtimes change in any way, not just if they're newer. Similarly, hashed-based ninja implementations could not enforce an order on file contents, so they would have the same problem. To fix this, lift the glob checking out of ninja and into soong_ui. Soong_build will output a globs report file every time it's run, and every time soong_ui is run it will check the globs file, and if any globs change, update an input to soong_build. soong_ui is essentially doing what was done in ninja with bpglob actions before. Bug: 364749114 Test: m nothing, m nothing again doesn't reanalyze, create a new file under a glob directory, m nothing again reanalyzes Change-Id: I0dbc5ec58c89b869b59cd0602b82215c4972d799
This commit is contained in:
@@ -145,36 +145,19 @@ EOF
|
||||
run_soong
|
||||
local -r ninja_mtime1=$(stat -c "%y" out/soong/build."${target_product}".ninja)
|
||||
|
||||
local glob_deps_file=out/soong/globs/"${target_product}"/0.d
|
||||
|
||||
run_soong
|
||||
local -r ninja_mtime2=$(stat -c "%y" out/soong/build."${target_product}".ninja)
|
||||
|
||||
# There is an ineffiencency in glob that requires bpglob to rerun once for each glob to update
|
||||
# the entry in the .ninja_log. It doesn't update the output file, but we can detect the rerun
|
||||
# by checking if the deps file was created.
|
||||
if [ ! -e "$glob_deps_file" ]; then
|
||||
fail "Glob deps file missing after second build"
|
||||
fi
|
||||
|
||||
local -r glob_deps_mtime2=$(stat -c "%y" "$glob_deps_file")
|
||||
|
||||
if [[ "$ninja_mtime1" != "$ninja_mtime2" ]]; then
|
||||
fail "Ninja file rewritten on null incremental build"
|
||||
fi
|
||||
|
||||
run_soong
|
||||
local -r ninja_mtime3=$(stat -c "%y" out/soong/build."${target_product}".ninja)
|
||||
local -r glob_deps_mtime3=$(stat -c "%y" "$glob_deps_file")
|
||||
|
||||
if [[ "$ninja_mtime2" != "$ninja_mtime3" ]]; then
|
||||
fail "Ninja file rewritten on null incremental build"
|
||||
fi
|
||||
|
||||
# The bpglob commands should not rerun after the first incremental build.
|
||||
if [[ "$glob_deps_mtime2" != "$glob_deps_mtime3" ]]; then
|
||||
fail "Glob deps file rewritten on second null incremental build"
|
||||
fi
|
||||
}
|
||||
|
||||
function test_add_file_to_glob() {
|
||||
|
Reference in New Issue
Block a user