Merge "bp2build: make libdl build." am: a4a930feef am: b5267deaf2 am: 5ada02a02f

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

Change-Id: I477374e839bde37981135e123dc6919cd563a9a2
This commit is contained in:
Jingwen Chen
2021-04-29 11:23:19 +00:00
committed by Automerger Merge Worker
4 changed files with 105 additions and 13 deletions

View File

@@ -68,9 +68,61 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) {
}
}
// Deps in the static: { .. } and shared: { .. } props of a cc_library.
if lib, ok := module.compiler.(*libraryDecorator); ok {
allDeps = append(allDeps, lib.SharedProperties.Shared.Static_libs...)
allDeps = append(allDeps, lib.SharedProperties.Shared.Whole_static_libs...)
allDeps = append(allDeps, lib.SharedProperties.Shared.Shared_libs...)
allDeps = append(allDeps, lib.SharedProperties.Shared.System_shared_libs...)
allDeps = append(allDeps, lib.StaticProperties.Static.Static_libs...)
allDeps = append(allDeps, lib.StaticProperties.Static.Whole_static_libs...)
allDeps = append(allDeps, lib.StaticProperties.Static.Shared_libs...)
allDeps = append(allDeps, lib.StaticProperties.Static.System_shared_libs...)
}
ctx.AddDependency(module, nil, android.SortedUniqueStrings(allDeps)...)
}
type sharedAttributes struct {
staticDeps bazel.LabelListAttribute
}
// bp2buildParseSharedProps returns the attributes for the shared variant of a cc_library.
func bp2BuildParseSharedProps(ctx android.TopDownMutatorContext, module *Module) sharedAttributes {
lib, ok := module.compiler.(*libraryDecorator)
if !ok {
return sharedAttributes{}
}
var staticDeps bazel.LabelListAttribute
staticDeps.Value = android.BazelLabelForModuleDeps(ctx, lib.SharedProperties.Shared.Whole_static_libs)
return sharedAttributes{
staticDeps: staticDeps,
}
}
type staticAttributes struct {
srcs bazel.LabelListAttribute
}
// bp2buildParseStaticProps returns the attributes for the static variant of a cc_library.
func bp2BuildParseStaticProps(ctx android.TopDownMutatorContext, module *Module) staticAttributes {
lib, ok := module.compiler.(*libraryDecorator)
if !ok {
return staticAttributes{}
}
var srcs bazel.LabelListAttribute
srcs.Value = android.BazelLabelForModuleSrc(ctx, lib.StaticProperties.Static.Srcs)
return staticAttributes{
srcs: srcs,
}
}
// Convenience struct to hold all attributes parsed from compiler properties.
type compilerAttributes struct {
copts bazel.StringListAttribute

View File

@@ -217,13 +217,14 @@ func RegisterLibraryBuildComponents(ctx android.RegistrationContext) {
// For bp2build conversion.
type bazelCcLibraryAttributes struct {
Srcs bazel.LabelListAttribute
Hdrs bazel.LabelListAttribute
Copts bazel.StringListAttribute
Linkopts bazel.StringListAttribute
Deps bazel.LabelListAttribute
User_link_flags bazel.StringListAttribute
Includes bazel.StringListAttribute
Srcs bazel.LabelListAttribute
Hdrs bazel.LabelListAttribute
Copts bazel.StringListAttribute
Linkopts bazel.StringListAttribute
Deps bazel.LabelListAttribute
User_link_flags bazel.StringListAttribute
Includes bazel.StringListAttribute
Static_deps_for_shared bazel.LabelListAttribute
}
type bazelCcLibrary struct {
@@ -254,16 +255,23 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
return
}
sharedAttrs := bp2BuildParseSharedProps(ctx, m)
staticAttrs := bp2BuildParseStaticProps(ctx, m)
compilerAttrs := bp2BuildParseCompilerProps(ctx, m)
linkerAttrs := bp2BuildParseLinkerProps(ctx, m)
exportedIncludes := bp2BuildParseExportedIncludes(ctx, m)
var srcs bazel.LabelListAttribute
srcs.Append(compilerAttrs.srcs)
srcs.Append(staticAttrs.srcs)
attrs := &bazelCcLibraryAttributes{
Srcs: compilerAttrs.srcs,
Copts: compilerAttrs.copts,
Linkopts: linkerAttrs.linkopts,
Deps: linkerAttrs.deps,
Includes: exportedIncludes,
Srcs: srcs,
Copts: compilerAttrs.copts,
Linkopts: linkerAttrs.linkopts,
Deps: linkerAttrs.deps,
Static_deps_for_shared: sharedAttrs.staticDeps,
Includes: exportedIncludes,
}
props := bazel.BazelTargetModuleProperties{