Add libbuildversion in converion instead of macro
Test: bp2build.sh
Change-Id: I96fa6e4dda7d54224a20bcb35414d61c6f70cf7e
diff --git a/cc/bp2build.go b/cc/bp2build.go
index 7a5657a..95ac598 100644
--- a/cc/bp2build.go
+++ b/cc/bp2build.go
@@ -838,6 +838,7 @@
var (
soongSystemSharedLibs = []string{"libc", "libm", "libdl"}
+ versionLib = "libbuildversion"
)
// resolveTargetApex re-adds the shared and static libs in target.apex.exclude_shared|static_libs props to non-apex variant
@@ -877,10 +878,27 @@
var axisFeatures []string
wholeStaticLibs := android.FirstUniqueStrings(props.Whole_static_libs)
- la.wholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, wholeStaticLibs, props.Exclude_static_libs))
+ staticLibs := android.FirstUniqueStrings(android.RemoveListFromList(props.Static_libs, wholeStaticLibs))
+ if axis == bazel.NoConfigAxis {
+ la.useVersionLib.SetSelectValue(axis, config, props.Use_version_lib)
+ if proptools.Bool(props.Use_version_lib) {
+ versionLibAlreadyInDeps := android.InList(versionLib, wholeStaticLibs)
+ // remove from static libs so there is no duplicate dependency
+ _, staticLibs = android.RemoveFromList(versionLib, staticLibs)
+ // only add the dep if it is not in progress
+ if !versionLibAlreadyInDeps {
+ if isBinary {
+ wholeStaticLibs = append(wholeStaticLibs, versionLib)
+ } else {
+ la.implementationWholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, []string{versionLib}, props.Exclude_static_libs))
+ }
+ }
+ }
+ }
+
// Excludes to parallel Soong:
// https://cs.android.com/android/platform/superproject/+/master:build/soong/cc/linker.go;l=247-249;drc=088b53577dde6e40085ffd737a1ae96ad82fc4b0
- staticLibs := android.FirstUniqueStrings(android.RemoveListFromList(props.Static_libs, wholeStaticLibs))
+ la.wholeArchiveDeps.SetSelectValue(axis, config, bazelLabelForWholeDepsExcludes(ctx, wholeStaticLibs, props.Exclude_static_libs))
staticDeps := maybePartitionExportedAndImplementationsDepsExcludes(
ctx,
@@ -1006,10 +1024,6 @@
la.linkopts.SetSelectValue(axis, config, parseCommandLineFlags(linkerFlags, false, filterOutClangUnknownCflags))
la.useLibcrt.SetSelectValue(axis, config, props.libCrt())
- if axis == bazel.NoConfigAxis {
- la.useVersionLib.SetSelectValue(axis, config, props.Use_version_lib)
- }
-
// it's very unlikely for nocrt to be arch variant, so bp2build doesn't support it.
if props.crt() != nil {
if axis == bazel.NoConfigAxis {
diff --git a/cc/library.go b/cc/library.go
index 93bb26a..a8653a0 100644
--- a/cc/library.go
+++ b/cc/library.go
@@ -367,7 +367,6 @@
Stl: compilerAttrs.stl,
Cpp_std: compilerAttrs.cppStd,
C_std: compilerAttrs.cStd,
- Use_version_lib: linkerAttrs.useVersionLib,
Features: baseAttributes.features,
}
@@ -2631,8 +2630,7 @@
attrs = &bazelCcLibraryStaticAttributes{
staticOrSharedAttributes: commonAttrs,
- Use_libcrt: linkerAttrs.useLibcrt,
- Use_version_lib: linkerAttrs.useVersionLib,
+ Use_libcrt: linkerAttrs.useLibcrt,
Rtti: compilerAttrs.rtti,
Stl: compilerAttrs.stl,