diff options
Diffstat (limited to 'cc')
| -rw-r--r-- | cc/bp2build.go | 45 | ||||
| -rw-r--r-- | cc/library.go | 50 |
2 files changed, 33 insertions, 62 deletions
diff --git a/cc/bp2build.go b/cc/bp2build.go index 7c6ee0a68..76c5f3be9 100644 --- a/cc/bp2build.go +++ b/cc/bp2build.go @@ -142,15 +142,14 @@ func depsBp2BuildMutator(ctx android.BottomUpMutatorContext) { // staticOrSharedAttributes are the Bazel-ified versions of StaticOrSharedProperties -- // properties which apply to either the shared or static version of a cc_library module. type staticOrSharedAttributes struct { - srcs bazel.LabelListAttribute - srcs_c bazel.LabelListAttribute - srcs_as bazel.LabelListAttribute - - copts bazel.StringListAttribute - - staticDeps bazel.LabelListAttribute - dynamicDeps bazel.LabelListAttribute - wholeArchiveDeps bazel.LabelListAttribute + Srcs bazel.LabelListAttribute + Srcs_c bazel.LabelListAttribute + Srcs_as bazel.LabelListAttribute + Copts bazel.StringListAttribute + + Static_deps bazel.LabelListAttribute + Dynamic_deps bazel.LabelListAttribute + Whole_archive_deps bazel.LabelListAttribute } func groupSrcsByExtension(ctx android.TopDownMutatorContext, srcs bazel.LabelListAttribute) (cppSrcs, cSrcs, asSrcs bazel.LabelListAttribute) { @@ -251,19 +250,19 @@ func bp2buildParseStaticOrSharedProps(ctx android.TopDownMutatorContext, module } attrs := staticOrSharedAttributes{ - copts: bazel.StringListAttribute{Value: props.Cflags}, - srcs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, props.Srcs)), - staticDeps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, props.Static_libs)), - dynamicDeps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, props.Shared_libs)), - wholeArchiveDeps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleWholeDeps(ctx, props.Whole_static_libs)), + Copts: bazel.StringListAttribute{Value: props.Cflags}, + Srcs: bazel.MakeLabelListAttribute(android.BazelLabelForModuleSrc(ctx, props.Srcs)), + Static_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, props.Static_libs)), + Dynamic_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, props.Shared_libs)), + Whole_archive_deps: bazel.MakeLabelListAttribute(android.BazelLabelForModuleWholeDeps(ctx, props.Whole_static_libs)), } setAttrs := func(axis bazel.ConfigurationAxis, config string, props StaticOrSharedProperties) { - attrs.copts.SetSelectValue(axis, config, props.Cflags) - attrs.srcs.SetSelectValue(axis, config, android.BazelLabelForModuleSrc(ctx, props.Srcs)) - attrs.staticDeps.SetSelectValue(axis, config, android.BazelLabelForModuleDeps(ctx, props.Static_libs)) - attrs.dynamicDeps.SetSelectValue(axis, config, android.BazelLabelForModuleDeps(ctx, props.Shared_libs)) - attrs.wholeArchiveDeps.SetSelectValue(axis, config, android.BazelLabelForModuleWholeDeps(ctx, props.Whole_static_libs)) + attrs.Copts.SetSelectValue(axis, config, props.Cflags) + attrs.Srcs.SetSelectValue(axis, config, android.BazelLabelForModuleSrc(ctx, props.Srcs)) + attrs.Static_deps.SetSelectValue(axis, config, android.BazelLabelForModuleDeps(ctx, props.Static_libs)) + attrs.Dynamic_deps.SetSelectValue(axis, config, android.BazelLabelForModuleDeps(ctx, props.Shared_libs)) + attrs.Whole_archive_deps.SetSelectValue(axis, config, android.BazelLabelForModuleWholeDeps(ctx, props.Whole_static_libs)) } if isStatic { @@ -284,10 +283,10 @@ func bp2buildParseStaticOrSharedProps(ctx android.TopDownMutatorContext, module } } - cppSrcs, cSrcs, asSrcs := groupSrcsByExtension(ctx, attrs.srcs) - attrs.srcs = cppSrcs - attrs.srcs_c = cSrcs - attrs.srcs_as = asSrcs + cppSrcs, cSrcs, asSrcs := groupSrcsByExtension(ctx, attrs.Srcs) + attrs.Srcs = cppSrcs + attrs.Srcs_c = cSrcs + attrs.Srcs_as = asSrcs return attrs } diff --git a/cc/library.go b/cc/library.go index fd0a388e7..2b3b994eb 100644 --- a/cc/library.go +++ b/cc/library.go @@ -237,29 +237,12 @@ type bazelCcLibraryAttributes struct { Linkopts bazel.StringListAttribute Use_libcrt bazel.BoolAttribute - // Attributes pertaining to shared variant. - Shared_srcs bazel.LabelListAttribute - Shared_srcs_c bazel.LabelListAttribute - Shared_srcs_as bazel.LabelListAttribute - Shared_copts bazel.StringListAttribute - - Exported_deps_for_shared 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_srcs bazel.LabelListAttribute - Static_srcs_c bazel.LabelListAttribute - Static_srcs_as bazel.LabelListAttribute - Static_copts bazel.StringListAttribute - - Exported_deps_for_static bazel.LabelListAttribute - Static_deps_for_static bazel.LabelListAttribute - Dynamic_deps_for_static bazel.LabelListAttribute - Whole_archive_deps_for_static bazel.LabelListAttribute + // This is shared only. + Version_script bazel.LabelAttribute + + // Common properties shared between both shared and static variants. + Shared staticOrSharedAttributes + Static staticOrSharedAttributes Strip stripAttributes } @@ -334,6 +317,8 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) { Linkopts: linkerAttrs.linkopts, Use_libcrt: linkerAttrs.useLibcrt, + Version_script: linkerAttrs.versionScript, + Strip: stripAttributes{ Keep_symbols: linkerAttrs.stripKeepSymbols, Keep_symbols_and_debug_frame: linkerAttrs.stripKeepSymbolsAndDebugFrame, @@ -342,22 +327,9 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) { None: linkerAttrs.stripNone, }, - Shared_srcs: sharedAttrs.srcs, - Shared_srcs_c: sharedAttrs.srcs_c, - Shared_srcs_as: sharedAttrs.srcs_as, - Shared_copts: sharedAttrs.copts, - Static_deps_for_shared: sharedAttrs.staticDeps, - Whole_archive_deps_for_shared: sharedAttrs.wholeArchiveDeps, - Dynamic_deps_for_shared: sharedAttrs.dynamicDeps, - Version_script: linkerAttrs.versionScript, - - Static_srcs: staticAttrs.srcs, - Static_srcs_c: staticAttrs.srcs_c, - Static_srcs_as: staticAttrs.srcs_as, - Static_copts: staticAttrs.copts, - Static_deps_for_static: staticAttrs.staticDeps, - Whole_archive_deps_for_static: staticAttrs.wholeArchiveDeps, - Dynamic_deps_for_static: staticAttrs.dynamicDeps, + Shared: sharedAttrs, + + Static: staticAttrs, } props := bazel.BazelTargetModuleProperties{ |