From ecf0f10d3d706ecdd656583eb3b14227d811cfef Mon Sep 17 00:00:00 2001 From: Anton Hansson Date: Wed, 19 Sep 2018 22:14:17 +0100 Subject: [PATCH] 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 --- ui/build/build.go | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/ui/build/build.go b/ui/build/build.go index 96cfdbb30..52ef0058f 100644 --- a/ui/build/build.go +++ b/ui/build/build.go @@ -71,6 +71,17 @@ const ( 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 @@ func Build(ctx Context, config Config, what int) { buildLock := BecomeSingletonOrFail(ctx, config) defer buildLock.Unlock() + checkProblematicFiles(ctx) + SetupOutDir(ctx, config) checkCaseSensitivity(ctx, config)