From 6587beddfa79ee06db08625a3673f6b97d7a68bd Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Sat, 18 Apr 2020 20:25:59 -0700 Subject: [PATCH] Turn on ninja phony outputs This replaces the _kati_always_build_ hack with a ninja feature so that ninja can actually understand what's happening. This means that we can turn on some more options and checks around expected output filenames: * Remove the output file(s) before the command executes * Error if the output file(s) don't exist after the execution * Error if the output is a directory They're turned on immediately during the soong bootstrap runs, as those run a limited number of rules. The main ninja execution does not remove the output files, and prints warnings instead of errors for the others. I'll turn them on as we understand how often those warnings are seen. Test: m (check for new warnings) Test: treehugger (check for new warnings) Change-Id: I7f5c1a361dd1498eb54a2c07a918f3b0aa086e4c --- ui/build/build.go | 1 - ui/build/kati.go | 1 + ui/build/ninja.go | 1 + ui/build/soong.go | 4 ++++ 4 files changed, 6 insertions(+), 1 deletion(-) diff --git a/ui/build/build.go b/ui/build/build.go index f3feac2be..112273345 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -53,7 +53,6 @@ builddir = {{.OutDir}} {{end -}} pool highmem_pool depth = {{.HighmemParallel}} -build _kati_always_build_: phony {{if .HasKatiSuffix}}subninja {{.KatiBuildNinjaFile}} subninja {{.KatiPackageNinjaFile}} {{end -}} diff --git a/ui/build/kati.go b/ui/build/kati.go index 8796a4f05..2eb785032 100644 --- a/ui/build/kati.go +++ b/ui/build/kati.go @@ -67,6 +67,7 @@ func runKati(ctx Context, config Config, extraSuffix string, args []string, envF "--ninja_dir=" + config.OutDir(), "--ninja_suffix=" + config.KatiSuffix() + extraSuffix, "--no_ninja_prelude", + "--use_ninja_phony_output", "--regen", "--ignore_optional_include=" + filepath.Join(config.OutDir(), "%.P"), "--detect_android_echo", diff --git a/ui/build/ninja.go b/ui/build/ninja.go index dfc3be1f3..1b13e5d36 100644 --- a/ui/build/ninja.go +++ b/ui/build/ninja.go @@ -58,6 +58,7 @@ func runNinja(ctx Context, config Config) { args = append(args, "-f", config.CombinedNinjaFile()) args = append(args, + "-o", "usesphonyoutputs=yes", "-w", "dupbuild=err", "-w", "missingdepfile=err") diff --git a/ui/build/soong.go b/ui/build/soong.go index 9b8d648ea..2fbf381b6 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -119,7 +119,11 @@ func runSoong(ctx Context, config Config) { cmd := Command(ctx, config, "soong "+name, config.PrebuiltBuildTool("ninja"), "-d", "keepdepfile", + "-o", "usesphonyoutputs=yes", + "-o", "preremoveoutputs=yes", "-w", "dupbuild=err", + "-w", "outputdir=err", + "-w", "missingoutfile=err", "-j", strconv.Itoa(config.Parallel()), "--frontend_file", fifo, "-f", filepath.Join(config.SoongOutDir(), file))