Sanity check the tree before building.

Check for the presence of Android.mk or CleanSpec.mk, which
are somewhat common problems.

Bug: 113147143
Test: m (with and without files present)
Change-Id: I31cf60c325e7f6c6fce7aec54712c1cb802055c2
diff --git a/ui/build/build.go b/ui/build/build.go
index 96cfdbb..52ef005 100644
--- a/ui/build/build.go
+++ b/ui/build/build.go
@@ -71,6 +71,17 @@
 	BuildAll           = BuildProductConfig | BuildSoong | BuildKati | BuildNinja
 )
 
+func checkProblematicFiles(ctx Context) {
+	files := []string{"Android.mk", "CleanSpec.mk"}
+	for _, file := range files {
+		if _, err := os.Stat(file); !os.IsNotExist(err) {
+			absolute := absPath(ctx, file)
+			ctx.Printf("Found %s in tree root. This file needs to be removed to build.\n", file)
+			ctx.Fatalf("    rm %s\n", absolute)
+		}
+	}
+}
+
 func checkCaseSensitivity(ctx Context, config Config) {
 	outDir := config.OutDir()
 	lowerCase := filepath.Join(outDir, "casecheck.txt")
@@ -131,6 +142,8 @@
 	buildLock := BecomeSingletonOrFail(ctx, config)
 	defer buildLock.Unlock()
 
+	checkProblematicFiles(ctx)
+
 	SetupOutDir(ctx, config)
 
 	checkCaseSensitivity(ctx, config)