kernel_headers.go 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright 2017 Google Inc. All rights reserved.
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // http://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. package cc
  15. import (
  16. "android/soong/android"
  17. )
  18. type kernelHeadersDecorator struct {
  19. *libraryDecorator
  20. }
  21. func (stub *kernelHeadersDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps, objs Objects) android.Path {
  22. if ctx.Device() {
  23. f := &stub.libraryDecorator.flagExporter
  24. f.reexportSystemDirs(android.PathsForSource(ctx, ctx.DeviceConfig().DeviceKernelHeaderDirs())...)
  25. f.setProvider(ctx)
  26. }
  27. return stub.libraryDecorator.linkStatic(ctx, flags, deps, objs)
  28. }
  29. // kernel_headers retrieves the list of kernel headers directories from
  30. // TARGET_BOARD_KERNEL_HEADERS and TARGET_PRODUCT_KERNEL_HEADERS variables in
  31. // a makefile for compilation. See
  32. // https://android.googlesource.com/platform/build/+/master/core/config.mk
  33. // for more details on them.
  34. func kernelHeadersFactory() android.Module {
  35. module, library := NewLibrary(android.HostAndDeviceSupported)
  36. library.HeaderOnly()
  37. stub := &kernelHeadersDecorator{
  38. libraryDecorator: library,
  39. }
  40. module.linker = stub
  41. return module.Init()
  42. }
  43. func init() {
  44. android.RegisterModuleType("kernel_headers", kernelHeadersFactory)
  45. }