Output properties before sets in snapshot module
This ensures a consistent output irrespective of whether property sets are created before or after the properties are added. This provides a little more flexibility in the creation code which allows that to be simplfied. Also switches from using reflection to a type switch. Bug: 142918168 Test: m nothing Change-Id: Ia025bfc751f1217d1658de6fb8e15091ea0ea9ff
This commit is contained in:
@@ -1212,12 +1212,12 @@ module_exports_snapshot {
|
|||||||
name: "myexports@current",
|
name: "myexports@current",
|
||||||
device_supported: false,
|
device_supported: false,
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
native_static_libs: ["myexports_mynativelib@current"],
|
||||||
target: {
|
target: {
|
||||||
host: {
|
host: {
|
||||||
compile_multilib: "64",
|
compile_multilib: "64",
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
native_static_libs: ["myexports_mynativelib@current"],
|
|
||||||
}`),
|
}`),
|
||||||
checkAllCopyRules(`
|
checkAllCopyRules(`
|
||||||
include/Test.h -> include/include/Test.h
|
include/Test.h -> include/include/Test.h
|
||||||
|
@@ -920,6 +920,7 @@ java_import {
|
|||||||
module_exports_snapshot {
|
module_exports_snapshot {
|
||||||
name: "myexports@current",
|
name: "myexports@current",
|
||||||
host_supported: true,
|
host_supported: true,
|
||||||
|
java_libs: ["myexports_myjavalib@current"],
|
||||||
target: {
|
target: {
|
||||||
android: {
|
android: {
|
||||||
java_header_libs: ["myexports_androidjavalib@current"],
|
java_header_libs: ["myexports_androidjavalib@current"],
|
||||||
@@ -928,7 +929,6 @@ module_exports_snapshot {
|
|||||||
java_header_libs: ["myexports_hostjavalib@current"],
|
java_header_libs: ["myexports_hostjavalib@current"],
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
java_libs: ["myexports_myjavalib@current"],
|
|
||||||
}
|
}
|
||||||
`),
|
`),
|
||||||
checkAllCopyRules(`
|
checkAllCopyRules(`
|
||||||
|
@@ -515,41 +515,53 @@ func generateBpContents(contents *generatedContents, bpFile *bpFile) {
|
|||||||
|
|
||||||
func outputPropertySet(contents *generatedContents, set *bpPropertySet) {
|
func outputPropertySet(contents *generatedContents, set *bpPropertySet) {
|
||||||
contents.Indent()
|
contents.Indent()
|
||||||
|
|
||||||
|
// Output the properties first, followed by the nested sets. This ensures a
|
||||||
|
// consistent output irrespective of whether property sets are created before
|
||||||
|
// or after the properties. This simplifies the creation of the module.
|
||||||
for _, name := range set.order {
|
for _, name := range set.order {
|
||||||
value := set.getValue(name)
|
value := set.getValue(name)
|
||||||
|
|
||||||
reflectedValue := reflect.ValueOf(value)
|
switch v := value.(type) {
|
||||||
t := reflectedValue.Type()
|
case []string:
|
||||||
|
length := len(v)
|
||||||
kind := t.Kind()
|
|
||||||
switch kind {
|
|
||||||
case reflect.Slice:
|
|
||||||
length := reflectedValue.Len()
|
|
||||||
if length > 1 {
|
if length > 1 {
|
||||||
contents.Printfln("%s: [", name)
|
contents.Printfln("%s: [", name)
|
||||||
contents.Indent()
|
contents.Indent()
|
||||||
for i := 0; i < length; i = i + 1 {
|
for i := 0; i < length; i = i + 1 {
|
||||||
contents.Printfln("%q,", reflectedValue.Index(i).Interface())
|
contents.Printfln("%q,", v[i])
|
||||||
}
|
}
|
||||||
contents.Dedent()
|
contents.Dedent()
|
||||||
contents.Printfln("],")
|
contents.Printfln("],")
|
||||||
} else if length == 0 {
|
} else if length == 0 {
|
||||||
contents.Printfln("%s: [],", name)
|
contents.Printfln("%s: [],", name)
|
||||||
} else {
|
} else {
|
||||||
contents.Printfln("%s: [%q],", name, reflectedValue.Index(0).Interface())
|
contents.Printfln("%s: [%q],", name, v[0])
|
||||||
}
|
}
|
||||||
case reflect.Bool:
|
|
||||||
contents.Printfln("%s: %t,", name, reflectedValue.Bool())
|
|
||||||
|
|
||||||
case reflect.Ptr:
|
case bool:
|
||||||
contents.Printfln("%s: {", name)
|
contents.Printfln("%s: %t,", name, v)
|
||||||
outputPropertySet(contents, reflectedValue.Interface().(*bpPropertySet))
|
|
||||||
contents.Printfln("},")
|
case *bpPropertySet:
|
||||||
|
// Do not write property sets in the properties phase.
|
||||||
|
|
||||||
default:
|
default:
|
||||||
contents.Printfln("%s: %q,", name, value)
|
contents.Printfln("%s: %q,", name, value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for _, name := range set.order {
|
||||||
|
value := set.getValue(name)
|
||||||
|
|
||||||
|
// Only write property sets in the sets phase.
|
||||||
|
switch v := value.(type) {
|
||||||
|
case *bpPropertySet:
|
||||||
|
contents.Printfln("%s: {", name)
|
||||||
|
outputPropertySet(contents, v)
|
||||||
|
contents.Printfln("},")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
contents.Dedent()
|
contents.Dedent()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user