diff --git a/ui/build/config.go b/ui/build/config.go index f279c139f..915919054 100644 --- a/ui/build/config.go +++ b/ui/build/config.go @@ -152,7 +152,8 @@ func NewConfig(ctx Context, args ...string) Config { // Tell python not to spam the source tree with .pyc files. ret.environ.Set("PYTHONDONTWRITEBYTECODE", "1") - ret.environ.Set("TMPDIR", absPath(ctx, ret.TempDir())) + tmpDir := absPath(ctx, ret.TempDir()) + ret.environ.Set("TMPDIR", tmpDir) // Precondition: the current directory is the top of the source tree if _, err := os.Stat(srcDirFileCheck); err != nil { @@ -218,12 +219,19 @@ func NewConfig(ctx Context, args ...string) Config { } else { content = strconv.FormatInt(time.Now().Unix(), 10) } + err := ioutil.WriteFile(buildDateTimeFile, []byte(content), 0777) if err != nil { ctx.Fatalln("Failed to write BUILD_DATETIME to file:", err) } ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile) + if ret.UseRBE() { + for k, v := range getRBEVars(ctx, tmpDir) { + ret.environ.Set(k, v) + } + } + return Config{ret} } diff --git a/ui/build/rbe.go b/ui/build/rbe.go index c80b8ea7d..147afcc72 100644 --- a/ui/build/rbe.go +++ b/ui/build/rbe.go @@ -15,7 +15,10 @@ package build import ( + "fmt" + "math/rand" "path/filepath" + "time" "android/soong/ui/metrics" ) @@ -24,6 +27,11 @@ const bootstrapCmd = "bootstrap" const rbeLeastNProcs = 2500 const rbeLeastNFiles = 16000 +func getRBEVars(ctx Context, tmpDir string) map[string]string { + rand.Seed(time.Now().UnixNano()) + return map[string]string{"RBE_server_address": fmt.Sprintf("unix://%v/reproxy_%v.sock", tmpDir, rand.Intn(1000))} +} + func startRBE(ctx Context, config Config) { ctx.BeginTrace(metrics.RunSetupTool, "rbe_bootstrap") defer ctx.EndTrace()