Ver código fonte

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 <doesn't rebuild everything>
Change-Id: I82f30c7c3b5d25e5cbf28fe37a97fdb776c4a164
Dan Willemsen 6 anos atrás
pai
commit
e7945d76ac
1 arquivos alterados com 1 adições e 2 exclusões
  1. 1 2
      ui/build/soong.go

+ 1 - 2
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()