[DO NOT MERGE] Generate RBE socket address randomly for each invocation of soong. am: 498a732edb

Original change: https://googleplex-android-review.googlesource.com/c/platform/build/soong/+/12595309

Change-Id: I474582214c26fab393c5b1cd48a932bdfa98fe62
This commit is contained in:
Ramy Medhat 2020-09-16 09:23:57 +00:00 committed by Automerger Merge Worker
commit 8743dfac7d
2 changed files with 17 additions and 1 deletions

View File

@ -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}
}

View File

@ -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()