AndroidMkEntries minor refactoring.
This includes a few changes that make AndroidMkEntries more resemble AndroidMkData, especially in terms of how extra entries are added. Most importantly it can now have multiple custom functions. Test: Soong tests Change-Id: Ibf9102624d16d0c1c9894a2794fc7c797bb34c9a
This commit is contained in:
parent
21738f6032
commit
e0dc8dfd22
|
@ -79,12 +79,14 @@ type AndroidMkEntries struct {
|
|||
header bytes.Buffer
|
||||
footer bytes.Buffer
|
||||
|
||||
AddCustomEntries func(name, prefix, moduleDir string, entries *AndroidMkEntries)
|
||||
ExtraEntries []AndroidMkExtraEntriesFunc
|
||||
|
||||
EntryMap map[string][]string
|
||||
entryOrder []string
|
||||
}
|
||||
|
||||
type AndroidMkExtraEntriesFunc func(entries *AndroidMkEntries)
|
||||
|
||||
func (a *AndroidMkEntries) SetString(name, value string) {
|
||||
if _, ok := a.EntryMap[name]; !ok {
|
||||
a.entryOrder = append(a.entryOrder, name)
|
||||
|
@ -246,9 +248,8 @@ func (a *AndroidMkEntries) fillInEntries(config Config, bpPath string, mod bluep
|
|||
prefix = "2ND_" + prefix
|
||||
}
|
||||
}
|
||||
blueprintDir := filepath.Dir(bpPath)
|
||||
if a.AddCustomEntries != nil {
|
||||
a.AddCustomEntries(name, prefix, blueprintDir, a)
|
||||
for _, extra := range a.ExtraEntries {
|
||||
extra(a)
|
||||
}
|
||||
|
||||
// Write to footer.
|
||||
|
|
|
@ -155,7 +155,8 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries {
|
|||
Class: "ETC",
|
||||
SubName: nameSuffix,
|
||||
OutputFile: OptionalPathForPath(p.outputFilePath),
|
||||
AddCustomEntries: func(name, prefix, moduleDir string, entries *AndroidMkEntries) {
|
||||
ExtraEntries: []AndroidMkExtraEntriesFunc{
|
||||
func(entries *AndroidMkEntries) {
|
||||
entries.SetString("LOCAL_MODULE_TAGS", "optional")
|
||||
entries.SetString("LOCAL_MODULE_PATH", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
|
||||
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.outputFilePath.Base())
|
||||
|
@ -166,6 +167,7 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries {
|
|||
}
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -133,9 +133,11 @@ func (s *ShBinary) AndroidMkEntries() AndroidMkEntries {
|
|||
Class: "EXECUTABLES",
|
||||
OutputFile: OptionalPathForPath(s.outputFilePath),
|
||||
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
|
||||
AddCustomEntries: func(name, prefix, moduleDir string, entries *AndroidMkEntries) {
|
||||
ExtraEntries: []AndroidMkExtraEntriesFunc{
|
||||
func(entries *AndroidMkEntries) {
|
||||
s.customAndroidMkEntries(entries)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -156,7 +158,8 @@ func (s *ShTest) AndroidMkEntries() AndroidMkEntries {
|
|||
Class: "NATIVE_TESTS",
|
||||
OutputFile: OptionalPathForPath(s.outputFilePath),
|
||||
Include: "$(BUILD_SYSTEM)/soong_cc_prebuilt.mk",
|
||||
AddCustomEntries: func(name, prefix, moduleDir string, entries *AndroidMkEntries) {
|
||||
ExtraEntries: []AndroidMkExtraEntriesFunc{
|
||||
func(entries *AndroidMkEntries) {
|
||||
s.customAndroidMkEntries(entries)
|
||||
|
||||
entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", s.testProperties.Test_suites...)
|
||||
|
@ -171,6 +174,7 @@ func (s *ShTest) AndroidMkEntries() AndroidMkEntries {
|
|||
entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1687,12 +1687,14 @@ func (p *Prebuilt) AndroidMkEntries() android.AndroidMkEntries {
|
|||
Class: "ETC",
|
||||
OutputFile: android.OptionalPathForPath(p.inputApex),
|
||||
Include: "$(BUILD_PREBUILT)",
|
||||
AddCustomEntries: func(name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
|
||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||
func(entries *android.AndroidMkEntries) {
|
||||
entries.SetString("LOCAL_MODULE_PATH", filepath.Join("$(OUT_DIR)", p.installDir.RelPathString()))
|
||||
entries.SetString("LOCAL_MODULE_STEM", p.installFilename)
|
||||
entries.SetBoolIfTrue("LOCAL_UNINSTALLABLE_MODULE", !p.installable())
|
||||
entries.AddStrings("LOCAL_OVERRIDES_PACKAGES", p.properties.Overrides...)
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -614,7 +614,8 @@ func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
|
|||
Class: "APPS",
|
||||
OutputFile: android.OptionalPathForPath(a.outputFile),
|
||||
Include: "$(BUILD_SYSTEM)/soong_app_prebuilt.mk",
|
||||
AddCustomEntries: func(name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
|
||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||
func(entries *android.AndroidMkEntries) {
|
||||
entries.SetBoolIfTrue("LOCAL_PRIVILEGED_MODULE", Bool(a.properties.Privileged))
|
||||
if a.certificate != nil {
|
||||
entries.SetString("LOCAL_CERTIFICATE", a.certificate.Pem.String())
|
||||
|
@ -627,6 +628,7 @@ func (a *AndroidAppImport) AndroidMkEntries() android.AndroidMkEntries {
|
|||
}
|
||||
entries.AddStrings("LOCAL_INSTALLED_MODULE_STEM", a.installPath.Rel())
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,10 +77,12 @@ func (p *platformCompatConfig) AndroidMkEntries() android.AndroidMkEntries {
|
|||
Class: "ETC",
|
||||
OutputFile: android.OptionalPathForPath(p.configFile),
|
||||
Include: "$(BUILD_PREBUILT)",
|
||||
AddCustomEntries: func(name, prefix, moduleDir string, entries *android.AndroidMkEntries) {
|
||||
ExtraEntries: []android.AndroidMkExtraEntriesFunc{
|
||||
func(entries *android.AndroidMkEntries) {
|
||||
entries.SetString("LOCAL_MODULE_PATH", "$(OUT_DIR)/"+p.installDirPath.RelPathString())
|
||||
entries.SetString("LOCAL_INSTALLED_MODULE_STEM", p.configFile.Base())
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue