Revert "Add bp2build support for cc_library_static."
Revert submission 1594391-bp2build-cc_library_static
Reason for revert: Broke the build on aosp-master
Reverted Changes:
Ib16ccf31a:Add cc_library_static macro to help with bp2build ...
I37c856be2:Add bp2build support for cc_library_static.
Change-Id: Ie94d5bc6da81758cd4e0461c08a810a29643c971
diff --git a/cc/Android.bp b/cc/Android.bp
index 79e92cb..bdbb3c0 100644
--- a/cc/Android.bp
+++ b/cc/Android.bp
@@ -10,7 +10,6 @@
"blueprint-pathtools",
"soong",
"soong-android",
- "soong-bazel",
"soong-cc-config",
"soong-etc",
"soong-genrule",
diff --git a/cc/library.go b/cc/library.go
index 305ed43..22a36c6 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -27,7 +27,6 @@
"github.com/google/blueprint/pathtools"
"android/soong/android"
- "android/soong/bazel"
"android/soong/cc/config"
)
@@ -201,8 +200,6 @@
func init() {
RegisterLibraryBuildComponents(android.InitRegistrationContext)
-
- android.RegisterBp2BuildMutator("cc_library_static", CcLibraryStaticBp2Build)
}
func RegisterLibraryBuildComponents(ctx android.RegistrationContext) {
@@ -2027,137 +2024,3 @@
return outputFile
}
-
-func Bp2BuildParseHeaderLibs(ctx android.TopDownMutatorContext, module *Module) bazel.LabelList {
- var headerLibs []string
- for _, linkerProps := range module.linker.linkerProps() {
- if baseLinkerProps, ok := linkerProps.(*BaseLinkerProperties); ok {
- headerLibs = baseLinkerProps.Header_libs
- // FIXME: re-export include dirs from baseLinkerProps.Export_header_lib_headers?
- break
- }
- }
-
- headerLibsLabels := android.BazelLabelForModuleDeps(ctx, headerLibs)
- return headerLibsLabels
-}
-
-func Bp2BuildParseExportedIncludes(ctx android.TopDownMutatorContext, module *Module) (bazel.LabelList, bazel.LabelList) {
- libraryDecorator := module.linker.(*libraryDecorator)
-
- includeDirs := libraryDecorator.flagExporter.Properties.Export_system_include_dirs
- includeDirs = append(includeDirs, libraryDecorator.flagExporter.Properties.Export_include_dirs...)
-
- includeDirsLabels := android.BazelLabelForModuleSrc(ctx, includeDirs)
-
- var includeDirGlobs []string
- for _, includeDir := range includeDirs {
- includeDirGlobs = append(includeDirGlobs, includeDir+"/**/*.h")
- includeDirGlobs = append(includeDirGlobs, includeDir+"/**/*.inc")
- includeDirGlobs = append(includeDirGlobs, includeDir+"/**/*.hpp")
- }
-
- headersLabels := android.BazelLabelForModuleSrc(ctx, includeDirGlobs)
-
- return includeDirsLabels, headersLabels
-}
-
-type bazelCcLibraryStaticAttributes struct {
- Copts []string
- Srcs bazel.LabelList
- Deps bazel.LabelList
- Linkstatic bool
- Includes bazel.LabelList
- Hdrs bazel.LabelList
-}
-
-type bazelCcLibraryStatic struct {
- android.BazelTargetModuleBase
- bazelCcLibraryStaticAttributes
-}
-
-func BazelCcLibraryStaticFactory() android.Module {
- module := &bazelCcLibraryStatic{}
- module.AddProperties(&module.bazelCcLibraryStaticAttributes)
- android.InitBazelTargetModule(module)
- return module
-}
-
-func CcLibraryStaticBp2Build(ctx android.TopDownMutatorContext) {
- module, ok := ctx.Module().(*Module)
- if !ok {
- // Not a cc module
- return
- }
- if !module.ConvertWithBp2build() {
- return
- }
- if ctx.ModuleType() != "cc_library_static" {
- return
- }
-
- var copts []string
- var srcs []string
- var includeDirs []string
- var localIncludeDirs []string
- for _, props := range module.compiler.compilerProps() {
- if baseCompilerProps, ok := props.(*BaseCompilerProperties); ok {
- copts = baseCompilerProps.Cflags
- srcs = baseCompilerProps.Srcs
- includeDirs = baseCompilerProps.Include_dirs
- localIncludeDirs = baseCompilerProps.Local_include_dirs
- break
- }
- }
- srcsLabels := android.BazelLabelForModuleSrc(ctx, srcs)
-
- var staticLibs []string
- var wholeStaticLibs []string
- for _, props := range module.linker.linkerProps() {
- if baseLinkerProperties, ok := props.(*BaseLinkerProperties); ok {
- staticLibs = baseLinkerProperties.Static_libs
- wholeStaticLibs = baseLinkerProperties.Whole_static_libs
- break
- }
- }
-
- // FIXME: Treat Static_libs and Whole_static_libs differently?
- allDeps := staticLibs
- allDeps = append(allDeps, wholeStaticLibs...)
-
- depsLabels := android.BazelLabelForModuleDeps(ctx, allDeps)
-
- // FIXME: Unify absolute vs relative paths
- // FIXME: Use -I copts instead of setting includes= ?
- allIncludes := includeDirs
- allIncludes = append(allIncludes, localIncludeDirs...)
- includesLabels := android.BazelLabelForModuleSrc(ctx, allIncludes)
-
- exportedIncludesLabels, exportedIncludesHeadersLabels := Bp2BuildParseExportedIncludes(ctx, module)
- includesLabels.Append(exportedIncludesLabels)
-
- headerLibsLabels := Bp2BuildParseHeaderLibs(ctx, module)
- depsLabels.Append(headerLibsLabels)
-
- attrs := &bazelCcLibraryStaticAttributes{
- Copts: copts,
- Srcs: bazel.UniqueBazelLabelList(srcsLabels),
- Deps: bazel.UniqueBazelLabelList(depsLabels),
- Linkstatic: true,
- Includes: bazel.UniqueBazelLabelList(includesLabels),
- Hdrs: bazel.UniqueBazelLabelList(exportedIncludesHeadersLabels),
- }
-
- props := bazel.BazelTargetModuleProperties{
- Rule_class: "cc_library_static",
- Bzl_load_location: "//build/bazel/rules:cc_library_static.bzl",
- }
-
- ctx.CreateBazelTargetModule(BazelCcLibraryStaticFactory, module.Name(), props, attrs)
-}
-
-func (m *bazelCcLibraryStatic) Name() string {
- return m.BaseModuleName()
-}
-
-func (m *bazelCcLibraryStatic) GenerateAndroidBuildActions(ctx android.ModuleContext) {}
diff --git a/cc/library_headers.go b/cc/library_headers.go
index 8754dde..115b775 100644
--- a/cc/library_headers.go
+++ b/cc/library_headers.go
@@ -94,14 +94,35 @@
return
}
- exportedIncludesLabels, exportedIncludesHeadersLabels := Bp2BuildParseExportedIncludes(ctx, module)
+ lib, _ := module.linker.(*libraryDecorator)
- headerLibsLabels := Bp2BuildParseHeaderLibs(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)
attrs := &bazelCcLibraryHeadersAttributes{
- Includes: exportedIncludesLabels,
- Hdrs: exportedIncludesHeadersLabels,
- Deps: headerLibsLabels,
+ Includes: includeDirLabels,
+ Hdrs: headerLabels,
+ Deps: headerLibLabels,
}
props := bazel.BazelTargetModuleProperties{