diff options
| author | Jaewoong Jung <jungjw@google.com> | 2019-08-27 17:33:16 -0700 |
|---|---|---|
| committer | Michael Bestas <mkbestas@lineageos.org> | 2019-12-11 19:03:32 +0200 |
| commit | e5dd6accd3cfa98b70322db8304351b1b5839b67 (patch) | |
| tree | 275ff160931a901ee3a201a4b3b860974b64ca71 /android | |
| parent | 050d2048e953d7f29e65f4627eefdad4b4b25685 (diff) | |
| download | build_soong-e5dd6accd3cfa98b70322db8304351b1b5839b67.tar.gz build_soong-e5dd6accd3cfa98b70322db8304351b1b5839b67.tar.bz2 build_soong-e5dd6accd3cfa98b70322db8304351b1b5839b67.zip | |
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
Diffstat (limited to 'android')
| -rw-r--r-- | android/androidmk.go | 9 | ||||
| -rw-r--r-- | android/prebuilt_etc.go | 20 | ||||
| -rw-r--r-- | android/sh_binary.go | 34 |
3 files changed, 35 insertions, 28 deletions
diff --git a/android/androidmk.go b/android/androidmk.go index 89dfd0ea..4a968f5e 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -75,12 +75,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) @@ -228,9 +230,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. diff --git a/android/prebuilt_etc.go b/android/prebuilt_etc.go index bec24c77..f35e3c76 100644 --- a/android/prebuilt_etc.go +++ b/android/prebuilt_etc.go @@ -140,16 +140,18 @@ func (p *PrebuiltEtc) AndroidMkEntries() AndroidMkEntries { Class: "ETC", SubName: nameSuffix, OutputFile: OptionalPathForPath(p.outputFilePath), - AddCustomEntries: func(name, prefix, moduleDir string, 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()) - entries.SetString("LOCAL_UNINSTALLABLE_MODULE", strconv.FormatBool(!p.Installable())) - if p.additionalDependencies != nil { - for _, path := range *p.additionalDependencies { - entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES", path.String()) + 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()) + entries.SetString("LOCAL_UNINSTALLABLE_MODULE", strconv.FormatBool(!p.Installable())) + if p.additionalDependencies != nil { + for _, path := range *p.additionalDependencies { + entries.SetString("LOCAL_ADDITIONAL_DEPENDENCIES", path.String()) + } } - } + }, }, } } diff --git a/android/sh_binary.go b/android/sh_binary.go index 2855aa04..ba0c8be7 100644 --- a/android/sh_binary.go +++ b/android/sh_binary.go @@ -133,8 +133,10 @@ 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) { - s.customAndroidMkEntries(entries) + ExtraEntries: []AndroidMkExtraEntriesFunc{ + func(entries *AndroidMkEntries) { + s.customAndroidMkEntries(entries) + }, }, } } @@ -156,20 +158,22 @@ 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) { - s.customAndroidMkEntries(entries) - - entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", s.testProperties.Test_suites...) - entries.SetString("LOCAL_TEST_CONFIG", String(s.testProperties.Test_config)) - for _, d := range s.data { - rel := d.Rel() - path := d.String() - if !strings.HasSuffix(path, rel) { - panic(fmt.Errorf("path %q does not end with %q", path, rel)) + ExtraEntries: []AndroidMkExtraEntriesFunc{ + func(entries *AndroidMkEntries) { + s.customAndroidMkEntries(entries) + + entries.AddStrings("LOCAL_COMPATIBILITY_SUITE", s.testProperties.Test_suites...) + entries.SetString("LOCAL_TEST_CONFIG", String(s.testProperties.Test_config)) + for _, d := range s.data { + rel := d.Rel() + path := d.String() + if !strings.HasSuffix(path, rel) { + panic(fmt.Errorf("path %q does not end with %q", path, rel)) + } + path = strings.TrimSuffix(path, rel) + entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel) } - path = strings.TrimSuffix(path, rel) - entries.AddStrings("LOCAL_TEST_DATA", path+":"+rel) - } + }, }, } } |
