soong: allow overriding header files
Includes:
Author: Jan Altensen <info@stricted.net>
Date: Sat Aug 7 19:41:59 2021 +0200
soong: move header override to compiler.go
* library.go only covers libraries
Change-Id: I3374999d6b364dd1bbc2060996964ee7b04493e7
Change-Id: Ia9d2210605c5927b529fbe9485b0e5abd079f487
diff --git a/android/config.go b/android/config.go
index 4745a16..94c3d89 100644
--- a/android/config.go
+++ b/android/config.go
@@ -1423,6 +1423,10 @@
return c.config.productVariables.DeviceKernelHeaders
}
+func (c *deviceConfig) TargetSpecificHeaderPath() string {
+ return String(c.config.productVariables.TargetSpecificHeaderPath)
+}
+
// JavaCoverageEnabledForPath returns whether Java code coverage is enabled for
// path. Coverage is enabled by default when the product variable
// JavaCoveragePaths is empty. If JavaCoveragePaths is not empty, coverage is
diff --git a/android/variable.go b/android/variable.go
index 2500140..e5099a9 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -362,6 +362,8 @@
DeviceKernelHeaders []string `json:",omitempty"`
+ TargetSpecificHeaderPath *string `json:",omitempty"`
+
ExtraVndkVersions []string `json:",omitempty"`
NamespacesToExport []string `json:",omitempty"`
diff --git a/cc/compiler.go b/cc/compiler.go
index d8446fb..ec46394 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -363,6 +363,16 @@
tc := ctx.toolchain()
modulePath := ctx.ModuleDir()
+ additionalIncludeDirs := ctx.DeviceConfig().TargetSpecificHeaderPath()
+ if len(additionalIncludeDirs) > 0 {
+ // devices can have multiple paths in TARGET_SPECIFIC_HEADER_PATH
+ // add -I in front of all of them
+ if (strings.Contains(additionalIncludeDirs, " ")) {
+ additionalIncludeDirs = strings.ReplaceAll(additionalIncludeDirs, " ", " -I")
+ }
+ flags.Local.CommonFlags = append(flags.Local.CommonFlags, "-I" + additionalIncludeDirs)
+ }
+
compiler.srcsBeforeGen = android.PathsForModuleSrcExcludes(ctx, compiler.Properties.Srcs, compiler.Properties.Exclude_srcs)
compiler.srcsBeforeGen = append(compiler.srcsBeforeGen, deps.GeneratedSources...)