Add support for per-target exported includes. am: 375451edfe am: 0190e56ad0 am: cb584b1731

Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1686625

Change-Id: Iee0049ab7a2e129cc34ba7c3e7619dc37eab8e8c
This commit is contained in:
Rupert Shuttleworth
2021-04-26 14:25:47 +00:00
committed by Automerger Merge Worker
2 changed files with 88 additions and 0 deletions

View File

@@ -262,6 +262,7 @@ func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Mo
archIncludeDirs = append(archIncludeDirs, flagExporterProperties.Export_include_dirs...)
// To avoid duplicate includes when base includes + arch includes are combined
// FIXME: This doesn't take conflicts between arch and os includes into account
archIncludeDirs = bazel.SubtractStrings(archIncludeDirs, includeDirs)
if len(archIncludeDirs) > 0 {
@@ -275,6 +276,7 @@ func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Mo
archHeaders = bazel.UniqueBazelLabelList(archHeaders)
// To avoid duplicate headers when base headers + arch headers are combined
// FIXME: This doesn't take conflicts between arch and os includes into account
archHeaders = bazel.SubtractBazelLabelList(archHeaders, headers)
if len(archHeaders.Includes) > 0 || len(archHeaders.Excludes) > 0 {
@@ -283,5 +285,34 @@ func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Mo
}
}
for os, props := range module.GetTargetProperties(&FlagExporterProperties{}) {
if flagExporterProperties, ok := props.(*FlagExporterProperties); ok {
osIncludeDirs := flagExporterProperties.Export_system_include_dirs
osIncludeDirs = append(osIncludeDirs, flagExporterProperties.Export_include_dirs...)
// To avoid duplicate includes when base includes + os includes are combined
// FIXME: This doesn't take conflicts between arch and os includes into account
osIncludeDirs = bazel.SubtractStrings(osIncludeDirs, includeDirs)
if len(osIncludeDirs) > 0 {
includeDirsAttribute.SetValueForOS(os.Name, osIncludeDirs)
}
var osHeaders bazel.LabelList
for _, osIncludeDir := range osIncludeDirs {
osHeaders.Append(bp2BuildListHeadersInDir(ctx, osIncludeDir))
}
osHeaders = bazel.UniqueBazelLabelList(osHeaders)
// To avoid duplicate headers when base headers + os headers are combined
// FIXME: This doesn't take conflicts between arch and os includes into account
osHeaders = bazel.SubtractBazelLabelList(osHeaders, headers)
if len(osHeaders.Includes) > 0 || len(osHeaders.Excludes) > 0 {
headersAttribute.SetValueForOS(os.Name, osHeaders)
}
}
}
return includeDirsAttribute, headersAttribute
}