Fix upload-only to retrieve the METRICS_UPLOADER variable
in a timely manner.
There should not be harm in bypassing fetchEnvConfig for this case
as the metrics uploader should not be present for invalid cases.
Bug: b/264905338
Test: b build libcore:all
Test: printfs to verify that upload.go has the variable set.
Change-Id: Ia7d03f25e74d4ec2d6cb83793b793a23b47f26de
diff --git a/ui/build/config.go b/ui/build/config.go
index 61f6b1c..b928faa 100644
--- a/ui/build/config.go
+++ b/ui/build/config.go
@@ -204,16 +204,11 @@
return nil
}
-func loadEnvConfig(ctx Context, config *configImpl) error {
- bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
+func loadEnvConfig(ctx Context, config *configImpl, bc string) error {
if bc == "" {
return nil
}
- if err := fetchEnvConfig(ctx, config, bc); err != nil {
- ctx.Verbosef("Failed to fetch config file: %v\n", err)
- }
-
configDirs := []string{
config.OutDir(),
os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR"),
@@ -262,6 +257,12 @@
environ: OsEnvironment(),
sandboxConfig: &SandboxConfig{},
}
+ srcDir := absPath(ctx, ".")
+ bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
+ if err := loadEnvConfig(ctx, ret, bc); err != nil {
+ ctx.Fatalln("Failed to parse env config files: %v", err)
+ }
+ ret.metricsUploader = GetMetricsUploader(srcDir, ret.environ)
return Config{ret}
}
@@ -294,8 +295,15 @@
// loadEnvConfig needs to know what the OUT_DIR is, so it should
// be called after we determine the appropriate out directory.
- if err := loadEnvConfig(ctx, ret); err != nil {
- ctx.Fatalln("Failed to parse env config files: %v", err)
+ bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
+
+ if bc != "" {
+ if err := fetchEnvConfig(ctx, ret, bc); err != nil {
+ ctx.Verbosef("Failed to fetch config file: %v\n", err)
+
+ } else if err := loadEnvConfig(ctx, ret, bc); err != nil {
+ ctx.Fatalln("Failed to parse env config files: %v", err)
+ }
}
if distDir, ok := ret.environ.Get("DIST_DIR"); ok {