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
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 50e97b1..21ea22a 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -77,23 +77,18 @@
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 @@
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 @@
}
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())