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

Commit ecde72f2 authored by Jooyung Han's avatar Jooyung Han Committed by Gerrit Code Review
Browse files

Merge "Revert "Revert "cc: use platform sdk version for vendor/product ..."" into main

parents 2c17b256 aa2d3f57
Loading
Loading
Loading
Loading
+5 −6
Original line number Diff line number Diff line
@@ -1560,12 +1560,11 @@ func (ctx *moduleContextImpl) minSdkVersion() string {
	}

	if ctx.ctx.Device() {
		config := ctx.ctx.Config()
		if ctx.inVendor() {
			// If building for vendor with final API, then use the latest _stable_ API as "current".
			if config.VendorApiLevelFrozen() && (ver == "" || ver == "current") {
				ver = config.PlatformSdkVersion().String()
			}
		// When building for vendor/product, use the latest _stable_ API as "current".
		// This is passed to clang/aidl compilers so that compiled/generated code works
		// with the system.
		if (ctx.inVendor() || ctx.inProduct()) && (ver == "" || ver == "current") {
			ver = ctx.ctx.Config().PlatformSdkVersion().String()
		}
	}

+12 −14
Original line number Diff line number Diff line
@@ -1008,7 +1008,7 @@ func TestLlndkLibrary(t *testing.T) {
	android.AssertArrayString(t, "variants for llndk stubs", expected, actual)

	params := result.ModuleForTests("libllndk", "android_vendor_arm_armv7-a-neon_shared").Description("generate stub")
	android.AssertSame(t, "use Vendor API level for default stubs", "202404", params.Args["apiLevel"])
	android.AssertSame(t, "use Vendor API level for default stubs", "999999", params.Args["apiLevel"])

	checkExportedIncludeDirs := func(module, variant string, expectedSystemDirs []string, expectedDirs ...string) {
		t.Helper()
@@ -3153,7 +3153,7 @@ func TestImageVariants(t *testing.T) {
	testDepWithVariant("product")
}

func TestVendorSdkVersion(t *testing.T) {
func TestVendorOrProductVariantUsesPlatformSdkVersionAsDefault(t *testing.T) {
	t.Parallel()

	bp := `
@@ -3161,31 +3161,29 @@ func TestVendorSdkVersion(t *testing.T) {
			name: "libfoo",
			srcs: ["libfoo.cc"],
			vendor_available: true,
			product_available: true,
		}

		cc_library {
			name: "libbar",
			srcs: ["libbar.cc"],
			vendor_available: true,
			product_available: true,
			min_sdk_version: "29",
		}
	`

	ctx := prepareForCcTest.RunTestWithBp(t, bp)
	testSdkVersionFlag := func(module, version string) {
		flags := ctx.ModuleForTests(module, "android_vendor_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
		android.AssertStringDoesContain(t, "min sdk version", flags, "-target aarch64-linux-android"+version)
	testSdkVersionFlag := func(module, variant, version string) {
		flags := ctx.ModuleForTests(module, "android_"+variant+"_arm64_armv8-a_static").Rule("cc").Args["cFlags"]
		android.AssertStringDoesContain(t, "target SDK version", flags, "-target aarch64-linux-android"+version)
	}

	testSdkVersionFlag("libfoo", "10000")
	testSdkVersionFlag("libbar", "29")

	ctx = android.GroupFixturePreparers(
		prepareForCcTest,
		android.PrepareForTestWithBuildFlag("RELEASE_BOARD_API_LEVEL_FROZEN", "true"),
	).RunTestWithBp(t, bp)
	testSdkVersionFlag("libfoo", "30")
	testSdkVersionFlag("libbar", "29")
	testSdkVersionFlag("libfoo", "vendor", "30")
	testSdkVersionFlag("libfoo", "product", "30")
	// target SDK version can be set explicitly with min_sdk_version
	testSdkVersionFlag("libbar", "vendor", "29")
	testSdkVersionFlag("libbar", "product", "29")
}

func TestClangVerify(t *testing.T) {
+2 −8
Original line number Diff line number Diff line
@@ -566,16 +566,10 @@ func (library *libraryDecorator) getHeaderAbiCheckerProperties(m *Module) header

func (library *libraryDecorator) compile(ctx ModuleContext, flags Flags, deps PathDeps) Objects {
	if ctx.IsLlndk() {
		vendorApiLevel := ctx.Config().VendorApiLevel()
		if vendorApiLevel == "" {
			// TODO(b/321892570): Some tests relying on old fixtures which
			// doesn't set vendorApiLevel. Needs to fix them.
			vendorApiLevel = ctx.Config().PlatformSdkVersion().String()
		}
		// This is the vendor variant of an LLNDK library, build the LLNDK stubs.
		futureVendorApiLevel := android.ApiLevelOrPanic(ctx, "999999")
		nativeAbiResult := parseNativeAbiDefinition(ctx,
			String(library.Properties.Llndk.Symbol_file),
			android.ApiLevelOrPanic(ctx, vendorApiLevel), "--llndk")
			futureVendorApiLevel, "--llndk")
		objs := compileStubLibrary(ctx, flags, nativeAbiResult.stubSrc)
		if !Bool(library.Properties.Llndk.Unversioned) {
			library.versionScriptPath = android.OptionalPathForPath(