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

Commit 8c56183f authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge changes Id33bf640,I4d67b9b9

* changes:
  Don't use incorrect version names like VER or BOARD even in tests
  SdkSpec = Scope + ApiLevel
parents 7fef94f5 f58c46e3
Loading
Loading
Loading
Loading
+43 −76
Original line number Diff line number Diff line
@@ -75,58 +75,15 @@ func (k SdkKind) String() string {
	}
}

// SdkVersion represents a specific version number of an SDK spec of a particular kind
type SdkVersion int

const (
	// special version number for a not-yet-frozen SDK
	SdkVersionCurrent SdkVersion = SdkVersion(FutureApiLevelInt)
	// special version number to be used for SDK specs where version number doesn't
	// make sense, e.g. "none", "", etc.
	SdkVersionNone SdkVersion = SdkVersion(0)
)

// IsCurrent checks if the SdkVersion refers to the not-yet-published version of an SdkKind
func (v SdkVersion) IsCurrent() bool {
	return v == SdkVersionCurrent
}

// IsNumbered checks if the SdkVersion refers to the published (a.k.a numbered) version of an SdkKind
func (v SdkVersion) IsNumbered() bool {
	return !v.IsCurrent() && v != SdkVersionNone
}

// String returns the string representation of this SdkVersion.
func (v SdkVersion) String() string {
	if v.IsCurrent() {
		return "current"
	} else if v.IsNumbered() {
		return strconv.Itoa(int(v))
	}
	return "(no version)"
}

func (v SdkVersion) ApiLevel(ctx EarlyModuleContext) ApiLevel {
	return ApiLevelOrPanic(ctx, v.String())
}

// AsNumberString directly converts the numeric value of this sdk version as a string.
// When isNumbered() is true, this method is the same as String(). However, for SdkVersionCurrent
// and SdkVersionNone, this returns 10000 and 0 while String() returns "current" and "(no version"),
// respectively.
func (v SdkVersion) AsNumberString() string {
	return strconv.Itoa(int(v))
}

// SdkSpec represents the kind and the version of an SDK for a module to build against
type SdkSpec struct {
	Kind     SdkKind
	Version SdkVersion
	ApiLevel ApiLevel
	Raw      string
}

func (s SdkSpec) String() string {
	return fmt.Sprintf("%s_%s", s.Kind, s.Version)
	return fmt.Sprintf("%s_%s", s.Kind, s.ApiLevel)
}

// Valid checks if this SdkSpec is well-formed. Note however that true doesn't mean that the
@@ -177,10 +134,10 @@ func (s SdkSpec) ForVendorPartition(ctx EarlyModuleContext) SdkSpec {
	}

	if s.Kind == SdkPublic || s.Kind == SdkSystem {
		if s.Version.IsCurrent() {
		if s.ApiLevel.IsCurrent() {
			if i, err := strconv.Atoi(currentSdkVersion); err == nil {
				version := SdkVersion(i)
				return SdkSpec{s.Kind, version, s.Raw}
				apiLevel := uncheckedFinalApiLevel(i)
				return SdkSpec{s.Kind, apiLevel, s.Raw}
			}
			panic(fmt.Errorf("BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES must be either \"current\" or a number, but was %q", currentSdkVersion))
		}
@@ -190,10 +147,10 @@ func (s SdkSpec) ForVendorPartition(ctx EarlyModuleContext) SdkSpec {

// UsePrebuilt determines whether prebuilt SDK should be used for this SdkSpec with the given context.
func (s SdkSpec) UsePrebuilt(ctx EarlyModuleContext) bool {
	if s.Version.IsCurrent() {
	if s.ApiLevel.IsCurrent() {
		// "current" can be built from source and be from prebuilt SDK
		return ctx.Config().AlwaysUsePrebuiltSdks()
	} else if s.Version.IsNumbered() {
	} else if !s.ApiLevel.IsPreview() {
		// validation check
		if s.Kind != SdkPublic && s.Kind != SdkSystem && s.Kind != SdkTest && s.Kind != SdkModule {
			panic(fmt.Errorf("prebuilt SDK is not not available for SdkKind=%q", s.Kind))
@@ -206,50 +163,60 @@ func (s SdkSpec) UsePrebuilt(ctx EarlyModuleContext) bool {
	return false
}

// EffectiveVersion converts an SdkSpec into the concrete SdkVersion that the module
// should use. For modules targeting an unreleased SDK (meaning it does not yet have a number)
// it returns FutureApiLevel(10000).
func (s SdkSpec) EffectiveVersion(ctx EarlyModuleContext) (SdkVersion, error) {
// EffectiveVersion converts an SdkSpec into the concrete ApiLevel that the module should use. For
// modules targeting an unreleased SDK (meaning it does not yet have a number) it returns
// FutureApiLevel(10000).
func (s SdkSpec) EffectiveVersion(ctx EarlyModuleContext) (ApiLevel, error) {
	if !s.Valid() {
		return s.Version, fmt.Errorf("invalid sdk version %q", s.Raw)
		return s.ApiLevel, fmt.Errorf("invalid sdk version %q", s.Raw)
	}

	if ctx.DeviceSpecific() || ctx.SocSpecific() {
		s = s.ForVendorPartition(ctx)
	}
	if s.Version.IsNumbered() {
		return s.Version, nil
	if !s.ApiLevel.IsPreview() {
		return s.ApiLevel, nil
	}
	return SdkVersion(ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt()), nil
	ret := ctx.Config().DefaultAppTargetSdk(ctx)
	if ret.IsPreview() {
		return FutureApiLevel, nil
	}
	return ret, nil
}

// EffectiveVersionString converts an SdkSpec into the concrete version string that the module
// should use. For modules targeting an unreleased SDK (meaning it does not yet have a number)
// it returns the codename (P, Q, R, etc.)
func (s SdkSpec) EffectiveVersionString(ctx EarlyModuleContext) (string, error) {
	ver, err := s.EffectiveVersion(ctx)
	if err == nil && int(ver) == ctx.Config().DefaultAppTargetSdk(ctx).FinalOrFutureInt() {
		return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil
	if !s.Valid() {
		return s.ApiLevel.String(), fmt.Errorf("invalid sdk version %q", s.Raw)
	}
	return ver.String(), err

	if ctx.DeviceSpecific() || ctx.SocSpecific() {
		s = s.ForVendorPartition(ctx)
	}
	if !s.ApiLevel.IsPreview() {
		return s.ApiLevel.String(), nil
	}
	return ctx.Config().DefaultAppTargetSdk(ctx).String(), nil
}

func SdkSpecFrom(str string) SdkSpec {
	switch str {
	// special cases first
	case "":
		return SdkSpec{SdkPrivate, SdkVersionNone, str}
		return SdkSpec{SdkPrivate, NoneApiLevel, str}
	case "none":
		return SdkSpec{SdkNone, SdkVersionNone, str}
		return SdkSpec{SdkNone, NoneApiLevel, str}
	case "core_platform":
		return SdkSpec{SdkCorePlatform, SdkVersionNone, str}
		return SdkSpec{SdkCorePlatform, NoneApiLevel, str}
	default:
		// the syntax is [kind_]version
		sep := strings.LastIndex(str, "_")

		var kindString string
		if sep == 0 {
			return SdkSpec{SdkInvalid, SdkVersionNone, str}
			return SdkSpec{SdkInvalid, NoneApiLevel, str}
		} else if sep == -1 {
			kindString = ""
		} else {
@@ -272,19 +239,19 @@ func SdkSpecFrom(str string) SdkSpec {
		case "system_server":
			kind = SdkSystemServer
		default:
			return SdkSpec{SdkInvalid, SdkVersionNone, str}
			return SdkSpec{SdkInvalid, NoneApiLevel, str}
		}

		var version SdkVersion
		var apiLevel ApiLevel
		if versionString == "current" {
			version = SdkVersionCurrent
			apiLevel = FutureApiLevel
		} else if i, err := strconv.Atoi(versionString); err == nil {
			version = SdkVersion(i)
			apiLevel = uncheckedFinalApiLevel(i)
		} else {
			return SdkSpec{SdkInvalid, SdkVersionNone, str}
			return SdkSpec{SdkInvalid, apiLevel, str}
		}

		return SdkSpec{kind, version, str}
		return SdkSpec{kind, apiLevel, str}
	}
}

@@ -292,7 +259,7 @@ func (s SdkSpec) ValidateSystemSdk(ctx EarlyModuleContext) bool {
	// Ensures that the specified system SDK version is one of BOARD_SYSTEMSDK_VERSIONS (for vendor/product Java module)
	// Assuming that BOARD_SYSTEMSDK_VERSIONS := 28 29,
	// sdk_version of the modules in vendor/product that use system sdk must be either system_28, system_29 or system_current
	if s.Kind != SdkSystem || !s.Version.IsNumbered() {
	if s.Kind != SdkSystem || s.ApiLevel.IsPreview() {
		return true
	}
	allowedVersions := ctx.DeviceConfig().PlatformSystemSdkVersions()
@@ -302,7 +269,7 @@ func (s SdkSpec) ValidateSystemSdk(ctx EarlyModuleContext) bool {
			allowedVersions = systemSdkVersions
		}
	}
	if len(allowedVersions) > 0 && !InList(s.Version.String(), allowedVersions) {
	if len(allowedVersions) > 0 && !InList(s.ApiLevel.String(), allowedVersions) {
		ctx.PropertyErrorf("sdk_version", "incompatible sdk version %q. System SDK version should be one of %q",
			s.Raw, allowedVersions)
		return false
+15 −15
Original line number Diff line number Diff line
@@ -216,7 +216,7 @@ var prepareForApexTest = android.GroupFixturePreparers(
		variables.Platform_sdk_codename = proptools.StringPtr("Q")
		variables.Platform_sdk_final = proptools.BoolPtr(false)
		variables.Platform_version_active_codenames = []string{"Q"}
		variables.Platform_vndk_version = proptools.StringPtr("VER")
		variables.Platform_vndk_version = proptools.StringPtr("29")
	}),
)

@@ -1366,13 +1366,13 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
			ensureListEmpty(t, names(apexManifestRule.Args["provideNativeLibs"]))
			ensureListContains(t, names(apexManifestRule.Args["requireNativeLibs"]), "libbar.so")

			mylibLdFlags := ctx.ModuleForTests("mylib", "android_vendor.VER_arm64_armv8-a_shared_"+tc.apexVariant).Rule("ld").Args["libFlags"]
			ensureContains(t, mylibLdFlags, "libbar/android_vendor.VER_arm64_armv8-a_shared_"+tc.shouldLink+"/libbar.so")
			mylibLdFlags := ctx.ModuleForTests("mylib", "android_vendor.29_arm64_armv8-a_shared_"+tc.apexVariant).Rule("ld").Args["libFlags"]
			ensureContains(t, mylibLdFlags, "libbar/android_vendor.29_arm64_armv8-a_shared_"+tc.shouldLink+"/libbar.so")
			for _, ver := range tc.shouldNotLink {
				ensureNotContains(t, mylibLdFlags, "libbar/android_vendor.VER_arm64_armv8-a_shared_"+ver+"/libbar.so")
				ensureNotContains(t, mylibLdFlags, "libbar/android_vendor.29_arm64_armv8-a_shared_"+ver+"/libbar.so")
			}

			mylibCFlags := ctx.ModuleForTests("mylib", "android_vendor.VER_arm64_armv8-a_static_"+tc.apexVariant).Rule("cc").Args["cFlags"]
			mylibCFlags := ctx.ModuleForTests("mylib", "android_vendor.29_arm64_armv8-a_static_"+tc.apexVariant).Rule("cc").Args["cFlags"]
			ver := tc.shouldLink
			if tc.shouldLink == "current" {
				ver = strconv.Itoa(android.FutureApiLevelInt)
@@ -2411,8 +2411,8 @@ func TestUseVendor(t *testing.T) {
	inputsString := strings.Join(inputsList, " ")

	// ensure that the apex includes vendor variants of the direct and indirect deps
	ensureContains(t, inputsString, "android_vendor.VER_arm64_armv8-a_shared_apex10000/mylib.so")
	ensureContains(t, inputsString, "android_vendor.VER_arm64_armv8-a_shared_apex10000/mylib2.so")
	ensureContains(t, inputsString, "android_vendor.29_arm64_armv8-a_shared_apex10000/mylib.so")
	ensureContains(t, inputsString, "android_vendor.29_arm64_armv8-a_shared_apex10000/mylib2.so")

	// ensure that the apex does not include core variants
	ensureNotContains(t, inputsString, "android_arm64_armv8-a_shared_apex10000/mylib.so")
@@ -2558,7 +2558,7 @@ func TestVendorApex_use_vndk_as_stable(t *testing.T) {
		}
	`)

	vendorVariant := "android_vendor.VER_arm64_armv8-a"
	vendorVariant := "android_vendor.29_arm64_armv8-a"

	ldRule := ctx.ModuleForTests("mybin", vendorVariant+"_apex10000").Rule("ld")
	libs := names(ldRule.Args["libFlags"])
@@ -2607,7 +2607,7 @@ func TestProductVariant(t *testing.T) {
	)

	cflags := strings.Fields(
		ctx.ModuleForTests("foo", "android_product.VER_arm64_armv8-a_apex10000").Rule("cc").Args["cFlags"])
		ctx.ModuleForTests("foo", "android_product.29_arm64_armv8-a_apex10000").Rule("cc").Args["cFlags"])
	ensureListContains(t, cflags, "-D__ANDROID_VNDK__")
	ensureListContains(t, cflags, "-D__ANDROID_APEX__")
	ensureListContains(t, cflags, "-D__ANDROID_PRODUCT__")
@@ -3305,11 +3305,11 @@ func TestVndkApexCurrent(t *testing.T) {
		"lib64/libvndk.so",
		"lib64/libvndksp.so",
		"lib64/libc++.so",
		"etc/llndk.libraries.VER.txt",
		"etc/vndkcore.libraries.VER.txt",
		"etc/vndksp.libraries.VER.txt",
		"etc/vndkprivate.libraries.VER.txt",
		"etc/vndkproduct.libraries.VER.txt",
		"etc/llndk.libraries.29.txt",
		"etc/vndkcore.libraries.29.txt",
		"etc/vndksp.libraries.29.txt",
		"etc/vndkprivate.libraries.29.txt",
		"etc/vndkproduct.libraries.29.txt",
	})
}

@@ -3495,7 +3495,7 @@ func TestVndkApexNameRule(t *testing.T) {
		}
	}

	assertApexName("com.android.vndk.vVER", "com.android.vndk.current")
	assertApexName("com.android.vndk.v29", "com.android.vndk.current")
	assertApexName("com.android.vndk.v28", "com.android.vndk.v28")
}

+9 −9
Original line number Diff line number Diff line
@@ -59,11 +59,11 @@ func TestVndkApexForVndkLite(t *testing.T) {
		"lib/libc++.so",
		"lib64/libvndksp.so",
		"lib64/libc++.so",
		"etc/llndk.libraries.VER.txt",
		"etc/vndkcore.libraries.VER.txt",
		"etc/vndksp.libraries.VER.txt",
		"etc/vndkprivate.libraries.VER.txt",
		"etc/vndkproduct.libraries.VER.txt",
		"etc/llndk.libraries.29.txt",
		"etc/vndkcore.libraries.29.txt",
		"etc/vndksp.libraries.29.txt",
		"etc/vndkprivate.libraries.29.txt",
		"etc/vndkproduct.libraries.29.txt",
	})
}

@@ -111,7 +111,7 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {

		// VNDK APEX doesn't create apex variant
		files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
	})

	t.Run("VNDK APEX gathers only vendor variants even if product variants are available", func(t *testing.T) {
@@ -123,7 +123,7 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {
		)

		files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")
	})

	t.Run("VNDK APEX supports coverage variants", func(t *testing.T) {
@@ -135,9 +135,9 @@ func TestVndkApexUsesVendorVariant(t *testing.T) {
		)

		files := getFiles(t, ctx, "com.android.vndk.current", "android_common_image")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared/libfoo.so")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared/libfoo.so")

		files = getFiles(t, ctx, "com.android.vndk.current", "android_common_cov_image")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.VER_arm_armv7-a-neon_shared_cov/libfoo.so")
		ensureFileSrc(t, files, "lib/libfoo.so", "libfoo/android_vendor.29_arm_armv7-a-neon_shared_cov/libfoo.so")
	})
}
+39 −39
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@ var prepareForCcTest = android.GroupFixturePreparers(
	android.FixtureModifyProductVariables(func(variables android.FixtureProductVariables) {
		variables.DeviceVndkVersion = StringPtr("current")
		variables.ProductVndkVersion = StringPtr("current")
		variables.Platform_vndk_version = StringPtr("VER")
		variables.Platform_vndk_version = StringPtr("29")
	}),
)

@@ -75,7 +75,7 @@ func testCc(t *testing.T, bp string) *android.TestContext {
func testCcNoVndk(t *testing.T, bp string) *android.TestContext {
	t.Helper()
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")

	return testCcWithConfig(t, config)
}
@@ -89,7 +89,7 @@ func testCcNoProductVndk(t *testing.T, bp string) *android.TestContext {
	t.Helper()
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")

	return testCcWithConfig(t, config)
}
@@ -116,7 +116,7 @@ func testCcError(t *testing.T, pattern string, bp string) {
	t.Helper()
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	testCcErrorWithConfig(t, pattern, config)
	return
}
@@ -131,15 +131,15 @@ func testCcErrorProductVndk(t *testing.T, pattern string, bp string) {
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.ProductVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	testCcErrorWithConfig(t, pattern, config)
	return
}

const (
	coreVariant     = "android_arm64_armv8-a_shared"
	vendorVariant   = "android_vendor.VER_arm64_armv8-a_shared"
	productVariant  = "android_product.VER_arm64_armv8-a_shared"
	vendorVariant   = "android_vendor.29_arm64_armv8-a_shared"
	productVariant  = "android_product.29_arm64_armv8-a_shared"
	recoveryVariant = "android_recovery_arm64_armv8-a_shared"
)

@@ -456,7 +456,7 @@ func TestVndk(t *testing.T) {
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.ProductVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")

	ctx := testCcWithConfig(t, config)

@@ -486,8 +486,8 @@ func TestVndk(t *testing.T) {
	vndkCoreLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-core")
	vndkSpLib2ndPath := filepath.Join(vndkLib2ndPath, "shared", "vndk-sp")

	variant := "android_vendor.VER_arm64_armv8-a_shared"
	variant2nd := "android_vendor.VER_arm_armv7-a-neon_shared"
	variant := "android_vendor.29_arm64_armv8-a_shared"
	variant2nd := "android_vendor.29_arm_armv7-a-neon_shared"

	snapshotSingleton := ctx.SingletonForTests("vndk-snapshot")

@@ -577,12 +577,12 @@ func TestVndkLibrariesTxtAndroidMk(t *testing.T) {
		}`
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	ctx := testCcWithConfig(t, config)

	module := ctx.ModuleForTests("llndk.libraries.txt", "")
	entries := android.AndroidMkEntriesForTest(t, ctx, module.Module())[0]
	assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.VER.txt"})
	assertArrayString(t, entries.EntryMap["LOCAL_MODULE_STEM"], []string{"llndk.libraries.29.txt"})
}

func TestVndkUsingCoreVariant(t *testing.T) {
@@ -627,7 +627,7 @@ func TestVndkUsingCoreVariant(t *testing.T) {

	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)

	setVndkMustUseVendorVariantListForTest(config, []string{"libvndk"})
@@ -654,7 +654,7 @@ func TestDataLibs(t *testing.T) {

	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)

	ctx := testCcWithConfig(t, config)
@@ -705,7 +705,7 @@ func TestDataLibsRelativeInstallPath(t *testing.T) {

	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)

	ctx := testCcWithConfig(t, config)
@@ -1331,7 +1331,7 @@ func TestVndkExt(t *testing.T) {
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.ProductVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")

	ctx := testCcWithConfig(t, config)

@@ -1776,7 +1776,7 @@ func TestProductVndkExtDependency(t *testing.T) {
	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.ProductVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")

	testCcWithConfig(t, config)
}
@@ -2140,7 +2140,7 @@ func TestEnforceProductVndkVersion(t *testing.T) {
}

func TestEnforceProductVndkVersionErrors(t *testing.T) {
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
		cc_library {
			name: "libprod",
			product_specific: true,
@@ -2155,7 +2155,7 @@ func TestEnforceProductVndkVersionErrors(t *testing.T) {
			nocrt: true,
		}
	`)
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
		cc_library {
			name: "libprod",
			product_specific: true,
@@ -2169,7 +2169,7 @@ func TestEnforceProductVndkVersionErrors(t *testing.T) {
			nocrt: true,
		}
	`)
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
		cc_library {
			name: "libprod",
			product_specific: true,
@@ -2204,7 +2204,7 @@ func TestEnforceProductVndkVersionErrors(t *testing.T) {
			nocrt: true,
		}
	`)
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.VER", `
	testCcErrorProductVndk(t, "dependency \".*\" of \".*\" missing variant:\n.*image:product.29", `
		cc_library {
			name: "libprod",
			product_specific: true,
@@ -2330,7 +2330,7 @@ func TestMakeLinkType(t *testing.T) {

	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	// native:vndk
	ctx := testCcWithConfig(t, config)

@@ -2664,27 +2664,27 @@ func TestLlndkLibrary(t *testing.T) {
	`)
	actual := ctx.ModuleVariantsForTests("libllndk")
	for i := 0; i < len(actual); i++ {
		if !strings.HasPrefix(actual[i], "android_vendor.VER_") {
		if !strings.HasPrefix(actual[i], "android_vendor.29_") {
			actual = append(actual[:i], actual[i+1:]...)
			i--
		}
	}
	expected := []string{
		"android_vendor.VER_arm64_armv8-a_shared_1",
		"android_vendor.VER_arm64_armv8-a_shared_2",
		"android_vendor.VER_arm64_armv8-a_shared_current",
		"android_vendor.VER_arm64_armv8-a_shared",
		"android_vendor.VER_arm_armv7-a-neon_shared_1",
		"android_vendor.VER_arm_armv7-a-neon_shared_2",
		"android_vendor.VER_arm_armv7-a-neon_shared_current",
		"android_vendor.VER_arm_armv7-a-neon_shared",
		"android_vendor.29_arm64_armv8-a_shared_1",
		"android_vendor.29_arm64_armv8-a_shared_2",
		"android_vendor.29_arm64_armv8-a_shared_current",
		"android_vendor.29_arm64_armv8-a_shared",
		"android_vendor.29_arm_armv7-a-neon_shared_1",
		"android_vendor.29_arm_armv7-a-neon_shared_2",
		"android_vendor.29_arm_armv7-a-neon_shared_current",
		"android_vendor.29_arm_armv7-a-neon_shared",
	}
	checkEquals(t, "variants for llndk stubs", expected, actual)

	params := ctx.ModuleForTests("libllndk", "android_vendor.VER_arm_armv7-a-neon_shared").Description("generate stub")
	params := ctx.ModuleForTests("libllndk", "android_vendor.29_arm_armv7-a-neon_shared").Description("generate stub")
	checkEquals(t, "use VNDK version for default stubs", "current", params.Args["apiLevel"])

	params = ctx.ModuleForTests("libllndk", "android_vendor.VER_arm_armv7-a-neon_shared_1").Description("generate stub")
	params = ctx.ModuleForTests("libllndk", "android_vendor.29_arm_armv7-a-neon_shared_1").Description("generate stub")
	checkEquals(t, "override apiLevel for versioned stubs", "1", params.Args["apiLevel"])
}

@@ -2714,7 +2714,7 @@ func TestLlndkHeaders(t *testing.T) {
	`)

	// _static variant is used since _shared reuses *.o from the static variant
	cc := ctx.ModuleForTests("libvendor", "android_vendor.VER_arm_armv7-a-neon_static").Rule("cc")
	cc := ctx.ModuleForTests("libvendor", "android_vendor.29_arm_armv7-a-neon_static").Rule("cc")
	cflags := cc.Args["cFlags"]
	if !strings.Contains(cflags, "-Imy_include") {
		t.Errorf("cflags for libvendor must contain -Imy_include, but was %#v.", cflags)
@@ -2835,7 +2835,7 @@ func TestRuntimeLibs(t *testing.T) {

	// 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"
	variant = "android_vendor.29_arm64_armv8-a_shared"

	module = ctx.ModuleForTests("libvendor_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available.vendor"}, module)
@@ -2845,7 +2845,7 @@ func TestRuntimeLibs(t *testing.T) {

	// 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"
	variant = "android_product.29_arm64_armv8-a_shared"

	module = ctx.ModuleForTests("libproduct_available1", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available.product"}, module)
@@ -2861,7 +2861,7 @@ func TestExcludeRuntimeLibs(t *testing.T) {
	module := ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, []string{"liball_available"}, module)

	variant = "android_vendor.VER_arm64_armv8-a_shared"
	variant = "android_vendor.29_arm64_armv8-a_shared"
	module = ctx.ModuleForTests("libvendor_available2", variant).Module().(*Module)
	checkRuntimeLibs(t, nil, module)
}
@@ -3044,7 +3044,7 @@ func TestVendorPublicLibraries(t *testing.T) {
	`)

	coreVariant := "android_arm64_armv8-a_shared"
	vendorVariant := "android_vendor.VER_arm64_armv8-a_shared"
	vendorVariant := "android_vendor.29_arm64_armv8-a_shared"

	// test if header search paths are correctly added
	// _static variant is used since _shared reuses *.o from the static variant
@@ -3124,7 +3124,7 @@ func TestDataLibsPrebuiltSharedTestLibrary(t *testing.T) {

	config := TestConfig(t.TempDir(), android.Android, nil, bp, nil)
	config.TestProductVariables.DeviceVndkVersion = StringPtr("current")
	config.TestProductVariables.Platform_vndk_version = StringPtr("VER")
	config.TestProductVariables.Platform_vndk_version = StringPtr("29")
	config.TestProductVariables.VndkUseCoreVariant = BoolPtr(true)

	ctx := testCcWithConfig(t, config)
+48 −48

File changed.

Preview size limit exceeded, changes collapsed.

Loading