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

Commit 2895eed9 authored by LaMont Jones's avatar LaMont Jones Committed by Android Build Coastguard Worker
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
(cherry picked from https://android-review.googlesource.com/q/commit:639423daacc146457f10cf3d060bc2932dc903eb)
Merged-In: Ie4bc8137f2bd10f3b90efcffe8d2c8e317dcc2fc
Change-Id: Ie4bc8137f2bd10f3b90efcffe8d2c8e317dcc2fc
parent 3ff024c3
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)
		}
	}