Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 7901e585 authored by MarkDacek's avatar MarkDacek
Browse files

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
parent 57b1e406
Loading
Loading
Loading
Loading
+16 −8
Original line number Diff line number Diff line
@@ -204,16 +204,11 @@ func fetchEnvConfig(ctx Context, config *configImpl, envConfigName string) error
	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 @@ func UploadOnlyConfig(ctx Context, _ ...string) Config {
		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,9 +295,16 @@ func NewConfig(ctx Context, args ...string) Config {

	// 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 {
	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 {
		ret.distDir = filepath.Clean(distDir)