Skip to content

Commit

Permalink
Enforce exclusive release config component directories
Browse files Browse the repository at this point in the history
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
  • Loading branch information
lamontj authored and Android Build Coastguard Worker committed Oct 11, 2024
1 parent 3ff024c commit 2895eed
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions cmd/release_config/release_config_lib/release_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down

0 comments on commit 2895eed

Please sign in to comment.