From 27a4b05441a30a26de0d19cd3495a3d1229a2e57 Mon Sep 17 00:00:00 2001 From: Colin Cross Date: Thu, 10 Aug 2017 16:32:23 -0700 Subject: [PATCH] Remove error from AndroidMkData.Extra It's never anything except nil, and it unnecessarily complicates the implementations. Test: m -j checkbuild Change-Id: I8a117a86aa39aeb07d9d8d0686ef869c52784f19 --- android/androidmk.go | 9 ++++----- cc/androidmk.go | 40 ++++++++++++---------------------------- cc/sanitize.go | 4 +--- java/androidmk.go | 6 ++---- python/androidmk.go | 3 +-- 5 files changed, 20 insertions(+), 42 deletions(-) diff --git a/android/androidmk.go b/android/androidmk.go index 6197f5974..d5ee045b7 100644 --- a/android/androidmk.go +++ b/android/androidmk.go @@ -45,9 +45,11 @@ type AndroidMkData struct { 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 { return &androidMkSingleton{} } @@ -255,10 +257,7 @@ func translateAndroidMkModule(ctx blueprint.SingletonContext, w io.Writer, mod b } for _, extra := range data.Extra { - err = extra(w, data.OutputFile.Path()) - if err != nil { - return err - } + extra(w, data.OutputFile.Path()) } fmt.Fprintln(w, "include $(BUILD_PREBUILT)") diff --git a/cc/androidmk.go b/cc/androidmk.go index 940e7c779..f68ddbb9e 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -56,7 +56,7 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) { } 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") if len(c.Properties.AndroidMkSharedLibs) > 0 { 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() { fmt.Fprintln(w, "LOCAL_USE_VNDK := true") } - return nil }) for _, feature := range c.features { @@ -106,9 +105,8 @@ func androidMkWriteTestData(data android.Paths, ctx AndroidMkContext, ret *andro testFiles = append(testFiles, path+":"+rel) } 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, " ")) - return nil }) } } @@ -167,7 +165,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An 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) fmt.Fprintln(w, "LOCAL_ADDITIONAL_DEPENDENCIES := ") if library.sAbiOutputFile.Valid() { @@ -185,8 +183,6 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An if library.coverageOutputFile.Valid() { fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", library.coverageOutputFile.String()) } - - return nil }) if library.shared() { @@ -210,7 +206,7 @@ func (binary *binaryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.Andr ctx.subAndroidMk(ret, &binary.stripper) 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 :=") if Bool(binary.Properties.Static_executable) { 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() { fmt.Fprintln(w, "LOCAL_PREBUILT_COVERAGE_ARCHIVE :=", binary.coverageOutputFile.String()) } - return nil }) } func (benchmark *benchmarkDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { ctx.subAndroidMk(ret, benchmark.binaryDecorator) 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 { fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(benchmark.Properties.Test_suites, " ")) } - return nil }) 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.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 { fmt.Fprintln(w, "LOCAL_COMPATIBILITY_SUITE :=", strings.Join(test.Properties.Test_suites, " ")) } - return nil }) 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) { 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_SYSTEM_SHARED_LIBRARIES :=") - - return nil }) } @@ -279,7 +270,7 @@ func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMk 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 { fmt.Fprintln(w, "LOCAL_STRIP_MODULE := false") } else if stripper.StripProperties.Strip.Keep_symbols { @@ -287,17 +278,14 @@ func (stripper *stripper) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMk } else { fmt.Fprintln(w, "LOCAL_STRIP_MODULE := mini-debug-info") } - - return nil }) } 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 { 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.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() dir, file := filepath.Split(path) stem := strings.TrimSuffix(file, 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_STEM := "+stem) - return nil }) } @@ -323,7 +310,7 @@ func (c *stubDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkDa ret.SubName = ndkLibrarySuffix + "." + c.properties.ApiLevel 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) stem := strings.TrimSuffix(file, filepath.Ext(file)) 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 // and the real versions of the libraries from the platform). 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.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) 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_NO_NOTICE_FILE := true") fmt.Fprintln(w, "LOCAL_USE_VNDK := true") - - return nil }) } diff --git a/cc/sanitize.go b/cc/sanitize.go index 1fcb32c9c..4ea4d2604 100644 --- a/cc/sanitize.go +++ b/cc/sanitize.go @@ -444,12 +444,10 @@ func (sanitize *sanitize) flags(ctx ModuleContext, flags Flags) Flags { } 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 != "" { fmt.Fprintln(w, "LOCAL_SHARED_LIBRARIES += "+sanitize.androidMkRuntimeLibrary) } - - return nil }) } diff --git a/java/androidmk.go b/java/androidmk.go index 92af0ed2d..fd967cb5b 100644 --- a/java/androidmk.go +++ b/java/androidmk.go @@ -24,9 +24,8 @@ import ( func (library *Library) AndroidMk() (ret android.AndroidMkData, err error) { ret.Class = "JAVA_LIBRARIES" 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") - return nil }) return } @@ -34,9 +33,8 @@ func (library *Library) AndroidMk() (ret android.AndroidMkData, err error) { func (prebuilt *Import) AndroidMk() (ret android.AndroidMkData, err error) { ret.Class = "JAVA_LIBRARIES" 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") - return nil }) return } diff --git a/python/androidmk.go b/python/androidmk.go index 0a79e7368..386eeeed1 100644 --- a/python/androidmk.go +++ b/python/androidmk.go @@ -61,7 +61,7 @@ func (installer *pythonInstaller) AndroidMk(base *pythonBaseModule, ret *android 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() dir, file := filepath.Split(path) 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_PATH := $(OUT_DIR)/"+filepath.Clean(dir)) fmt.Fprintln(w, "LOCAL_MODULE_STEM := "+stem) - return nil }) }