Handle cc_library shared/static only properties
Also handle whole_static_libs via a different attribute (whole_archive_deps), separating these dependencies from regular static deps. Test: Build //bionic/libdl with bazel in conjunction with bzl changes Change-Id: I45019b6127a0d2731592ec35537ca15e77001cc2
This commit is contained in:
@@ -220,16 +220,29 @@ 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
|
||||
Dynamic_deps bazel.LabelListAttribute
|
||||
User_link_flags bazel.StringListAttribute
|
||||
Includes bazel.StringListAttribute
|
||||
Static_deps_for_shared bazel.LabelListAttribute
|
||||
Version_script bazel.LabelAttribute
|
||||
// Attributes pertaining to both static and shared variants.
|
||||
Srcs bazel.LabelListAttribute
|
||||
Hdrs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Dynamic_deps bazel.LabelListAttribute
|
||||
Whole_archive_deps bazel.LabelListAttribute
|
||||
Copts bazel.StringListAttribute
|
||||
Includes bazel.StringListAttribute
|
||||
Linkopts bazel.StringListAttribute
|
||||
// Attributes pertaining to shared variant.
|
||||
Shared_copts bazel.StringListAttribute
|
||||
Shared_srcs bazel.LabelListAttribute
|
||||
Static_deps_for_shared bazel.LabelListAttribute
|
||||
Dynamic_deps_for_shared bazel.LabelListAttribute
|
||||
Whole_archive_deps_for_shared bazel.LabelListAttribute
|
||||
User_link_flags bazel.StringListAttribute
|
||||
Version_script bazel.LabelAttribute
|
||||
// Attributes pertaining to static variant.
|
||||
Static_copts bazel.StringListAttribute
|
||||
Static_srcs bazel.LabelListAttribute
|
||||
Static_deps_for_static bazel.LabelListAttribute
|
||||
Dynamic_deps_for_static bazel.LabelListAttribute
|
||||
Whole_archive_deps_for_static bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
type bazelCcLibrary struct {
|
||||
@@ -276,17 +289,26 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
||||
|
||||
var srcs bazel.LabelListAttribute
|
||||
srcs.Append(compilerAttrs.srcs)
|
||||
srcs.Append(staticAttrs.srcs)
|
||||
|
||||
attrs := &bazelCcLibraryAttributes{
|
||||
Srcs: srcs,
|
||||
Copts: compilerAttrs.copts,
|
||||
Linkopts: linkerAttrs.linkopts,
|
||||
Deps: linkerAttrs.deps,
|
||||
Dynamic_deps: linkerAttrs.dynamicDeps,
|
||||
Version_script: linkerAttrs.versionScript,
|
||||
Static_deps_for_shared: sharedAttrs.staticDeps,
|
||||
Includes: exportedIncludes,
|
||||
Srcs: srcs,
|
||||
Deps: linkerAttrs.deps,
|
||||
Dynamic_deps: linkerAttrs.dynamicDeps,
|
||||
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
|
||||
Copts: compilerAttrs.copts,
|
||||
Includes: exportedIncludes,
|
||||
Linkopts: linkerAttrs.linkopts,
|
||||
Shared_copts: sharedAttrs.copts,
|
||||
Shared_srcs: sharedAttrs.srcs,
|
||||
Static_deps_for_shared: sharedAttrs.staticDeps,
|
||||
Whole_archive_deps_for_shared: sharedAttrs.wholeArchiveDeps,
|
||||
Dynamic_deps_for_shared: sharedAttrs.dynamicDeps,
|
||||
Version_script: linkerAttrs.versionScript,
|
||||
Static_copts: staticAttrs.copts,
|
||||
Static_srcs: staticAttrs.srcs,
|
||||
Static_deps_for_static: staticAttrs.staticDeps,
|
||||
Whole_archive_deps_for_static: staticAttrs.wholeArchiveDeps,
|
||||
Dynamic_deps_for_static: staticAttrs.dynamicDeps,
|
||||
}
|
||||
|
||||
props := bazel.BazelTargetModuleProperties{
|
||||
@@ -2194,13 +2216,14 @@ func maybeInjectBoringSSLHash(ctx android.ModuleContext, outputFile android.Modu
|
||||
}
|
||||
|
||||
type bazelCcLibraryStaticAttributes struct {
|
||||
Copts bazel.StringListAttribute
|
||||
Srcs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Linkopts bazel.StringListAttribute
|
||||
Linkstatic bool
|
||||
Includes bazel.StringListAttribute
|
||||
Hdrs bazel.LabelListAttribute
|
||||
Copts bazel.StringListAttribute
|
||||
Srcs bazel.LabelListAttribute
|
||||
Deps bazel.LabelListAttribute
|
||||
Whole_archive_deps bazel.LabelListAttribute
|
||||
Linkopts bazel.StringListAttribute
|
||||
Linkstatic bool
|
||||
Includes bazel.StringListAttribute
|
||||
Hdrs bazel.LabelListAttribute
|
||||
}
|
||||
|
||||
type bazelCcLibraryStatic struct {
|
||||
@@ -2221,9 +2244,11 @@ func ccLibraryStaticBp2BuildInternal(ctx android.TopDownMutatorContext, module *
|
||||
exportedIncludes := bp2BuildParseExportedIncludes(ctx, module)
|
||||
|
||||
attrs := &bazelCcLibraryStaticAttributes{
|
||||
Copts: compilerAttrs.copts,
|
||||
Srcs: compilerAttrs.srcs,
|
||||
Deps: linkerAttrs.deps,
|
||||
Copts: compilerAttrs.copts,
|
||||
Srcs: compilerAttrs.srcs,
|
||||
Deps: linkerAttrs.deps,
|
||||
Whole_archive_deps: linkerAttrs.wholeArchiveDeps,
|
||||
|
||||
Linkopts: linkerAttrs.linkopts,
|
||||
Linkstatic: true,
|
||||
Includes: exportedIncludes,
|
||||
|
Reference in New Issue
Block a user