Pass --writable to kati

These warnings are usually hit in one of the two conditions:

1. Targets that should be marked .PHONY, but are not.
2. Attempts to define output files in the source tree.

See https://android.googlesource.com/platform/build/+/master/Changes.md#phony_targets
for more information.

Test: multiproduct_kati in all downstream branches
Change-Id: Ibe37cce320612825c22987e94d0740e8c0565b6f
diff --git a/ui/build/config.go b/ui/build/config.go
index 2605f5b..fdeb8f2 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -369,14 +369,14 @@
 
 func (c *configImpl) OutDir() string {
 	if outDir, ok := c.environ.Get("OUT_DIR"); ok {
-		return outDir
+		return filepath.Clean(outDir)
 	}
 	return "out"
 }
 
 func (c *configImpl) DistDir() string {
 	if distDir, ok := c.environ.Get("DIST_DIR"); ok {
-		return distDir
+		return filepath.Clean(distDir)
 	}
 	return filepath.Join(c.OutDir(), "dist")
 }
diff --git a/ui/build/kati.go b/ui/build/kati.go
index b54872c..b26d673 100644
--- a/ui/build/kati.go
+++ b/ui/build/kati.go
@@ -81,6 +81,8 @@
 		"--warn_real_to_phony",
 		"--warn_phony_looks_real",
 		"--kati_stats",
+		"--writable", config.OutDir() + "/",
+		"--writable", config.DistDir() + "/",
 		"-f", "build/make/core/main.mk",
 	}
 
@@ -94,7 +96,10 @@
 	}
 
 	if !config.BuildBrokenPhonyTargets() {
-		args = append(args, "--werror_real_to_phony", "--werror_phony_looks_real")
+		args = append(args,
+			"--werror_real_to_phony",
+			"--werror_phony_looks_real",
+			"--werror_writable")
 	}
 
 	if !config.Environment().IsFalse("KATI_EMULATE_FIND") {