Use inclusive language in build/soong

Bug: 158889297
Test: m checkbuild
Change-Id: Id07890b7cbc2397291a658ca00e86b43c743aafc
Merged-In: Id07890b7cbc2397291a658ca00e86b43c743aafc
(cherry picked from commit 440e0d0542)
This commit is contained in:
Colin Cross 2020-06-11 11:32:11 -07:00
parent 871b80fb77
commit 95f7b34e8e
14 changed files with 70 additions and 68 deletions

View File

@ -1171,8 +1171,8 @@ func (c *config) EnforceSystemCertificate() bool {
return Bool(c.productVariables.EnforceSystemCertificate) return Bool(c.productVariables.EnforceSystemCertificate)
} }
func (c *config) EnforceSystemCertificateWhitelist() []string { func (c *config) EnforceSystemCertificateAllowList() []string {
return c.productVariables.EnforceSystemCertificateWhitelist return c.productVariables.EnforceSystemCertificateAllowList
} }
func (c *config) EnforceProductPartitionInterface() bool { func (c *config) EnforceProductPartitionInterface() bool {

View File

@ -166,7 +166,7 @@ func createMediaRules() []Rule {
} }
func createJavaDeviceForHostRules() []Rule { func createJavaDeviceForHostRules() []Rule {
javaDeviceForHostProjectsWhitelist := []string{ javaDeviceForHostProjectsAllowedList := []string{
"external/guava", "external/guava",
"external/robolectric-shadows", "external/robolectric-shadows",
"framework/layoutlib", "framework/layoutlib",
@ -174,14 +174,14 @@ func createJavaDeviceForHostRules() []Rule {
return []Rule{ return []Rule{
NeverAllow(). NeverAllow().
NotIn(javaDeviceForHostProjectsWhitelist...). NotIn(javaDeviceForHostProjectsAllowedList...).
ModuleType("java_device_for_host", "java_host_for_device"). 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 { func createCcSdkVariantRules() []Rule {
sdkVersionOnlyWhitelist := []string{ sdkVersionOnlyAllowedList := []string{
// derive_sdk_prefer32 has stem: "derive_sdk" which conflicts with the derive_sdk. // 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 // This sometimes works because the APEX modules that contain derive_sdk and
// derive_sdk_prefer32 suppress the platform installation rules, but fails when // derive_sdk_prefer32 suppress the platform installation rules, but fails when
@ -189,7 +189,7 @@ func createCcSdkVariantRules() []Rule {
"frameworks/base/apex/sdkextensions/derive_sdk", "frameworks/base/apex/sdkextensions/derive_sdk",
} }
platformVariantPropertiesWhitelist := []string{ platformVariantPropertiesAllowedList := []string{
// android_native_app_glue and libRSSupport use native_window.h but target old // android_native_app_glue and libRSSupport use native_window.h but target old
// sdk versions (minimum and 9 respectively) where libnativewindow didn't exist, // 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 // so they can't add libnativewindow to shared_libs to get the header directory
@ -201,13 +201,13 @@ func createCcSdkVariantRules() []Rule {
return []Rule{ return []Rule{
NeverAllow(). NeverAllow().
NotIn(sdkVersionOnlyWhitelist...). NotIn(sdkVersionOnlyAllowedList...).
WithMatcher("sdk_variant_only", isSetMatcherInstance). 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(). NeverAllow().
NotIn(platformVariantPropertiesWhitelist...). NotIn(platformVariantPropertiesAllowedList...).
WithMatcher("platform.shared_libs", isSetMatcherInstance). 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"),
} }
} }

View File

@ -212,7 +212,7 @@ var neverallowTests = []struct {
}`), }`),
}, },
expectedErrors: []string{ 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 // Libcore rule tests
@ -261,46 +261,46 @@ var neverallowTests = []struct {
}, },
// CC sdk rule tests // CC sdk rule tests
{ {
name: `"sdk_variant_only" outside whitelist`, name: `"sdk_variant_only" outside allowed list`,
fs: map[string][]byte{ fs: map[string][]byte{
"Android.bp": []byte(` "Android.bp": []byte(`
cc_library { cc_library {
name: "outside_whitelist", name: "outside_allowed_list",
sdk_version: "current", sdk_version: "current",
sdk_variant_only: true, sdk_variant_only: true,
}`), }`),
}, },
expectedErrors: []string{ 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{ fs: map[string][]byte{
"Android.bp": []byte(` "Android.bp": []byte(`
cc_library { cc_library {
name: "outside_whitelist", name: "outside_allowed_list",
sdk_version: "current", sdk_version: "current",
sdk_variant_only: false, sdk_variant_only: false,
}`), }`),
}, },
expectedErrors: []string{ 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{ fs: map[string][]byte{
"Android.bp": []byte(` "Android.bp": []byte(`
cc_library { cc_library {
name: "outside_whitelist", name: "outside_allowed_list",
platform: { platform: {
shared_libs: ["libfoo"], shared_libs: ["libfoo"],
}, },
}`), }`),
}, },
expectedErrors: []string{ expectedErrors: []string{
`module "outside_whitelist": violates neverallow`, `module "outside_allowed_list": violates neverallow`,
}, },
}, },
{ {

View File

@ -310,7 +310,7 @@ type productVariables struct {
PackageNameOverrides []string `json:",omitempty"` PackageNameOverrides []string `json:",omitempty"`
EnforceSystemCertificate *bool `json:",omitempty"` EnforceSystemCertificate *bool `json:",omitempty"`
EnforceSystemCertificateWhitelist []string `json:",omitempty"` EnforceSystemCertificateAllowList []string `json:",omitempty"`
ProductHiddenAPIStubs []string `json:",omitempty"` ProductHiddenAPIStubs []string `json:",omitempty"`
ProductHiddenAPIStubsSystem []string `json:",omitempty"` ProductHiddenAPIStubsSystem []string `json:",omitempty"`

View File

@ -63,13 +63,14 @@ var (
certificateTag = dependencyTag{name: "certificate"} certificateTag = dependencyTag{name: "certificate"}
usesTag = dependencyTag{name: "uses"} usesTag = dependencyTag{name: "uses"}
androidAppTag = dependencyTag{name: "androidApp", payload: true} 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. // 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) r := make(map[string][]string)
for apex, modules := range m { for apex, modules := range m {
for _, module := range modules { for _, module := range modules {
@ -79,16 +80,16 @@ func invertApexWhiteList(m map[string][]string) map[string][]string {
return r return r
} }
// Retrieve the while list of apexes to which the supplied module belongs. // Retrieve the baseline of apexes to which the supplied module belongs.
func WhitelistedApexAvailable(moduleName string) []string { func BaselineApexAvailable(moduleName string) []string {
return inverseApexAvailWl[normalizeModuleName(moduleName)] return inverseApexAvailBaseline[normalizeModuleName(moduleName)]
} }
// This is a map from apex to modules, which overrides the // This is a map from apex to modules, which overrides the
// apex_available setting for that particular module to make // apex_available setting for that particular module to make
// it available for the apex regardless of its setting. // it available for the apex regardless of its setting.
// TODO(b/147364041): remove this // 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. // The "Module separator"s below are employed to minimize merge conflicts.
m := make(map[string][]string) m := make(map[string][]string)
// //
@ -905,17 +906,17 @@ func apexUsesMutator(mctx android.BottomUpMutatorContext) {
} }
var ( 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__, // When use_vendor is used, native modules are built with __ANDROID_VNDK__ and __ANDROID_APEX__,
// which may cause compatibility issues. (e.g. libbinder) // which may cause compatibility issues. (e.g. libbinder)
// Even though libbinder restricts its availability via 'apex_available' property and relies on // 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 // yet another macro __ANDROID_APEX_<NAME>__, we restrict usage of "use_vendor:" from other APEX modules
// to avoid similar problems. // to avoid similar problems.
func useVendorWhitelist(config android.Config) []string { func useVendorAllowList(config android.Config) []string {
return config.Once(useVendorWhitelistKey, func() interface{} { return config.Once(useVendorAllowListKey, func() interface{} {
return []string{ return []string{
// swcodec uses "vendor" variants for smaller size // swcodec uses "vendor" variants for smaller size
"com.android.media.swcodec", "com.android.media.swcodec",
@ -924,11 +925,11 @@ func useVendorWhitelist(config android.Config) []string {
}).([]string) }).([]string)
} }
// setUseVendorWhitelistForTest overrides useVendorWhitelist and must be // setUseVendorAllowListForTest overrides useVendorAllowList and must be
// called before the first call to useVendorWhitelist() // called before the first call to useVendorAllowList()
func setUseVendorWhitelistForTest(config android.Config, whitelist []string) { func setUseVendorAllowListForTest(config android.Config, allowList []string) {
config.Once(useVendorWhitelistKey, func() interface{} { config.Once(useVendorAllowListKey, func() interface{} {
return whitelist return allowList
}) })
} }
@ -1030,7 +1031,7 @@ type apexBundleProperties struct {
// List of providing APEXes' names so that this APEX can depend on provided shared libraries. // List of providing APEXes' names so that this APEX can depend on provided shared libraries.
Uses []string Uses []string
// A txt file containing list of files that are whitelisted to be included in this APEX. // A txt file containing list of files that are allowed to be included in this APEX.
Whitelisted_files *string Whitelisted_files *string
// package format of this apex variant; could be non-flattened, flattened, or zip. // package format of this apex variant; could be non-flattened, flattened, or zip.
@ -1358,7 +1359,7 @@ func (a *apexBundle) combineProperties(ctx android.BottomUpMutatorContext) {
} }
func (a *apexBundle) DepsMutator(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") ctx.PropertyErrorf("use_vendor", "not allowed to set use_vendor: true")
} }
@ -1832,7 +1833,7 @@ func (a *apexBundle) checkApexAvailability(ctx android.ModuleContext) {
return false return false
} }
if to.AvailableFor(apexName) || whitelistedApexAvailable(apexName, toName) { if to.AvailableFor(apexName) || baselineApexAvailable(apexName, toName) {
return true return true
} }
message := "" 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 key := apex
moduleName = normalizeModuleName(moduleName) 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 return true
} }
key = android.AvailableToAnyApex 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 return true
} }

View File

@ -963,7 +963,7 @@ func TestApexDependsOnLLNDKTransitively(t *testing.T) {
symbol_file: "", symbol_file: "",
} }
`, func(fs map[string][]byte, config android.Config) { `, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"}) setUseVendorAllowListForTest(config, []string{"myapex"})
}, withUnbundledBuild) }, withUnbundledBuild)
// Ensure that LLNDK dep is not included // Ensure that LLNDK dep is not included
@ -1632,7 +1632,7 @@ func TestUseVendor(t *testing.T) {
apex_available: [ "myapex" ], apex_available: [ "myapex" ],
} }
`, func(fs map[string][]byte, config android.Config) { `, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"}) setUseVendorAllowListForTest(config, []string{"myapex"})
}) })
inputsList := []string{} inputsList := []string{}
@ -1665,9 +1665,9 @@ func TestUseVendorRestriction(t *testing.T) {
private_key: "testkey.pem", private_key: "testkey.pem",
} }
`, func(fs map[string][]byte, config android.Config) { `, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{""}) setUseVendorAllowListForTest(config, []string{""})
}) })
// no error with whitelist // no error with allow list
testApex(t, ` testApex(t, `
apex { apex {
name: "myapex", name: "myapex",
@ -1680,7 +1680,7 @@ func TestUseVendorRestriction(t *testing.T) {
private_key: "testkey.pem", private_key: "testkey.pem",
} }
`, func(fs map[string][]byte, config android.Config) { `, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"}) setUseVendorAllowListForTest(config, []string{"myapex"})
}) })
} }
@ -3412,7 +3412,7 @@ func TestApexUsesFailsIfUseVenderMismatch(t *testing.T) {
private_key: "testkey.pem", private_key: "testkey.pem",
} }
`, func(fs map[string][]byte, config android.Config) { `, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"}) setUseVendorAllowListForTest(config, []string{"myapex"})
}) })
} }

View File

@ -165,13 +165,13 @@ var (
diffApexContentRule = pctx.StaticRule("diffApexContentRule", blueprint.RuleParams{ diffApexContentRule = pctx.StaticRule("diffApexContentRule", blueprint.RuleParams{
Command: `diff --unchanged-group-format='' \` + Command: `diff --unchanged-group-format='' \` +
`--changed-group-format='%<' \` + `--changed-group-format='%<' \` +
`${image_content_file} ${whitelisted_files_file} || (` + `${image_content_file} ${allowed_files_file} || (` +
`echo -e "New unexpected files were added to ${apex_module_name}." ` + `echo -e "New unexpected files were added to ${apex_module_name}." ` +
` "To fix the build run following command:" && ` + ` "To fix the build run following command:" && ` +
`echo "system/apex/tools/update_whitelist.sh ${whitelisted_files_file} ${image_content_file}" && ` + `echo "system/apex/tools/update_allowed_list.sh ${allowed_files_file} ${image_content_file}" && ` +
`exit 1); touch ${out}`, `exit 1); touch ${out}`,
Description: "Diff ${image_content_file} and ${whitelisted_files_file}", Description: "Diff ${image_content_file} and ${allowed_files_file}",
}, "image_content_file", "whitelisted_files_file", "apex_module_name") }, "image_content_file", "allowed_files_file", "apex_module_name")
) )
func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, requireNativeLibs []string) { func (a *apexBundle) buildManifest(ctx android.ModuleContext, provideNativeLibs, requireNativeLibs []string) {
@ -380,7 +380,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
}, },
}) })
implicitInputs = append(implicitInputs, imageContentFile) implicitInputs = append(implicitInputs, imageContentFile)
whitelistedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Whitelisted_files)) allowedFilesFile := android.PathForModuleSrc(ctx, proptools.String(a.properties.Whitelisted_files))
phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output") phonyOutput := android.PathForModuleOut(ctx, a.Name()+"-diff-phony-output")
ctx.Build(pctx, android.BuildParams{ ctx.Build(pctx, android.BuildParams{
@ -389,7 +389,7 @@ func (a *apexBundle) buildUnflattenedApex(ctx android.ModuleContext) {
Output: phonyOutput, Output: phonyOutput,
Description: "diff apex image content", Description: "diff apex image content",
Args: map[string]string{ Args: map[string]string{
"whitelisted_files_file": whitelistedFilesFile.String(), "allowed_files_file": allowedFilesFile.String(),
"image_content_file": imageContentFile.String(), "image_content_file": imageContentFile.String(),
"apex_module_name": a.Name(), "apex_module_name": a.Name(),
}, },

View File

@ -515,7 +515,7 @@ func (compiler *baseCompiler) compilerFlags(ctx ModuleContext, flags Flags, deps
flags.Local.CFlags = append(flags.Local.CFlags, "-fopenmp") flags.Local.CFlags = append(flags.Local.CFlags, "-fopenmp")
} }
// Exclude directories from manual binder interface whitelisting. // Exclude directories from manual binder interface allowed list.
//TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths. //TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
if android.HasAnyPrefix(ctx.ModuleDir(), allowedManualInterfacePaths) { if android.HasAnyPrefix(ctx.ModuleDir(), allowedManualInterfacePaths) {
flags.Local.CFlags = append(flags.Local.CFlags, "-DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES") flags.Local.CFlags = append(flags.Local.CFlags, "-DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES")

View File

@ -686,9 +686,9 @@ func processMainCert(m android.ModuleBase, certPropValue string, certificates []
systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String() systemCertPath := ctx.Config().DefaultAppCertificateDir(ctx).String()
if strings.HasPrefix(certPath, systemCertPath) { if strings.HasPrefix(certPath, systemCertPath) {
enforceSystemCert := ctx.Config().EnforceSystemCertificate() enforceSystemCert := ctx.Config().EnforceSystemCertificate()
whitelist := ctx.Config().EnforceSystemCertificateWhitelist() allowed := ctx.Config().EnforceSystemCertificateAllowList()
if enforceSystemCert && !inList(m.Name(), whitelist) { if enforceSystemCert && !inList(m.Name(), allowed) {
ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.") ctx.PropertyErrorf("certificate", "The module in product partition cannot be signed with certificate in system.")
} }
} }

View File

@ -51,7 +51,7 @@ type DeviceForHost struct {
// java_device_for_host makes the classes.jar output of a device java_library module available to host // java_device_for_host makes the classes.jar output of a device java_library module available to host
// java_library modules. // java_library modules.
// //
// It is rarely necessary, and its usage is restricted to a few whitelisted projects. // It is rarely necessary, and its usage is restricted to a few allowed projects.
func DeviceForHostFactory() android.Module { func DeviceForHostFactory() android.Module {
module := &DeviceForHost{} module := &DeviceForHost{}
@ -68,7 +68,7 @@ type HostForDevice struct {
// java_host_for_device makes the classes.jar output of a host java_library module available to device // java_host_for_device makes the classes.jar output of a host java_library module available to device
// java_library modules. // java_library modules.
// //
// It is rarely necessary, and its usage is restricted to a few whitelisted projects. // It is rarely necessary, and its usage is restricted to a few allowed projects.
func HostForDeviceFactory() android.Module { func HostForDeviceFactory() android.Module {
module := &HostForDevice{} module := &HostForDevice{}

View File

@ -1,5 +1,5 @@
# Additional owner/reviewers for rust rules, including parent directory owners. # Additional owner/reviewers for rust rules, including parent directory owners.
per-file * = chh@google.com, ivanlozano@google.com, jeffv@google.com, srhines@google.com per-file * = chh@google.com, ivanlozano@google.com, jeffv@google.com, srhines@google.com
# Limited owners/reviewers of the whitelist. # Limited owners/reviewers of the allowed list.
per-file whitelist.go = chh@google.com, ivanlozano@google.com, jeffv@google.com, jgalenson@google.com, srhines@google.com per-file allowed_list.go = chh@google.com, ivanlozano@google.com, jeffv@google.com, jgalenson@google.com, srhines@google.com

View File

@ -10,7 +10,7 @@ bootstrap_go_package {
"arm64_device.go", "arm64_device.go",
"global.go", "global.go",
"toolchain.go", "toolchain.go",
"whitelist.go", "allowed_list.go",
"x86_darwin_host.go", "x86_darwin_host.go",
"x86_linux_host.go", "x86_linux_host.go",
"x86_device.go", "x86_device.go",

View File

@ -22,6 +22,7 @@ import (
"android/soong/apex" "android/soong/apex"
"android/soong/cc" "android/soong/cc"
"github.com/google/blueprint" "github.com/google/blueprint"
"github.com/google/blueprint/proptools" "github.com/google/blueprint/proptools"
@ -667,8 +668,8 @@ func (s *snapshotBuilder) AddPrebuiltModule(member android.SdkMember, moduleType
if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok { if apexAware, ok := variant.(interface{ ApexAvailable() []string }); ok {
apexAvailable := apexAware.ApexAvailable() apexAvailable := apexAware.ApexAvailable()
// Add in any white listed apex available settings. // Add in any baseline apex available settings.
apexAvailable = append(apexAvailable, apex.WhitelistedApexAvailable(member.Name())...) apexAvailable = append(apexAvailable, apex.BaselineApexAvailable(member.Name())...)
if len(apexAvailable) > 0 { if len(apexAvailable) > 0 {
// Remove duplicates and sort. // Remove duplicates and sort.