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

Commit 47d186cd authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "Create vndkproduct.libraries.txt"

parents 26ab0f10 8a2600cf
Loading
Loading
Loading
Loading
+3 −2
Original line number Diff line number Diff line
@@ -3150,6 +3150,7 @@ func TestVndkApexCurrent(t *testing.T) {
		"etc/vndkcore.libraries.VER.txt",
		"etc/vndksp.libraries.VER.txt",
		"etc/vndkprivate.libraries.VER.txt",
		"etc/vndkproduct.libraries.VER.txt",
	})
}

@@ -3216,7 +3217,7 @@ 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"} {
			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
				result += `
					vndk_libraries_txt {
						name: "` + txt + `.libraries.txt",
@@ -3224,7 +3225,7 @@ func vndkLibrariesTxtFiles(vers ...string) (result string) {
				`
			}
		} else {
			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate"} {
			for _, txt := range []string{"llndk", "vndkcore", "vndksp", "vndkprivate", "vndkproduct"} {
				result += `
					prebuilt_etc {
						name: "` + txt + `.libraries.` + v + `.txt",
+1 −0
Original line number Diff line number Diff line
@@ -60,6 +60,7 @@ func TestVndkApexForVndkLite(t *testing.T) {
		"etc/vndkcore.libraries.VER.txt",
		"etc/vndksp.libraries.VER.txt",
		"etc/vndkprivate.libraries.VER.txt",
		"etc/vndkproduct.libraries.VER.txt",
	})
}

+93 −22
Original line number Diff line number Diff line
@@ -68,6 +68,7 @@ func testCc(t *testing.T, bp string) *android.TestContext {
	t.Helper()
	config := TestConfig(buildDir, android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.ProductVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")

	return testCcWithConfig(t, config)
@@ -81,6 +82,15 @@ func testCcNoVndk(t *testing.T, bp string) *android.TestContext {
	return testCcWithConfig(t, config)
}

func testCcNoProductVndk(t *testing.T, bp string) *android.TestContext {
	t.Helper()
	config := TestConfig(buildDir, android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")

	return testCcWithConfig(t, config)
}

func testCcErrorWithConfig(t *testing.T, pattern string, config android.Config) {
	t.Helper()

@@ -420,6 +430,9 @@ func TestVndk(t *testing.T) {
		vndk_libraries_txt {
			name: "vndkprivate.libraries.txt",
		}
		vndk_libraries_txt {
			name: "vndkproduct.libraries.txt",
		}
		vndk_libraries_txt {
			name: "vndkcorevariant.libraries.txt",
		}
@@ -445,7 +458,6 @@ func TestVndk(t *testing.T) {
	checkVndkModule(t, ctx, "libvndk_sp_product_private", "", true, "", productVariant)

	// Check VNDK snapshot output.

	snapshotDir := "vndk-snapshot"
	snapshotVariantPath := filepath.Join(buildDir, snapshotDir, "arm64")

@@ -476,6 +488,7 @@ func TestVndk(t *testing.T) {
	checkSnapshot(t, ctx, snapshotSingleton, "vndkcore.libraries.txt", "vndkcore.libraries.txt", snapshotConfigsPath, "")
	checkSnapshot(t, ctx, snapshotSingleton, "vndksp.libraries.txt", "vndksp.libraries.txt", snapshotConfigsPath, "")
	checkSnapshot(t, ctx, snapshotSingleton, "vndkprivate.libraries.txt", "vndkprivate.libraries.txt", snapshotConfigsPath, "")
	checkSnapshot(t, ctx, snapshotSingleton, "vndkproduct.libraries.txt", "vndkproduct.libraries.txt", snapshotConfigsPath, "")

	checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
		"LLNDK: libc.so",
@@ -493,11 +506,15 @@ func TestVndk(t *testing.T) {
		"VNDK-private: libvndk-private.so",
		"VNDK-private: libvndk_sp_private-x.so",
		"VNDK-private: libvndk_sp_product_private-x.so",
		"VNDK-product: libc++.so",
		"VNDK-product: libvndk_product.so",
		"VNDK-product: libvndk_sp_product_private-x.so",
	})
	checkVndkLibrariesOutput(t, ctx, "llndk.libraries.txt", []string{"libc.so", "libdl.so", "libft2.so", "libm.so"})
	checkVndkLibrariesOutput(t, ctx, "vndkcore.libraries.txt", []string{"libvndk-private.so", "libvndk.so", "libvndk_product.so"})
	checkVndkLibrariesOutput(t, ctx, "vndksp.libraries.txt", []string{"libc++.so", "libvndk_sp-x.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"})
	checkVndkLibrariesOutput(t, ctx, "vndkprivate.libraries.txt", []string{"libft2.so", "libvndk-private.so", "libvndk_sp_private-x.so", "libvndk_sp_product_private-x.so"})
	checkVndkLibrariesOutput(t, ctx, "vndkproduct.libraries.txt", []string{"libc++.so", "libvndk_product.so", "libvndk_sp_product_private-x.so"})
	checkVndkLibrariesOutput(t, ctx, "vndkcorevariant.libraries.txt", nil)
}

@@ -711,6 +728,15 @@ func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
			},
			nocrt: true,
		}
		cc_library {
			name: "libvndk-private",
			vendor_available: false,
			product_available: false,
			vndk: {
				enabled: true,
			},
			nocrt: true,
		}
	`)

	checkVndkOutput(t, ctx, "vndk/vndk.libraries.txt", []string{
@@ -719,8 +745,13 @@ func TestVndkWhenVndkVersionIsNotSet(t *testing.T) {
		"LLNDK: libft2.so",
		"LLNDK: libm.so",
		"VNDK-SP: libc++.so",
		"VNDK-core: libvndk-private.so",
		"VNDK-core: libvndk.so",
		"VNDK-private: libft2.so",
		"VNDK-private: libvndk-private.so",
		"VNDK-product: libc++.so",
		"VNDK-product: libvndk-private.so",
		"VNDK-product: libvndk.so",
	})
}

@@ -2200,7 +2231,7 @@ func TestVndkExtWithoutBoardVndkVersion(t *testing.T) {

func TestVndkExtWithoutProductVndkVersion(t *testing.T) {
	// This test checks the VNDK-Ext properties when PRODUCT_PRODUCT_VNDK_VERSION is not set.
	ctx := testCc(t, `
	ctx := testCcNoProductVndk(t, `
		cc_library {
			name: "libvndk",
			vendor_available: true,
@@ -3512,27 +3543,28 @@ func checkRuntimeLibs(t *testing.T, expected []string, module *Module) {

const runtimeLibAndroidBp = `
	cc_library {
		name: "libvendor_available1",
		name: "liball_available",
		vendor_available: true,
		product_available: true,
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
	}
	cc_library {
		name: "libvendor_available2",
		name: "libvendor_available1",
		vendor_available: true,
		runtime_libs: ["libvendor_available1"],
		runtime_libs: ["liball_available"],
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
	}
	cc_library {
		name: "libvendor_available3",
		name: "libvendor_available2",
		vendor_available: true,
		runtime_libs: ["libvendor_available1"],
		runtime_libs: ["liball_available"],
		target: {
			vendor: {
				exclude_runtime_libs: ["libvendor_available1"],
				exclude_runtime_libs: ["liball_available"],
			}
		},
		no_libcrt : true,
@@ -3541,7 +3573,7 @@ const runtimeLibAndroidBp = `
	}
	cc_library {
		name: "libcore",
		runtime_libs: ["libvendor_available1"],
		runtime_libs: ["liball_available"],
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
@@ -3556,7 +3588,30 @@ const runtimeLibAndroidBp = `
	cc_library {
		name: "libvendor2",
		vendor: true,
		runtime_libs: ["libvendor_available1", "libvendor1"],
		runtime_libs: ["liball_available", "libvendor1"],
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
	}
	cc_library {
		name: "libproduct_available1",
		product_available: true,
		runtime_libs: ["liball_available"],
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
	}
	cc_library {
		name: "libproduct1",
		product_specific: true,
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
	}
	cc_library {
		name: "libproduct2",
		product_specific: true,
		runtime_libs: ["liball_available", "libproduct1"],
		no_libcrt : true,
		nocrt : true,
		system_shared_libs : [],
@@ -3569,32 +3624,45 @@ func TestRuntimeLibs(t *testing.T) {
	// runtime_libs for core variants use the module names without suffixes.
	variant := "android_arm64_armv8-a_shared"

	module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
	module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available"}, module)

	module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available"}, module)

	module = ctx.ModuleForTests("libcore", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
	checkRuntimeLibs(t, []string{"liball_available"}, module)

	// runtime_libs for vendor variants have '.vendor' suffixes if the modules have both core
	// and vendor variants.
	variant = "android_vendor.VER_arm64_armv8-a_shared"

	module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1.vendor"}, module)
	module = ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available.vendor"}, module)

	module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1.vendor", "libvendor1"}, module)
	checkRuntimeLibs(t, []string{"liball_available.vendor", "libvendor1"}, module)

	// runtime_libs for product variants have '.product' suffixes if the modules have both core
	// and product variants.
	variant = "android_product.VER_arm64_armv8-a_shared"

	module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available.product"}, module)

	module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available.product", "libproduct1"}, module)
}

func TestExcludeRuntimeLibs(t *testing.T) {
	ctx := testCc(t, runtimeLibAndroidBp)

	variant := "android_arm64_armv8-a_shared"
	module := ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
	module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available"}, module)

	variant = "android_vendor.VER_arm64_armv8-a_shared"
	module = ctx.ModuleForTests("libvendor_available3", variant).Module().(*Module)
	module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, nil, module)
}

@@ -3605,11 +3673,14 @@ func TestRuntimeLibsNoVndk(t *testing.T) {

	variant := "android_arm64_armv8-a_shared"

	module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1"}, module)
	module := ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available"}, module)

	module = ctx.ModuleForTests("libvendor2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"libvendor_available1", "libvendor1"}, module)
	checkRuntimeLibs(t, []string{"liball_available", "libvendor1"}, module)

	module = ctx.ModuleForTests("libproduct2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available", "libproduct1"}, module)
}

func checkStaticLibs(t *testing.T, expected []string, module *Module) {
+1 −2
Original line number Diff line number Diff line
@@ -67,9 +67,8 @@ const (
)

func (ctx *moduleContext) ProductSpecific() bool {
	//TODO(b/150902910): Replace HasNonSystemVariants() with HasProductVariant()
	return ctx.ModuleContext.ProductSpecific() ||
		(ctx.mod.HasNonSystemVariants() && ctx.mod.InProduct())
		(ctx.mod.HasProductVariant() && ctx.mod.InProduct())
}

func (ctx *moduleContext) SocSpecific() bool {
+28 −10
Original line number Diff line number Diff line
@@ -35,6 +35,7 @@ const (
	vndkCoreLibrariesTxt             = "vndkcore.libraries.txt"
	vndkSpLibrariesTxt               = "vndksp.libraries.txt"
	vndkPrivateLibrariesTxt          = "vndkprivate.libraries.txt"
	vndkProductLibrariesTxt          = "vndkproduct.libraries.txt"
	vndkUsingCoreVariantLibrariesTxt = "vndkcorevariant.libraries.txt"
)

@@ -45,6 +46,7 @@ func VndkLibrariesTxtModules(vndkVersion string) []string {
			vndkCoreLibrariesTxt,
			vndkSpLibrariesTxt,
			vndkPrivateLibrariesTxt,
			vndkProductLibrariesTxt,
		}
	}
	// Snapshot vndks have their own *.libraries.VER.txt files.
@@ -54,6 +56,7 @@ func VndkLibrariesTxtModules(vndkVersion string) []string {
		insertVndkVersion(vndkCoreLibrariesTxt, vndkVersion),
		insertVndkVersion(vndkSpLibrariesTxt, vndkVersion),
		insertVndkVersion(vndkPrivateLibrariesTxt, vndkVersion),
		insertVndkVersion(vndkProductLibrariesTxt, vndkVersion),
	}
}

@@ -229,10 +232,11 @@ func vndkIsVndkDepAllowed(from *vndkdep, to *vndkdep) error {
}

var (
	vndkCoreLibrariesKey             = android.NewOnceKey("vndkCoreLibrarires")
	vndkSpLibrariesKey               = android.NewOnceKey("vndkSpLibrarires")
	llndkLibrariesKey                = android.NewOnceKey("llndkLibrarires")
	vndkPrivateLibrariesKey          = android.NewOnceKey("vndkPrivateLibrarires")
	vndkCoreLibrariesKey             = android.NewOnceKey("vndkCoreLibraries")
	vndkSpLibrariesKey               = android.NewOnceKey("vndkSpLibraries")
	llndkLibrariesKey                = android.NewOnceKey("llndkLibraries")
	vndkPrivateLibrariesKey          = android.NewOnceKey("vndkPrivateLibraries")
	vndkProductLibrariesKey          = android.NewOnceKey("vndkProductLibraries")
	vndkUsingCoreVariantLibrariesKey = android.NewOnceKey("vndkUsingCoreVariantLibraries")
	vndkMustUseVendorVariantListKey  = android.NewOnceKey("vndkMustUseVendorVariantListKey")
	vndkLibrariesLock                sync.Mutex
@@ -262,6 +266,12 @@ func vndkPrivateLibraries(config android.Config) map[string]string {
	}).(map[string]string)
}

func vndkProductLibraries(config android.Config) map[string]string {
	return config.Once(vndkProductLibrariesKey, func() interface{} {
		return make(map[string]string)
	}).(map[string]string)
}

func vndkUsingCoreVariantLibraries(config android.Config) map[string]string {
	return config.Once(vndkUsingCoreVariantLibrariesKey, func() interface{} {
		return make(map[string]string)
@@ -299,6 +309,12 @@ func processLlndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
}

func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
	if m.InProduct() {
		// We may skip the steps for the product variants because they
		// are already covered by the vendor variants.
		return
	}

	name := m.BaseModuleName()
	filename, err := getVndkFileName(m)
	if err != nil {
@@ -318,12 +334,6 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
	vndkLibrariesLock.Lock()
	defer vndkLibrariesLock.Unlock()

	if m.InProduct() {
		// We may skip the other steps for the product variants because they
		// are already covered by the vendor variants.
		return
	}

	if inList(name, vndkMustUseVendorVariantList(mctx.Config())) {
		m.Properties.MustUseVendorVariant = true
	}
@@ -339,6 +349,9 @@ func processVndkLibrary(mctx android.BottomUpMutatorContext, m *Module) {
	if m.IsVndkPrivate() {
		vndkPrivateLibraries(mctx.Config())[name] = filename
	}
	if m.VendorProperties.Product_available != nil {
		vndkProductLibraries(mctx.Config())[name] = filename
	}
}

// Check for modules that mustn't be VNDK
@@ -453,6 +466,7 @@ var _ android.OutputFileProducer = &vndkLibrariesTxt{}
// - vndkcore.libraries.txt
// - vndksp.libraries.txt
// - vndkprivate.libraries.txt
// - vndkproduct.libraries.txt
// - vndkcorevariant.libraries.txt
// A module behaves like a prebuilt_etc but its content is generated by soong.
// By being a soong module, these files can be referenced by other soong modules.
@@ -486,6 +500,8 @@ func (txt *vndkLibrariesTxt) GenerateAndroidBuildActions(ctx android.ModuleConte
		list = android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
	case vndkPrivateLibrariesTxt:
		list = android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
	case vndkProductLibrariesTxt:
		list = android.SortedStringMapValues(vndkProductLibraries(ctx.Config()))
	case vndkUsingCoreVariantLibrariesTxt:
		list = android.SortedStringMapValues(vndkUsingCoreVariantLibraries(ctx.Config()))
	default:
@@ -807,6 +823,7 @@ func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.Singleton
	vndkcore := android.SortedStringMapValues(vndkCoreLibraries(ctx.Config()))
	vndksp := android.SortedStringMapValues(vndkSpLibraries(ctx.Config()))
	vndkprivate := android.SortedStringMapValues(vndkPrivateLibraries(ctx.Config()))
	vndkproduct := android.SortedStringMapValues(vndkProductLibraries(ctx.Config()))

	// Build list of vndk libs as merged & tagged & filter-out(libclang_rt):
	// Since each target have different set of libclang_rt.* files,
@@ -824,6 +841,7 @@ func (c *vndkSnapshotSingleton) buildVndkLibrariesTxtFiles(ctx android.Singleton
	merged = append(merged, addPrefix(vndksp, "VNDK-SP: ")...)
	merged = append(merged, addPrefix(filterOutLibClangRt(vndkcore), "VNDK-core: ")...)
	merged = append(merged, addPrefix(vndkprivate, "VNDK-private: ")...)
	merged = append(merged, addPrefix(filterOutLibClangRt(vndkproduct), "VNDK-product: ")...)
	c.vndkLibrariesFile = android.PathForOutput(ctx, "vndk", "vndk.libraries.txt")
	android.WriteFileRule(ctx, c.vndkLibrariesFile, strings.Join(merged, "\n"))
}