Support release configs with only aconfig flags
Release configs with `aconfig_flags_only: true` can inherit build flag values, but cannot set them. Bug: 328495189 Test: manual Change-Id: I2bdc88761d61fb20f10dc734f2ba87114f51b859
This commit is contained in:
parent
d58ac5358d
commit
dc86819307
6 changed files with 83 additions and 38 deletions
|
@ -160,6 +160,9 @@ func SetCommand(configs *rc_lib.ReleaseConfigs, commonFlags Flags, cmd string, a
|
|||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if release.AconfigFlagsOnly {
|
||||
return fmt.Errorf("%s does not allow build flag overrides", targetRelease)
|
||||
}
|
||||
flagArtifact, ok := release.FlagArtifacts[name]
|
||||
if !ok {
|
||||
return fmt.Errorf("Unknown build flag %s", name)
|
||||
|
|
|
@ -15,18 +15,29 @@ import (
|
|||
"google.golang.org/protobuf/proto"
|
||||
)
|
||||
|
||||
// When a flag declaration has an initial value that is a string, the default workflow is PREBUILT.
|
||||
// If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL.
|
||||
var manualFlagNamePrefixes []string = []string{
|
||||
"RELEASE_ACONFIG_",
|
||||
"RELEASE_PLATFORM_",
|
||||
}
|
||||
var (
|
||||
// When a flag declaration has an initial value that is a string, the default workflow is PREBUILT.
|
||||
// If the flag name starts with any of prefixes in manualFlagNamePrefixes, it is MANUAL.
|
||||
manualFlagNamePrefixes []string = []string{
|
||||
"RELEASE_ACONFIG_",
|
||||
"RELEASE_PLATFORM_",
|
||||
}
|
||||
|
||||
var defaultFlagNamespace string = "android_UNKNOWN"
|
||||
// Set `aconfig_flags_only: true` in these release configs.
|
||||
aconfigFlagsOnlyConfigs map[string]bool = map[string]bool{
|
||||
"trunk_food": true,
|
||||
}
|
||||
|
||||
// Default namespace value. This is intentionally invalid.
|
||||
defaultFlagNamespace string = "android_UNKNOWN"
|
||||
|
||||
// What is the current name for "next".
|
||||
nextName string = "ap3a"
|
||||
)
|
||||
|
||||
func RenameNext(name string) string {
|
||||
if name == "next" {
|
||||
return "ap3a"
|
||||
return nextName
|
||||
}
|
||||
return name
|
||||
}
|
||||
|
@ -205,6 +216,9 @@ func ProcessBuildConfigs(dir, name string, paths []string, releaseProto *rc_prot
|
|||
fmt.Printf("%s: Unexpected value %s=%s\n", path, valName, valValue)
|
||||
}
|
||||
if flagValue != nil {
|
||||
if releaseProto.AconfigFlagsOnly {
|
||||
return fmt.Errorf("%s does not allow build flag overrides", RenameNext(name))
|
||||
}
|
||||
valPath := filepath.Join(dir, "flag_values", RenameNext(name), fmt.Sprintf("%s.textproto", valName))
|
||||
err := WriteFile(valPath, flagValue)
|
||||
if err != nil {
|
||||
|
@ -285,6 +299,9 @@ func ProcessReleaseConfigMap(dir string, descriptionMap map[string]string) error
|
|||
releaseConfig := &rc_proto.ReleaseConfig{
|
||||
Name: proto.String(RenameNext(name)),
|
||||
}
|
||||
if aconfigFlagsOnlyConfigs[name] {
|
||||
releaseConfig.AconfigFlagsOnly = true
|
||||
}
|
||||
configFiles := config[configRegexp.SubexpIndex("files")]
|
||||
files := strings.Split(strings.ReplaceAll(configFiles, "$(local_dir)", dir+"/"), " ")
|
||||
configInherits := config[configRegexp.SubexpIndex("inherits")]
|
||||
|
|
|
@ -62,6 +62,10 @@ type ReleaseConfig struct {
|
|||
// The names of release configs that we inherit
|
||||
InheritNames []string
|
||||
|
||||
// True if this release config only allows inheritance and aconfig flag
|
||||
// overrides. Build flag value overrides are an error.
|
||||
AconfigFlagsOnly bool
|
||||
|
||||
// Unmarshalled flag artifacts
|
||||
FlagArtifacts FlagArtifacts
|
||||
|
||||
|
@ -174,6 +178,9 @@ func (config *ReleaseConfig) GenerateReleaseConfig(configs *ReleaseConfigs) erro
|
|||
})
|
||||
|
||||
myDirsMap[contrib.DeclarationIndex] = true
|
||||
if config.AconfigFlagsOnly && len(contrib.FlagValues) > 0 {
|
||||
return fmt.Errorf("%s does not allow build flag overrides", config.Name)
|
||||
}
|
||||
for _, value := range contrib.FlagValues {
|
||||
name := *value.proto.Name
|
||||
fa, ok := config.FlagArtifacts[name]
|
||||
|
|
|
@ -206,6 +206,9 @@ func (configs *ReleaseConfigs) LoadReleaseConfigMap(path string, ConfigDirIndex
|
|||
if err2 != nil {
|
||||
return err2
|
||||
}
|
||||
if releaseConfigContribution.proto.GetAconfigFlagsOnly() {
|
||||
config.AconfigFlagsOnly = true
|
||||
}
|
||||
m.ReleaseConfigContributions[name] = releaseConfigContribution
|
||||
config.Contributions = append(config.Contributions, releaseConfigContribution)
|
||||
return nil
|
||||
|
|
|
@ -387,6 +387,8 @@ type ReleaseConfig struct {
|
|||
// List of names of the aconfig_value_set soong module(s) for this
|
||||
// contribution.
|
||||
AconfigValueSets []string `protobuf:"bytes,3,rep,name=aconfig_value_sets,json=aconfigValueSets" json:"aconfig_value_sets,omitempty"`
|
||||
// Only aconfig flags are allowed in this release config.
|
||||
AconfigFlagsOnly *bool `protobuf:"varint,4,opt,name=aconfig_flags_only,json=aconfigFlagsOnly" json:"aconfig_flags_only,omitempty"`
|
||||
}
|
||||
|
||||
func (x *ReleaseConfig) Reset() {
|
||||
|
@ -442,6 +444,13 @@ func (x *ReleaseConfig) GetAconfigValueSets() []string {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (x *ReleaseConfig) GetAconfigFlagsOnly() bool {
|
||||
if x != nil && x.AconfigFlagsOnly != nil {
|
||||
return *x.AconfigFlagsOnly
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Any aliases. These are used for continuous integration builder config.
|
||||
type ReleaseAlias struct {
|
||||
state protoimpl.MessageState
|
||||
|
@ -609,36 +618,39 @@ var file_build_flags_src_proto_rawDesc = []byte{
|
|||
0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x76, 0x61, 0x6c, 0x75, 0x65, 0x52, 0x05, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x12, 0x1b, 0x0a, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65, 0x64,
|
||||
0x18, 0xca, 0x01, 0x20, 0x01, 0x28, 0x08, 0x52, 0x08, 0x72, 0x65, 0x64, 0x61, 0x63, 0x74, 0x65,
|
||||
0x64, 0x22, 0x6e, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e,
|
||||
0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72,
|
||||
0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65, 0x72,
|
||||
0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x76,
|
||||
0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52,
|
||||
0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65, 0x74,
|
||||
0x73, 0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69,
|
||||
0x61, 0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74,
|
||||
0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac,
|
||||
0x01, 0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69,
|
||||
0x67, 0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73,
|
||||
0x18, 0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64,
|
||||
0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f,
|
||||
0x70, 0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c,
|
||||
0x69, 0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b,
|
||||
0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28,
|
||||
0x09, 0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d,
|
||||
0x0a, 0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69,
|
||||
0x6e, 0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61,
|
||||
0x75, 0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a,
|
||||
0x08, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53,
|
||||
0x50, 0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f,
|
||||
0x77, 0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12,
|
||||
0x0c, 0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a,
|
||||
0x06, 0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64,
|
||||
0x72, 0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61,
|
||||
0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73,
|
||||
0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
0x64, 0x22, 0x9c, 0x01, 0x0a, 0x0e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f,
|
||||
0x6e, 0x66, 0x69, 0x67, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01,
|
||||
0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x1a, 0x0a, 0x08, 0x69, 0x6e, 0x68, 0x65,
|
||||
0x72, 0x69, 0x74, 0x73, 0x18, 0x02, 0x20, 0x03, 0x28, 0x09, 0x52, 0x08, 0x69, 0x6e, 0x68, 0x65,
|
||||
0x72, 0x69, 0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f,
|
||||
0x76, 0x61, 0x6c, 0x75, 0x65, 0x5f, 0x73, 0x65, 0x74, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09,
|
||||
0x52, 0x10, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x56, 0x61, 0x6c, 0x75, 0x65, 0x53, 0x65,
|
||||
0x74, 0x73, 0x12, 0x2c, 0x0a, 0x12, 0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x66, 0x6c,
|
||||
0x61, 0x67, 0x73, 0x5f, 0x6f, 0x6e, 0x6c, 0x79, 0x18, 0x04, 0x20, 0x01, 0x28, 0x08, 0x52, 0x10,
|
||||
0x61, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x46, 0x6c, 0x61, 0x67, 0x73, 0x4f, 0x6e, 0x6c, 0x79,
|
||||
0x22, 0x3b, 0x0a, 0x0d, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69, 0x61,
|
||||
0x73, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52,
|
||||
0x04, 0x6e, 0x61, 0x6d, 0x65, 0x12, 0x16, 0x0a, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x18,
|
||||
0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x06, 0x74, 0x61, 0x72, 0x67, 0x65, 0x74, 0x22, 0xac, 0x01,
|
||||
0x0a, 0x12, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67,
|
||||
0x5f, 0x6d, 0x61, 0x70, 0x12, 0x45, 0x0a, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x18,
|
||||
0x01, 0x20, 0x03, 0x28, 0x0b, 0x32, 0x2b, 0x2e, 0x61, 0x6e, 0x64, 0x72, 0x6f, 0x69, 0x64, 0x2e,
|
||||
0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70,
|
||||
0x72, 0x6f, 0x74, 0x6f, 0x2e, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65, 0x5f, 0x61, 0x6c, 0x69,
|
||||
0x61, 0x73, 0x52, 0x07, 0x61, 0x6c, 0x69, 0x61, 0x73, 0x65, 0x73, 0x12, 0x20, 0x0a, 0x0b, 0x64,
|
||||
0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x18, 0x02, 0x20, 0x01, 0x28, 0x09,
|
||||
0x52, 0x0b, 0x64, 0x65, 0x73, 0x63, 0x72, 0x69, 0x70, 0x74, 0x69, 0x6f, 0x6e, 0x12, 0x2d, 0x0a,
|
||||
0x12, 0x64, 0x65, 0x66, 0x61, 0x75, 0x6c, 0x74, 0x5f, 0x63, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e,
|
||||
0x65, 0x72, 0x73, 0x18, 0x03, 0x20, 0x03, 0x28, 0x09, 0x52, 0x11, 0x64, 0x65, 0x66, 0x61, 0x75,
|
||||
0x6c, 0x74, 0x43, 0x6f, 0x6e, 0x74, 0x61, 0x69, 0x6e, 0x65, 0x72, 0x73, 0x2a, 0x4a, 0x0a, 0x08,
|
||||
0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77, 0x12, 0x18, 0x0a, 0x14, 0x55, 0x4e, 0x53, 0x50,
|
||||
0x45, 0x43, 0x49, 0x46, 0x49, 0x45, 0x44, 0x5f, 0x77, 0x6f, 0x72, 0x6b, 0x66, 0x6c, 0x6f, 0x77,
|
||||
0x10, 0x00, 0x12, 0x0a, 0x0a, 0x06, 0x4c, 0x41, 0x55, 0x4e, 0x43, 0x48, 0x10, 0x01, 0x12, 0x0c,
|
||||
0x0a, 0x08, 0x50, 0x52, 0x45, 0x42, 0x55, 0x49, 0x4c, 0x54, 0x10, 0x02, 0x12, 0x0a, 0x0a, 0x06,
|
||||
0x4d, 0x41, 0x4e, 0x55, 0x41, 0x4c, 0x10, 0x03, 0x42, 0x33, 0x5a, 0x31, 0x61, 0x6e, 0x64, 0x72,
|
||||
0x6f, 0x69, 0x64, 0x2f, 0x73, 0x6f, 0x6f, 0x6e, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73,
|
||||
0x65, 0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x2f, 0x72, 0x65, 0x6c, 0x65, 0x61, 0x73, 0x65,
|
||||
0x5f, 0x63, 0x6f, 0x6e, 0x66, 0x69, 0x67, 0x5f, 0x70, 0x72, 0x6f, 0x74, 0x6f,
|
||||
}
|
||||
|
||||
var (
|
||||
|
|
|
@ -119,6 +119,9 @@ message release_config {
|
|||
// List of names of the aconfig_value_set soong module(s) for this
|
||||
// contribution.
|
||||
repeated string aconfig_value_sets = 3;
|
||||
|
||||
// Only aconfig flags are allowed in this release config.
|
||||
optional bool aconfig_flags_only = 4;
|
||||
}
|
||||
|
||||
// Any aliases. These are used for continuous integration builder config.
|
||||
|
|
Loading…
Reference in a new issue