Loading cmd/release_config/release_config/main.go +2 −2 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ func main() { panic(err) } makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, targetRelease)) makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, targetRelease)) useProto, ok := config.FlagArtifacts["RELEASE_BUILD_FLAGS_IN_PROTOBUF"] if guard && (!ok || rc_lib.MarshalValue(useProto.Value) == "") { // We were told to guard operation and either we have no build flag, or it is False. Loading @@ -94,7 +94,7 @@ func main() { // Write one makefile per release config, using the canonical release name. for _, c := range configs.GetSortedReleaseConfigs() { if c.Name != targetRelease { makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, c.Name)) makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, c.Name)) err = configs.WriteMakefile(makefilePath, c.Name) if err != nil { panic(err) Loading cmd/release_config/release_config_lib/release_config.go +31 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,9 @@ type ReleaseConfig struct { // Unmarshalled flag artifacts FlagArtifacts FlagArtifacts // The files used by this release config FilesUsedMap map[string]bool // Generated release config ReleaseConfigArtifact *rc_proto.ReleaseConfigArtifact Loading @@ -80,10 +83,17 @@ type ReleaseConfig struct { } func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { return &ReleaseConfig{Name: name, DeclarationIndex: index} return &ReleaseConfig{ Name: name, DeclarationIndex: index, FilesUsedMap: make(map[string]bool), } } func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { for f := range iConfig.FilesUsedMap { config.FilesUsedMap[f] = true } for _, fa := range iConfig.FlagArtifacts { name := *fa.FlagDeclaration.Name myFa, ok := config.FlagArtifacts[name] Loading @@ -106,6 +116,17 @@ func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { return nil } func (config *ReleaseConfig) GetSortedFileList() []string { ret := []string{} for k := range config.FilesUsedMap { ret = append(ret, k) } slices.SortFunc(ret, func(a, b string) int { return cmp.Compare(a, b) }) return ret } func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { if config.ReleaseConfigArtifact != nil { return nil Loading Loading @@ -145,6 +166,15 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return err } } // If we inherited nothing, then we need to mark the global files as used for this // config. If we inherited, then we already marked them as part of inheritance. if len(config.InheritNames) == 0 { for f := range configs.FilesUsedMap { config.FilesUsedMap[f] = true } } contributionsToApply = append(contributionsToApply, config.Contributions...) workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) Loading cmd/release_config/release_config_lib/release_configs.go +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,9 @@ type ReleaseConfigs struct { // Map of directory to *ReleaseConfigMap releaseConfigMapsMap map[string]*ReleaseConfigMap // The files used by all release configs FilesUsedMap map[string]bool // The list of config directories used. configDirs []string Loading Loading @@ -102,6 +105,7 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { releaseConfigMapsMap: make(map[string]*ReleaseConfigMap), configDirs: []string{}, configDirIndexes: make(ReleaseConfigDirMap), FilesUsedMap: make(map[string]bool), } workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) releaseAconfigValueSets := FlagArtifact{ Loading Loading @@ -180,6 +184,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return fmt.Errorf("Release config map %s has invalid container %s", path, container) } } configs.FilesUsedMap[path] = true dir := filepath.Dir(path) // Record any aliases, checking for duplicates. for _, alias := range m.proto.Aliases { Loading Loading @@ -226,6 +231,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return fmt.Errorf("Duplicate definition of %s", *flagDeclaration.Name) } // Set the initial value in the flag artifact. configs.FilesUsedMap[path] = true configs.FlagArtifacts[name].UpdateValue( FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) Loading @@ -249,6 +255,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex configs.ReleaseConfigs[name] = ReleaseConfigFactory(name, ConfigDirIndex) } config := configs.ReleaseConfigs[name] config.FilesUsedMap[path] = true config.InheritNames = append(config.InheritNames, releaseConfigContribution.proto.Inherits...) // Only walk flag_values/{RELEASE} for defined releases. Loading @@ -260,6 +267,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if *flagValue.proto.Name == "RELEASE_ACONFIG_VALUE_SETS" { return fmt.Errorf("%s: %s is a reserved build flag", path, *flagValue.proto.Name) } config.FilesUsedMap[path] = true releaseConfigContribution.FlagValues = append(releaseConfigContribution.FlagValues, flagValue) return nil }) Loading Loading @@ -371,6 +379,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro } // The variable _all_release_configs will get deleted during processing, so do not mark it read-only. data += fmt.Sprintf("_all_release_configs := %s\n", strings.Join(configs.GetAllReleaseNames(), " ")) data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " ")) data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) for _, pName := range pNames { data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " ")) Loading Loading
cmd/release_config/release_config/main.go +2 −2 Original line number Diff line number Diff line Loading @@ -77,7 +77,7 @@ func main() { panic(err) } makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, targetRelease)) makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, targetRelease)) useProto, ok := config.FlagArtifacts["RELEASE_BUILD_FLAGS_IN_PROTOBUF"] if guard && (!ok || rc_lib.MarshalValue(useProto.Value) == "") { // We were told to guard operation and either we have no build flag, or it is False. Loading @@ -94,7 +94,7 @@ func main() { // Write one makefile per release config, using the canonical release name. for _, c := range configs.GetSortedReleaseConfigs() { if c.Name != targetRelease { makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, c.Name)) makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.varmk", product, c.Name)) err = configs.WriteMakefile(makefilePath, c.Name) if err != nil { panic(err) Loading
cmd/release_config/release_config_lib/release_config.go +31 −1 Original line number Diff line number Diff line Loading @@ -69,6 +69,9 @@ type ReleaseConfig struct { // Unmarshalled flag artifacts FlagArtifacts FlagArtifacts // The files used by this release config FilesUsedMap map[string]bool // Generated release config ReleaseConfigArtifact *rc_proto.ReleaseConfigArtifact Loading @@ -80,10 +83,17 @@ type ReleaseConfig struct { } func ReleaseConfigFactory(name string, index int) (c *ReleaseConfig) { return &ReleaseConfig{Name: name, DeclarationIndex: index} return &ReleaseConfig{ Name: name, DeclarationIndex: index, FilesUsedMap: make(map[string]bool), } } func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { for f := range iConfig.FilesUsedMap { config.FilesUsedMap[f] = true } for _, fa := range iConfig.FlagArtifacts { name := *fa.FlagDeclaration.Name myFa, ok := config.FlagArtifacts[name] Loading @@ -106,6 +116,17 @@ func (config *ReleaseConfig) InheritConfig(iConfig *ReleaseConfig) error { return nil } func (config *ReleaseConfig) GetSortedFileList() []string { ret := []string{} for k := range config.FilesUsedMap { ret = append(ret, k) } slices.SortFunc(ret, func(a, b string) int { return cmp.Compare(a, b) }) return ret } func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) error { if config.ReleaseConfigArtifact != nil { return nil Loading Loading @@ -145,6 +166,15 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro return err } } // If we inherited nothing, then we need to mark the global files as used for this // config. If we inherited, then we already marked them as part of inheritance. if len(config.InheritNames) == 0 { for f := range configs.FilesUsedMap { config.FilesUsedMap[f] = true } } contributionsToApply = append(contributionsToApply, config.Contributions...) workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) Loading
cmd/release_config/release_config_lib/release_configs.go +9 −0 Original line number Diff line number Diff line Loading @@ -67,6 +67,9 @@ type ReleaseConfigs struct { // Map of directory to *ReleaseConfigMap releaseConfigMapsMap map[string]*ReleaseConfigMap // The files used by all release configs FilesUsedMap map[string]bool // The list of config directories used. configDirs []string Loading Loading @@ -102,6 +105,7 @@ func ReleaseConfigsFactory() (c *ReleaseConfigs) { releaseConfigMapsMap: make(map[string]*ReleaseConfigMap), configDirs: []string{}, configDirIndexes: make(ReleaseConfigDirMap), FilesUsedMap: make(map[string]bool), } workflowManual := rc_proto.Workflow(rc_proto.Workflow_MANUAL) releaseAconfigValueSets := FlagArtifact{ Loading Loading @@ -180,6 +184,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return fmt.Errorf("Release config map %s has invalid container %s", path, container) } } configs.FilesUsedMap[path] = true dir := filepath.Dir(path) // Record any aliases, checking for duplicates. for _, alias := range m.proto.Aliases { Loading Loading @@ -226,6 +231,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex return fmt.Errorf("Duplicate definition of %s", *flagDeclaration.Name) } // Set the initial value in the flag artifact. configs.FilesUsedMap[path] = true configs.FlagArtifacts[name].UpdateValue( FlagValue{path: path, proto: rc_proto.FlagValue{ Name: proto.String(name), Value: flagDeclaration.Value}}) Loading @@ -249,6 +255,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex configs.ReleaseConfigs[name] = ReleaseConfigFactory(name, ConfigDirIndex) } config := configs.ReleaseConfigs[name] config.FilesUsedMap[path] = true config.InheritNames = append(config.InheritNames, releaseConfigContribution.proto.Inherits...) // Only walk flag_values/{RELEASE} for defined releases. Loading @@ -260,6 +267,7 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex if *flagValue.proto.Name == "RELEASE_ACONFIG_VALUE_SETS" { return fmt.Errorf("%s: %s is a reserved build flag", path, *flagValue.proto.Name) } config.FilesUsedMap[path] = true releaseConfigContribution.FlagValues = append(releaseConfigContribution.FlagValues, flagValue) return nil }) Loading Loading @@ -371,6 +379,7 @@ func (configs *ReleaseConfigs) WriteMakefile(outFile, targetRelease string) erro } // The variable _all_release_configs will get deleted during processing, so do not mark it read-only. data += fmt.Sprintf("_all_release_configs := %s\n", strings.Join(configs.GetAllReleaseNames(), " ")) data += fmt.Sprintf("_used_files := %s\n", strings.Join(config.GetSortedFileList(), " ")) data += fmt.Sprintf("_ALL_RELEASE_FLAGS :=$= %s\n", strings.Join(names, " ")) for _, pName := range pNames { data += fmt.Sprintf("_ALL_RELEASE_FLAGS.PARTITIONS.%s :=$= %s\n", pName, strings.Join(partitions[pName], " ")) Loading