Fix crash in mergeListProperties
The value of a property to be merged may be a reference to a variable. When we first create an attribute for a makefile variable (e.g. we create 'android_static_libs' from LOCAL_STATIC_ANDROID_LIBRARIES), we set its type correctly. However, reparse in bpfix erases this information, so by the time 'android_static_libs' attribute is to be merged with 'static_libs', it has no type and merge occurs. It isn't easy to fix properly, so just don't merge in such case, Soong will complain and it will be fixed manually. Fixes: 125519127 Test: unit tests in androidmk_test.go Change-Id: Ic66d7ab686a2fdde987f32e2b204c72d9bf0d026
This commit is contained in:
@@ -1073,6 +1073,25 @@ vts_config {
|
|||||||
expected: `
|
expected: `
|
||||||
// Comment line 1 \
|
// Comment line 1 \
|
||||||
// Comment line 2
|
// Comment line 2
|
||||||
|
`,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
desc: "Merge with variable reference",
|
||||||
|
in: `
|
||||||
|
include $(CLEAR_VARS)
|
||||||
|
LOCAL_MODULE := foo
|
||||||
|
LOCAL_STATIC_ANDROID_LIBRARIES := $(FOO)
|
||||||
|
LOCAL_STATIC_JAVA_LIBRARIES := javalib
|
||||||
|
LOCAL_JAVA_RESOURCE_DIRS := $(FOO)
|
||||||
|
include $(BUILD_PACKAGE)
|
||||||
|
`,
|
||||||
|
expected: `
|
||||||
|
android_app {
|
||||||
|
name: "foo",
|
||||||
|
static_libs: FOO,
|
||||||
|
static_libs: ["javalib"],
|
||||||
|
java_resource_dirs: FOO,
|
||||||
|
}
|
||||||
`,
|
`,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
@@ -786,6 +786,14 @@ func mergeMatchingProperties(properties *[]*parser.Property, buf []byte, patchli
|
|||||||
}
|
}
|
||||||
|
|
||||||
func mergeProperties(a, b *parser.Property, buf []byte, patchlist *parser.PatchList) error {
|
func mergeProperties(a, b *parser.Property, buf []byte, patchlist *parser.PatchList) error {
|
||||||
|
// The value of one of the properties may be a variable reference with no type assigned
|
||||||
|
// Bail out in this case. Soong will notice duplicate entries and will tell to merge them.
|
||||||
|
if _, isVar := a.Value.(*parser.Variable); isVar {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
if _, isVar := b.Value.(*parser.Variable); isVar {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if a.Value.Type() != b.Value.Type() {
|
if a.Value.Type() != b.Value.Type() {
|
||||||
return fmt.Errorf("type mismatch when merging properties %q: %s and %s", a.Name, a.Value.Type(), b.Value.Type())
|
return fmt.Errorf("type mismatch when merging properties %q: %s and %s", a.Name, a.Value.Type(), b.Value.Type())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user