Soong works with empty VNDK version

This change is to fix more misc issues to enable Soong without VNDK
version. This change contains

* Update properties in generated Android.mk
* Update VNDK APEX build to work without VNDK version

Bug: 316829758
Test: AOSP Cuttlefish build succeeded
Change-Id: I10f3c798299afe2d539ec3426b8e2b6068a158f6
This commit is contained in:
Kiyoung Kim
2024-01-11 16:03:13 +09:00
parent 1c4cc3d40e
commit 8487c0b876
4 changed files with 39 additions and 24 deletions

View File

@@ -65,24 +65,27 @@ func apexVndkMutator(mctx android.TopDownMutatorContext) {
} }
vndkVersion := ab.vndkVersion(mctx.DeviceConfig()) vndkVersion := ab.vndkVersion(mctx.DeviceConfig())
apiLevel, err := android.ApiLevelFromUser(mctx, vndkVersion) if vndkVersion != "" {
if err != nil { apiLevel, err := android.ApiLevelFromUser(mctx, vndkVersion)
mctx.PropertyErrorf("vndk_version", "%s", err.Error()) if err != nil {
return mctx.PropertyErrorf("vndk_version", "%s", err.Error())
} return
}
targets := mctx.MultiTargets() targets := mctx.MultiTargets()
if len(targets) > 0 && apiLevel.LessThan(cc.MinApiForArch(mctx, targets[0].Arch.ArchType)) && if len(targets) > 0 && apiLevel.LessThan(cc.MinApiForArch(mctx, targets[0].Arch.ArchType)) &&
vndkVersion != mctx.DeviceConfig().PlatformVndkVersion() { vndkVersion != mctx.DeviceConfig().PlatformVndkVersion() {
// Disable VNDK APEXes for VNDK versions less than the minimum supported API // Disable VNDK APEXes for VNDK versions less than the minimum supported API
// level for the primary architecture. This validation is skipped if the VNDK // level for the primary architecture. This validation is skipped if the VNDK
// version matches the platform VNDK version, which can occur when the device // version matches the platform VNDK version, which can occur when the device
// config targets the 'current' VNDK (see `vndkVersion`). // config targets the 'current' VNDK (see `vndkVersion`).
ab.Disable() ab.Disable()
} }
if proptools.String(ab.vndkProperties.Vndk_version) != "" && if proptools.String(ab.vndkProperties.Vndk_version) != "" &&
apiLevel.GreaterThanOrEqualTo(android.ApiLevelOrPanic(mctx, mctx.DeviceConfig().PlatformVndkVersion())) { mctx.DeviceConfig().PlatformVndkVersion() != "" &&
ab.Disable() apiLevel.GreaterThanOrEqualTo(android.ApiLevelOrPanic(mctx, mctx.DeviceConfig().PlatformVndkVersion())) {
ab.Disable()
}
} }
} }
} }
@@ -94,6 +97,11 @@ func apexVndkDepsMutator(mctx android.BottomUpMutatorContext) {
if vndkVersion == "" { if vndkVersion == "" {
vndkVersion = mctx.DeviceConfig().PlatformVndkVersion() vndkVersion = mctx.DeviceConfig().PlatformVndkVersion()
} }
if vndkVersion == "" {
return
}
if vndkVersion == mctx.DeviceConfig().PlatformVndkVersion() { if vndkVersion == mctx.DeviceConfig().PlatformVndkVersion() {
vndkVersion = "current" vndkVersion = "current"
} else { } else {

View File

@@ -105,7 +105,7 @@ func (c *Module) AndroidMkEntries() []android.AndroidMkEntries {
entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...) entries.AddStrings("LOCAL_RUNTIME_LIBRARIES", c.Properties.AndroidMkRuntimeLibs...)
} }
entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType) entries.SetString("LOCAL_SOONG_LINK_TYPE", c.makeLinkType)
if c.UseVndk() { if c.InVendorOrProduct() {
entries.SetBool("LOCAL_USE_VNDK", true) entries.SetBool("LOCAL_USE_VNDK", true)
if c.IsVndk() && !c.static() { if c.IsVndk() && !c.static() {
entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion()) entries.SetString("LOCAL_SOONG_VNDK_VERSION", c.VndkVersion())

View File

@@ -3785,7 +3785,7 @@ func (c *Module) Object() bool {
} }
func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string { func GetMakeLinkType(actx android.ModuleContext, c LinkableInterface) string {
if c.UseVndk() { if c.InVendorOrProduct() {
if c.IsLlndk() { if c.IsLlndk() {
if !c.IsLlndkPublic() { if !c.IsLlndkPublic() {
return "native:vndk_private" return "native:vndk_private"

View File

@@ -17,6 +17,7 @@ package cc
import ( import (
"fmt" "fmt"
"io" "io"
"log"
"path/filepath" "path/filepath"
"regexp" "regexp"
"strconv" "strconv"
@@ -871,12 +872,18 @@ func (library *libraryDecorator) getLibNameHelper(baseModuleName string, inVendo
func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string { func (library *libraryDecorator) getLibName(ctx BaseModuleContext) string {
name := library.getLibNameHelper(ctx.baseModuleName(), ctx.inVendor(), ctx.inProduct()) name := library.getLibNameHelper(ctx.baseModuleName(), ctx.inVendor(), ctx.inProduct())
// Replace name with VNDK ext as original lib only when VNDK is enabled
if ctx.IsVndkExt() { if ctx.IsVndkExt() {
// vndk-ext lib should have the same name with original lib if ctx.DeviceConfig().VndkVersion() != "" {
ctx.VisitDirectDepsWithTag(vndkExtDepTag, func(module android.Module) { // vndk-ext lib should have the same name with original lib
originalName := module.(*Module).outputFile.Path() ctx.VisitDirectDepsWithTag(vndkExtDepTag, func(module android.Module) {
name = strings.TrimSuffix(originalName.Base(), originalName.Ext()) originalName := module.(*Module).outputFile.Path()
}) name = strings.TrimSuffix(originalName.Base(), originalName.Ext())
})
} else {
// TODO(b/320208784) : Suggest a solution for former VNDK-ext libraries before VNDK deprecation.
log.Printf("VNDK Extension on module %s will not be available once VNDK is deprecated", ctx.baseModuleName())
}
} }
if ctx.Host() && Bool(library.Properties.Unique_host_soname) { if ctx.Host() && Bool(library.Properties.Unique_host_soname) {