aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJiyong Park <jiyong@google.com>2017-07-03 13:18:12 +0900
committerJiyong Park <jiyong@google.com>2017-07-08 09:29:04 +0900
commitd773eb3e8673162af6c841306c5e4ca7fabe4d51 (patch)
treede90a9335bc292078b5b0f93cda51e17fe6c4092
parent0c3a1efae4814f62ece007c7fc2251386aaae2f2 (diff)
downloadbuild_soong-d773eb3e8673162af6c841306c5e4ca7fabe4d51.tar.gz
build_soong-d773eb3e8673162af6c841306c5e4ca7fabe4d51.tar.bz2
build_soong-d773eb3e8673162af6c841306c5e4ca7fabe4d51.zip
add device_kernel_headers module for vendor-specific kernel headers
device_kernel_headers is a built-in heder-only lib that provides device-specific kernel headers. The header path is configured via a new product variable SystemIncludeDirs, which is currently the mirror of TARGET_PROJECT_SYSTEM_INCLUDES in the make world. Note: generic kernel headers (bionic/libc/kernel) have been added to the include path by default. "device_kernel_headers" module is for device-specific kernel headers such as /device/*/*/kernel-headers. Note 2: this is opt-in for Android.bp modules (i.e. header_libs : ["device_kernel_headers"] required.) while it is always provided to Android.mk modules. Bug: 62939405 Test: choosecombo to aosp_sailfish (or any other Pixel/Nexus targets) BOARD_VNDK_VERSION=current m -j gralloc.msm8996 (or any other vendor libs using vendor-specific kernel headers) Change-Id: I81c60abc13942c89fff723d1544b27a81b300db0
-rw-r--r--Android.bp7
-rw-r--r--android/config.go4
-rw-r--r--android/variable.go2
-rw-r--r--cc/kernel_headers.go53
4 files changed, 66 insertions, 0 deletions
diff --git a/Android.bp b/Android.bp
index 1eac394a..496dcd28 100644
--- a/Android.bp
+++ b/Android.bp
@@ -141,6 +141,8 @@ bootstrap_go_package {
"cc/ndk_sysroot.go",
"cc/llndk_library.go",
+
+ "cc/kernel_headers.go",
],
testSrcs: [
"cc/cc_test.go",
@@ -308,3 +310,8 @@ toolchain_library {
},
},
}
+
+kernel_headers {
+ name: "device_kernel_headers",
+ vendor: true,
+}
diff --git a/android/config.go b/android/config.go
index 1b060638..3de1ef1f 100644
--- a/android/config.go
+++ b/android/config.go
@@ -516,6 +516,10 @@ func (c *deviceConfig) BtConfigIncludeDir() string {
return String(c.config.ProductVariables.BtConfigIncludeDir)
}
+func (c *deviceConfig) DeviceKernelHeaderDirs() []string {
+ return c.config.ProductVariables.DeviceKernelHeaders
+}
+
func (c *deviceConfig) NativeCoverageEnabled() bool {
return Bool(c.config.ProductVariables.NativeCoverage)
}
diff --git a/android/variable.go b/android/variable.go
index 1efab47e..7ca7a55a 100644
--- a/android/variable.go
+++ b/android/variable.go
@@ -162,6 +162,8 @@ type productVariables struct {
BtConfigIncludeDir *string `json:",omitempty"`
Override_rs_driver *string `json:",omitempty"`
+
+ DeviceKernelHeaders []string `json:",omitempty"`
}
func boolPtr(v bool) *bool {
diff --git a/cc/kernel_headers.go b/cc/kernel_headers.go
new file mode 100644
index 00000000..c66fca68
--- /dev/null
+++ b/cc/kernel_headers.go
@@ -0,0 +1,53 @@
+// Copyright 2017 Google Inc. All rights reserved.
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package cc
+
+import (
+ "android/soong/android"
+)
+
+type kernelHeadersDecorator struct {
+ *libraryDecorator
+}
+
+func (stub *kernelHeadersDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
+ if ctx.Device() {
+ f := &stub.libraryDecorator.flagExporter
+ for _, dir := range ctx.DeviceConfig().DeviceKernelHeaderDirs() {
+ f.flags = append(f.flags, "-isystem"+dir)
+ }
+ }
+ return stub.libraryDecorator.linkStatic(ctx, flags, deps, objs)
+}
+
+func kernelHeadersFactory() android.Module {
+ module, library := NewLibrary(android.HostAndDeviceSupported)
+ library.HeaderOnly()
+
+ stub := &kernelHeadersDecorator{
+ libraryDecorator: library,
+ }
+
+ module.compiler = nil
+ module.linker = stub
+ module.installer = nil
+
+ android.InitAndroidArchModule(module, android.DeviceSupported, android.MultilibBoth)
+ return module
+}
+
+func init() {
+ android.RegisterModuleType("kernel_headers", kernelHeadersFactory)
+}