Guard with RELEASE_BUILD_FLAGS_IN_PROTOBUF
If false, then we output an empty file, which will cause release_config.mk to do the old process. Bug: 328495189 Test: manual Change-Id: I4aa82301f3bbb29633a275a801431a6667feb48d
This commit is contained in:
@@ -21,6 +21,7 @@ var (
|
|||||||
manualFlagNamePrefixes []string = []string{
|
manualFlagNamePrefixes []string = []string{
|
||||||
"RELEASE_ACONFIG_",
|
"RELEASE_ACONFIG_",
|
||||||
"RELEASE_PLATFORM_",
|
"RELEASE_PLATFORM_",
|
||||||
|
"RELEASE_BUILD_FLAGS_",
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set `aconfig_flags_only: true` in these release configs.
|
// Set `aconfig_flags_only: true` in these release configs.
|
||||||
|
@@ -35,6 +35,7 @@ func main() {
|
|||||||
var product string
|
var product string
|
||||||
var allMake bool
|
var allMake bool
|
||||||
var useBuildVar bool
|
var useBuildVar bool
|
||||||
|
var guard bool
|
||||||
|
|
||||||
defaultRelease := os.Getenv("TARGET_RELEASE")
|
defaultRelease := os.Getenv("TARGET_RELEASE")
|
||||||
if defaultRelease == "" {
|
if defaultRelease == "" {
|
||||||
@@ -52,6 +53,7 @@ func main() {
|
|||||||
flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf")
|
flag.BoolVar(&pb, "pb", true, "write artifacts as binary protobuf")
|
||||||
flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs")
|
flag.BoolVar(&allMake, "all_make", true, "write makefiles for all release configs")
|
||||||
flag.BoolVar(&useBuildVar, "use_get_build_var", false, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS")
|
flag.BoolVar(&useBuildVar, "use_get_build_var", false, "use get_build_var PRODUCT_RELEASE_CONFIG_MAPS")
|
||||||
|
flag.BoolVar(&guard, "guard", true, "whether to guard with RELEASE_BUILD_FLAGS_IN_PROTOBUF")
|
||||||
|
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
|
|
||||||
@@ -76,20 +78,21 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
|
||||||
if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil {
|
makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName))
|
||||||
panic(err)
|
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.
|
||||||
if allMake {
|
// Write an empty file so that release_config.mk will use the old process.
|
||||||
|
os.WriteFile(makefilePath, []byte{}, 0644)
|
||||||
|
} else if allMake {
|
||||||
for k, _ := range configs.ReleaseConfigs {
|
for k, _ := range configs.ReleaseConfigs {
|
||||||
makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k))
|
makefilePath = filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, k))
|
||||||
err = configs.WriteMakefile(makefilePath, k)
|
err = configs.WriteMakefile(makefilePath, k)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
makefilePath := filepath.Join(outputDir, fmt.Sprintf("release_config-%s-%s.mk", product, releaseName))
|
|
||||||
err = configs.WriteMakefile(makefilePath, targetRelease)
|
err = configs.WriteMakefile(makefilePath, targetRelease)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
@@ -113,4 +116,8 @@ func main() {
|
|||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if err = config.WritePartitionBuildFlags(outputDir, product, targetRelease); err != nil {
|
||||||
|
panic(err)
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -52,6 +52,9 @@ func UnmarshalValue(str string) *rc_proto.Value {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func MarshalValue(value *rc_proto.Value) string {
|
func MarshalValue(value *rc_proto.Value) string {
|
||||||
|
if value == nil {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
switch val := value.Val.(type) {
|
switch val := value.Val.(type) {
|
||||||
case *rc_proto.Value_UnspecifiedValue:
|
case *rc_proto.Value_UnspecifiedValue:
|
||||||
// Value was never set.
|
// Value was never set.
|
||||||
|
@@ -24,7 +24,7 @@ import (
|
|||||||
"google.golang.org/protobuf/proto"
|
"google.golang.org/protobuf/proto"
|
||||||
)
|
)
|
||||||
|
|
||||||
type testCaseFlagValue struct {
|
type testCaseFlagValueFactory struct {
|
||||||
protoPath string
|
protoPath string
|
||||||
name string
|
name string
|
||||||
data []byte
|
data []byte
|
||||||
@@ -32,14 +32,14 @@ type testCaseFlagValue struct {
|
|||||||
err error
|
err error
|
||||||
}
|
}
|
||||||
|
|
||||||
func (tc testCaseFlagValue) assertProtoEqual(t *testing.T, expected, actual proto.Message) {
|
func (tc testCaseFlagValueFactory) assertProtoEqual(t *testing.T, expected, actual proto.Message) {
|
||||||
if !proto.Equal(expected, actual) {
|
if !proto.Equal(expected, actual) {
|
||||||
t.Errorf("Expected %q found %q", expected, actual)
|
t.Errorf("Expected %q found %q", expected, actual)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestFlagValue(t *testing.T) {
|
func TestFlagValueFactory(t *testing.T) {
|
||||||
testCases := []testCaseFlagValue{
|
testCases := []testCaseFlagValueFactory{
|
||||||
{
|
{
|
||||||
name: "stringVal",
|
name: "stringVal",
|
||||||
protoPath: "build/release/flag_values/test/RELEASE_FOO.textproto",
|
protoPath: "build/release/flag_values/test/RELEASE_FOO.textproto",
|
||||||
@@ -65,3 +65,50 @@ func TestFlagValue(t *testing.T) {
|
|||||||
tc.assertProtoEqual(t, &tc.expected, &actual.proto)
|
tc.assertProtoEqual(t, &tc.expected, &actual.proto)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type testCaseMarshalValue struct {
|
||||||
|
name string
|
||||||
|
value *rc_proto.Value
|
||||||
|
expected string
|
||||||
|
}
|
||||||
|
|
||||||
|
func TestMarshalValue(t *testing.T) {
|
||||||
|
testCases := []testCaseMarshalValue{
|
||||||
|
{
|
||||||
|
name: "nil",
|
||||||
|
value: nil,
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "unspecified",
|
||||||
|
value: &rc_proto.Value{},
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "false",
|
||||||
|
value: &rc_proto.Value{Val: &rc_proto.Value_BoolValue{false}},
|
||||||
|
expected: "",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "true",
|
||||||
|
value: &rc_proto.Value{Val: &rc_proto.Value_BoolValue{true}},
|
||||||
|
expected: "true",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "string",
|
||||||
|
value: &rc_proto.Value{Val: &rc_proto.Value_StringValue{"BAR"}},
|
||||||
|
expected: "BAR",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
name: "obsolete",
|
||||||
|
value: &rc_proto.Value{Val: &rc_proto.Value_Obsolete{true}},
|
||||||
|
expected: " #OBSOLETE",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
actual := MarshalValue(tc.value)
|
||||||
|
if actual != tc.expected {
|
||||||
|
t.Errorf("Expected %q found %q", tc.expected, actual)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user