Support testing versioned/unversioned sdk Android.bp files separately

Previously, the only way to test the Android.bp file generated by the
sdk module was to test both the unversioned and versioned parts
together. This change allows them to be tested separately.

Bug: 180479010
Test: m nothing
Change-Id: I3d695bcfbff030a6da393283ab30ec0979fb2826
This commit is contained in:
Paul Duffin
2021-02-17 11:23:00 +00:00
parent bc179bc44f
commit d075907d29
2 changed files with 65 additions and 8 deletions

View File

@@ -572,12 +572,20 @@ func (t pruneEmptySetTransformer) transformPropertySetAfterContents(name string,
}
func generateBpContents(contents *generatedContents, bpFile *bpFile) {
generateFilteredBpContents(contents, bpFile, func(*bpModule) bool {
return true
})
}
func generateFilteredBpContents(contents *generatedContents, bpFile *bpFile, moduleFilter func(module *bpModule) bool) {
contents.Printfln("// This is auto-generated. DO NOT EDIT.")
for _, bpModule := range bpFile.order {
contents.Printfln("")
contents.Printfln("%s {", bpModule.moduleType)
outputPropertySet(contents, bpModule.bpPropertySet)
contents.Printfln("}")
if moduleFilter(bpModule) {
contents.Printfln("")
contents.Printfln("%s {", bpModule.moduleType)
outputPropertySet(contents, bpModule.bpPropertySet)
contents.Printfln("}")
}
}
}
@@ -639,6 +647,22 @@ func (s *sdk) GetAndroidBpContentsForTests() string {
return contents.content.String()
}
func (s *sdk) GetUnversionedAndroidBpContentsForTests() string {
contents := &generatedContents{}
generateFilteredBpContents(contents, s.builderForTests.bpFile, func(module *bpModule) bool {
return !strings.Contains(module.properties["name"].(string), "@")
})
return contents.content.String()
}
func (s *sdk) GetVersionedAndroidBpContentsForTests() string {
contents := &generatedContents{}
generateFilteredBpContents(contents, s.builderForTests.bpFile, func(module *bpModule) bool {
return strings.Contains(module.properties["name"].(string), "@")
})
return contents.content.String()
}
type snapshotBuilder struct {
ctx android.ModuleContext
sdk *sdk