Actually write an empty ninja file with --empty-ninja-file

Otherwise we'll re-run the primary builder every time this is used. This
triggered my new ninja checks that verify that all commands write their
outputs.

Change-Id: Ic92d1ea57203b953da8025a170b24e6420c5436c
This commit is contained in:
Dan Willemsen 2020-04-19 12:50:48 -07:00
parent 6957a46d38
commit 6c6c103612

View file

@ -183,6 +183,12 @@ func Main(ctx *blueprint.Context, config interface{}, extraNinjaFileDeps ...stri
var f *os.File var f *os.File
var buf *bufio.Writer var buf *bufio.Writer
if emptyNinjaFile {
if err := ioutil.WriteFile(absolutePath(outFile), []byte(nil), outFilePermissions); err != nil {
fatalf("error writing empty Ninja file: %s", err)
}
}
if stage != StageMain || !emptyNinjaFile { if stage != StageMain || !emptyNinjaFile {
f, err = os.OpenFile(absolutePath(outFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions) f, err = os.OpenFile(absolutePath(outFile), os.O_WRONLY|os.O_CREATE|os.O_TRUNC, outFilePermissions)
if err != nil { if err != nil {