add device_kernel_headers module for vendor-specific kernel headers

am: d773eb3e86

Change-Id: I5df3aded9d8ba25cde31eee61ca337eb74113ef4
This commit is contained in:
Jiyong Park
2017-07-08 03:18:59 +00:00
committed by android-build-merger
4 changed files with 66 additions and 0 deletions

View File

@@ -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,
}

View File

@@ -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)
}

View File

@@ -163,6 +163,8 @@ type productVariables struct {
BtConfigIncludeDir *string `json:",omitempty"`
Override_rs_driver *string `json:",omitempty"`
DeviceKernelHeaders []string `json:",omitempty"`
}
func boolPtr(v bool) *bool {

53
cc/kernel_headers.go Normal file
View File

@@ -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)
}