diff options
author | Paul Duffin <paulduffin@google.com> | 2020-03-11 18:17:42 +0000 |
---|---|---|
committer | Paul Duffin <paulduffin@google.com> | 2020-04-22 12:51:40 +0100 |
commit | 35dbafcf5412bd7b2109b1ab1af7c5a6cffc9d6c (patch) | |
tree | d702d6df51f923706c1fe97271b624c42e8309e0 /sdk | |
parent | 2bdbe83ec91391c278093542fcc0c0ce7f60011b (diff) | |
download | build_soong-35dbafcf5412bd7b2109b1ab1af7c5a6cffc9d6c.tar.gz build_soong-35dbafcf5412bd7b2109b1ab1af7c5a6cffc9d6c.tar.bz2 build_soong-35dbafcf5412bd7b2109b1ab1af7c5a6cffc9d6c.zip |
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
Bug: 153306490
Test: m nothing
Merged-In: Ia025bfc751f1217d1658de6fb8e15091ea0ea9ff
Change-Id: Ia025bfc751f1217d1658de6fb8e15091ea0ea9ff
Diffstat (limited to 'sdk')
-rw-r--r-- | sdk/cc_sdk_test.go | 2 | ||||
-rw-r--r-- | sdk/java_sdk_test.go | 2 | ||||
-rw-r--r-- | sdk/update.go | 42 |
3 files changed, 29 insertions, 17 deletions
diff --git a/sdk/cc_sdk_test.go b/sdk/cc_sdk_test.go index bba111b0..6f9dc3c1 100644 --- a/sdk/cc_sdk_test.go +++ b/sdk/cc_sdk_test.go @@ -1212,12 +1212,12 @@ module_exports_snapshot { name: "myexports@current", device_supported: false, host_supported: true, + native_static_libs: ["myexports_mynativelib@current"], target: { host: { compile_multilib: "64", }, }, - native_static_libs: ["myexports_mynativelib@current"], }`), checkAllCopyRules(` include/Test.h -> include/include/Test.h diff --git a/sdk/java_sdk_test.go b/sdk/java_sdk_test.go index c60002b0..cbffb501 100644 --- a/sdk/java_sdk_test.go +++ b/sdk/java_sdk_test.go @@ -920,6 +920,7 @@ java_import { module_exports_snapshot { name: "myexports@current", host_supported: true, + java_libs: ["myexports_myjavalib@current"], target: { android: { java_header_libs: ["myexports_androidjavalib@current"], @@ -928,7 +929,6 @@ module_exports_snapshot { java_header_libs: ["myexports_hostjavalib@current"], }, }, - java_libs: ["myexports_myjavalib@current"], } `), checkAllCopyRules(` diff --git a/sdk/update.go b/sdk/update.go index e790746c..779ba1a6 100644 --- a/sdk/update.go +++ b/sdk/update.go @@ -510,41 +510,53 @@ func generateBpContents(contents *generatedContents, bpFile *bpFile) { func outputPropertySet(contents *generatedContents, set *bpPropertySet) { 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 { value := set.getValue(name) - reflectedValue := reflect.ValueOf(value) - t := reflectedValue.Type() - - kind := t.Kind() - switch kind { - case reflect.Slice: - length := reflectedValue.Len() + switch v := value.(type) { + case []string: + length := len(v) if length > 1 { contents.Printfln("%s: [", name) contents.Indent() for i := 0; i < length; i = i + 1 { - contents.Printfln("%q,", reflectedValue.Index(i).Interface()) + contents.Printfln("%q,", v[i]) } contents.Dedent() contents.Printfln("],") } else if length == 0 { contents.Printfln("%s: [],", name) } 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: - contents.Printfln("%s: {", name) - outputPropertySet(contents, reflectedValue.Interface().(*bpPropertySet)) - contents.Printfln("},") + case bool: + contents.Printfln("%s: %t,", name, v) + + case *bpPropertySet: + // Do not write property sets in the properties phase. default: 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() } |