Add support for shared_libs in cc_library targets.
Test: cd bp2build; go test Test: bazel build //bionic/... Test: ./build/bazel/scripts/run_presubmits.sh Change-Id: I71e279470a0d69b243dd0a2b53ce31842fd36ee4
This commit is contained in:
parent
564fce4578
commit
c50fa8dd05
|
@ -300,6 +300,37 @@ cc_library {
|
|||
copts = ["-Ifoo/bar"],
|
||||
srcs = ["a.cpp"],
|
||||
version_script = "v.map",
|
||||
)`},
|
||||
},
|
||||
{
|
||||
description: "cc_library shared_libs",
|
||||
moduleTypeUnderTest: "cc_library",
|
||||
moduleTypeUnderTestFactory: cc.LibraryFactory,
|
||||
moduleTypeUnderTestBp2BuildMutator: cc.CcLibraryBp2Build,
|
||||
depsMutators: []android.RegisterMutatorFunc{cc.RegisterDepsBp2Build},
|
||||
dir: "foo/bar",
|
||||
filesystem: map[string]string{
|
||||
"foo/bar/Android.bp": `
|
||||
cc_library {
|
||||
name: "mylib",
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
|
||||
cc_library {
|
||||
name: "a",
|
||||
shared_libs: ["mylib",],
|
||||
bazel_module: { bp2build_available: true },
|
||||
}
|
||||
`,
|
||||
},
|
||||
bp: soongCcLibraryPreamble,
|
||||
expectedBazelTargets: []string{`cc_library(
|
||||
name = "a",
|
||||
copts = ["-Ifoo/bar"],
|
||||
dynamic_deps = [":mylib"],
|
||||
)`, `cc_library(
|
||||
name = "mylib",
|
||||
copts = ["-Ifoo/bar"],
|
||||
)`},
|
||||
},
|
||||
}
|
||||
|
|
|
@ -247,6 +247,7 @@ func bp2BuildParseCompilerProps(ctx android.TopDownMutatorContext, module *Modul
|
|||
// Convenience struct to hold all attributes parsed from linker properties.
|
||||
type linkerAttributes struct {
|
||||
deps bazel.LabelListAttribute
|
||||
dynamicDeps bazel.LabelListAttribute
|
||||
linkopts bazel.StringListAttribute
|
||||
versionScript bazel.LabelAttribute
|
||||
}
|
||||
|
@ -255,6 +256,7 @@ type linkerAttributes struct {
|
|||
// configurable attribute values.
|
||||
func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
|
||||
var deps bazel.LabelListAttribute
|
||||
var dynamicDeps bazel.LabelListAttribute
|
||||
var linkopts bazel.StringListAttribute
|
||||
var versionScript bazel.LabelAttribute
|
||||
|
||||
|
@ -266,11 +268,16 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
||||
libs = android.SortedUniqueStrings(libs)
|
||||
deps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, libs))
|
||||
|
||||
linkopts.Value = baseLinkerProps.Ldflags
|
||||
|
||||
if baseLinkerProps.Version_script != nil {
|
||||
versionScript.Value = android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script)
|
||||
}
|
||||
|
||||
sharedLibs := baseLinkerProps.Shared_libs
|
||||
dynamicDeps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, sharedLibs))
|
||||
|
||||
break
|
||||
}
|
||||
}
|
||||
|
@ -283,10 +290,15 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
||||
libs = android.SortedUniqueStrings(libs)
|
||||
deps.SetValueForArch(arch.Name, android.BazelLabelForModuleDeps(ctx, libs))
|
||||
|
||||
linkopts.SetValueForArch(arch.Name, baseLinkerProps.Ldflags)
|
||||
|
||||
if baseLinkerProps.Version_script != nil {
|
||||
versionScript.SetValueForArch(arch.Name,
|
||||
android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script))
|
||||
|
||||
sharedLibs := baseLinkerProps.Shared_libs
|
||||
dynamicDeps.SetValueForArch(arch.Name, android.BazelLabelForModuleDeps(ctx, sharedLibs))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -299,12 +311,17 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
||||
libs = android.SortedUniqueStrings(libs)
|
||||
deps.SetValueForOS(os.Name, android.BazelLabelForModuleDeps(ctx, libs))
|
||||
|
||||
linkopts.SetValueForOS(os.Name, baseLinkerProps.Ldflags)
|
||||
|
||||
sharedLibs := baseLinkerProps.Shared_libs
|
||||
dynamicDeps.SetValueForOS(os.Name, android.BazelLabelForModuleDeps(ctx, sharedLibs))
|
||||
}
|
||||
}
|
||||
|
||||
return linkerAttributes{
|
||||
deps: deps,
|
||||
dynamicDeps: dynamicDeps,
|
||||
linkopts: linkopts,
|
||||
versionScript: versionScript,
|
||||
}
|
||||
|
|
|
@ -225,6 +225,7 @@ type bazelCcLibraryAttributes struct {
|
|||
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
|
||||
|
@ -282,6 +283,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||
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,
|
||||
|
|
Loading…
Reference in New Issue