bp2build: remove header globs in generated srcs.
Not needed anymore for bp2build-incremental since https://android-review.googlesource.com/q/topic:no-include-check.
Not needed for mixed builds either, since cc compile actions aren't sandboxed.
Fixes: 186488830
Test: treehugger and go tests
Change-Id: Ib5d4908dcce6bf910a653c457bb251d726e717d4
diff --git a/cc/bp2build.go b/cc/bp2build.go
index efa2752..b11602d 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -80,7 +80,7 @@
// bp2BuildParseCompilerProps returns copts, srcs and hdrs and other attributes.
func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Module) compilerAttributes {
- var localHdrs, srcs bazel.LabelListAttribute
+ var srcs bazel.LabelListAttribute
var copts bazel.StringListAttribute
// Creates the -I flag for a directory, while making the directory relative
@@ -121,10 +121,8 @@
if c, ok := module.compiler.(*baseCompiler); ok && c.includeBuildDirectory() {
copts.Value = append(copts.Value, includeFlag("."))
- localHdrs.Value = bp2BuildListHeadersInDir(ctx, ".")
} else if c, ok := module.compiler.(*libraryDecorator); ok && c.includeBuildDirectory() {
copts.Value = append(copts.Value, includeFlag("."))
- localHdrs.Value = bp2BuildListHeadersInDir(ctx, ".")
}
for arch, props := range module.GetArchProperties(&BaseCompilerProperties{}) {
@@ -143,9 +141,6 @@
}
}
- // Combine local, non-exported hdrs into srcs
- srcs.Append(localHdrs)
-
return compilerAttributes{
srcs: srcs,
copts: copts,
@@ -207,11 +202,6 @@
}
}
-func bp2BuildListHeadersInDir(ctx android.TopDownMutatorContext, includeDir string) bazel.LabelList {
- globs := bazel.GlobsInDir(includeDir, true, headerExts)
- return android.BazelLabelForModuleSrc(ctx, globs)
-}
-
// Relativize a list of root-relative paths with respect to the module's
// directory.
//
@@ -236,9 +226,8 @@
}
// bp2BuildParseExportedIncludes creates a string list attribute contains the
-// exported included directories of a module, and a label list attribute
-// containing the exported headers of a module.
-func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) (bazel.StringListAttribute, bazel.LabelListAttribute) {
+// exported included directories of a module.
+func bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) bazel.StringListAttribute {
libraryDecorator := module.linker.(*libraryDecorator)
// Export_system_include_dirs and export_include_dirs are already module dir
@@ -248,14 +237,6 @@
includeDirs = append(includeDirs, libraryDecorator.flagExporter.Properties.Export_include_dirs...)
includeDirsAttribute := bazel.MakeStringListAttribute(includeDirs)
- var headersAttribute bazel.LabelListAttribute
- var headers bazel.LabelList
- for _, includeDir := range includeDirs {
- headers.Append(bp2BuildListHeadersInDir(ctx, includeDir))
- }
- headers = bazel.UniqueBazelLabelList(headers)
- headersAttribute.Value = headers
-
for arch, props := range module.GetArchProperties(&FlagExporterProperties{}) {
if flagExporterProperties, ok := props.(*FlagExporterProperties); ok {
archIncludeDirs := flagExporterProperties.Export_system_include_dirs
@@ -268,20 +249,6 @@
if len(archIncludeDirs) > 0 {
includeDirsAttribute.SetValueForArch(arch.Name, archIncludeDirs)
}
-
- var archHeaders bazel.LabelList
- for _, archIncludeDir := range archIncludeDirs {
- archHeaders.Append(bp2BuildListHeadersInDir(ctx, archIncludeDir))
- }
- 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 {
- headersAttribute.SetValueForArch(arch.Name, archHeaders)
- }
}
}
@@ -297,22 +264,8 @@
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
+ return includeDirsAttribute
}
diff --git a/cc/library.go b/cc/library.go
index af92b24..f49698e 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -259,11 +259,10 @@
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
linkerAttrs := bp2BuildParseLinkerProps(ctx, m)
- exportedIncludes, exportedIncludesHeaders := bp2BuildParseExportedIncludes(ctx, m)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, m)
attrs := &bazelCcLibraryAttributes{
Srcs: compilerAttrs.srcs,
- Hdrs: exportedIncludesHeaders,
Copts: compilerAttrs.copts,
Linkopts: linkerAttrs.linkopts,
Deps: linkerAttrs.deps,
@@ -2176,7 +2175,7 @@
compilerAttrs := bp2BuildParseCompilerProps(ctx, module)
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
- exportedIncludes, exportedIncludesHeaders := bp2BuildParseExportedIncludes(ctx, module)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
attrs := &bazelCcLibraryStaticAttributes{
Copts: compilerAttrs.copts,
@@ -2184,7 +2183,6 @@
Deps: linkerAttrs.deps,
Linkstatic: true,
Includes: exportedIncludes,
- Hdrs: exportedIncludesHeaders,
}
props := bazel.BazelTargetModuleProperties{
diff --git a/cc/library_headers.go b/cc/library_headers.go
index f2cb52b..0aba8de 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -142,14 +142,13 @@
return
}
- exportedIncludes, exportedHdrs := bp2BuildParseExportedIncludes(ctx, module)
+ exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
compilerAttrs := bp2BuildParseCompilerProps(ctx, module)
linkerAttrs := bp2BuildParseLinkerProps(ctx, module)
attrs := &bazelCcLibraryHeadersAttributes{
Copts: compilerAttrs.copts,
Includes: exportedIncludes,
- Hdrs: exportedHdrs,
Deps: linkerAttrs.deps,
}