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

Commit 749dacac authored by Kousik Kumar's avatar Kousik Kumar Committed by Automerger Merge Worker
Browse files

[conflict] Add additional directories from which env config can be loaded am:...

[conflict] Add additional directories from which env config can be loaded am: ef073be1 am: cc5020c9 am: 8f012ef4

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



Change-Id: Ie336521979100a49f540cba860478f3091afd65c
Signed-off-by: default avatarAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>
parents dd28ec51 8f012ef4
Loading
Loading
Loading
Loading
+17 −8
Original line number Diff line number Diff line
@@ -117,12 +117,23 @@ func inList(s string, list []string) bool {
	return indexList(s, list) != -1
}

func loadEnvConfig() error {
func loadEnvConfig(config build.Config) error {
	bc := os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG")
	if bc == "" {
		return nil
	}
	cfgFile := filepath.Join(os.Getenv("TOP"), configDir, fmt.Sprintf("%s.%s", bc, jsonSuffix))
	configDirs := []string{
		os.Getenv("ANDROID_BUILD_ENVIRONMENT_CONFIG_DIR"),
		config.OutDir(),
		configDir,
	}
	var cfgFile string
	for _, dir := range configDirs {
		cfgFile = filepath.Join(os.Getenv("TOP"), dir, fmt.Sprintf("%s.%s", bc, jsonSuffix))
		if _, err := os.Stat(cfgFile); err == nil {
			break
		}
	}

	envVarsJSON, err := ioutil.ReadFile(cfgFile)
	if err != nil {
@@ -138,9 +149,7 @@ func loadEnvConfig() error {
		if os.Getenv(k) != "" {
			continue
		}
		if err := os.Setenv(k, v); err != nil {
			return err
		}
		config.Environment().Set(k, v)
	}
	return nil
}
@@ -195,13 +204,13 @@ func main() {
		Status:  stat,
	}}

	if err := loadEnvConfig(); err != nil {
	config := c.config(buildCtx, args...)

	if err := loadEnvConfig(config); err != nil {
		fmt.Fprintf(os.Stderr, "failed to parse env config files: %v", err)
		os.Exit(1)
	}

	config := c.config(buildCtx, args...)

	build.SetupOutDir(buildCtx, config)

	logsDir := config.OutDir()