From e7945d76ac0df046667bfc399b5666bd777264ea Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Tue, 23 Jan 2018 22:15:15 -0800 Subject: [PATCH] Make GOROOT consistent We were previously setting GOROOT to "prebuilts/go/linux-x86" during the ninja executions when we were running Soong. But we can also run Soong during the main ninja execution, were GOROOT was unset. When the GOROOT was unset, the default GOROOT in our Go installation is "./prebuilts/go/linux-x86" (note the extra ./). This would cause g.bootstrap.goRoot to change between some soong runs, causing us to rebuild all go programs (and anything depending on them) more often than necessary. So instead, keep GOROOT undefined when running Soong. Everything that matters is using runtime.GOROOT(), which will fall back to the default. Continue setting $GOROOT for bootstrap.bash, otherwise it fails when there is no system provided go binary. What we give bootstrap.bash doesn't really matter, since we don't actually use the blueprint wrapper in Android. Test: m blueprint_tools; touch bionic/libc/tzcode/new.c; m blueprint_tools Change-Id: I82f30c7c3b5d25e5cbf28fe37a97fdb776c4a164 --- ui/build/soong.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/ui/build/soong.go b/ui/build/soong.go index 6dafd273c..cbb75c764 100644 --- a/ui/build/soong.go +++ b/ui/build/soong.go @@ -35,7 +35,7 @@ func runSoong(ctx Context, config Config) { cmd.Environment.Set("BLUEPRINTDIR", "./build/blueprint") cmd.Environment.Set("BOOTSTRAP", "./build/blueprint/bootstrap.bash") cmd.Environment.Set("BUILDDIR", config.SoongOutDir()) - cmd.Environment.Set("GOROOT", filepath.Join("./prebuilts/go", config.HostPrebuiltTag())) + cmd.Environment.Set("GOROOT", "./"+filepath.Join("prebuilts/go", config.HostPrebuiltTag())) cmd.Environment.Set("BLUEPRINT_LIST_FILE", filepath.Join(config.FileListDir(), "Android.bp.list")) cmd.Environment.Set("NINJA_BUILDDIR", config.OutDir()) cmd.Environment.Set("SRCDIR", ".") @@ -99,7 +99,6 @@ func runSoong(ctx Context, config Config) { if config.IsVerbose() { cmd.Args = append(cmd.Args, "-v") } - cmd.Environment.Set("GOROOT", filepath.Join("./prebuilts/go", config.HostPrebuiltTag())) cmd.Sandbox = soongSandbox cmd.Stdin = ctx.Stdin() cmd.Stdout = ctx.Stdout()