aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLiz Kammer <eakammer@google.com>2020-11-24 08:36:14 -0800
committerLiz Kammer <eakammer@google.com>2020-12-04 00:22:17 +0000
commitba15748990c9ebd695e1ed12a0631d80836c2adf (patch)
treea493c40f27995e1e0debdb416fd4be92260f6766
parenta3f4ee51d5cef973a8b6f4bfbdf3589f1ba545c4 (diff)
downloadsoong-ba15748990c9ebd695e1ed12a0631d80836c2adf.tar.gz
Refactor python to use AndroidMkEntries.
This is to enable consolidating test compatibility suite handling in Soong's AndroidMk files. Bug: 170318013 Test: go test soong tests Test: m nothing and compare soong/Android mk files -- only diffs is that lines matching "^LOCAL_SHARED_LIBRARIES := $" are absent (cherry picked from commit I4922a1c8b0231cd98ebd2bc7257956eb9c0d240c) Merged-In: I4922a1c8b0231cd98ebd2bc7257956eb9c0d240c Change-Id: I4922a1c8b0231cd98ebd2bc7257956eb9c0d240c
-rw-r--r--python/androidmk.go68
-rw-r--r--python/python.go2
2 files changed, 30 insertions, 40 deletions
diff --git a/python/androidmk.go b/python/androidmk.go
index 247b80dc0..61cde019c 100644
--- a/python/androidmk.go
+++ b/python/androidmk.go
@@ -16,84 +16,74 @@ package python
import (
"android/soong/android"
- "fmt"
- "io"
"path/filepath"
"strings"
)
type subAndroidMkProvider interface {
- AndroidMk(*Module, *android.AndroidMkData)
+ AndroidMk(*Module, *android.AndroidMkEntries)
}
-func (p *Module) subAndroidMk(data *android.AndroidMkData, obj interface{}) {
+func (p *Module) subAndroidMk(entries *android.AndroidMkEntries, obj interface{}) {
if p.subAndroidMkOnce == nil {
p.subAndroidMkOnce = make(map[subAndroidMkProvider]bool)
}
if androidmk, ok := obj.(subAndroidMkProvider); ok {
if !p.subAndroidMkOnce[androidmk] {
p.subAndroidMkOnce[androidmk] = true
- androidmk.AndroidMk(p, data)
+ androidmk.AndroidMk(p, entries)
}
}
}
-func (p *Module) AndroidMk() android.AndroidMkData {
- ret := android.AndroidMkData{OutputFile: p.installSource}
+func (p *Module) AndroidMkEntries() []android.AndroidMkEntries {
+ entries := android.AndroidMkEntries{OutputFile: p.installSource}
- p.subAndroidMk(&ret, p.installer)
+ p.subAndroidMk(&entries, p.installer)
- return ret
+ return []android.AndroidMkEntries{entries}
}
-func (p *binaryDecorator) AndroidMk(base *Module, ret *android.AndroidMkData) {
- ret.Class = "EXECUTABLES"
+func (p *binaryDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
+ entries.Class = "EXECUTABLES"
- ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
- if len(p.binaryProperties.Test_suites) > 0 {
- fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
- strings.Join(p.binaryProperties.Test_suites, " "))
- }
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+ entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", p.binaryProperties.Test_suites...)
})
- base.subAndroidMk(ret, p.pythonInstaller)
+ base.subAndroidMk(entries, p.pythonInstaller)
}
-func (p *testDecorator) AndroidMk(base *Module, ret *android.AndroidMkData) {
- ret.Class = "NATIVE_TESTS"
+func (p *testDecorator) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
+ entries.Class = "NATIVE_TESTS"
- ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
- if len(p.binaryDecorator.binaryProperties.Test_suites) > 0 {
- fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
- strings.Join(p.binaryDecorator.binaryProperties.Test_suites, " "))
- }
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
+ entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", p.binaryDecorator.binaryProperties.Test_suites...)
if p.testConfig != nil {
- fmt.Fprintln(w, "LOCAL_FULL_TEST_CONFIG :=",
- p.testConfig.String())
+ entries.SetString("LOCAL_FULL_TEST_CONFIG", p.testConfig.String())
}
- if !BoolDefault(p.binaryProperties.Auto_gen_config, true) {
- fmt.Fprintln(w, "LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG := true")
- }
+ entries.SetBoolIfTrue("LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG", !BoolDefault(p.binaryProperties.Auto_gen_config, true))
+
})
- base.subAndroidMk(ret, p.binaryDecorator.pythonInstaller)
+ base.subAndroidMk(entries, p.binaryDecorator.pythonInstaller)
}
-func (installer *pythonInstaller) AndroidMk(base *Module, ret *android.AndroidMkData) {
+func (installer *pythonInstaller) AndroidMk(base *Module, entries *android.AndroidMkEntries) {
// Soong installation is only supported for host modules. Have Make
// installation trigger Soong installation.
if base.Target().Os.Class == android.Host {
- ret.OutputFile = android.OptionalPathForPath(installer.path)
+ entries.OutputFile = android.OptionalPathForPath(installer.path)
}
- ret.Required = append(ret.Required, "libc++")
- ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
+ entries.Required = append(entries.Required, "libc++")
+ entries.ExtraEntries = append(entries.ExtraEntries, func(entries *android.AndroidMkEntries) {
path, file := filepath.Split(installer.path.ToMakePath().String())
stem := strings.TrimSuffix(file, filepath.Ext(file))
- fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
- fmt.Fprintln(w, "LOCAL_MODULE_PATH := "+path)
- fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
- fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(installer.androidMkSharedLibs, " "))
- fmt.Fprintln(w, "LOCAL_CHECK_ELF_FILES := false")
+ entries.SetString("LOCAL_MODULE_SUFFIX", filepath.Ext(file))
+ entries.SetString("LOCAL_MODULE_PATH", path)
+ entries.SetString("LOCAL_MODULE_STEM", stem)
+ entries.AddStrings("LOCAL_SHARED_LIBRARIES", installer.androidMkSharedLibs...)
+ entries.SetBool("LOCAL_CHECK_ELF_FILES", false)
})
}
diff --git a/python/python.go b/python/python.go
index 8b912be17..4e15d3a07 100644
--- a/python/python.go
+++ b/python/python.go
@@ -185,7 +185,7 @@ func (p *Module) GetSrcsZip() android.Path {
var _ PythonDependency = (*Module)(nil)
-var _ android.AndroidMkDataProvider = (*Module)(nil)
+var _ android.AndroidMkEntriesProvider = (*Module)(nil)
func (p *Module) Init() android.Module {