Default apex_available to //apex_available:platform

This means everything that goes into apexes need to be
explicitly labeled to be available for apex.

Whitelist the current offenders. This list should be
trimmed down.

Bug: 147364041
Test: m
Test: multiproduct_kati -only-soong
Exempt-From-Owner-Approval: cherry-pick from internal
Change-Id: I837299c6a15d46f8a5ba544b613776b1cc27d7b8
Merged-In: I837299c6a15d46f8a5ba544b613776b1cc27d7b8
(cherry picked from commit 93488cbb10d4882845abb732f8e53714f0982031)
This commit is contained in:
Anton Hansson 2020-01-10 15:12:39 +00:00
parent 8122cf6d09
commit eec79ebe03
5 changed files with 390 additions and 4 deletions

View File

@ -144,9 +144,9 @@ const (
func CheckAvailableForApex(what string, apex_available []string) bool {
if len(apex_available) == 0 {
// apex_available defaults to ["//apex_available:platform", "//apex_available:anyapex"],
// which means 'available to everybody'.
return true
// apex_available defaults to ["//apex_available:platform"],
// which means 'available to the platform but no apexes'.
return what == AvailableToPlatform
}
return InList(what, apex_available) ||
(what != AvailableToPlatform && InList(availableToAnyApex, apex_available))

View File

@ -57,8 +57,249 @@ var (
certificateTag = dependencyTag{name: "certificate"}
usesTag = dependencyTag{name: "uses"}
androidAppTag = dependencyTag{name: "androidApp"}
apexAvailWl = makeApexAvailableWhitelist()
)
// 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 {
// The "Module separator"s below are employed to minimize merge conflicts.
m := make(map[string][]string)
//
// Module separator
//
m["com.android.adbd"] = []string{"adbd", "libcrypto"}
//
// Module separator
//
m["com.android.art"] = []string{
"jacocoagent",
"libadbconnection_server",
"libartd-disassembler",
"libbacktrace",
"libbase",
"libc++",
"libcrypto",
"libdexfile_support",
"libexpat",
"libicuuc",
"liblzma",
"libmeminfo",
"libprocinfo",
"libunwindstack",
"libvixl",
"libvixld",
"libz",
"libziparchive",
"prebuilt_libclang_rt",
}
//
// Module separator
//
m["com.android.bluetooth.updatable"] = []string{
"android.hardware.audio.common@5.0",
"android.hardware.bluetooth@1.0",
"android.hardware.bluetooth@1.1",
"android.hardware.bluetooth.a2dp@1.0",
"android.hardware.bluetooth.audio@2.0",
"android.hidl.safe_union@1.0",
"libbase",
"libbinderthreadstate",
"libbluetooth",
"libbluetooth_jni",
"libc++",
"libchrome",
"libcrypto",
"libcutils",
"libevent",
"libfmq",
"libhidlbase",
"libprocessgroup",
"libprotobuf-cpp-lite",
"libstatslog",
"libtinyxml2",
"libutils",
"libz",
}
//
// Module separator
//
m["com.android.conscrypt"] = []string{"boringssl_self_test", "libc++", "libcrypto", "libssl"}
//
// Module separator
//
m["com.android.cronet"] = []string{"org.chromium.net.cronet", "prebuilt_libcronet.80.0.3986.0"}
//
// Module separator
//
m["com.android.media"] = []string{
"android.hardware.cas@1.0",
"android.hardware.cas.native@1.0",
"android.hidl.allocator@1.0",
"android.hidl.memory@1.0",
"android.hidl.memory.token@1.0",
"android.hidl.token@1.0",
"android.hidl.token@1.0-utils",
"libaacextractor",
"libamrextractor",
"libbase",
"libbinderthreadstate",
"libc++",
"libcrypto",
"libcutils",
"libflacextractor",
"libhidlbase",
"libhidlmemory",
"libmidiextractor",
"libmkvextractor",
"libmp3extractor",
"libmp4extractor",
"libmpeg2extractor",
"liboggextractor",
"libprocessgroup",
"libutils",
"libwavextractor",
"updatable-media",
}
//
// Module separator
//
m["com.android.media.swcodec"] = []string{
"android.frameworks.bufferhub@1.0",
"android.hardware.configstore@1.0",
"android.hardware.configstore@1.1",
"android.hardware.configstore-utils",
"android.hardware.graphics.allocator@2.0",
"android.hardware.graphics.allocator@3.0",
"android.hardware.graphics.bufferqueue@1.0",
"android.hardware.graphics.bufferqueue@2.0",
"android.hardware.graphics.common@1.0",
"android.hardware.graphics.common@1.1",
"android.hardware.graphics.common@1.2",
"android.hardware.graphics.mapper@2.0",
"android.hardware.graphics.mapper@2.1",
"android.hardware.graphics.mapper@3.0",
"android.hardware.media@1.0",
"android.hardware.media.bufferpool@2.0",
"android.hardware.media.c2@1.0",
"android.hardware.media.omx@1.0",
"android.hidl.memory@1.0",
"android.hidl.memory.token@1.0",
"android.hidl.safe_union@1.0",
"android.hidl.token@1.0",
"android.hidl.token@1.0-utils",
"libavservices_minijail",
"libbacktrace",
"libbase",
"libbinderthreadstate",
"libc++",
"libcap",
"libcodec2",
"libcodec2_hidl@1.0",
"libcodec2_soft_aacdec",
"libcodec2_soft_aacenc",
"libcodec2_soft_amrnbdec",
"libcodec2_soft_amrnbenc",
"libcodec2_soft_amrwbdec",
"libcodec2_soft_amrwbenc",
"libcodec2_soft_av1dec_gav1",
"libcodec2_soft_avcdec",
"libcodec2_soft_avcenc",
"libcodec2_soft_common",
"libcodec2_soft_flacdec",
"libcodec2_soft_flacenc",
"libcodec2_soft_g711alawdec",
"libcodec2_soft_g711mlawdec",
"libcodec2_soft_gsmdec",
"libcodec2_soft_h263dec",
"libcodec2_soft_h263enc",
"libcodec2_soft_hevcdec",
"libcodec2_soft_hevcenc",
"libcodec2_soft_mp3dec",
"libcodec2_soft_mpeg2dec",
"libcodec2_soft_mpeg4dec",
"libcodec2_soft_mpeg4enc",
"libcodec2_soft_opusdec",
"libcodec2_soft_opusenc",
"libcodec2_soft_rawdec",
"libcodec2_soft_vorbisdec",
"libcodec2_soft_vp8dec",
"libcodec2_soft_vp8enc",
"libcodec2_soft_vp9dec",
"libcodec2_soft_vp9enc",
"libcodec2_vndk",
"libc_scudo",
"libcutils",
"libdexfile_support",
"libEGL",
"libfmq",
"libgraphicsenv",
"libhardware",
"libhidlbase",
"libhidlmemory",
"libion",
"liblzma",
"libmedia_codecserviceregistrant",
"libminijail",
"libnativebridge_lazy",
"libnativeloader_lazy",
"libopus",
"libprocessgroup",
"libscudo_wrapper",
"libsfplugin_ccodec_utils",
"libstagefright_amrnb_common",
"libstagefright_bufferpool@2.0.1",
"libstagefright_bufferqueue_helper",
"libstagefright_enc_common",
"libstagefright_flacdec",
"libstagefright_foundation",
"libsync",
"libui",
"libunwindstack",
"libutils",
"libvorbisidec",
"libvpx",
"mediaswcodec",
"prebuilt_libclang_rt",
}
//
// Module separator
//
m["com.android.runtime"] = []string{
"libbase",
"libc++",
"libdexfile_support",
"liblzma",
"libunwindstack",
"prebuilt_libclang_rt",
}
//
// Module separator
//
m["com.android.resolv"] = []string{"libcrypto", "libnetd_resolv", "libssl"}
//
// Module separator
//
m["com.android.tethering"] = []string{"libbase", "libc++", "libnativehelper_compat_libc++"}
//
// Module separator
//
m["com.android.vndk"] = []string{
"libbacktrace",
"libbinderthreadstate",
"libblas",
"libcompiler_rt",
"libgui",
"libunwind",
}
//
// Module separator
//
return m
}
func init() {
android.RegisterModuleType("apex", BundleFactory)
android.RegisterModuleType("apex_test", testApexBundleFactory)
@ -1233,7 +1474,12 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
if !ctx.Host() && !a.testApex {
for _, fi := range filesInfo {
if am, ok := fi.module.(android.ApexModule); ok {
if !am.AvailableFor(ctx.ModuleName()) {
// vndk {enabled:true} implies visibility to the vndk apex
if ccm, ok := fi.module.(*cc.Module); ok && ccm.IsVndk() && a.vndkApex {
continue
}
if !am.AvailableFor(ctx.ModuleName()) && !whitelistedApexAvailable(ctx.ModuleName(), a.vndkApex, fi.module) {
ctx.ModuleErrorf("requires %q that is not available for the APEX", fi.module.Name())
// don't stop so that we can report other violations in the same run
}
@ -1282,6 +1528,25 @@ func (a *apexBundle) GenerateAndroidBuildActions(ctx android.ModuleContext) {
a.buildApexDependencyInfo(ctx)
}
func whitelistedApexAvailable(apex string, is_vndk bool, module android.Module) bool {
key := apex
key = strings.Replace(key, "test_", "", 1)
key = strings.Replace(key, "com.android.art.debug", "com.android.art", 1)
key = strings.Replace(key, "com.android.art.release", "com.android.art", 1)
moduleName := module.Name()
if strings.Contains(moduleName, "prebuilt_libclang_rt") {
// This module has variants that depend on the product being built.
moduleName = "prebuilt_libclang_rt"
}
if val, ok := apexAvailWl[key]; ok && android.InList(moduleName, val) {
return true
}
return false
}
func newApexBundle() *apexBundle {
module := &apexBundle{}
module.AddProperties(&module.properties)

View File

@ -403,6 +403,11 @@ func TestBasicApex(t *testing.T) {
shared_libs: ["mylib2"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
cc_binary {
@ -422,6 +427,7 @@ func TestBasicApex(t *testing.T) {
system_shared_libs: [],
static_executable: true,
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -430,6 +436,11 @@ func TestBasicApex(t *testing.T) {
system_shared_libs: [],
stl: "none",
notice: "custom_notice",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
java_library {
@ -440,6 +451,11 @@ func TestBasicApex(t *testing.T) {
compile_dex: true,
static_libs: ["myotherjar"],
libs: ["mysharedjar"],
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
java_library {
@ -560,6 +576,7 @@ func TestDefaults(t *testing.T) {
name: "mylib",
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
java_library {
@ -568,6 +585,7 @@ func TestDefaults(t *testing.T) {
sdk_version: "none",
system_modules: "none",
compile_dex: true,
apex_available: [ "myapex" ],
}
android_app {
@ -575,6 +593,7 @@ func TestDefaults(t *testing.T) {
srcs: ["foo/bar/MyClass.java"],
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
}
`)
ensureExactContents(t, ctx, "myapex", []string{
@ -627,6 +646,7 @@ func TestBasicZipApex(t *testing.T) {
shared_libs: ["mylib2"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -634,6 +654,7 @@ func TestBasicZipApex(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
`)
@ -674,6 +695,7 @@ func TestApexWithStubs(t *testing.T) {
shared_libs: ["mylib2", "mylib3"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -696,6 +718,7 @@ func TestApexWithStubs(t *testing.T) {
stubs: {
versions: ["10", "11", "12"],
},
apex_available: [ "myapex" ],
}
cc_library {
@ -703,6 +726,7 @@ func TestApexWithStubs(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
`)
@ -764,6 +788,7 @@ func TestApexWithExplicitStubsDependency(t *testing.T) {
shared_libs: ["libfoo#10"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex2" ],
}
cc_library {
@ -845,6 +870,7 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
runtime_libs: ["libfoo", "libbar"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -862,6 +888,7 @@ func TestApexWithRuntimeLibsDependency(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
`)
@ -906,6 +933,7 @@ func TestApexDependencyToLLNDK(t *testing.T) {
shared_libs: ["libbar"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -956,6 +984,7 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
srcs: ["mylib.cpp"],
shared_libs: ["libdl#27"],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library_shared {
@ -963,6 +992,7 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
srcs: ["mylib.cpp"],
shared_libs: ["libdl#27"],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -985,6 +1015,10 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
stubs: {
versions: ["27", "28", "29"],
},
apex_available: [
"//apex_available:platform",
"myapex"
],
}
cc_library {
@ -996,6 +1030,10 @@ func TestApexWithSystemLibsStubs(t *testing.T) {
stubs: {
versions: ["27", "28", "29"],
},
apex_available: [
"//apex_available:platform",
"myapex"
],
}
cc_library {
@ -1087,6 +1125,7 @@ func TestFilesInSubDir(t *testing.T) {
relative_install_path: "foo/bar",
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_binary {
@ -1096,6 +1135,7 @@ func TestFilesInSubDir(t *testing.T) {
system_shared_libs: [],
static_executable: true,
stl: "none",
apex_available: [ "myapex" ],
}
`)
@ -1140,6 +1180,7 @@ func TestUseVendor(t *testing.T) {
system_shared_libs: [],
vendor_available: true,
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -1148,6 +1189,7 @@ func TestUseVendor(t *testing.T) {
system_shared_libs: [],
vendor_available: true,
stl: "none",
apex_available: [ "myapex" ],
}
`, func(fs map[string][]byte, config android.Config) {
setUseVendorWhitelistForTest(config, []string{"myapex"})
@ -1248,6 +1290,10 @@ func TestStaticLinking(t *testing.T) {
stubs: {
versions: ["1", "2", "3"],
},
apex_available: [
"//apex_available:platform",
"myapex",
],
}
cc_binary {
@ -1281,6 +1327,7 @@ func TestKeys(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex_keytest" ],
}
apex_key {
@ -1474,6 +1521,12 @@ func TestMacro(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
"otherapex",
],
}
`)
@ -1527,6 +1580,7 @@ func TestHeaderLibsDependency(t *testing.T) {
stubs: {
versions: ["1", "2", "3"],
},
apex_available: [ "myapex" ],
}
cc_library {
@ -1629,6 +1683,7 @@ func TestVndkApexCurrent(t *testing.T) {
},
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -1641,6 +1696,7 @@ func TestVndkApexCurrent(t *testing.T) {
},
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
`+vndkLibrariesTxtFiles("current"))
@ -1678,6 +1734,7 @@ func TestVndkApexWithPrebuilt(t *testing.T) {
},
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_prebuilt_library_shared {
@ -1695,6 +1752,7 @@ func TestVndkApexWithPrebuilt(t *testing.T) {
},
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
`+vndkLibrariesTxtFiles("current"),
withFiles(map[string][]byte{
@ -1765,6 +1823,7 @@ func TestVndkApexVersion(t *testing.T) {
srcs: ["libvndk27_arm64.so"],
},
},
apex_available: [ "myapex_v27" ],
}
vndk_prebuilt_shared {
@ -1901,6 +1960,7 @@ func TestVndkApexSkipsNativeBridgeSupportedModules(t *testing.T) {
},
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
`+vndkLibrariesTxtFiles("current"),
withTargets(map[android.OsType][]android.Target{
@ -1993,6 +2053,7 @@ func TestVndkApexWithBinder32(t *testing.T) {
srcs: ["libvndk27binder32.so"],
}
},
apex_available: [ "myapex_v27" ],
}
`+vndkLibrariesTxtFiles("27"),
withFiles(map[string][]byte{
@ -2058,6 +2119,7 @@ func TestDependenciesInApexManifest(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex_nodep" ],
}
cc_library {
@ -2066,6 +2128,11 @@ func TestDependenciesInApexManifest(t *testing.T) {
shared_libs: ["libfoo"],
system_shared_libs: [],
stl: "none",
apex_available: [
"myapex_dep",
"myapex_provider",
"myapex_selfcontained",
],
}
cc_library {
@ -2076,6 +2143,10 @@ func TestDependenciesInApexManifest(t *testing.T) {
},
system_shared_libs: [],
stl: "none",
apex_available: [
"myapex_provider",
"myapex_selfcontained",
],
}
`)
@ -2148,6 +2219,10 @@ func TestNonTestApex(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
apex_available: [
"//apex_available:platform",
"myapex",
],
}
`)
@ -2199,6 +2274,11 @@ func TestTestApex(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
`)
@ -2267,6 +2347,11 @@ func TestApexWithTarget(t *testing.T) {
srcs: ["mylib.cpp"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
cc_library {
@ -2275,6 +2360,11 @@ func TestApexWithTarget(t *testing.T) {
system_shared_libs: [],
stl: "none",
compile_multilib: "first",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
cc_library {
@ -2701,6 +2791,7 @@ func TestApexUsesOtherApex(t *testing.T) {
shared_libs: ["libcommon"],
system_shared_libs: [],
stl: "none",
apex_available: [ "myapex" ],
}
cc_library {
@ -2708,6 +2799,12 @@ func TestApexUsesOtherApex(t *testing.T) {
srcs: ["mylib_common.cpp"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"commonapex",
"myapex",
],
}
`)
@ -2859,6 +2956,7 @@ func TestApexWithApps(t *testing.T) {
sdk_version: "none",
system_modules: "none",
jni_libs: ["libjni"],
apex_available: [ "myapex" ],
}
android_app {
@ -2867,6 +2965,7 @@ func TestApexWithApps(t *testing.T) {
sdk_version: "none",
system_modules: "none",
privileged: true,
apex_available: [ "myapex" ],
}
cc_library_shared {
@ -2960,6 +3059,7 @@ func TestApexWithTestHelperApp(t *testing.T) {
android_test_helper_app {
name: "TesterHelpAppFoo",
srcs: ["foo/bar/MyClass.java"],
apex_available: [ "myapex" ],
}
`)
@ -3215,6 +3315,7 @@ func TestOverrideApex(t *testing.T) {
package_name: "foo",
sdk_version: "none",
system_modules: "none",
apex_available: [ "myapex" ],
}
override_android_app {
@ -3298,6 +3399,7 @@ func TestJavaSDKLibrary(t *testing.T) {
name: "foo",
srcs: ["a.java"],
api_packages: ["foo"],
apex_available: [ "myapex" ],
}
`, withFiles(map[string][]byte{
"api/current.txt": nil,
@ -3363,6 +3465,7 @@ func TestCarryRequiredModuleNames(t *testing.T) {
required: ["a", "b"],
host_required: ["c", "d"],
target_required: ["e", "f"],
apex_available: [ "myapex" ],
}
`)

View File

@ -101,6 +101,11 @@ func TestBasicSdkWithCc(t *testing.T) {
srcs: ["libfoo.so"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex",
],
}
cc_prebuilt_library_shared {
@ -109,6 +114,11 @@ func TestBasicSdkWithCc(t *testing.T) {
srcs: ["libfoo.so"],
system_shared_libs: [],
stl: "none",
// TODO: remove //apex_available:platform
apex_available: [
"//apex_available:platform",
"myapex2",
],
}
cc_library_shared {
@ -117,6 +127,10 @@ func TestBasicSdkWithCc(t *testing.T) {
shared_libs: ["sdkmember"],
system_shared_libs: [],
stl: "none",
apex_available: [
"myapex",
"myapex2",
],
}
apex {

View File

@ -73,6 +73,10 @@ func TestBasicSdkWithJavaLibrary(t *testing.T) {
sdk_version: "none",
compile_dex: true,
host_supported: true,
apex_available: [
"myapex",
"myapex2",
],
}
apex {