Add reasonable defaults to RBE configuration parameters.
Test: simple one action build
Change-Id: Ic66ad2b89866a67008950035bc3b559dae4e3a3e
diff --git a/ui/build/config.go b/ui/build/config.go
index b263a98..0414175 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -15,6 +15,7 @@
package build
import (
+ "fmt"
"os"
"path/filepath"
"runtime"
@@ -258,7 +259,7 @@
ret.environ.Set("BUILD_DATETIME_FILE", buildDateTimeFile)
if ret.UseRBE() {
- for k, v := range getRBEVars(ctx, tmpDir) {
+ for k, v := range getRBEVars(ctx, Config{ret}) {
ret.environ.Set(k, v)
}
}
@@ -806,13 +807,73 @@
return true
}
-func (c *configImpl) RBEStatsOutputDir() string {
+func (c *configImpl) logDir() string {
+ if c.Dist() {
+ return filepath.Join(c.DistDir(), "logs")
+ }
+ return c.OutDir()
+}
+
+func (c *configImpl) rbeStatsOutputDir() string {
for _, f := range []string{"RBE_output_dir", "FLAG_output_dir"} {
if v, ok := c.environ.Get(f); ok {
return v
}
}
- return ""
+ return c.logDir()
+}
+
+func (c *configImpl) rbeLogPath() string {
+ for _, f := range []string{"RBE_log_path", "FLAG_log_path"} {
+ if v, ok := c.environ.Get(f); ok {
+ return v
+ }
+ }
+ return fmt.Sprintf("text://%v/reproxy_log.txt", c.logDir())
+}
+
+func (c *configImpl) rbeExecRoot() string {
+ for _, f := range []string{"RBE_exec_root", "FLAG_exec_root"} {
+ if v, ok := c.environ.Get(f); ok {
+ return v
+ }
+ }
+ wd, err := os.Getwd()
+ if err != nil {
+ return ""
+ }
+ return wd
+}
+
+func (c *configImpl) rbeDir() string {
+ if v, ok := c.environ.Get("RBE_DIR"); ok {
+ return v
+ }
+ return "prebuilts/remoteexecution-client/live/"
+}
+
+func (c *configImpl) rbeReproxy() string {
+ for _, f := range []string{"RBE_re_proxy", "FLAG_re_proxy"} {
+ if v, ok := c.environ.Get(f); ok {
+ return v
+ }
+ }
+ return filepath.Join(c.rbeDir(), "reproxy")
+}
+
+func (c *configImpl) rbeAuth() (string, string) {
+ credFlags := []string{"use_application_default_credentials", "use_gce_credentials", "credential_file"}
+ for _, cf := range credFlags {
+ for _, f := range []string{"RBE_" + cf, "FLAG_" + cf} {
+ if v, ok := c.environ.Get(f); ok {
+ v = strings.TrimSpace(v)
+ if v != "" && v != "false" && v != "0" {
+ return "RBE_" + cf, v
+ }
+ }
+ }
+ }
+ return "RBE_use_application_default_credentials", "true"
}
func (c *configImpl) UseRemoteBuild() bool {