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

Commit f4a5492e authored by Colin Cross's avatar Colin Cross Committed by Android (Google) Code Review
Browse files

Merge changes from topics "soong-inclusive-language", "soong_inclusive_language2" into rvc-dev

* changes:
  Use inclusive language in Android.bp files
  Use inclusive language in build/soong
parents c8697f6a a44a6b27
Loading
Loading
Loading
Loading
+2 −2
Original line number Diff line number Diff line
@@ -1171,8 +1171,8 @@ func (c *config) EnforceSystemCertificate() bool {
	return Bool(c.productVariables.EnforceSystemCertificate)
}

func (c *config) EnforceSystemCertificateWhitelist() []string {
	return c.productVariables.EnforceSystemCertificateWhitelist
func (c *config) EnforceSystemCertificateAllowList() []string {
	return c.productVariables.EnforceSystemCertificateAllowList
}

func (c *config) EnforceProductPartitionInterface() bool {
+9 −9
Original line number Diff line number Diff line
@@ -166,7 +166,7 @@ func createMediaRules() []Rule {
}

func createJavaDeviceForHostRules() []Rule {
	javaDeviceForHostProjectsWhitelist := []string{
	javaDeviceForHostProjectsAllowedList := []string{
		"external/guava",
		"external/robolectric-shadows",
		"framework/layoutlib",
@@ -174,14 +174,14 @@ func createJavaDeviceForHostRules() []Rule {

	return []Rule{
		NeverAllow().
			NotIn(javaDeviceForHostProjectsWhitelist...).
			NotIn(javaDeviceForHostProjectsAllowedList...).
			ModuleType("java_device_for_host", "java_host_for_device").
			Because("java_device_for_host can only be used in whitelisted projects"),
			Because("java_device_for_host can only be used in allowed projects"),
	}
}

func createCcSdkVariantRules() []Rule {
	sdkVersionOnlyWhitelist := []string{
	sdkVersionOnlyAllowedList := []string{
		// derive_sdk_prefer32 has stem: "derive_sdk" which conflicts with the derive_sdk.
		// This sometimes works because the APEX modules that contain derive_sdk and
		// derive_sdk_prefer32 suppress the platform installation rules, but fails when
@@ -189,7 +189,7 @@ func createCcSdkVariantRules() []Rule {
		"frameworks/base/apex/sdkextensions/derive_sdk",
	}

	platformVariantPropertiesWhitelist := []string{
	platformVariantPropertiesAllowedList := []string{
		// android_native_app_glue and libRSSupport use native_window.h but target old
		// sdk versions (minimum and 9 respectively) where libnativewindow didn't exist,
		// so they can't add libnativewindow to shared_libs to get the header directory
@@ -201,13 +201,13 @@ func createCcSdkVariantRules() []Rule {

	return []Rule{
		NeverAllow().
			NotIn(sdkVersionOnlyWhitelist...).
			NotIn(sdkVersionOnlyAllowedList...).
			WithMatcher("sdk_variant_only", isSetMatcherInstance).
			Because("sdk_variant_only can only be used in whitelisted projects"),
			Because("sdk_variant_only can only be used in allowed projects"),
		NeverAllow().
			NotIn(platformVariantPropertiesWhitelist...).
			NotIn(platformVariantPropertiesAllowedList...).
			WithMatcher("platform.shared_libs", isSetMatcherInstance).
			Because("platform variant properties can only be used in whitelisted projects"),
			Because("platform variant properties can only be used in allowed projects"),
	}
}

+10 −10
Original line number Diff line number Diff line
@@ -212,7 +212,7 @@ var neverallowTests = []struct {
				}`),
		},
		expectedErrors: []string{
			"java_device_for_host can only be used in whitelisted projects",
			"java_device_for_host can only be used in allowed projects",
		},
	},
	// Libcore rule tests
@@ -261,46 +261,46 @@ var neverallowTests = []struct {
	},
	// CC sdk rule tests
	{
		name: `"sdk_variant_only" outside whitelist`,
		name: `"sdk_variant_only" outside allowed list`,
		fs: map[string][]byte{
			"Android.bp": []byte(`
				cc_library {
					name: "outside_whitelist",
					name: "outside_allowed_list",
					sdk_version: "current",
					sdk_variant_only: true,
				}`),
		},
		expectedErrors: []string{
			`module "outside_whitelist": violates neverallow`,
			`module "outside_allowed_list": violates neverallow`,
		},
	},
	{
		name: `"sdk_variant_only: false" outside whitelist`,
		name: `"sdk_variant_only: false" outside allowed list`,
		fs: map[string][]byte{
			"Android.bp": []byte(`
				cc_library {
					name: "outside_whitelist",
					name: "outside_allowed_list",
					sdk_version: "current",
					sdk_variant_only: false,
				}`),
		},
		expectedErrors: []string{
			`module "outside_whitelist": violates neverallow`,
			`module "outside_allowed_list": violates neverallow`,
		},
	},
	{
		name: `"platform" outside whitelist`,
		name: `"platform" outside allowed list`,
		fs: map[string][]byte{
			"Android.bp": []byte(`
				cc_library {
					name: "outside_whitelist",
					name: "outside_allowed_list",
					platform: {
						shared_libs: ["libfoo"],
					},
				}`),
		},
		expectedErrors: []string{
			`module "outside_whitelist": violates neverallow`,
			`module "outside_allowed_list": violates neverallow`,
		},
	},
	{
+1 −1
Original line number Diff line number Diff line
@@ -310,7 +310,7 @@ type productVariables struct {
	PackageNameOverrides         []string `json:",omitempty"`

	EnforceSystemCertificate          *bool    `json:",omitempty"`
	EnforceSystemCertificateWhitelist []string `json:",omitempty"`
	EnforceSystemCertificateAllowList []string `json:",omitempty"`

	ProductHiddenAPIStubs       []string `json:",omitempty"`
	ProductHiddenAPIStubsSystem []string `json:",omitempty"`
+24 −23
Original line number Diff line number Diff line
@@ -63,13 +63,14 @@ var (
	certificateTag = dependencyTag{name: "certificate"}
	usesTag        = dependencyTag{name: "uses"}
	androidAppTag  = dependencyTag{name: "androidApp", payload: true}
	apexAvailWl    = makeApexAvailableWhitelist()

	inverseApexAvailWl = invertApexWhiteList(apexAvailWl)
	apexAvailBaseline = makeApexAvailableBaseline()

	inverseApexAvailBaseline = invertApexBaseline(apexAvailBaseline)
)

// Transform the map of apex -> modules to module -> apexes.
func invertApexWhiteList(m map[string][]string) map[string][]string {
func invertApexBaseline(m map[string][]string) map[string][]string {
	r := make(map[string][]string)
	for apex, modules := range m {
		for _, module := range modules {
@@ -79,16 +80,16 @@ func invertApexWhiteList(m map[string][]string) map[string][]string {
	return r
}

// Retrieve the while list of apexes to which the supplied module belongs.
func WhitelistedApexAvailable(moduleName string) []string {
	return inverseApexAvailWl[normalizeModuleName(moduleName)]
// Retrieve the baseline of apexes to which the supplied module belongs.
func BaselineApexAvailable(moduleName string) []string {
	return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
}

// This is a map from apex to modules, which overrides the
// apex_available setting for that particular module to make
// it available for the apex regardless of its setting.
// TODO(b/147364041): remove this
func makeApexAvailableWhitelist() map[string][]string {
func makeApexAvailableBaseline() map[string][]string {
	// The "Module separator"s below are employed to minimize merge conflicts.
	m := make(map[string][]string)
	//
@@ -905,17 +906,17 @@ func apexUsesMutator(mctx android.BottomUpMutatorContext) {
}

var (
	useVendorWhitelistKey = android.NewOnceKey("useVendorWhitelist")
	useVendorAllowListKey = android.NewOnceKey("useVendorAllowList")
)

// useVendorWhitelist returns the list of APEXes which are allowed to use_vendor.
// useVendorAllowList returns the list of APEXes which are allowed to use_vendor.
// When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
// which may cause compatibility issues. (e.g. libbinder)
// Even though libbinder restricts its availability via 'apex_available' property and relies on
// yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
// to avoid similar problems.
func useVendorWhitelist(config android.Config) []string {
	return config.Once(useVendorWhitelistKey, func() interface{} {
func useVendorAllowList(config android.Config) []string {
	return config.Once(useVendorAllowListKey, func() interface{} {
		return []string{
			// swcodec uses "vendor" variants for smaller size
			"com.android.media.swcodec",
@@ -924,11 +925,11 @@ func useVendorWhitelist(config android.Config) []string {
	}).([]string)
}

// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be
// called before the first call to useVendorWhitelist()
func setUseVendorWhitelistForTest(config android.Config, whitelist []string) {
	config.Once(useVendorWhitelistKey, func() interface{} {
		return whitelist
// setUseVendorAllowListForTest overrides useVendorAllowList and must be
// called before the first call to useVendorAllowList()
func setUseVendorAllowListForTest(config android.Config, allowList []string) {
	config.Once(useVendorAllowListKey, func() interface{} {
		return allowList
	})
}

@@ -1030,8 +1031,8 @@ type apexBundleProperties struct {
	// List of providing APEXes' names so that this APEX can depend on provided shared libraries.
	Uses []string

	// A txt file containing list of files that are whitelisted to be included in this APEX.
	Whitelisted_files *string
	// A txt file containing list of files that are allowed to be included in this APEX.
	Allowed_files *string

	// package format of this apex variant; could be non-flattened, flattened, or zip.
	// imageApex, zipApex or flattened
@@ -1358,7 +1359,7 @@ func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
}

func (a *apexBundle) DepsMutator(ctx android.BottomUpMutatorContext) {
	if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorWhitelist(ctx.Config())) {
	if proptools.Bool(a.properties.Use_vendor) && !android.InList(a.Name(), useVendorAllowList(ctx.Config())) {
		ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
	}

@@ -1832,7 +1833,7 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
			return false
		}

		if to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) {
		if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
			return true
		}
		message := ""
@@ -2220,16 +2221,16 @@ func (a *apexBundle) checkJavaStableSdkVersion(ctx android.ModuleContext) {
	})
}

func whitelistedApexAvailable(apex, moduleName string) bool {
func baselineApexAvailable(apex, moduleName string) bool {
	key := apex
	moduleName = normalizeModuleName(moduleName)

	if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
	if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
		return true
	}

	key = android.AvailableToAnyApex
	if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
	if val, ok := apexAvailBaseline[key]; ok && android.InList(moduleName, val) {
		return true
	}

Loading