summaryrefslogtreecommitdiff
path: root/cc
diff options
context:
space:
mode:
Diffstat (limited to 'cc')
-rw-r--r--cc/androidmk.go12
-rw-r--r--cc/binary.go18
-rw-r--r--cc/builder.go23
-rw-r--r--cc/cc.go72
-rw-r--r--cc/compiler.go5
-rw-r--r--cc/genrule.go2
-rw-r--r--cc/kernel_headers.go4
-rw-r--r--cc/library.go142
-rw-r--r--cc/llndk_library.go11
-rw-r--r--cc/ndk_library.go5
-rw-r--r--cc/ndk_prebuilt.go2
-rw-r--r--cc/prebuilt.go8
-rw-r--r--cc/sabi.go4
-rw-r--r--cc/util.go4
-rw-r--r--cc/vendor_public_library.go1
15 files changed, 176 insertions, 137 deletions
diff --git a/cc/androidmk.go b/cc/androidmk.go
index 32ccf4c15..272d3d443 100644
--- a/cc/androidmk.go
+++ b/cc/androidmk.go
@@ -156,12 +156,18 @@ func makeOverrideModuleNames(ctx AndroidMkContext, overrides []string) []string
func (library *libraryDecorator) androidMkWriteExportedFlags(w io.Writer) {
exportedFlags := library.exportedFlags()
+ for _, dir := range library.exportedDirs() {
+ exportedFlags = append(exportedFlags, "-I"+dir)
+ }
+ for _, dir := range library.exportedSystemDirs() {
+ exportedFlags = append(exportedFlags, "-isystem "+dir)
+ }
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(), " "))
+ exportedDeps := library.exportedDeps()
+ if len(exportedDeps) > 0 {
+ fmt.Fprintln(w, "LOCAL_EXPORT_C_INCLUDE_DEPS :=", strings.Join(exportedDeps.Strings(), " "))
}
}
diff --git a/cc/binary.go b/cc/binary.go
index 8428d7ec2..1757f1cd6 100644
--- a/cc/binary.go
+++ b/cc/binary.go
@@ -36,7 +36,7 @@ type BinaryLinkerProperties struct {
Prefix_symbols *string
// if set, install a symlink to the preferred architecture
- Symlink_preferred_arch *bool
+ Symlink_preferred_arch *bool `android:"arch_variant"`
// install symlinks to the binary. Symlink names will have the suffix and the binary
// extension (if any) appended
@@ -106,13 +106,17 @@ func (binary *binaryDecorator) linkerProps() []interface{} {
}
-func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
+func (binary *binaryDecorator) getStemWithoutSuffix(ctx BaseModuleContext) string {
stem := ctx.baseModuleName()
if String(binary.Properties.Stem) != "" {
stem = String(binary.Properties.Stem)
}
- return stem + String(binary.Properties.Suffix)
+ return stem
+}
+
+func (binary *binaryDecorator) getStem(ctx BaseModuleContext) string {
+ return binary.getStemWithoutSuffix(ctx) + String(binary.Properties.Suffix)
}
func (binary *binaryDecorator) linkerDeps(ctx DepsContext, deps Deps) Deps {
@@ -388,7 +392,7 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
objs.coverageFiles = append(objs.coverageFiles, deps.StaticLibObjs.coverageFiles...)
objs.coverageFiles = append(objs.coverageFiles, deps.WholeStaticLibObjs.coverageFiles...)
- binary.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, binary.getStem(ctx))
+ binary.coverageOutputFile = TransformCoverageFilesToZip(ctx, objs, binary.getStem(ctx))
// Need to determine symlinks early since some targets (ie APEX) need this
// information but will not call 'install'
@@ -398,11 +402,11 @@ func (binary *binaryDecorator) link(ctx ModuleContext,
}
if Bool(binary.Properties.Symlink_preferred_arch) {
- if String(binary.Properties.Stem) == "" && String(binary.Properties.Suffix) == "" {
- ctx.PropertyErrorf("symlink_preferred_arch", "must also specify stem or suffix")
+ if String(binary.Properties.Suffix) == "" {
+ ctx.PropertyErrorf("symlink_preferred_arch", "must also specify suffix")
}
if ctx.TargetPrimary() {
- binary.symlinks = append(binary.symlinks, ctx.baseModuleName())
+ binary.symlinks = append(binary.symlinks, binary.getStemWithoutSuffix(ctx))
}
}
diff --git a/cc/builder.go b/cc/builder.go
index 7cf5c291f..3a8afc0d8 100644
--- a/cc/builder.go
+++ b/cc/builder.go
@@ -228,6 +228,14 @@ var (
blueprint.RuleParams{
Command: "gunzip -c $in > $out",
})
+
+ zip = pctx.AndroidStaticRule("zip",
+ blueprint.RuleParams{
+ Command: "cat $out.rsp | tr ' ' '\\n' | tr -d \\' | sort -u > ${out}.tmp && ${SoongZipCmd} -o ${out} -C $$OUT_DIR -l ${out}.tmp",
+ CommandDeps: []string{"${SoongZipCmd}"},
+ Rspfile: "$out.rsp",
+ RspfileContent: "$in",
+ })
)
func init() {
@@ -240,6 +248,8 @@ func init() {
// Darwin doesn't have /proc
pctx.StaticVariable("relPwd", "")
}
+
+ pctx.HostBinToolVariable("SoongZipCmd", "soong_zip")
}
type builderFlags struct {
@@ -883,13 +893,18 @@ func TransformDarwinStrip(ctx android.ModuleContext, inputFile android.Path,
})
}
-func TransformCoverageFilesToLib(ctx android.ModuleContext,
- inputs Objects, flags builderFlags, baseName string) android.OptionalPath {
+func TransformCoverageFilesToZip(ctx android.ModuleContext,
+ inputs Objects, baseName string) android.OptionalPath {
if len(inputs.coverageFiles) > 0 {
- outputFile := android.PathForModuleOut(ctx, baseName+".gcnodir")
+ outputFile := android.PathForModuleOut(ctx, baseName+".zip")
- TransformObjToStaticLib(ctx, inputs.coverageFiles, flags, outputFile, nil)
+ ctx.Build(pctx, android.BuildParams{
+ Rule: zip,
+ Description: "zip " + outputFile.Base(),
+ Inputs: inputs.coverageFiles,
+ Output: outputFile,
+ })
return android.OptionalPathForPath(outputFile)
}
diff --git a/cc/cc.go b/cc/cc.go
index e61857d87..26d3d98bd 100644
--- a/cc/cc.go
+++ b/cc/cc.go
@@ -119,8 +119,13 @@ type PathDeps struct {
GeneratedSources android.Paths
GeneratedHeaders android.Paths
- Flags, ReexportedFlags []string
- ReexportedFlagsDeps android.Paths
+ Flags []string
+ IncludeDirs []string
+ SystemIncludeDirs []string
+ ReexportedDirs []string
+ ReexportedSystemDirs []string
+ ReexportedFlags []string
+ ReexportedDeps android.Paths
// Paths to crt*.o files
CrtBegin, CrtEnd android.OptionalPath
@@ -278,7 +283,7 @@ type ModuleContext interface {
}
type BaseModuleContext interface {
- android.BaseContext
+ android.BaseModuleContext
ModuleContextIntf
}
@@ -641,7 +646,7 @@ func installToBootstrap(name string, config android.Config) bool {
}
type baseModuleContext struct {
- android.BaseContext
+ android.BaseModuleContext
moduleContextImpl
}
@@ -988,6 +993,14 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
flags.ConlyFlags, _ = filterList(flags.ConlyFlags, config.IllegalFlags)
flags.GlobalFlags = append(flags.GlobalFlags, deps.Flags...)
+
+ for _, dir := range deps.IncludeDirs {
+ flags.GlobalFlags = append(flags.GlobalFlags, "-I"+dir)
+ }
+ for _, dir := range deps.SystemIncludeDirs {
+ flags.GlobalFlags = append(flags.GlobalFlags, "-isystem "+dir)
+ }
+
c.flags = flags
// We need access to all the flags seen by a source file.
if c.sabi != nil {
@@ -1040,7 +1053,7 @@ func (c *Module) GenerateAndroidBuildActions(actx android.ModuleContext) {
}
}
-func (c *Module) toolchain(ctx android.BaseContext) config.Toolchain {
+func (c *Module) toolchain(ctx android.BaseModuleContext) config.Toolchain {
if c.cachedToolchain == nil {
c.cachedToolchain = config.FindToolchain(ctx.Os(), ctx.Arch())
}
@@ -1161,7 +1174,7 @@ func (c *Module) deps(ctx DepsContext) Deps {
func (c *Module) beginMutator(actx android.BottomUpMutatorContext) {
ctx := &baseModuleContext{
- BaseContext: actx,
+ BaseModuleContext: actx,
moduleContextImpl: moduleContextImpl{
mod: c,
},
@@ -1578,6 +1591,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
llndkLibraries := llndkLibraries(ctx.Config())
vendorPublicLibraries := vendorPublicLibraries(ctx.Config())
+ reexportExporter := func(exporter exportedFlagsProducer) {
+ depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, exporter.exportedDirs()...)
+ depPaths.ReexportedSystemDirs = append(depPaths.ReexportedSystemDirs, exporter.exportedSystemDirs()...)
+ depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, exporter.exportedFlags()...)
+ depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, exporter.exportedDeps()...)
+ }
+
ctx.VisitDirectDeps(func(dep android.Module) {
depName := ctx.OtherModuleName(dep)
depTag := ctx.OtherModuleDependencyTag(dep)
@@ -1599,14 +1619,13 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if genRule, ok := dep.(genrule.SourceFileGenerator); ok {
depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders,
genRule.GeneratedDeps()...)
- flags := includeDirsToFlags(genRule.GeneratedHeaderDirs())
- depPaths.Flags = append(depPaths.Flags, flags)
+ dirs := genRule.GeneratedHeaderDirs().Strings()
+ depPaths.IncludeDirs = append(depPaths.IncludeDirs, dirs...)
if depTag == genHeaderExportDepTag {
- depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags)
- depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps,
- genRule.GeneratedDeps()...)
+ depPaths.ReexportedDirs = append(depPaths.ReexportedDirs, dirs...)
+ depPaths.ReexportedDeps = append(depPaths.ReexportedDeps, genRule.GeneratedDeps()...)
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
- c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags)
+ c.sabi.Properties.ReexportedIncludes = append(c.sabi.Properties.ReexportedIncludes, dirs...)
}
} else {
@@ -1644,10 +1663,9 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
if depTag == reuseObjTag {
if l, ok := ccDep.compiler.(libraryInterface); ok {
c.staticVariant = ccDep
- objs, flags, deps := l.reuseObjs()
+ objs, exporter := l.reuseObjs()
depPaths.Objs = depPaths.Objs.Append(objs)
- depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
- depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
+ reexportExporter(exporter)
return
}
}
@@ -1710,18 +1728,20 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
}
if i, ok := ccDep.linker.(exportedFlagsProducer); ok {
- flags := i.exportedFlags()
- deps := i.exportedFlagsDeps()
- depPaths.Flags = append(depPaths.Flags, flags...)
- depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, deps...)
+ depPaths.IncludeDirs = append(depPaths.IncludeDirs, i.exportedDirs()...)
+ depPaths.SystemIncludeDirs = append(depPaths.SystemIncludeDirs, i.exportedSystemDirs()...)
+ depPaths.GeneratedHeaders = append(depPaths.GeneratedHeaders, i.exportedDeps()...)
+ depPaths.Flags = append(depPaths.Flags, i.exportedFlags()...)
if t.reexportFlags {
- depPaths.ReexportedFlags = append(depPaths.ReexportedFlags, flags...)
- depPaths.ReexportedFlagsDeps = append(depPaths.ReexportedFlagsDeps, deps...)
+ reexportExporter(i)
// Add these re-exported flags to help header-abi-dumper to infer the abi exported by a library.
// Re-exported shared library headers must be included as well since they can help us with type information
// about template instantiations (instantiated from their headers).
- c.sabi.Properties.ReexportedIncludeFlags = append(c.sabi.Properties.ReexportedIncludeFlags, flags...)
+ // -isystem headers are not included since for bionic libraries, abi-filtering is taken care of by version
+ // scripts.
+ c.sabi.Properties.ReexportedIncludes = append(
+ c.sabi.Properties.ReexportedIncludes, i.exportedDirs()...)
}
}
@@ -1883,12 +1903,16 @@ func (c *Module) depsToPaths(ctx android.ModuleContext) PathDeps {
// Dedup exported flags from dependencies
depPaths.Flags = android.FirstUniqueStrings(depPaths.Flags)
+ depPaths.IncludeDirs = android.FirstUniqueStrings(depPaths.IncludeDirs)
+ depPaths.SystemIncludeDirs = android.FirstUniqueStrings(depPaths.SystemIncludeDirs)
depPaths.GeneratedHeaders = android.FirstUniquePaths(depPaths.GeneratedHeaders)
+ depPaths.ReexportedDirs = android.FirstUniqueStrings(depPaths.ReexportedDirs)
+ depPaths.ReexportedSystemDirs = android.FirstUniqueStrings(depPaths.ReexportedSystemDirs)
depPaths.ReexportedFlags = android.FirstUniqueStrings(depPaths.ReexportedFlags)
- depPaths.ReexportedFlagsDeps = android.FirstUniquePaths(depPaths.ReexportedFlagsDeps)
+ depPaths.ReexportedDeps = android.FirstUniquePaths(depPaths.ReexportedDeps)
if c.sabi != nil {
- c.sabi.Properties.ReexportedIncludeFlags = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludeFlags)
+ c.sabi.Properties.ReexportedIncludes = android.FirstUniqueStrings(c.sabi.Properties.ReexportedIncludes)
}
return depPaths
diff --git a/cc/compiler.go b/cc/compiler.go
index 7667ae7ab..fd6184b3a 100644
--- a/cc/compiler.go
+++ b/cc/compiler.go
@@ -225,11 +225,6 @@ func (compiler *baseCompiler) compilerDeps(ctx DepsContext, deps Deps) Deps {
deps = protoDeps(ctx, deps, &compiler.Proto, Bool(compiler.Properties.Proto.Static))
}
- if compiler.hasSrcExt(".sysprop") {
- deps.HeaderLibs = append(deps.HeaderLibs, "libbase_headers")
- deps.SharedLibs = append(deps.SharedLibs, "liblog")
- }
-
if Bool(compiler.Properties.Openmp) {
deps.StaticLibs = append(deps.StaticLibs, "libomp")
}
diff --git a/cc/genrule.go b/cc/genrule.go
index decf6ea57..e594f4b2f 100644
--- a/cc/genrule.go
+++ b/cc/genrule.go
@@ -42,5 +42,7 @@ func genRuleFactory() android.Module {
android.InitAndroidArchModule(module, android.HostAndDeviceSupported, android.MultilibBoth)
+ android.InitApexModule(module)
+
return module
}
diff --git a/cc/kernel_headers.go b/cc/kernel_headers.go
index c1da578b5..fff419e60 100644
--- a/cc/kernel_headers.go
+++ b/cc/kernel_headers.go
@@ -25,9 +25,7 @@ type kernelHeadersDecorator struct {
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)
- }
+ f.reexportSystemDirs(ctx.DeviceConfig().DeviceKernelHeaderDirs()...)
}
return stub.libraryDecorator.linkStatic(ctx, flags, deps, objs)
}
diff --git a/cc/library.go b/cc/library.go
index 0bc5b5bba..fab583753 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -15,6 +15,7 @@
package cc
import (
+ "fmt"
"io"
"path/filepath"
"regexp"
@@ -207,8 +208,10 @@ func LibraryHeaderFactory() android.Module {
type flagExporter struct {
Properties FlagExporterProperties
- flags []string
- flagsDeps android.Paths
+ dirs []string
+ systemDirs []string
+ flags []string
+ deps android.Paths
}
func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
@@ -219,32 +222,57 @@ func (f *flagExporter) exportedIncludes(ctx ModuleContext) android.Paths {
}
}
-func (f *flagExporter) exportIncludes(ctx ModuleContext, inc string) {
- includeDirs := f.exportedIncludes(ctx)
- for _, dir := range includeDirs.Strings() {
- f.flags = append(f.flags, inc+dir)
- }
+func (f *flagExporter) exportIncludes(ctx ModuleContext) {
+ f.dirs = append(f.dirs, f.exportedIncludes(ctx).Strings()...)
+}
+
+func (f *flagExporter) exportIncludesAsSystem(ctx ModuleContext) {
+ f.systemDirs = append(f.systemDirs, f.exportedIncludes(ctx).Strings()...)
+}
+
+func (f *flagExporter) reexportDirs(dirs ...string) {
+ f.dirs = append(f.dirs, dirs...)
+}
+
+func (f *flagExporter) reexportSystemDirs(dirs ...string) {
+ f.systemDirs = append(f.systemDirs, dirs...)
}
-func (f *flagExporter) reexportFlags(flags []string) {
+func (f *flagExporter) reexportFlags(flags ...string) {
+ for _, flag := range flags {
+ if strings.HasPrefix(flag, "-I") || strings.HasPrefix(flag, "-isystem") {
+ panic(fmt.Errorf("Exporting invalid flag %q: "+
+ "use reexportDirs or reexportSystemDirs to export directories", flag))
+ }
+ }
f.flags = append(f.flags, flags...)
}
-func (f *flagExporter) reexportDeps(deps android.Paths) {
- f.flagsDeps = append(f.flagsDeps, deps...)
+func (f *flagExporter) reexportDeps(deps ...android.Path) {
+ f.deps = append(f.deps, deps...)
+}
+
+func (f *flagExporter) exportedDirs() []string {
+ return f.dirs
+}
+
+func (f *flagExporter) exportedSystemDirs() []string {
+ return f.systemDirs
}
func (f *flagExporter) exportedFlags() []string {
return f.flags
}
-func (f *flagExporter) exportedFlagsDeps() android.Paths {
- return f.flagsDeps
+func (f *flagExporter) exportedDeps() android.Paths {
+ return f.deps
}
type exportedFlagsProducer interface {
+ exportedDirs() []string
+ exportedSystemDirs() []string
exportedFlags() []string
- exportedFlagsDeps() android.Paths
+ exportedDeps() android.Paths
}
var _ exportedFlagsProducer = (*flagExporter)(nil)
@@ -256,9 +284,7 @@ type libraryDecorator struct {
MutatedProperties LibraryMutatedProperties
// For reusing static library objects for shared library
- reuseObjects Objects
- reuseExportedFlags []string
- reuseExportedDeps android.Paths
+ reuseObjects Objects
// table-of-contents file to optimize out relinking when possible
tocFile android.OptionalPath
@@ -405,25 +431,6 @@ func (library *libraryDecorator) compilerFlags(ctx ModuleContext, flags Flags, d
return flags
}
-func extractExportIncludesFromFlags(flags []string) []string {
- // This method is used in the generation of rules which produce
- // abi-dumps for source files. Exported headers are needed to infer the
- // abi exported by a library and filter out the rest of the abi dumped
- // from a source. We extract the include flags exported by a library.
- // This includes the flags exported which are re-exported from static
- // library dependencies, exported header library dependencies and
- // generated header dependencies. -isystem headers are not included
- // since for bionic libraries, abi-filtering is taken care of by version
- // scripts.
- var exportedIncludes []string
- for _, flag := range flags {
- if strings.HasPrefix(flag, "-I") {
- exportedIncludes = append(exportedIncludes, flag)
- }
- }
- return exportedIncludes
-}
-
func (library *libraryDecorator) shouldCreateVndkSourceAbiDump(ctx ModuleContext) bool {
if library.Properties.Header_abi_checker.Enabled != nil {
return Bool(library.Properties.Header_abi_checker.Enabled)
@@ -456,8 +463,8 @@ func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps Pa
for _, dir := range exportIncludeDirs.Strings() {
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
}
- for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
- SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
+ for _, reexportedInclude := range library.sabi.Properties.ReexportedIncludes {
+ SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude)
}
flags.SAbiFlags = SourceAbiFlags
total_length := len(library.baseCompiler.Properties.Srcs) + len(deps.GeneratedSources) + len(library.Properties.Shared.Srcs) +
@@ -487,7 +494,7 @@ type libraryInterface interface {
getWholeStaticMissingDeps() []string
static() bool
objs() Objects
- reuseObjs() (Objects, []string, android.Paths)
+ reuseObjs() (Objects, exportedFlagsProducer)
toc() android.OptionalPath
// Returns true if the build options for the module have selected a static or shared build
@@ -644,7 +651,7 @@ func (library *libraryDecorator) linkStatic(ctx ModuleContext,
TransformObjToStaticLib(ctx, library.objects.objFiles, builderFlags, outputFile, objs.tidyFiles)
- library.coverageOutputFile = TransformCoverageFilesToLib(ctx, library.objects, builderFlags,
+ library.coverageOutputFile = TransformCoverageFilesToZip(ctx, library.objects,
ctx.ModuleName()+library.MutatedProperties.VariantName)
library.wholeStaticMissingDeps = ctx.GetMissingDependencies()
@@ -764,7 +771,7 @@ func (library *libraryDecorator) linkShared(ctx ModuleContext,
objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.StaticLibObjs.sAbiDumpFiles...)
objs.sAbiDumpFiles = append(objs.sAbiDumpFiles, deps.WholeStaticLibObjs.sAbiDumpFiles...)
- library.coverageOutputFile = TransformCoverageFilesToLib(ctx, objs, builderFlags, library.getLibName(ctx))
+ library.coverageOutputFile = TransformCoverageFilesToZip(ctx, objs, library.getLibName(ctx))
library.linkSAbiDumpFiles(ctx, objs, fileName, ret)
return ret
@@ -814,8 +821,8 @@ func (library *libraryDecorator) linkSAbiDumpFiles(ctx ModuleContext, objs Objec
for _, dir := range exportIncludeDirs.Strings() {
SourceAbiFlags = append(SourceAbiFlags, "-I"+dir)
}
- for _, reexportedInclude := range extractExportIncludesFromFlags(library.sabi.Properties.ReexportedIncludeFlags) {
- SourceAbiFlags = append(SourceAbiFlags, reexportedInclude)
+ for _, reexportedInclude := range library.sabi.Properties.ReexportedIncludes {
+ SourceAbiFlags = append(SourceAbiFlags, "-I"+reexportedInclude)
}
exportedHeaderFlags := strings.Join(SourceAbiFlags, " ")
library.sAbiOutputFile = TransformDumpToLinkedDump(ctx, objs.sAbiDumpFiles, soFile, fileName, exportedHeaderFlags,
@@ -842,19 +849,17 @@ func (library *libraryDecorator) link(ctx ModuleContext,
out = library.linkShared(ctx, flags, deps, objs)
}
- library.exportIncludes(ctx, "-I")
- library.reexportFlags(deps.ReexportedFlags)
- library.reexportDeps(deps.ReexportedFlagsDeps)
+ library.exportIncludes(ctx)
+ library.reexportDirs(deps.ReexportedDirs...)
+ library.reexportSystemDirs(deps.ReexportedSystemDirs...)
+ library.reexportFlags(deps.ReexportedFlags...)
+ library.reexportDeps(deps.ReexportedDeps...)
if Bool(library.Properties.Aidl.Export_aidl_headers) {
if library.baseCompiler.hasSrcExt(".aidl") {
- flags := []string{
- "-I" + android.PathForModuleGen(ctx, "aidl").String(),
- }
- library.reexportFlags(flags)
- library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
- library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to aidl deps
- library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...)
+ dir := android.PathForModuleGen(ctx, "aidl").String()
+ library.reexportDirs(dir)
+ library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to aidl deps
}
}
@@ -862,26 +867,16 @@ func (library *libraryDecorator) link(ctx ModuleContext,
if library.baseCompiler.hasSrcExt(".proto") {
includes := []string{}
if flags.proto.CanonicalPathFromRoot {
- includes = append(includes, "-I"+flags.proto.SubDir.String())
+ includes = append(includes, flags.proto.SubDir.String())
}
- includes = append(includes, "-I"+flags.proto.Dir.String())
- library.reexportFlags(includes)
- library.reuseExportedFlags = append(library.reuseExportedFlags, includes...)
- library.reexportDeps(library.baseCompiler.pathDeps) // TODO: restrict to proto deps
- library.reuseExportedDeps = append(library.reuseExportedDeps, library.baseCompiler.pathDeps...)
+ includes = append(includes, flags.proto.Dir.String())
+ library.reexportDirs(includes...)
+ library.reexportDeps(library.baseCompiler.pathDeps...) // TODO: restrict to proto deps
}
}
if library.baseCompiler.hasSrcExt(".sysprop") {
- internalFlags := []string{
- "-I" + android.PathForModuleGen(ctx, "sysprop", "include").String(),
- }
- systemFlags := []string{
- "-I" + android.PathForModuleGen(ctx, "sysprop/system", "include").String(),
- }
-
- flags := internalFlags
-
+ dir := android.PathForModuleGen(ctx, "sysprop", "include").String()
if library.Properties.Sysprop.Platform != nil {
isProduct := ctx.ProductSpecific() && !ctx.useVndk()
isVendor := ctx.useVndk()
@@ -890,17 +885,16 @@ func (library *libraryDecorator) link(ctx ModuleContext,
useSystem := isProduct || (isOwnerPlatform == isVendor)
if useSystem {
- flags = systemFlags
+ dir = android.PathForModuleGen(ctx, "sysprop/system", "include").String()
}
}
- library.reexportFlags(flags)
- library.reexportDeps(library.baseCompiler.pathDeps)
- library.reuseExportedFlags = append(library.reuseExportedFlags, flags...)
+ library.reexportDirs(dir)
+ library.reexportDeps(library.baseCompiler.pathDeps...)
}
if library.buildStubs() {
- library.reexportFlags([]string{"-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion()})
+ library.reexportFlags("-D" + versioningMacroName(ctx.ModuleName()) + "=" + library.stubsVersion())
}
return out
@@ -922,8 +916,8 @@ func (library *libraryDecorator) objs() Objects {
return library.objects
}
-func (library *libraryDecorator) reuseObjs() (Objects, []string, android.Paths) {
- return library.reuseObjects, library.reuseExportedFlags, library.reuseExportedDeps
+func (library *libraryDecorator) reuseObjs() (Objects, exportedFlagsProducer) {
+ return library.reuseObjects, &library.flagExporter
}
func (library *libraryDecorator) toc() android.OptionalPath {
diff --git a/cc/llndk_library.go b/cc/llndk_library.go
index 6cdf5c700..82901037b 100644
--- a/cc/llndk_library.go
+++ b/cc/llndk_library.go
@@ -134,6 +134,7 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
if !Bool(stub.Properties.Unversioned) {
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
flags.LdFlags = append(flags.LdFlags, linkerScriptFlag)
+ flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
}
if len(stub.Properties.Export_preprocessed_headers) > 0 {
@@ -144,17 +145,17 @@ func (stub *llndkStubDecorator) link(ctx ModuleContext, flags Flags, deps PathDe
timestampFiles = append(timestampFiles, stub.processHeaders(ctx, dir, genHeaderOutDir))
}
- includePrefix := "-I"
if Bool(stub.Properties.Export_headers_as_system) {
- includePrefix = "-isystem "
+ stub.reexportSystemDirs(genHeaderOutDir.String())
+ } else {
+ stub.reexportDirs(genHeaderOutDir.String())
}
- stub.reexportFlags([]string{includePrefix + genHeaderOutDir.String()})
- stub.reexportDeps(timestampFiles)
+ stub.reexportDeps(timestampFiles...)
}
if Bool(stub.Properties.Export_headers_as_system) {
- stub.exportIncludes(ctx, "-isystem ")
+ stub.exportIncludesAsSystem(ctx)
stub.libraryDecorator.flagExporter.Properties.Export_include_dirs = []string{}
}
diff --git a/cc/ndk_library.go b/cc/ndk_library.go
index ff990b5f7..969cb3fa7 100644
--- a/cc/ndk_library.go
+++ b/cc/ndk_library.go
@@ -121,7 +121,7 @@ func intMax(a int, b int) int {
}
}
-func normalizeNdkApiLevel(ctx android.BaseContext, apiLevel string,
+func normalizeNdkApiLevel(ctx android.BaseModuleContext, apiLevel string,
arch android.Arch) (string, error) {
if apiLevel == "current" {
@@ -167,7 +167,7 @@ func getFirstGeneratedVersion(firstSupportedVersion string, platformVersion int)
return strconv.Atoi(firstSupportedVersion)
}
-func shouldUseVersionScript(ctx android.BaseContext, stub *stubDecorator) (bool, error) {
+func shouldUseVersionScript(ctx android.BaseModuleContext, stub *stubDecorator) (bool, error) {
// unversioned_until is normally empty, in which case we should use the version script.
if String(stub.properties.Unversioned_until) == "" {
return true, nil
@@ -337,6 +337,7 @@ func (stub *stubDecorator) link(ctx ModuleContext, flags Flags, deps PathDeps,
if useVersionScript {
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
flags.LdFlags = append(flags.LdFlags, linkerScriptFlag)
+ flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
}
return stub.libraryDecorator.link(ctx, flags, deps, objs)
diff --git a/cc/ndk_prebuilt.go b/cc/ndk_prebuilt.go
index fb168872b..4356732ef 100644
--- a/cc/ndk_prebuilt.go
+++ b/cc/ndk_prebuilt.go
@@ -151,7 +151,7 @@ func (ndk *ndkPrebuiltStlLinker) link(ctx ModuleContext, flags Flags,
ctx.ModuleErrorf("NDK prebuilt libraries must have an ndk_lib prefixed name")
}
- ndk.exportIncludes(ctx, "-isystem ")
+ ndk.exportIncludesAsSystem(ctx)
libName := strings.TrimPrefix(ctx.ModuleName(), "ndk_")
libExt := flags.Toolchain.ShlibSuffix()
diff --git a/cc/prebuilt.go b/cc/prebuilt.go
index f92c50d1e..dc6c43a7c 100644
--- a/cc/prebuilt.go
+++ b/cc/prebuilt.go
@@ -85,9 +85,11 @@ func (p *prebuiltLibraryLinker) link(ctx ModuleContext,
flags Flags, deps PathDeps, objs Objects) android.Path {
// TODO(ccross): verify shared library dependencies
if len(p.properties.Srcs) > 0 {
- p.libraryDecorator.exportIncludes(ctx, "-I")
- p.libraryDecorator.reexportFlags(deps.ReexportedFlags)
- p.libraryDecorator.reexportDeps(deps.ReexportedFlagsDeps)
+ p.libraryDecorator.exportIncludes(ctx)
+ p.libraryDecorator.reexportDirs(deps.ReexportedDirs...)
+ p.libraryDecorator.reexportSystemDirs(deps.ReexportedSystemDirs...)
+ p.libraryDecorator.reexportFlags(deps.ReexportedFlags...)
+ p.libraryDecorator.reexportDeps(deps.ReexportedDeps...)
builderFlags := flagsToBuilderFlags(flags)
diff --git a/cc/sabi.go b/cc/sabi.go
index 451176f1b..ae7b31d28 100644
--- a/cc/sabi.go
+++ b/cc/sabi.go
@@ -28,8 +28,8 @@ var (
)
type SAbiProperties struct {
- CreateSAbiDumps bool `blueprint:"mutated"`
- ReexportedIncludeFlags []string
+ CreateSAbiDumps bool `blueprint:"mutated"`
+ ReexportedIncludes []string `blueprint:"mutated"`
}
type sabi struct {
diff --git a/cc/util.go b/cc/util.go
index 3862728bb..2e1bb2590 100644
--- a/cc/util.go
+++ b/cc/util.go
@@ -29,10 +29,6 @@ func includeDirsToFlags(dirs android.Paths) string {
return android.JoinWithPrefix(dirs.Strings(), "-I")
}
-func includeFilesToFlags(files android.Paths) string {
- return android.JoinWithPrefix(files.Strings(), "-include ")
-}
-
func ldDirsToFlags(dirs []string) string {
return android.JoinWithPrefix(dirs, "-L")
}
diff --git a/cc/vendor_public_library.go b/cc/vendor_public_library.go
index 5738d25ab..f0de267c1 100644
--- a/cc/vendor_public_library.go
+++ b/cc/vendor_public_library.go
@@ -125,6 +125,7 @@ func (stub *vendorPublicLibraryStubDecorator) link(ctx ModuleContext, flags Flag
if !Bool(stub.Properties.Unversioned) {
linkerScriptFlag := "-Wl,--version-script," + stub.versionScriptPath.String()
flags.LdFlags = append(flags.LdFlags, linkerScriptFlag)
+ flags.LdFlagsDeps = append(flags.LdFlagsDeps, stub.versionScriptPath)
}
return stub.libraryDecorator.link(ctx, flags, deps, objs)
}