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

Commit 8606575a authored by Mark Dacek's avatar Mark Dacek Committed by Gerrit Code Review
Browse files

Merge "Fix upload-only to retrieve the METRICS_UPLOADER variable in a timely manner."

parents f7ef4a68 7901e585
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)