Make null builds always be null builds.
Previously, soong.environment.used was written after build.ninja and if the amount of time that passed between the two was long enough, Ninja would decide that build.ninja is older than soong.environment.used and rebuild it. Test: test_null_build in bootstrap_test.sh in a loop. Change-Id: I5467da487e8e8f2646644b8a7fb9549b9ff18276
This commit is contained in:
parent
b6535d329f
commit
c99c947c88
1 changed files with 14 additions and 2 deletions
|
@ -21,6 +21,7 @@ import (
|
|||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"android/soong/shared"
|
||||
"github.com/google/blueprint/bootstrap"
|
||||
|
@ -191,13 +192,24 @@ func main() {
|
|||
func writeUsedVariablesFile(path string, configuration android.Config) {
|
||||
data, err := shared.EnvFileContents(configuration.EnvDeps())
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error writing used variables file %s: %s", path, err)
|
||||
fmt.Fprintf(os.Stderr, "error writing used variables file %s: %s\n", path, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(path, data, 0666)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error writing used variables file %s: %s", path, err)
|
||||
fmt.Fprintf(os.Stderr, "error writing used variables file %s: %s\n", path, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
|
||||
// Touch the output Ninja 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.
|
||||
outputNinjaFile := shared.JoinPath(topDir, bootstrap.CmdlineOutFile())
|
||||
currentTime := time.Now().Local()
|
||||
err = os.Chtimes(outputNinjaFile, currentTime, currentTime)
|
||||
if err != nil {
|
||||
fmt.Fprintf(os.Stderr, "error touching output file %s: %s\n", outputNinjaFile, err)
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue