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

Commit 639423da authored by LaMont Jones's avatar LaMont Jones
Browse files

Enforce exclusive release config component directories

Enforce this requirement for delivery to aosp:
- "A release config shall exist in at most one of build/release and
  vendor/google_shared/build/release".

Bug: 349843674
Bug: 370829778
Bug: 371026851
Test: manual, TH
Change-Id: Ie4bc8137f2bd10f3b90efcffe8d2c8e317dcc2fc
parent 46694ccb
Loading
Loading
Loading
Loading
+17 −0
Original line number Diff line number Diff line
@@ -280,11 +280,28 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro

	directories := []string{}
	valueDirectories := []string{}
	// These path prefixes are exclusive for a release config.
	// "A release config shall exist in at most one of these."
	// If we find a benefit to generalizing this, we can do so at that time.
	exclusiveDirPrefixes := []string{
		"build/release",
		"vendor/google_shared/build/release",
	}
	var exclusiveDir string
	for idx, confDir := range configs.configDirs {
		if _, ok := myDirsMap[idx]; ok {
			directories = append(directories, confDir)
		}
		if _, ok := myValueDirsMap[idx]; ok {
			for _, dir := range exclusiveDirPrefixes {
				if strings.HasPrefix(confDir, dir) {
					if exclusiveDir != "" && !strings.HasPrefix(exclusiveDir, dir) {
						return fmt.Errorf("%s is declared in both %s and %s",
							config.Name, exclusiveDir, confDir)
					}
					exclusiveDir = confDir
				}
			}
			valueDirectories = append(valueDirectories, confDir)
		}
	}