Automate dependency on inputs of genrule module type.
This change automates one of the best practices for custom tools. The best practice says "Prefer to list input files on the command line, otherwise we may not know to re-run your command when a new input file is added." [1] Normally you'd reference these inputs with $(in) or one of the forms of the $(location*) substituions on the command line for the custom tool. However, if the custom tool does not accept the list of inputs on the command line, the build system could fail to re-run the custom tool if the list changes. This change adds a hash of the list of input names to the sbox command that wraps the custom tool. If the list of inputs change, the hash will change, and therefore the sbox command will change, causing ninja to re-run the custom tool. The hash is visible to (but ignored by) the sbox command, and hidden from your custom tool. [1] https://android.googlesource.com/platform/build/soong/+/refs/heads/master/docs/best_practices.md#custom-build-tools Test: TestGenruleHashInputs Bug: 149397658 Change-Id: I18b547ea3c4296ee15bd6150a4778a8f376d80b7
This commit is contained in:
@@ -36,6 +36,7 @@ var (
|
||||
outputRoot string
|
||||
keepOutDir bool
|
||||
depfileOut string
|
||||
inputHash string
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -51,6 +52,8 @@ func init() {
|
||||
flag.StringVar(&depfileOut, "depfile-out", "",
|
||||
"file path of the depfile to generate. This value will replace '__SBOX_DEPFILE__' in the command and will be treated as an output but won't be added to __SBOX_OUT_FILES__")
|
||||
|
||||
flag.StringVar(&inputHash, "input-hash", "",
|
||||
"This option is ignored. Typical usage is to supply a hash of the list of input names so that the module will be rebuilt if the list (and thus the hash) changes.")
|
||||
}
|
||||
|
||||
func usageViolation(violation string) {
|
||||
@@ -59,7 +62,7 @@ func usageViolation(violation string) {
|
||||
}
|
||||
|
||||
fmt.Fprintf(os.Stderr,
|
||||
"Usage: sbox -c <commandToRun> --sandbox-path <sandboxPath> --output-root <outputRoot> [--depfile-out depFile] <outputFile> [<outputFile>...]\n"+
|
||||
"Usage: sbox -c <commandToRun> --sandbox-path <sandboxPath> --output-root <outputRoot> [--depfile-out depFile] [--input-hash hash] <outputFile> [<outputFile>...]\n"+
|
||||
"\n"+
|
||||
"Deletes <outputRoot>,"+
|
||||
"runs <commandToRun>,"+
|
||||
|
Reference in New Issue
Block a user