Add bp2build support for cc_library_static.
Also refactor bp2build-related code for cc_library_headers.
(Retry of previous CL after the presubmit failed to detect a merge conflict)
Test: Added unit test.
Test: bp2build-sync.py write; bazel build //bionic/... still works (but bp2build is disabled for most cc_library_static targets for other reasons)
Change-Id: I2f4405c2fea305623bbc6daaaf62808b0c074216
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 0f4d8a6..719d538 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -94,35 +94,14 @@
return
}
- lib, _ := module.linker.(*libraryDecorator)
+ exportedIncludesLabels, exportedIncludesHeadersLabels := Bp2BuildParseExportedIncludes(ctx, module)
- // list of directories that will be added to the include path (using -I) for this
- // module and any module that links against this module.
- includeDirs := lib.flagExporter.Properties.Export_system_include_dirs
- includeDirs = append(includeDirs, lib.flagExporter.Properties.Export_include_dirs...)
- includeDirLabels := android.BazelLabelForModuleSrc(ctx, includeDirs)
-
- var includeDirGlobs []string
- for _, includeDir := range includeDirs {
- includeDirGlobs = append(includeDirGlobs, includeDir+"/**/*.h")
- }
-
- headerLabels := android.BazelLabelForModuleSrc(ctx, includeDirGlobs)
-
- // list of modules that should only provide headers for this module.
- var headerLibs []string
- for _, linkerProps := range lib.linkerProps() {
- if baseLinkerProps, ok := linkerProps.(*BaseLinkerProperties); ok {
- headerLibs = baseLinkerProps.Export_header_lib_headers
- break
- }
- }
- headerLibLabels := android.BazelLabelForModuleDeps(ctx, headerLibs)
+ headerLibsLabels := Bp2BuildParseHeaderLibs(ctx, module)
attrs := &bazelCcLibraryHeadersAttributes{
- Includes: includeDirLabels,
- Hdrs: headerLabels,
- Deps: headerLibLabels,
+ Includes: exportedIncludesLabels,
+ Hdrs: exportedIncludesHeadersLabels,
+ Deps: headerLibsLabels,
}
props := bazel.BazelTargetModuleProperties{