From 5853940a187a7ffec9e086714734955702f90523 Mon Sep 17 00:00:00 2001 From: Dan Willemsen Date: Sun, 19 Mar 2017 13:44:32 -0700 Subject: Pass exportedFlags directly to Make Instead of using LOCAL_EXPORT_C_INCLUDE_DIRS, use LOCAL_EXPORT_CFLAGS. This will let us pass -isystem (or potentially other cflags) in the future. Also refactors the function to be on libraryDecorator instead of a private lambda so that wrappers can use it. Test: m -j Merged-In: Id0dbde7dd03f4e1e1602f7958c445c86f5db15fe Change-Id: Id0dbde7dd03f4e1e1602f7958c445c86f5db15fe --- cc/androidmk.go | 29 ++++++++++++----------------- 1 file changed, 12 insertions(+), 17 deletions(-) (limited to 'cc/androidmk.go') diff --git a/cc/androidmk.go b/cc/androidmk.go index 50e97b12..21ea22ae 100644 --- a/cc/androidmk.go +++ b/cc/androidmk.go @@ -77,23 +77,18 @@ func (c *Module) AndroidMk() (ret android.AndroidMkData, err error) { return ret, nil } -func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { - writeExportedIncludes := func(w io.Writer) { - var exportedIncludes []string - for _, flag := range library.exportedFlags() { - if strings.HasPrefix(flag, "-I") { - exportedIncludes = append(exportedIncludes, strings.TrimPrefix(flag, "-I")) - } - } - if len(exportedIncludes) > 0 { - fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DIRS :=", strings.Join(exportedIncludes, " ")) - } - exportedIncludeDeps := library.exportedFlagsDeps() - if len(exportedIncludeDeps) > 0 { - fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedIncludeDeps.Strings(), " ")) - } +func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) { + exportedFlags := library.exportedFlags() + if len(exportedFlags) > 0 { + fmt.Fprintln(w, "LOCAL_EXPORT_CFLAGS :=", strings.Join(exportedFlags, " ")) + } + exportedFlagsDeps := library.exportedFlagsDeps() + if len(exportedFlagsDeps) > 0 { + fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedFlagsDeps.Strings(), " ")) } +} +func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.AndroidMkData) { if library.static() { ret.Class = "STATIC_LIBRARIES" } else if library.shared() { @@ -125,7 +120,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An fmt.Fprintln(w, "LOCAL_IS_HOST_MODULE := true") } - writeExportedIncludes(w) + library.androidMkWriteExportedFlags(w) fmt.Fprintln(w, "include $(BUILD_HEADER_LIBRARY)") return nil @@ -135,7 +130,7 @@ func (library *libraryDecorator) AndroidMk(ctx AndroidMkContext, ret *android.An } ret.Extra = append(ret.Extra, func(w io.Writer, outputFile android.Path) error { - writeExportedIncludes(w) + library.androidMkWriteExportedFlags(w) fmt.Fprintln(w, "LOCAL_BUILT_MODULE_STEM := $(LOCAL_MODULE)"+outputFile.Ext()) -- cgit v1.2.3