Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 87e41282 authored by Justin Yun's avatar Justin Yun Committed by Gerrit Code Review
Browse files

Merge "Stop using VNDK from product partition" into main

parents e19a173a d578412c
Loading
Loading
Loading
Loading
+12 −1
Original line number Diff line number Diff line
@@ -3882,13 +3882,24 @@ func TestVndkApexWithPrebuilt(t *testing.T) {
func vndkLibrariesTxtFiles(vers ...string) (result string) {
	for _, v := range vers {
		if v == "current" {
			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
			for _, txt := range []string{"vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
				result += `
					` + txt + `_libraries_txt {
						name: "` + txt + `.libraries.txt",
						insert_vndk_version: true,
					}
				`
			}
			result += `
				llndk_libraries_txt {
					name: "llndk.libraries.txt",
				}
				llndk_libraries_txt_for_apex {
					name: "llndk.libraries.txt.apex",
					stem: "llndk.libraries.txt",
					insert_vndk_version: true,
				}
			`
		} else {
			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
				result += `
+1 −1
Original line number Diff line number Diff line
@@ -2195,7 +2195,7 @@ func (library *libraryDecorator) install(ctx ModuleContext, file android.Path) {

			// do not install vndk libs
			// vndk libs are packaged into VNDK APEX
			if ctx.isVndk() && !ctx.IsVndkExt() && !ctx.Config().IsVndkDeprecated() {
			if ctx.isVndk() && !ctx.IsVndkExt() && !ctx.Config().IsVndkDeprecated() && !ctx.inProduct() {
				return
			}
		} else if library.hasStubsVariants() && !ctx.Host() && ctx.directlyInAnyApex() {
+25 −20
Original line number Diff line number Diff line
@@ -28,10 +28,12 @@ import (
	"android/soong/snapshot"

	"github.com/google/blueprint"
	"github.com/google/blueprint/proptools"
)

const (
	llndkLibrariesTxt                = "llndk.libraries.txt"
	llndkLibrariesTxtForApex         = "llndk.libraries.txt.apex"
	vndkCoreLibrariesTxt             = "vndkcore.libraries.txt"
	vndkSpLibrariesTxt               = "vndksp.libraries.txt"
	vndkPrivateLibrariesTxt          = "vndkprivate.libraries.txt"
@@ -40,6 +42,7 @@ const (
)

func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext) []string {
	// Return the list of vndk txt files for the vndk apex of the vndkVersion.
	if vndkVersion == "current" {
		// We can assume all txt files are snapshotted if we find one of them.
		currentVndkSnapshotted := ctx.OtherModuleExists(insertVndkVersion(llndkLibrariesTxt, ctx.DeviceConfig().PlatformVndkVersion()))
@@ -51,20 +54,13 @@ func VndkLibrariesTxtModules(vndkVersion string, ctx android.BaseModuleContext)
			vndkVersion = ctx.DeviceConfig().PlatformVndkVersion()
		} else {
			// Use the txt files generated from the source
			result := []string{
			return []string{
				llndkLibrariesTxtForApex,
				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)
			}

			return result
		}
	}

@@ -451,6 +447,7 @@ func init() {

func RegisterVndkLibraryTxtTypes(ctx android.RegistrationContext) {
	ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt", llndkLibrariesTxtFactory)
	ctx.RegisterParallelSingletonModuleType("llndk_libraries_txt_for_apex", llndkLibrariesTxtApexOnlyFactory)
	ctx.RegisterParallelSingletonModuleType("vndksp_libraries_txt", vndkSPLibrariesTxtFactory)
	ctx.RegisterParallelSingletonModuleType("vndkcore_libraries_txt", vndkCoreLibrariesTxtFactory)
	ctx.RegisterParallelSingletonModuleType("vndkprivate_libraries_txt", vndkPrivateLibrariesTxtFactory)
@@ -474,22 +471,31 @@ type vndkLibrariesTxt struct {

type VndkLibrariesTxtProperties struct {
	Insert_vndk_version *bool
	Stem                *string
}

var _ etc.PrebuiltEtcModule = &vndkLibrariesTxt{}
var _ android.OutputFileProducer = &vndkLibrariesTxt{}

// llndk_libraries_txt is a singleton module whose content is a list of LLNDK libraries
// generated by Soong but can be referenced by other modules.
// For example, apex_vndk can depend on these files as prebuilt.
// generated by Soong.
// Make uses LLNDK_LIBRARIES to determine which libraries to install.
// HWASAN is only part of the LL-NDK in builds in which libc depends on HWASAN.
// HWASAN is only part of the LLNDK in builds in which libc depends on HWASAN.
// Therefore, by removing the library here, we cause it to only be installed if libc
// depends on it.
func llndkLibrariesTxtFactory() android.SingletonModule {
	return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "LLNDK_LIBRARIES", "libclang_rt.hwasan")
}

// llndk_libraries_txt_for_apex is a singleton module that provide the same LLNDK libraries list
// with the llndk_libraries_txt, but skips setting make variable LLNDK_LIBRARIES. So, it must not
// be used without installing llndk_libraries_txt singleton.
// We include llndk_libraries_txt by default to install the llndk.libraries.txt file to system/etc.
// This singleton module is to install the llndk.libraries.<ver>.txt file to vndk apex.
func llndkLibrariesTxtApexOnlyFactory() android.SingletonModule {
	return newVndkLibrariesWithMakeVarFilter(llndkLibraries, "", "libclang_rt.hwasan")
}

// vndksp_libraries_txt is a singleton module whose content is a list of VNDKSP libraries
// generated by Soong but can be referenced by other modules.
// For example, apex_vndk can depend on these files as prebuilt.
@@ -557,15 +563,10 @@ func (txt *vndkLibrariesTxt) DepsMutator(mctx android.BottomUpMutatorContext) {
}

func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleContext) {
	filename := txt.Name()
	filename := proptools.StringDefault(txt.properties.Stem, txt.Name())

	shouldInsertVndkVersion := BoolDefault(txt.properties.Insert_vndk_version, true)
	// llndk.libraries.txt file installed in the system image should not contain version info.
	if ctx.Config().IsVndkDeprecated() && txt.Name() == llndkLibrariesTxt {
		shouldInsertVndkVersion = false
	}
	if shouldInsertVndkVersion {
		filename = insertVndkVersion(txt.Name(), ctx.DeviceConfig().PlatformVndkVersion())
	if Bool(txt.properties.Insert_vndk_version) {
		filename = insertVndkVersion(filename, ctx.DeviceConfig().PlatformVndkVersion())
	}

	txt.outputFile = android.PathForModuleOut(ctx, filename).OutputPath
@@ -592,6 +593,10 @@ func (txt *vndkLibrariesTxt) AndroidMkEntries() []android.AndroidMkEntries {
}

func (txt *vndkLibrariesTxt) MakeVars(ctx android.MakeVarsContext) {
	if txt.makeVarName == "" {
		return
	}

	filter := func(modules []string, prefix string) []string {
		if prefix == "" {
			return modules