Remove error from AndroidMkData.Extra

It's never anything except nil, and it unnecessarily complicates
the implementations.

Test: m -j checkbuild
Change-Id: I8a117a86aa39aeb07d9d8d0686ef869c52784f19
This commit is contained in:
Colin Cross
2017-08-10 16:32:23 -07:00
parent 6416271a1f
commit 27a4b05441
5 changed files with 20 additions and 42 deletions

View File

@@ -45,9 +45,11 @@ type AndroidMkData struct {
Custom func(w io.Writer, name, prefix, moduleDir string) error Custom func(w io.Writer, name, prefix, moduleDir string) error
Extra []func(w io.Writer, outputFile Path) error Extra []AndroidMkExtraFunc
} }
type AndroidMkExtraFunc func(w io.Writer, outputFile Path)
func AndroidMkSingleton() blueprint.Singleton { func AndroidMkSingleton() blueprint.Singleton {
return &androidMkSingleton{} return &androidMkSingleton{}
} }
@@ -255,10 +257,7 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b
} }
for _, extra := range data.Extra { for _, extra := range data.Extra {
err = extra(w, data.OutputFile.Path()) extra(w, data.OutputFile.Path())
if err != nil {
return err
}
} }
fmt.Fprintln(w, "include $(BUILD_PREBUILT)") fmt.Fprintln(w, "include $(BUILD_PREBUILT)")

View File

@@ -56,7 +56,7 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
} }
ret.OutputFile = c.outputFile ret.OutputFile = c.outputFile
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) (err error) { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_SANITIZE := never") fmt.Fprintln(w, "LOCAL_SANITIZE := never")
if len(c.Properties.AndroidMkSharedLibs) > 0 { if len(c.Properties.AndroidMkSharedLibs) > 0 {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " ")) fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES := "+strings.Join(c.Properties.AndroidMkSharedLibs, " "))
@@ -71,7 +71,6 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) {
if c.vndk() { if c.vndk() {
fmt.Fprintln(w, "LOCAL_USE_VNDK := true") fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
} }
return nil
}) })
for _, feature := range c.features { for _, feature := range c.features {
@@ -106,9 +105,8 @@ func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *andro
testFiles = append(testFiles, path+":"+rel) testFiles = append(testFiles, path+":"+rel)
} }
if len(testFiles) > 0 { if len(testFiles) > 0 {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " ")) fmt.Fprintln(w, "LOCAL_TEST_DATA := "+strings.Join(testFiles, " "))
return nil
}) })
} }
} }
@@ -167,7 +165,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
return return
} }
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
library.androidMkWriteExportedFlags(w) library.androidMkWriteExportedFlags(w)
fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ") fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ")
if library.sAbiOutputFile.Valid() { if library.sAbiOutputFile.Valid() {
@@ -185,8 +183,6 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An
if library.coverageOutputFile.Valid() { if library.coverageOutputFile.Valid() {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String())
} }
return nil
}) })
if library.shared() { if library.shared() {
@@ -210,7 +206,7 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr
ctx.subAndroidMk(ret, &binary.stripper) ctx.subAndroidMk(ret, &binary.stripper)
ret.Class = "EXECUTABLES" ret.Class = "EXECUTABLES"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
if Bool(binary.Properties.Static_executable) { if Bool(binary.Properties.Static_executable) {
fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true") fmt.Fprintln(w, "LOCAL_FORCE_STATIC_EXECUTABLE := true")
@@ -223,19 +219,17 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr
if binary.coverageOutputFile.Valid() { if binary.coverageOutputFile.Valid() {
fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String())
} }
return nil
}) })
} }
func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
ctx.subAndroidMk(ret, benchmark.binaryDecorator) ctx.subAndroidMk(ret, benchmark.binaryDecorator)
ret.Class = "NATIVE_TESTS" ret.Class = "NATIVE_TESTS"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
if len(benchmark.Properties.Test_suites) > 0 { if len(benchmark.Properties.Test_suites) > 0 {
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
strings.Join(benchmark.Properties.Test_suites, " ")) strings.Join(benchmark.Properties.Test_suites, " "))
} }
return nil
}) })
androidMkWriteTestData(benchmark.data, ctx, ret) androidMkWriteTestData(benchmark.data, ctx, ret)
@@ -248,12 +242,11 @@ func (test *testBinary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
ret.SubName = "_" + test.binaryDecorator.Properties.Stem ret.SubName = "_" + test.binaryDecorator.Properties.Stem
} }
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
if len(test.Properties.Test_suites) > 0 { if len(test.Properties.Test_suites) > 0 {
fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=",
strings.Join(test.Properties.Test_suites, " ")) strings.Join(test.Properties.Test_suites, " "))
} }
return nil
}) })
androidMkWriteTestData(test.data, ctx, ret) androidMkWriteTestData(test.data, ctx, ret)
@@ -265,11 +258,9 @@ func (test *testLibrary) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkD
func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { func (library *toolchainLibraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
ret.Class = "STATIC_LIBRARIES" ret.Class = "STATIC_LIBRARIES"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext()) fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+outputFile.Ext())
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
return nil
}) })
} }
@@ -279,7 +270,7 @@ func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMk
return return
} }
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
if stripper.StripProperties.Strip.None { if stripper.StripProperties.Strip.None {
fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false")
} else if stripper.StripProperties.Strip.Keep_symbols { } else if stripper.StripProperties.Strip.Keep_symbols {
@@ -287,17 +278,14 @@ func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMk
} else { } else {
fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info") fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info")
} }
return nil
}) })
} }
func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { func (packer *relocationPacker) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
if packer.Properties.PackingRelocations { if packer.Properties.PackingRelocations {
fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true") fmt.Fprintln(w, "LOCAL_PACK_MODULE_RELOCATIONS := true")
} }
return nil
}) })
} }
@@ -308,14 +296,13 @@ func (installer *baseInstaller) AndroidMk(ctx AndroidMkContext, ret *android.And
ret.OutputFile = android.OptionalPathForPath(installer.path) ret.OutputFile = android.OptionalPathForPath(installer.path)
} }
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
path := installer.path.RelPathString() path := installer.path.RelPathString()
dir, file := filepath.Split(path) dir, file := filepath.Split(path)
stem := strings.TrimSuffix(file, filepath.Ext(file)) stem := strings.TrimSuffix(file, filepath.Ext(file))
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
return nil
}) })
} }
@@ -323,7 +310,7 @@ func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel
ret.Class = "SHARED_LIBRARIES" ret.Class = "SHARED_LIBRARIES"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
path, file := filepath.Split(c.installPath) path, file := filepath.Split(c.installPath)
stem := strings.TrimSuffix(file, filepath.Ext(file)) stem := strings.TrimSuffix(file, filepath.Ext(file))
fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=") fmt.Fprintln(w, "LOCAL_SYSTEM_SHARED_LIBRARIES :=")
@@ -336,7 +323,6 @@ func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa
// dozens of libraries with the same name, they'll clobber each other // dozens of libraries with the same name, they'll clobber each other
// and the real versions of the libraries from the platform). // and the real versions of the libraries from the platform).
fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false") fmt.Fprintln(w, "LOCAL_COPY_TO_INTERMEDIATE_LIBRARIES := false")
return nil
}) })
} }
@@ -344,7 +330,7 @@ func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Androi
ret.Class = "SHARED_LIBRARIES" ret.Class = "SHARED_LIBRARIES"
ret.SubName = ".vendor" ret.SubName = ".vendor"
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
c.libraryDecorator.androidMkWriteExportedFlags(w) c.libraryDecorator.androidMkWriteExportedFlags(w)
fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext())
@@ -353,7 +339,5 @@ func (c *llndkStubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Androi
fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true") fmt.Fprintln(w, "LOCAL_UNINSTALLABLE_MODULE := true")
fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true") fmt.Fprintln(w, "LOCAL_NO_NOTICE_FILE := true")
fmt.Fprintln(w, "LOCAL_USE_VNDK := true") fmt.Fprintln(w, "LOCAL_USE_VNDK := true")
return nil
}) })
} }

View File

@@ -444,12 +444,10 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags {
} }
func (sanitize *sanitize) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { func (sanitize *sanitize) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) {
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
if sanitize.androidMkRuntimeLibrary != "" { if sanitize.androidMkRuntimeLibrary != "" {
fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES += "+sanitize.androidMkRuntimeLibrary) fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES += "+sanitize.androidMkRuntimeLibrary)
} }
return nil
}) })
} }

View File

@@ -24,9 +24,8 @@ import (
func (library *Library) AndroidMk() (ret android.AndroidMkData, err error) { func (library *Library) AndroidMk() (ret android.AndroidMkData, err error) {
ret.Class = "JAVA_LIBRARIES" ret.Class = "JAVA_LIBRARIES"
ret.OutputFile = android.OptionalPathForPath(library.outputFile) ret.OutputFile = android.OptionalPathForPath(library.outputFile)
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar") fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar")
return nil
}) })
return return
} }
@@ -34,9 +33,8 @@ func (library *Library) AndroidMk() (ret android.AndroidMkData, err error) {
func (prebuilt *Import) AndroidMk() (ret android.AndroidMkData, err error) { func (prebuilt *Import) AndroidMk() (ret android.AndroidMkData, err error) {
ret.Class = "JAVA_LIBRARIES" ret.Class = "JAVA_LIBRARIES"
ret.OutputFile = android.OptionalPathForPath(prebuilt.combinedClasspathFile) ret.OutputFile = android.OptionalPathForPath(prebuilt.combinedClasspathFile)
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar") fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := .jar")
return nil
}) })
return return
} }

View File

@@ -61,7 +61,7 @@ func (installer *pythonInstaller) AndroidMk(base *pythonBaseModule, ret *android
ret.OutputFile = android.OptionalPathForPath(installer.path) ret.OutputFile = android.OptionalPathForPath(installer.path)
} }
ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) {
path := installer.path.RelPathString() path := installer.path.RelPathString()
dir, file := filepath.Split(path) dir, file := filepath.Split(path)
stem := strings.TrimSuffix(file, filepath.Ext(file)) stem := strings.TrimSuffix(file, filepath.Ext(file))
@@ -69,6 +69,5 @@ func (installer *pythonInstaller) AndroidMk(base *pythonBaseModule, ret *android
fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file)) fmt.Fprintln(w, "LOCAL_MODULE_SUFFIX := "+filepath.Ext(file))
fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) fmt.Fprintln(w, "LOCAL_MODULE_PATH := $(OUT_DIR)/"+filepath.Clean(dir))
fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem)
return nil
}) })
} }