Add support for shared_libs in cc_library targets. am: c50fa8dd05
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1697794 Change-Id: Iac3b732e28b87ae39062fa025b26dd73cf60f9e9
This commit is contained in:
committed by
Automerger Merge Worker
commit
b28a33ceca
@@ -300,6 +300,37 @@ cc_library {
|
|||||||
copts = ["-Ifoo/bar"],
|
copts = ["-Ifoo/bar"],
|
||||||
srcs = ["a.cpp"],
|
srcs = ["a.cpp"],
|
||||||
version_script = "v.map",
|
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.
|
// Convenience struct to hold all attributes parsed from linker properties.
|
||||||
type linkerAttributes struct {
|
type linkerAttributes struct {
|
||||||
deps bazel.LabelListAttribute
|
deps bazel.LabelListAttribute
|
||||||
|
dynamicDeps bazel.LabelListAttribute
|
||||||
linkopts bazel.StringListAttribute
|
linkopts bazel.StringListAttribute
|
||||||
versionScript bazel.LabelAttribute
|
versionScript bazel.LabelAttribute
|
||||||
}
|
}
|
||||||
@@ -255,6 +256,7 @@ type linkerAttributes struct {
|
|||||||
// configurable attribute values.
|
// configurable attribute values.
|
||||||
func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
|
func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module) linkerAttributes {
|
||||||
var deps bazel.LabelListAttribute
|
var deps bazel.LabelListAttribute
|
||||||
|
var dynamicDeps bazel.LabelListAttribute
|
||||||
var linkopts bazel.StringListAttribute
|
var linkopts bazel.StringListAttribute
|
||||||
var versionScript bazel.LabelAttribute
|
var versionScript bazel.LabelAttribute
|
||||||
|
|
||||||
@@ -266,11 +268,16 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
||||||
libs = android.SortedUniqueStrings(libs)
|
libs = android.SortedUniqueStrings(libs)
|
||||||
deps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, libs))
|
deps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, libs))
|
||||||
|
|
||||||
linkopts.Value = baseLinkerProps.Ldflags
|
linkopts.Value = baseLinkerProps.Ldflags
|
||||||
|
|
||||||
if baseLinkerProps.Version_script != nil {
|
if baseLinkerProps.Version_script != nil {
|
||||||
versionScript.Value = android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script)
|
versionScript.Value = android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sharedLibs := baseLinkerProps.Shared_libs
|
||||||
|
dynamicDeps = bazel.MakeLabelListAttribute(android.BazelLabelForModuleDeps(ctx, sharedLibs))
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -283,10 +290,15 @@ func bp2BuildParseLinkerProps(ctx android.TopDownMutatorContext, module *Module)
|
|||||||
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
libs = append(libs, baseLinkerProps.Whole_static_libs...)
|
||||||
libs = android.SortedUniqueStrings(libs)
|
libs = android.SortedUniqueStrings(libs)
|
||||||
deps.SetValueForArch(arch.Name, android.BazelLabelForModuleDeps(ctx, libs))
|
deps.SetValueForArch(arch.Name, android.BazelLabelForModuleDeps(ctx, libs))
|
||||||
|
|
||||||
linkopts.SetValueForArch(arch.Name, baseLinkerProps.Ldflags)
|
linkopts.SetValueForArch(arch.Name, baseLinkerProps.Ldflags)
|
||||||
|
|
||||||
if baseLinkerProps.Version_script != nil {
|
if baseLinkerProps.Version_script != nil {
|
||||||
versionScript.SetValueForArch(arch.Name,
|
versionScript.SetValueForArch(arch.Name,
|
||||||
android.BazelLabelForModuleSrcSingle(ctx, *baseLinkerProps.Version_script))
|
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 = append(libs, baseLinkerProps.Whole_static_libs...)
|
||||||
libs = android.SortedUniqueStrings(libs)
|
libs = android.SortedUniqueStrings(libs)
|
||||||
deps.SetValueForOS(os.Name, android.BazelLabelForModuleDeps(ctx, libs))
|
deps.SetValueForOS(os.Name, android.BazelLabelForModuleDeps(ctx, libs))
|
||||||
|
|
||||||
linkopts.SetValueForOS(os.Name, baseLinkerProps.Ldflags)
|
linkopts.SetValueForOS(os.Name, baseLinkerProps.Ldflags)
|
||||||
|
|
||||||
|
sharedLibs := baseLinkerProps.Shared_libs
|
||||||
|
dynamicDeps.SetValueForOS(os.Name, android.BazelLabelForModuleDeps(ctx, sharedLibs))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return linkerAttributes{
|
return linkerAttributes{
|
||||||
deps: deps,
|
deps: deps,
|
||||||
|
dynamicDeps: dynamicDeps,
|
||||||
linkopts: linkopts,
|
linkopts: linkopts,
|
||||||
versionScript: versionScript,
|
versionScript: versionScript,
|
||||||
}
|
}
|
||||||
|
@@ -225,6 +225,7 @@ type bazelCcLibraryAttributes struct {
|
|||||||
Copts bazel.StringListAttribute
|
Copts bazel.StringListAttribute
|
||||||
Linkopts bazel.StringListAttribute
|
Linkopts bazel.StringListAttribute
|
||||||
Deps bazel.LabelListAttribute
|
Deps bazel.LabelListAttribute
|
||||||
|
Dynamic_deps bazel.LabelListAttribute
|
||||||
User_link_flags bazel.StringListAttribute
|
User_link_flags bazel.StringListAttribute
|
||||||
Includes bazel.StringListAttribute
|
Includes bazel.StringListAttribute
|
||||||
Static_deps_for_shared bazel.LabelListAttribute
|
Static_deps_for_shared bazel.LabelListAttribute
|
||||||
@@ -282,6 +283,7 @@ func CcLibraryBp2Build(ctx android.TopDownMutatorContext) {
|
|||||||
Copts: compilerAttrs.copts,
|
Copts: compilerAttrs.copts,
|
||||||
Linkopts: linkerAttrs.linkopts,
|
Linkopts: linkerAttrs.linkopts,
|
||||||
Deps: linkerAttrs.deps,
|
Deps: linkerAttrs.deps,
|
||||||
|
Dynamic_deps: linkerAttrs.dynamicDeps,
|
||||||
Version_script: linkerAttrs.versionScript,
|
Version_script: linkerAttrs.versionScript,
|
||||||
Static_deps_for_shared: sharedAttrs.staticDeps,
|
Static_deps_for_shared: sharedAttrs.staticDeps,
|
||||||
Includes: exportedIncludes,
|
Includes: exportedIncludes,
|
||||||
|
Reference in New Issue
Block a user