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
This commit is contained in:
Jingwen Chen
2021-03-25 06:11:59 +00:00
parent 21e743df41
commit f9410540a8
6 changed files with 27 additions and 453 deletions

View File

@@ -27,7 +27,6 @@ import (
"github.com/google/blueprint/pathtools"
"android/soong/android"
"android/soong/bazel"
"android/soong/cc/config"
)
@@ -201,8 +200,6 @@ type FlagExporterProperties struct {
func init() {
RegisterLibraryBuildComponents(android.InitRegistrationContext)
android.RegisterBp2BuildMutator("cc_library_static", CcLibraryStaticBp2Build)
}
func RegisterLibraryBuildComponents(ctx android.RegistrationContext) {
@@ -2027,137 +2024,3 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu
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) {}