From 74217d9177d41ca45781cb5a103eb36cc1b01117 Mon Sep 17 00:00:00 2001 From: Justin Yun Date: Mon, 21 Aug 2023 20:51:45 +0900 Subject: [PATCH] Use vndk snapshot libraries txt files if exist For the trunk stable next build, we have duplicated modules for the vndk libraries txt files: one from the generated list, the other from the prebuilt vndk snapshot files. If the current vndk version provided by the vndk snapshots, use the txt file from the prebuilt vndk snapshot. Bug: 296777146 Test: lunch cf_x86_64_phone-next-userdebug && m nothing Change-Id: I18bd7b7c77bd37c26c5e0b15cb020a59d50f4f2f --- cc/vndk.go | 45 +++++++++++++++++++++++++++++++++------------ 1 file changed, 33 insertions(+), 12 deletions(-) diff --git a/cc/vndk.go b/cc/vndk.go index 82a2a4b27..5ac5032c5 100644 --- a/cc/vndk.go +++ b/cc/vndk.go @@ -41,21 +41,33 @@ const ( func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext) []string { if vndkVersion == "current" { - result := []string{ - vndkCoreLibrariesTxt, - vndkSpLibrariesTxt, - vndkPrivateLibrariesTxt, - vndkProductLibrariesTxt, - } + // We can assume all txt files are snapshotted if we find one of them. + currentVndkSnapshotted := ctx.OtherModuleExists(insertVndkVersion(llndkLibrariesTxt, ctx.DeviceConfig().PlatformVndkVersion())) + if currentVndkSnapshotted { + // If the current VNDK is already snapshotted (which can happen with + // the `next` config), use the prebuilt txt files in the snapshot. + // This is because the txt files built from source are probably be + // for the in-development version. + vndkVersion = ctx.DeviceConfig().PlatformVndkVersion() + } else { + // Use the txt files generated from the source + result := []string{ + vndkCoreLibrariesTxt, + vndkSpLibrariesTxt, + vndkPrivateLibrariesTxt, + vndkProductLibrariesTxt, + } - // TODO(b/290159430) This part will not be required once deprecation of VNDK - // is handled with 'ro.vndk.version' property - if !ctx.Config().IsVndkDeprecated() { - result = append(result, llndkLibrariesTxt) - } + // TODO(b/290159430) This part will not be required once deprecation + // of VNDK is handled with 'ro.vndk.version' property + if !ctx.Config().IsVndkDeprecated() { + result = append(result, llndkLibrariesTxt) + } - return result + return result + } } + // Snapshot vndks have their own *.libraries.VER.txt files. // Note that snapshots don't have "vndkcorevariant.libraries.VER.txt" result := []string{ @@ -535,6 +547,15 @@ func insertVndkVersion(filename string, vndkVersion string) string { return filename } +func (txt *vndkLibrariesTxt) DepsMutator(mctx android.BottomUpMutatorContext) { + versionedName := insertVndkVersion(txt.Name(), mctx.DeviceConfig().PlatformVndkVersion()) + if mctx.OtherModuleExists(versionedName) { + // If the prebuilt vndk libraries txt files exist, install them instead. + txt.HideFromMake() + mctx.AddDependency(txt, nil, versionedName) + } +} + func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) { filename := txt.Name()