AndroidMkEntries() returns multiple AndroidMkEntries structs

AndroidMkEntries now returns multiple AndroidMkEntires so that a module
can emit multiple Make modules if needed.

Bug: 128708192
Test: m

Change-Id: I56b6f76d22943b80329951c5acb80a1b932441ad
This commit is contained in:
Jiyong Park 2019-12-03 13:24:29 +09:00
parent ce482dce02
commit 0b0e1b9804
17 changed files with 116 additions and 108 deletions

View file

@ -61,7 +61,7 @@ type AndroidMkExtraFunc func(w io.Writer, outputFile Path)
// Allows modules to customize their Android*.mk output. // Allows modules to customize their Android*.mk output.
type AndroidMkEntriesProvider interface { type AndroidMkEntriesProvider interface {
AndroidMkEntries() AndroidMkEntries AndroidMkEntries() []AndroidMkEntries
BaseModuleName() string BaseModuleName() string
} }
@ -510,10 +510,10 @@ func translateAndroidMkEntriesModule(ctx SingletonContext, w io.Writer, mod blue
return nil return nil
} }
entries := provider.AndroidMkEntries() for _, entries := range provider.AndroidMkEntries() {
entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod) entries.fillInEntries(ctx.Config(), ctx.BlueprintFile(mod), mod)
entries.write(w) entries.write(w)
}
return nil return nil
} }

View file

@ -165,12 +165,12 @@ func (p *PrebuiltEtc) GenerateAndroidBuildActions(ctx ModuleContext) {
}) })
} }
func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries { func (p *PrebuiltEtc) AndroidMkEntries() []AndroidMkEntries {
nameSuffix := "" nameSuffix := ""
if p.inRecovery() && !p.onlyInRecovery() { if p.inRecovery() && !p.onlyInRecovery() {
nameSuffix = ".recovery" nameSuffix = ".recovery"
} }
return AndroidMkEntries{ return []AndroidMkEntries{AndroidMkEntries{
Class: "ETC", Class: "ETC",
SubName: nameSuffix, SubName: nameSuffix,
OutputFile: OptionalPathForPath(p.outputFilePath), OutputFile: OptionalPathForPath(p.outputFilePath),
@ -187,7 +187,7 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries {
} }
}, },
}, },
} }}
} }
func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) { func InitPrebuiltEtcModule(p *PrebuiltEtc, dirBase string) {

View file

@ -142,7 +142,7 @@ func TestPrebuiltEtcAndroidMk(t *testing.T) {
} }
mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc) mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a_core").Module().(*PrebuiltEtc)
entries := AndroidMkEntriesForTest(t, config, "", mod) entries := AndroidMkEntriesForTest(t, config, "", mod)[0]
for k, expectedValue := range expected { for k, expectedValue := range expected {
if value, ok := entries.EntryMap[k]; ok { if value, ok := entries.EntryMap[k]; ok {
if !reflect.DeepEqual(value, expectedValue) { if !reflect.DeepEqual(value, expectedValue) {

View file

@ -135,8 +135,8 @@ func (s *ShBinary) GenerateAndroidBuildActions(ctx ModuleContext) {
}) })
} }
func (s *ShBinary) AndroidMkEntries() AndroidMkEntries { func (s *ShBinary) AndroidMkEntries() []AndroidMkEntries {
return AndroidMkEntries{ return []AndroidMkEntries{AndroidMkEntries{
Class: "EXECUTABLES", Class: "EXECUTABLES",
OutputFile: OptionalPathForPath(s.outputFilePath), OutputFile: OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
@ -145,7 +145,7 @@ func (s *ShBinary) AndroidMkEntries() AndroidMkEntries {
s.customAndroidMkEntries(entries) s.customAndroidMkEntries(entries)
}, },
}, },
} }}
} }
func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) { func (s *ShBinary) customAndroidMkEntries(entries *AndroidMkEntries) {
@ -163,8 +163,8 @@ func (s *ShTest) GenerateAndroidBuildActions(ctx ModuleContext) {
s.data = PathsForModuleSrc(ctx, s.testProperties.Data) s.data = PathsForModuleSrc(ctx, s.testProperties.Data)
} }
func (s *ShTest) AndroidMkEntries() AndroidMkEntries { func (s *ShTest) AndroidMkEntries() []AndroidMkEntries {
return AndroidMkEntries{ return []AndroidMkEntries{AndroidMkEntries{
Class: "NATIVE_TESTS", Class: "NATIVE_TESTS",
OutputFile: OptionalPathForPath(s.outputFilePath), OutputFile: OptionalPathForPath(s.outputFilePath),
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
@ -185,7 +185,7 @@ func (s *ShTest) AndroidMkEntries() AndroidMkEntries {
} }
}, },
}, },
} }}
} }
func InitShBinaryModule(s *ShBinary) { func InitShBinaryModule(s *ShBinary) {

View file

@ -42,7 +42,7 @@ func TestShTestTestData(t *testing.T) {
mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest) mod := ctx.ModuleForTests("foo", "android_arm64_armv8-a").Module().(*ShTest)
entries := AndroidMkEntriesForTest(t, config, "", mod) entries := AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{":testdata/data1", ":testdata/sub/data2"} expected := []string{":testdata/data1", ":testdata/sub/data2"}
actual := entries.EntryMap["LOCAL_TEST_DATA"] actual := entries.EntryMap["LOCAL_TEST_DATA"]
if !reflect.DeepEqual(expected, actual) { if !reflect.DeepEqual(expected, actual) {

View file

@ -403,15 +403,18 @@ func CheckErrorsAgainstExpectations(t *testing.T, errs []error, expectedErrorPat
} }
func AndroidMkEntriesForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkEntries { func AndroidMkEntriesForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) []AndroidMkEntries {
var p AndroidMkEntriesProvider var p AndroidMkEntriesProvider
var ok bool var ok bool
if p, ok = mod.(AndroidMkEntriesProvider); !ok { if p, ok = mod.(AndroidMkEntriesProvider); !ok {
t.Errorf("module does not implement AndroidMkEntriesProvider: " + mod.Name()) t.Errorf("module does not implement AndroidMkEntriesProvider: " + mod.Name())
} }
entries := p.AndroidMkEntries()
entries.fillInEntries(config, bpPath, mod) entriesList := p.AndroidMkEntries()
return entries for i, _ := range entriesList {
entriesList[i].fillInEntries(config, bpPath, mod)
}
return entriesList
} }
func AndroidMkDataForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkData { func AndroidMkDataForTest(t *testing.T, config Config, bpPath string, mod blueprint.Module) AndroidMkData {

View file

@ -2380,7 +2380,7 @@ func TestPrebuiltOverrides(t *testing.T) {
p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt) p := ctx.ModuleForTests("myapex.prebuilt", "android_common").Module().(*Prebuilt)
expected := []string{"myapex"} expected := []string{"myapex"}
actual := android.AndroidMkEntriesForTest(t, config, "", p).EntryMap["LOCAL_OVERRIDES_MODULES"] actual := android.AndroidMkEntriesForTest(t, config, "", p)[0].EntryMap["LOCAL_OVERRIDES_MODULES"]
if !reflect.DeepEqual(actual, expected) { if !reflect.DeepEqual(actual, expected) {
t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES value '%s', expected '%s'", actual, expected) t.Errorf("Incorrect LOCAL_OVERRIDES_MODULES value '%s', expected '%s'", actual, expected)
} }

View file

@ -181,8 +181,8 @@ func (p *Prebuilt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
// TODO(b/143192278): Add compat symlinks for prebuilt_apex // TODO(b/143192278): Add compat symlinks for prebuilt_apex
} }
func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries { func (p *Prebuilt) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC", Class: "ETC",
OutputFile: android.OptionalPathForPath(p.inputApex), OutputFile: android.OptionalPathForPath(p.inputApex),
Include: "$(BUILD_PREBUILT)", Include: "$(BUILD_PREBUILT)",
@ -194,5 +194,5 @@ func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries {
entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.properties.Overrides...) entries.AddStrings("LOCAL_OVERRIDES_MODULES", p.properties.Overrides...)
}, },
}, },
} }}
} }

View file

@ -421,7 +421,7 @@ func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
}`, config) }`, config)
module := ctx.ModuleForTests("llndk.libraries.txt", "") module := ctx.ModuleForTests("llndk.libraries.txt", "")
entries := android.AndroidMkEntriesForTest(t, config, "", module.Module()) entries := android.AndroidMkEntriesForTest(t, config, "", module.Module())[0]
assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.VER.txt"}) assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.VER.txt"})
} }

View file

@ -460,8 +460,8 @@ func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleConte
ctx.InstallFile(installPath, filename, txt.outputFile) ctx.InstallFile(installPath, filename, txt.outputFile)
} }
func (txt *vndkLibrariesTxt) AndroidMkEntries() android.AndroidMkEntries { func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC", Class: "ETC",
OutputFile: android.OptionalPathForPath(txt.outputFile), OutputFile: android.OptionalPathForPath(txt.outputFile),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
@ -469,7 +469,7 @@ func (txt *vndkLibrariesTxt) AndroidMkEntries() android.AndroidMkEntries {
entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base()) entries.SetString("LOCAL_MODULE_STEM", txt.outputFile.Base())
}, },
}, },
} }}
} }
func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath { func (txt *vndkLibrariesTxt) OutputFile() android.OutputPath {

View file

@ -22,8 +22,6 @@ import (
"android/soong/android" "android/soong/android"
) )
// TODO(jungjw): We'll probably want AndroidMkEntriesProvider.AndroidMkEntries to return multiple
// entries so that this can be more error-proof.
func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) { func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *android.AndroidMkEntries) {
if Bool(library.deviceProperties.Hostdex) && !library.Host() { if Bool(library.deviceProperties.Hostdex) && !library.Host() {
fmt.Fprintln(w, "include $(CLEAR_VARS)") fmt.Fprintln(w, "include $(CLEAR_VARS)")
@ -57,13 +55,13 @@ func (library *Library) AndroidMkHostDex(w io.Writer, name string, entries *andr
} }
} }
func (library *Library) AndroidMkEntries() android.AndroidMkEntries { func (library *Library) AndroidMkEntries() []android.AndroidMkEntries {
if !library.IsForPlatform() { if !library.IsForPlatform() {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true, Disabled: true,
}}
} }
} return []android.AndroidMkEntries{android.AndroidMkEntries{
return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(library.outputFile), OutputFile: android.OptionalPathForPath(library.outputFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@ -111,7 +109,7 @@ func (library *Library) AndroidMkEntries() android.AndroidMkEntries {
library.AndroidMkHostDex(w, name, entries) library.AndroidMkHostDex(w, name, entries)
}, },
}, },
} }}
} }
// Called for modules that are a component of a test suite. // Called for modules that are a component of a test suite.
@ -124,8 +122,9 @@ func testSuiteComponent(entries *android.AndroidMkEntries, test_suites []string)
} }
} }
func (j *Test) AndroidMkEntries() android.AndroidMkEntries { func (j *Test) AndroidMkEntries() []android.AndroidMkEntries {
entries := j.Library.AndroidMkEntries() entriesList := j.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, j.testProperties.Test_suites) testSuiteComponent(entries, j.testProperties.Test_suites)
if j.testConfig != nil { if j.testConfig != nil {
@ -134,25 +133,26 @@ func (j *Test) AndroidMkEntries() android.AndroidMkEntries {
androidMkWriteTestData(j.data, entries) androidMkWriteTestData(j.data, entries)
}) })
return entries return entriesList
} }
func (j *TestHelperLibrary) AndroidMkEntries() android.AndroidMkEntries { func (j *TestHelperLibrary) AndroidMkEntries() []android.AndroidMkEntries {
entries := j.Library.AndroidMkEntries() entriesList := j.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites) testSuiteComponent(entries, j.testHelperLibraryProperties.Test_suites)
}) })
return entries return entriesList
} }
func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries { func (prebuilt *Import) AndroidMkEntries() []android.AndroidMkEntries {
if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() { if !prebuilt.IsForPlatform() || !prebuilt.ContainingSdk().Unversioned() {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true, Disabled: true,
}}
} }
} return []android.AndroidMkEntries{android.AndroidMkEntries{
return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile), OutputFile: android.OptionalPathForPath(prebuilt.combinedClasspathFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@ -165,16 +165,16 @@ func (prebuilt *Import) AndroidMkEntries() android.AndroidMkEntries {
entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem()) entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
}, },
}, },
} }}
} }
func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries { func (prebuilt *DexImport) AndroidMkEntries() []android.AndroidMkEntries {
if !prebuilt.IsForPlatform() { if !prebuilt.IsForPlatform() {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true, Disabled: true,
}}
} }
} return []android.AndroidMkEntries{android.AndroidMkEntries{
return android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile), OutputFile: android.OptionalPathForPath(prebuilt.maybeStrippedDexJarFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@ -193,11 +193,11 @@ func (prebuilt *DexImport) AndroidMkEntries() android.AndroidMkEntries {
entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem()) entries.SetString("LOCAL_MODULE_STEM", prebuilt.Stem())
}, },
}, },
} }}
} }
func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries { func (prebuilt *AARImport) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(prebuilt.classpathFile), OutputFile: android.OptionalPathForPath(prebuilt.classpathFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@ -213,13 +213,13 @@ func (prebuilt *AARImport) AndroidMkEntries() android.AndroidMkEntries {
entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion()) entries.SetString("LOCAL_SDK_VERSION", prebuilt.sdkVersion())
}, },
}, },
} }}
} }
func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries { func (binary *Binary) AndroidMkEntries() []android.AndroidMkEntries {
if !binary.isWrapperVariant { if !binary.isWrapperVariant {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(binary.outputFile), OutputFile: android.OptionalPathForPath(binary.outputFile),
Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_java_prebuilt.mk",
@ -240,9 +240,9 @@ func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries {
fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)") fmt.Fprintln(w, "jar_installed_module := $(LOCAL_INSTALLED_MODULE)")
}, },
}, },
} }}
} else { } else {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "EXECUTABLES", Class: "EXECUTABLES",
OutputFile: android.OptionalPathForPath(binary.wrapperFile), OutputFile: android.OptionalPathForPath(binary.wrapperFile),
ExtraEntries: []android.AndroidMkExtraEntriesFunc{ ExtraEntries: []android.AndroidMkExtraEntriesFunc{
@ -257,17 +257,17 @@ func (binary *Binary) AndroidMkEntries() android.AndroidMkEntries {
fmt.Fprintln(w, "jar_installed_module :=") fmt.Fprintln(w, "jar_installed_module :=")
}, },
}, },
} }}
} }
} }
func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries { func (app *AndroidApp) AndroidMkEntries() []android.AndroidMkEntries {
if !app.IsForPlatform() { if !app.IsForPlatform() {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Disabled: true, Disabled: true,
}}
} }
} return []android.AndroidMkEntries{android.AndroidMkEntries{
return android.AndroidMkEntries{
Class: "APPS", Class: "APPS",
OutputFile: android.OptionalPathForPath(app.outputFile), OutputFile: android.OptionalPathForPath(app.outputFile),
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
@ -359,7 +359,7 @@ func (app *AndroidApp) AndroidMkEntries() android.AndroidMkEntries {
} }
}, },
}, },
} }}
} }
func (a *AndroidApp) getOverriddenPackages() []string { func (a *AndroidApp) getOverriddenPackages() []string {
@ -373,8 +373,9 @@ func (a *AndroidApp) getOverriddenPackages() []string {
return overridden return overridden
} }
func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries { func (a *AndroidTest) AndroidMkEntries() []android.AndroidMkEntries {
entries := a.AndroidApp.AndroidMkEntries() entriesList := a.AndroidApp.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.testProperties.Test_suites) testSuiteComponent(entries, a.testProperties.Test_suites)
if a.testConfig != nil { if a.testConfig != nil {
@ -383,20 +384,22 @@ func (a *AndroidTest) AndroidMkEntries() android.AndroidMkEntries {
androidMkWriteTestData(a.data, entries) androidMkWriteTestData(a.data, entries)
}) })
return entries return entriesList
} }
func (a *AndroidTestHelperApp) AndroidMkEntries() android.AndroidMkEntries { func (a *AndroidTestHelperApp) AndroidMkEntries() []android.AndroidMkEntries {
entries := a.AndroidApp.AndroidMkEntries() entriesList := a.AndroidApp.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites) testSuiteComponent(entries, a.appTestHelperAppProperties.Test_suites)
}) })
return entries return entriesList
} }
func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries { func (a *AndroidLibrary) AndroidMkEntries() []android.AndroidMkEntries {
entries := a.Library.AndroidMkEntries() entriesList := a.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
if a.aarFile != nil { if a.aarFile != nil {
@ -417,11 +420,11 @@ func (a *AndroidLibrary) AndroidMkEntries() android.AndroidMkEntries {
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true) entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", true)
}) })
return entries return entriesList
} }
func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries { func (jd *Javadoc) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(jd.stubsSrcJar), OutputFile: android.OptionalPathForPath(jd.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
@ -435,11 +438,11 @@ func (jd *Javadoc) AndroidMkEntries() android.AndroidMkEntries {
} }
}, },
}, },
} }}
} }
func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries { func (ddoc *Droiddoc) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar), OutputFile: android.OptionalPathForPath(ddoc.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
@ -520,11 +523,11 @@ func (ddoc *Droiddoc) AndroidMkEntries() android.AndroidMkEntries {
} }
}, },
}, },
} }}
} }
func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries { func (dstubs *Droidstubs) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "JAVA_LIBRARIES", Class: "JAVA_LIBRARIES",
OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar), OutputFile: android.OptionalPathForPath(dstubs.stubsSrcJar),
Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_droiddoc_prebuilt.mk",
@ -636,11 +639,11 @@ func (dstubs *Droidstubs) AndroidMkEntries() android.AndroidMkEntries {
} }
}, },
}, },
} }}
} }
func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries { func (a *AndroidAppImport) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "APPS", Class: "APPS",
OutputFile: android.OptionalPathForPath(a.outputFile), OutputFile: android.OptionalPathForPath(a.outputFile),
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk", Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
@ -659,16 +662,17 @@ func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel()) entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
}, },
}, },
} }}
} }
func (a *AndroidTestImport) AndroidMkEntries() android.AndroidMkEntries { func (a *AndroidTestImport) AndroidMkEntries() []android.AndroidMkEntries {
entries := a.AndroidAppImport.AndroidMkEntries() entriesList := a.AndroidAppImport.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) { entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
testSuiteComponent(entries, a.testProperties.Test_suites) testSuiteComponent(entries, a.testProperties.Test_suites)
androidMkWriteTestData(a.data, entries) androidMkWriteTestData(a.data, entries)
}) })
return entries return entriesList
} }
func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) { func androidMkWriteTestData(data android.Paths, entries *android.AndroidMkEntries) {

View file

@ -31,7 +31,7 @@ func TestRequired(t *testing.T) {
`) `)
mod := ctx.ModuleForTests("foo", "android_common").Module() mod := ctx.ModuleForTests("foo", "android_common").Module()
entries := android.AndroidMkEntriesForTest(t, config, "", mod) entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{"libfoo"} expected := []string{"libfoo"}
actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"] actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
@ -50,7 +50,7 @@ func TestHostdex(t *testing.T) {
`) `)
mod := ctx.ModuleForTests("foo", "android_common").Module() mod := ctx.ModuleForTests("foo", "android_common").Module()
entries := android.AndroidMkEntriesForTest(t, config, "", mod) entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{"foo"} expected := []string{"foo"}
actual := entries.EntryMap["LOCAL_MODULE"] actual := entries.EntryMap["LOCAL_MODULE"]
@ -75,7 +75,7 @@ func TestHostdexRequired(t *testing.T) {
`) `)
mod := ctx.ModuleForTests("foo", "android_common").Module() mod := ctx.ModuleForTests("foo", "android_common").Module()
entries := android.AndroidMkEntriesForTest(t, config, "", mod) entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
expected := []string{"libfoo"} expected := []string{"libfoo"}
actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"] actual := entries.EntryMap["LOCAL_REQUIRED_MODULES"]
@ -104,7 +104,7 @@ func TestHostdexSpecificRequired(t *testing.T) {
`) `)
mod := ctx.ModuleForTests("foo", "android_common").Module() mod := ctx.ModuleForTests("foo", "android_common").Module()
entries := android.AndroidMkEntriesForTest(t, config, "", mod) entries := android.AndroidMkEntriesForTest(t, config, "", mod)[0]
if r, ok := entries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok { if r, ok := entries.EntryMap["LOCAL_REQUIRED_MODULES"]; ok {
t.Errorf("Unexpected required modules: %q", r) t.Errorf("Unexpected required modules: %q", r)

View file

@ -1529,7 +1529,7 @@ func TestAndroidAppImport_Filename(t *testing.T) {
a := variant.Module().(*AndroidAppImport) a := variant.Module().(*AndroidAppImport)
expectedValues := []string{test.expected} expectedValues := []string{test.expected}
actualValues := android.AndroidMkEntriesForTest( actualValues := android.AndroidMkEntriesForTest(
t, config, "", a).EntryMap["LOCAL_INSTALLED_MODULE_STEM"] t, config, "", a)[0].EntryMap["LOCAL_INSTALLED_MODULE_STEM"]
if !reflect.DeepEqual(actualValues, expectedValues) { if !reflect.DeepEqual(actualValues, expectedValues) {
t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'", t.Errorf("Incorrect LOCAL_INSTALLED_MODULE_STEM value '%s', expected '%s'",
actualValues, expectedValues) actualValues, expectedValues)
@ -1615,7 +1615,7 @@ func TestAndroidTestImport(t *testing.T) {
test := ctx.ModuleForTests("foo", "android_common").Module().(*AndroidTestImport) test := ctx.ModuleForTests("foo", "android_common").Module().(*AndroidTestImport)
// Check android mks. // Check android mks.
entries := android.AndroidMkEntriesForTest(t, config, "", test) entries := android.AndroidMkEntriesForTest(t, config, "", test)[0]
expected := []string{"tests"} expected := []string{"tests"}
actual := entries.EntryMap["LOCAL_MODULE_TAGS"] actual := entries.EntryMap["LOCAL_MODULE_TAGS"]
if !reflect.DeepEqual(expected, actual) { if !reflect.DeepEqual(expected, actual) {

View file

@ -71,8 +71,8 @@ func (p *platformCompatConfig) GenerateAndroidBuildActions(ctx android.ModuleCon
} }
func (p *platformCompatConfig) AndroidMkEntries() android.AndroidMkEntries { func (p *platformCompatConfig) AndroidMkEntries() []android.AndroidMkEntries {
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "ETC", Class: "ETC",
OutputFile: android.OptionalPathForPath(p.configFile), OutputFile: android.OptionalPathForPath(p.configFile),
Include: "$(BUILD_PREBUILT)", Include: "$(BUILD_PREBUILT)",
@ -82,7 +82,7 @@ func (p *platformCompatConfig) AndroidMkEntries() android.AndroidMkEntries {
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.configFile.Base()) entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.configFile.Base())
}, },
}, },
} }}
} }
func platformCompatConfigFactory() android.Module { func platformCompatConfigFactory() android.Module {

View file

@ -158,8 +158,9 @@ func (r *robolectricTest) generateRoboSrcJar(ctx android.ModuleContext, outputFi
TransformResourcesToJar(ctx, outputFile, srcJarArgs, srcJarDeps) TransformResourcesToJar(ctx, outputFile, srcJarArgs, srcJarDeps)
} }
func (r *robolectricTest) AndroidMkEntries() android.AndroidMkEntries { func (r *robolectricTest) AndroidMkEntries() []android.AndroidMkEntries {
entries := r.Library.AndroidMkEntries() entriesList := r.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{ entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
@ -185,7 +186,7 @@ func (r *robolectricTest) AndroidMkEntries() android.AndroidMkEntries {
}, },
} }
return entries return entriesList
} }
func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, tests []string) { func (r *robolectricTest) writeTestRunner(w io.Writer, module, name string, tests []string) {

View file

@ -194,13 +194,13 @@ func (module *SdkLibrary) GenerateAndroidBuildActions(ctx android.ModuleContext)
}) })
} }
func (module *SdkLibrary) AndroidMkEntries() android.AndroidMkEntries { func (module *SdkLibrary) AndroidMkEntries() []android.AndroidMkEntries {
entries := module.Library.AndroidMkEntries() entriesList := module.Library.AndroidMkEntries()
entries := &entriesList[0]
entries.Required = append(entries.Required, module.xmlFileName()) entries.Required = append(entries.Required, module.xmlFileName())
entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{ entries.ExtraFooters = []android.AndroidMkExtraFootersFunc{
func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) { func(w io.Writer, name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
module.Library.AndroidMkHostDex(w, name, entries)
if !Bool(module.sdkLibraryProperties.No_dist) { if !Bool(module.sdkLibraryProperties.No_dist) {
// Create a phony module that installs the impl library, for the case when this lib is // Create a phony module that installs the impl library, for the case when this lib is
// in PRODUCT_PACKAGES. // in PRODUCT_PACKAGES.
@ -252,7 +252,7 @@ func (module *SdkLibrary) AndroidMkEntries() android.AndroidMkEntries {
} }
}, },
} }
return entries return entriesList
} }
// Module name of the stubs library // Module name of the stubs library

View file

@ -163,12 +163,12 @@ func (s *sdk) GenerateAndroidBuildActions(ctx android.ModuleContext) {
} }
} }
func (s *sdk) AndroidMkEntries() android.AndroidMkEntries { func (s *sdk) AndroidMkEntries() []android.AndroidMkEntries {
if !s.snapshotFile.Valid() { if !s.snapshotFile.Valid() {
return android.AndroidMkEntries{} return []android.AndroidMkEntries{}
} }
return android.AndroidMkEntries{ return []android.AndroidMkEntries{android.AndroidMkEntries{
Class: "FAKE", Class: "FAKE",
OutputFile: s.snapshotFile, OutputFile: s.snapshotFile,
DistFile: s.snapshotFile, DistFile: s.snapshotFile,
@ -180,7 +180,7 @@ func (s *sdk) AndroidMkEntries() android.AndroidMkEntries {
fmt.Fprintln(w, s.Name()+":", s.snapshotFile.String()) fmt.Fprintln(w, s.Name()+":", s.snapshotFile.String())
}, },
}, },
} }}
} }
// RegisterPreDepsMutators registers pre-deps mutators to support modules implementing SdkAware // RegisterPreDepsMutators registers pre-deps mutators to support modules implementing SdkAware