diff options
author | TreeHugger Robot <treehugger-gerrit@google.com> | 2020-12-05 00:07:06 +0000 |
---|---|---|
committer | Android (Google) Code Review <android-gerrit@google.com> | 2020-12-05 00:07:06 +0000 |
commit | 53a3d92368d49bef8b1ab66b785563f97354f358 (patch) | |
tree | 87968193cb210f57956464717327913df9447293 | |
parent | 176d99de10f098ebcf98b27d609d325b6a02b36c (diff) | |
parent | ba15748990c9ebd695e1ed12a0631d80836c2adf (diff) | |
download | soong-53a3d92368d49bef8b1ab66b785563f97354f358.tar.gz |
Merge "Refactor python to use AndroidMkEntries." into mainline-prod
-rw-r--r-- | python/androidmk.go | 68 | ||||
-rw-r--r-- | python/python.go | 2 |
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 { |