From 453555083b86ff35d874df08f68bf6252fc12fd1 Mon Sep 17 00:00:00 2001 From: Artur Satayev Date: Thu, 14 May 2020 15:15:01 +0100 Subject: [PATCH] Track allowed transitive deps in any updatable module. Instead of tracking per module and per module variant, track allowed list of dependecies for all modules combined. This avoids issues with different products and different downstream branches having different build graphs. To compare allowed_deps.txt vs head, run: :; m -j out/soong/apex/depsinfo/new-allowed-deps.txt.check To update source allowed_deps.txt, run: :; build/soong/scripts/update-apex-allowed-deps.sh Bug: 149622332 Test: m Change-Id: I56771ba3fea748de8e9c58c80758670572f7af53 Merged-In: Ic518fbd9ebfe1b46aaf9a58df731780a7e5a676b --- android/apex.go | 6 +- apex/OWNERS | 5 +- apex/allowed_deps.txt | 244 ++++++++++++++++++++++++++++ apex/apex_singleton.go | 74 +++++++-- apex/apex_test.go | 32 ++-- scripts/update-apex-allowed-deps.sh | 39 +++++ 6 files changed, 363 insertions(+), 37 deletions(-) create mode 100644 apex/allowed_deps.txt create mode 100755 scripts/update-apex-allowed-deps.sh diff --git a/android/apex.go b/android/apex.go index 47f07ca96..3437fedf9 100644 --- a/android/apex.go +++ b/android/apex.go @@ -450,15 +450,15 @@ func (d *ApexBundleDepsInfo) BuildDepsInfoLists(ctx ModuleContext, minSdkVersion var fullContent strings.Builder var flatContent strings.Builder - fmt.Fprintf(&flatContent, "%s(minSdkVersion:%s):\\n", ctx.ModuleName(), minSdkVersion) + fmt.Fprintf(&fullContent, "%s(minSdkVersion:%s):\\n", ctx.ModuleName(), minSdkVersion) for _, key := range FirstUniqueStrings(SortedStringKeys(depInfos)) { info := depInfos[key] toName := fmt.Sprintf("%s(minSdkVersion:%s)", info.To, info.MinSdkVersion) if info.IsExternal { toName = toName + " (external)" } - fmt.Fprintf(&fullContent, "%s <- %s\\n", toName, strings.Join(SortedUniqueStrings(info.From), ", ")) - fmt.Fprintf(&flatContent, " %s\\n", toName) + fmt.Fprintf(&fullContent, " %s <- %s\\n", toName, strings.Join(SortedUniqueStrings(info.From), ", ")) + fmt.Fprintf(&flatContent, "%s\\n", toName) } d.fullListPath = PathForModuleOut(ctx, "depsinfo", "fulllist.txt").OutputPath diff --git a/apex/OWNERS b/apex/OWNERS index a382ae810..793f3ed19 100644 --- a/apex/OWNERS +++ b/apex/OWNERS @@ -1 +1,4 @@ -per-file * = jiyong@google.com \ No newline at end of file +per-file * = jiyong@google.com + +per-file allowed_deps.txt = set noparent +per-file allowed_deps.txt = dariofreni@google.com,hansson@google.com,harpin@google.com,jiyong@google.com,narayan@google.com,omakoto@google.com,jham@google.com diff --git a/apex/allowed_deps.txt b/apex/allowed_deps.txt new file mode 100644 index 000000000..87a4bc6fd --- /dev/null +++ b/apex/allowed_deps.txt @@ -0,0 +1,244 @@ +# A list of allowed dependencies for all updatable modules. +# +# The list tracks all direct and transitive dependencies that end up within any +# of the updatable binaries; specifically excluding external dependencies +# required to compile those binaries. This prevents potential regressions in +# case a new dependency is not aware of the different functional and +# non-functional requirements being part of an updatable module, for example +# setting correct min_sdk_version. +# +# To update the list, run: +# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh +# +# See go/apex-allowed-deps-error for more details. +# TODO(b/157465465): introduce automated quality signals and remove this list. + +adbd(minSdkVersion:(no version)) +android.hardware.neuralnetworks@1.0(minSdkVersion:30) +android.hardware.neuralnetworks@1.1(minSdkVersion:30) +android.hardware.neuralnetworks@1.2(minSdkVersion:30) +android.hardware.neuralnetworks@1.3(minSdkVersion:30) +android.hardware.tetheroffload.config-V1.0-java(minSdkVersion:current) +android.hardware.tetheroffload.control-V1.0-java(minSdkVersion:current) +android.hidl.allocator@1.0(minSdkVersion:29) +android.hidl.base-V1.0-java(minSdkVersion:current) +android.hidl.memory.token@1.0(minSdkVersion:29) +android.hidl.memory@1.0(minSdkVersion:29) +android.hidl.safe_union@1.0(minSdkVersion:29) +android.net.ipsec.ike(minSdkVersion:current) +android.net.ipsec.ike.xml(minSdkVersion:(no version)) +androidx.activity_activity(minSdkVersion:14) +androidx.annotation_annotation(minSdkVersion:current) +androidx.arch.core_core-common(minSdkVersion:current) +androidx.arch.core_core-runtime(minSdkVersion:14) +androidx.asynclayoutinflater_asynclayoutinflater(minSdkVersion:14) +androidx.collection_collection(minSdkVersion:current) +androidx.coordinatorlayout_coordinatorlayout(minSdkVersion:14) +androidx.core_core(minSdkVersion:14) +androidx.cursoradapter_cursoradapter(minSdkVersion:14) +androidx.customview_customview(minSdkVersion:14) +androidx.documentfile_documentfile(minSdkVersion:14) +androidx.drawerlayout_drawerlayout(minSdkVersion:14) +androidx.fragment_fragment(minSdkVersion:14) +androidx.interpolator_interpolator(minSdkVersion:14) +androidx.legacy_legacy-support-core-ui(minSdkVersion:14) +androidx.legacy_legacy-support-core-utils(minSdkVersion:14) +androidx.legacy_legacy-support-v4(minSdkVersion:14) +androidx.lifecycle_lifecycle-common(minSdkVersion:current) +androidx.lifecycle_lifecycle-livedata-core(minSdkVersion:14) +androidx.lifecycle_lifecycle-runtime(minSdkVersion:14) +androidx.lifecycle_lifecycle-viewmodel(minSdkVersion:14) +androidx.lifecycle_lifecycle-viewmodel-savedstate(minSdkVersion:14) +androidx.loader_loader(minSdkVersion:14) +androidx.localbroadcastmanager_localbroadcastmanager(minSdkVersion:14) +androidx.media_media(minSdkVersion:14) +androidx.print_print(minSdkVersion:14) +androidx.savedstate_savedstate(minSdkVersion:14) +androidx.slidingpanelayout_slidingpanelayout(minSdkVersion:14) +androidx.swiperefreshlayout_swiperefreshlayout(minSdkVersion:14) +androidx.versionedparcelable_versionedparcelable(minSdkVersion:14) +androidx.viewpager_viewpager(minSdkVersion:14) +art.module.public.api.stubs(minSdkVersion:(no version)) +bcm_object(minSdkVersion:29) +boringssl_self_test(minSdkVersion:29) +bouncycastle_ike_digests(minSdkVersion:current) +captiveportal-lib(minSdkVersion:29) +conscrypt(minSdkVersion:29) +conscrypt.module.platform.api.stubs(minSdkVersion:(no version)) +conscrypt.module.public.api.stubs(minSdkVersion:(no version)) +core-lambda-stubs(minSdkVersion:(no version)) +core.current.stubs(minSdkVersion:(no version)) +crtbegin_dynamic(minSdkVersion:apex_inherit) +crtbegin_dynamic1(minSdkVersion:apex_inherit) +crtbegin_so(minSdkVersion:apex_inherit) +crtbegin_so1(minSdkVersion:apex_inherit) +crtbrand(minSdkVersion:apex_inherit) +crtend_android(minSdkVersion:apex_inherit) +crtend_so(minSdkVersion:apex_inherit) +datastallprotosnano(minSdkVersion:29) +derive_sdk(minSdkVersion:current) +derive_sdk_prefer32(minSdkVersion:current) +dnsresolver_aidl_interface-unstable-ndk_platform(minSdkVersion:29) +flatbuffer_headers(minSdkVersion:(no version)) +fmtlib(minSdkVersion:29) +framework-sdkextensions(minSdkVersion:current) +framework-tethering(minSdkVersion:current) +gemmlowp_headers(minSdkVersion:(no version)) +gwp_asan_headers(minSdkVersion:(no version)) +i18n.module.public.api.stubs(minSdkVersion:(no version)) +ike-internals(minSdkVersion:current) +InProcessTethering(minSdkVersion:current) +ipmemorystore-aidl-interfaces-java(minSdkVersion:29) +ipmemorystore-aidl-interfaces-unstable-java(minSdkVersion:29) +jni_headers(minSdkVersion:29) +legacy.art.module.platform.api.stubs(minSdkVersion:(no version)) +legacy.core.platform.api.stubs(minSdkVersion:(no version)) +legacy.i18n.module.platform.api.stubs(minSdkVersion:(no version)) +libadb_crypto(minSdkVersion:(no version)) +libadb_pairing_auth(minSdkVersion:(no version)) +libadb_pairing_connection(minSdkVersion:(no version)) +libadb_pairing_server(minSdkVersion:(no version)) +libadb_protos(minSdkVersion:(no version)) +libadb_tls_connection(minSdkVersion:(no version)) +libadbconnection_client(minSdkVersion:(no version)) +libadbconnection_server(minSdkVersion:(no version)) +libadbd(minSdkVersion:(no version)) +libadbd_core(minSdkVersion:(no version)) +libadbd_services(minSdkVersion:(no version)) +libapp_processes_protos_lite(minSdkVersion:(no version)) +libarect(minSdkVersion:29) +libasyncio(minSdkVersion:(no version)) +libatomic(minSdkVersion:(no version)) +libbacktrace_headers(minSdkVersion:apex_inherit) +libbase(minSdkVersion:29) +libbase_headers(minSdkVersion:29) +libbrotli(minSdkVersion:(no version)) +libbuildversion(minSdkVersion:(no version)) +libc(minSdkVersion:(no version)) +libc++(minSdkVersion:apex_inherit) +libc++_static(minSdkVersion:apex_inherit) +libc++abi(minSdkVersion:apex_inherit) +libc++demangle(minSdkVersion:apex_inherit) +libc_headers(minSdkVersion:apex_inherit) +libc_headers_arch(minSdkVersion:apex_inherit) +libcap(minSdkVersion:29) +libcrypto(minSdkVersion:29) +libcrypto_static(minSdkVersion:(no version)) +libcrypto_utils(minSdkVersion:(no version)) +libcutils(minSdkVersion:29) +libcutils_headers(minSdkVersion:29) +libcutils_sockets(minSdkVersion:29) +libdiagnose_usb(minSdkVersion:(no version)) +libdl(minSdkVersion:(no version)) +libeigen(minSdkVersion:(no version)) +libfmq(minSdkVersion:29) +libgcc_stripped(minSdkVersion:(no version)) +libgtest_prod(minSdkVersion:apex_inherit) +libhidlbase(minSdkVersion:29) +libhidlmemory(minSdkVersion:29) +libhwbinder-impl-internal(minSdkVersion:29) +libjavacrypto(minSdkVersion:29) +libjsoncpp(minSdkVersion:29) +liblog(minSdkVersion:(no version)) +liblog_headers(minSdkVersion:29) +liblz4(minSdkVersion:(no version)) +libm(minSdkVersion:(no version)) +libmath(minSdkVersion:29) +libmdnssd(minSdkVersion:(no version)) +libminijail(minSdkVersion:29) +libminijail_gen_constants(minSdkVersion:(no version)) +libminijail_gen_constants_obj(minSdkVersion:29) +libminijail_gen_syscall(minSdkVersion:(no version)) +libminijail_gen_syscall_obj(minSdkVersion:29) +libminijail_generated(minSdkVersion:29) +libnativehelper_compat_libc++(minSdkVersion:(no version)) +libnativehelper_header_only(minSdkVersion:29) +libnetd_resolv(minSdkVersion:29) +libnetdbinder_utils_headers(minSdkVersion:29) +libnetdutils(minSdkVersion:29) +libnetworkstackutilsjni(minSdkVersion:29) +libneuralnetworks(minSdkVersion:(no version)) +libneuralnetworks_common(minSdkVersion:(no version)) +libneuralnetworks_headers(minSdkVersion:(no version)) +libprocessgroup(minSdkVersion:29) +libprocessgroup_headers(minSdkVersion:29) +libprocpartition(minSdkVersion:(no version)) +libprotobuf-cpp-lite(minSdkVersion:29) +libprotobuf-java-lite(minSdkVersion:current) +libprotobuf-java-nano(minSdkVersion:9) +libqemu_pipe(minSdkVersion:(no version)) +libssl(minSdkVersion:29) +libstatslog_resolv(minSdkVersion:29) +libstatspush_compat(minSdkVersion:29) +libstatssocket_headers(minSdkVersion:29) +libsystem_headers(minSdkVersion:apex_inherit) +libsysutils(minSdkVersion:apex_inherit) +libtetherutilsjni(minSdkVersion:current) +libtextclassifier_hash_headers(minSdkVersion:(no version)) +libtextclassifier_hash_static(minSdkVersion:(no version)) +libtflite_kernel_utils(minSdkVersion:(no version)) +libunwind_llvm(minSdkVersion:apex_inherit) +libutils(minSdkVersion:apex_inherit) +libutils_headers(minSdkVersion:apex_inherit) +libzstd(minSdkVersion:(no version)) +metrics-constants-protos(minSdkVersion:29) +ndk_crtbegin_so.19(minSdkVersion:(no version)) +ndk_crtbegin_so.21(minSdkVersion:(no version)) +ndk_crtbegin_so.27(minSdkVersion:(no version)) +ndk_crtend_so.19(minSdkVersion:(no version)) +ndk_crtend_so.21(minSdkVersion:(no version)) +ndk_crtend_so.27(minSdkVersion:(no version)) +ndk_libc++_static(minSdkVersion:(no version)) +ndk_libc++abi(minSdkVersion:(no version)) +net-utils-framework-common(minSdkVersion:current) +netd_aidl_interface-unstable-java(minSdkVersion:29) +netd_event_listener_interface-ndk_platform(minSdkVersion:29) +netlink-client(minSdkVersion:29) +networkstack-aidl-interfaces-unstable-java(minSdkVersion:29) +networkstack-client(minSdkVersion:29) +NetworkStackApiStableDependencies(minSdkVersion:29) +NetworkStackApiStableLib(minSdkVersion:29) +networkstackprotos(minSdkVersion:29) +philox_random(minSdkVersion:(no version)) +philox_random_headers(minSdkVersion:(no version)) +prebuilt_androidx.activity_activity-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.annotation_annotation-nodeps(minSdkVersion:current) +prebuilt_androidx.arch.core_core-common-nodeps(minSdkVersion:current) +prebuilt_androidx.arch.core_core-runtime-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.asynclayoutinflater_asynclayoutinflater-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.collection_collection-nodeps(minSdkVersion:current) +prebuilt_androidx.coordinatorlayout_coordinatorlayout-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.core_core-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.cursoradapter_cursoradapter-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.customview_customview-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.documentfile_documentfile-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.drawerlayout_drawerlayout-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.fragment_fragment-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.interpolator_interpolator-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.legacy_legacy-support-core-ui-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.legacy_legacy-support-core-utils-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.lifecycle_lifecycle-common-nodeps(minSdkVersion:current) +prebuilt_androidx.lifecycle_lifecycle-livedata-core-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.lifecycle_lifecycle-runtime-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.lifecycle_lifecycle-viewmodel-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.lifecycle_lifecycle-viewmodel-savedstate-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.loader_loader-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.localbroadcastmanager_localbroadcastmanager-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.media_media-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.print_print-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.savedstate_savedstate-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.slidingpanelayout_slidingpanelayout-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.swiperefreshlayout_swiperefreshlayout-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.versionedparcelable_versionedparcelable-nodeps(minSdkVersion:(no version)) +prebuilt_androidx.viewpager_viewpager-nodeps(minSdkVersion:(no version)) +prebuilt_libclang_rt.builtins-aarch64-android(minSdkVersion:(no version)) +prebuilt_libclang_rt.builtins-arm-android(minSdkVersion:(no version)) +prebuilt_libclang_rt.builtins-i686-android(minSdkVersion:(no version)) +prebuilt_libclang_rt.builtins-x86_64-android(minSdkVersion:(no version)) +prebuilt_test_framework-sdkextensions(minSdkVersion:(no version)) +server_configurable_flags(minSdkVersion:29) +stats_proto(minSdkVersion:29) +statsprotos(minSdkVersion:29) +tensorflow_headers(minSdkVersion:(no version)) +Tethering(minSdkVersion:current) +TetheringApiCurrentLib(minSdkVersion:current) diff --git a/apex/apex_singleton.go b/apex/apex_singleton.go index 83a56a2b5..afb739cef 100644 --- a/apex/apex_singleton.go +++ b/apex/apex_singleton.go @@ -17,9 +17,9 @@ package apex import ( - "github.com/google/blueprint" - "android/soong/android" + + "github.com/google/blueprint" ) func init() { @@ -27,39 +27,79 @@ func init() { } type apexDepsInfoSingleton struct { - // Output file with all flatlists from updatable modules' deps-info combined - updatableFlatListsPath android.OutputPath + allowedApexDepsInfoCheckResult android.OutputPath } func apexDepsInfoSingletonFactory() android.Singleton { return &apexDepsInfoSingleton{} } -var combineFilesRule = pctx.AndroidStaticRule("combineFilesRule", - blueprint.RuleParams{ - Command: "cat $out.rsp | xargs cat > $out", +var ( + // Generate new apex allowed_deps.txt by merging all internal dependencies. + generateApexDepsInfoFilesRule = pctx.AndroidStaticRule("generateApexDepsInfoFilesRule", blueprint.RuleParams{ + Command: "cat $out.rsp | xargs cat" + + // Only track non-external dependencies, i.e. those that end up in the binary + " | grep -v '(external)'" + + // Ignore comments in any of the files + " | grep -v '^#'" + + " | sort -u -f >$out", Rspfile: "$out.rsp", RspfileContent: "$in", - }, + }) + + // Diff two given lists while ignoring comments in the allowed deps file. + diffAllowedApexDepsInfoRule = pctx.AndroidStaticRule("diffAllowedApexDepsInfoRule", blueprint.RuleParams{ + Description: "Diff ${allowed_deps} and ${new_allowed_deps}", + Command: ` + if grep -v '^#' ${allowed_deps} | diff -B - ${new_allowed_deps}; then + touch ${out}; + else + echo -e "\n******************************"; + echo "ERROR: go/apex-allowed-deps-error"; + echo "******************************"; + echo "Detected changes to allowed dependencies in updatable modules."; + echo "To fix and update build/soong/apex/allowed_deps.txt, please run:"; + echo "$$ (croot && build/soong/scripts/update-apex-allowed-deps.sh)"; + echo "Members of mainline-modularization@google.com will review the changes."; + echo -e "******************************\n"; + exit 1; + fi; + `, + }, "allowed_deps", "new_allowed_deps") ) func (s *apexDepsInfoSingleton) GenerateBuildActions(ctx android.SingletonContext) { updatableFlatLists := android.Paths{} ctx.VisitAllModules(func(module android.Module) { if binaryInfo, ok := module.(android.ApexBundleDepsInfoIntf); ok { - if path := binaryInfo.FlatListPath(); path != nil { - if binaryInfo.Updatable() { - updatableFlatLists = append(updatableFlatLists, path) - } + if path := binaryInfo.FlatListPath(); path != nil && binaryInfo.Updatable() { + updatableFlatLists = append(updatableFlatLists, path) } } }) - s.updatableFlatListsPath = android.PathForOutput(ctx, "apex", "depsinfo", "updatable-flatlists.txt") + allowedDeps := android.ExistentPathForSource(ctx, "build/soong/apex/allowed_deps.txt").Path() + + newAllowedDeps := android.PathForOutput(ctx, "apex", "depsinfo", "new-allowed-deps.txt") ctx.Build(pctx, android.BuildParams{ - Rule: combineFilesRule, - Description: "Generate " + s.updatableFlatListsPath.String(), - Inputs: updatableFlatLists, - Output: s.updatableFlatListsPath, + Rule: generateApexDepsInfoFilesRule, + Inputs: append(updatableFlatLists, allowedDeps), + Output: newAllowedDeps, + }) + + s.allowedApexDepsInfoCheckResult = android.PathForOutput(ctx, newAllowedDeps.Rel()+".check") + ctx.Build(pctx, android.BuildParams{ + Rule: diffAllowedApexDepsInfoRule, + Input: newAllowedDeps, + Output: s.allowedApexDepsInfoCheckResult, + Args: map[string]string{ + "allowed_deps": allowedDeps.String(), + "new_allowed_deps": newAllowedDeps.String(), + }, }) } + +func (s *apexDepsInfoSingleton) MakeVars(ctx android.MakeVarsContext) { + // Export check result to Make. The path is added to droidcore. + ctx.Strict("APEX_ALLOWED_DEPS_CHECK", s.allowedApexDepsInfoCheckResult.String()) +} diff --git a/apex/apex_test.go b/apex/apex_test.go index f06433848..500bb20bf 100644 --- a/apex/apex_test.go +++ b/apex/apex_test.go @@ -573,18 +573,18 @@ func TestBasicApex(t *testing.T) { ensureListContains(t, noticeInputs, "custom_notice_for_static_lib") fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n") - ensureListContains(t, fullDepsInfo, "myjar(minSdkVersion:(no version)) <- myapex") - ensureListContains(t, fullDepsInfo, "mylib(minSdkVersion:(no version)) <- myapex") - ensureListContains(t, fullDepsInfo, "mylib2(minSdkVersion:(no version)) <- mylib") - ensureListContains(t, fullDepsInfo, "myotherjar(minSdkVersion:(no version)) <- myjar") - ensureListContains(t, fullDepsInfo, "mysharedjar(minSdkVersion:(no version)) (external) <- myjar") + ensureListContains(t, fullDepsInfo, " myjar(minSdkVersion:(no version)) <- myapex") + ensureListContains(t, fullDepsInfo, " mylib(minSdkVersion:(no version)) <- myapex") + ensureListContains(t, fullDepsInfo, " mylib2(minSdkVersion:(no version)) <- mylib") + ensureListContains(t, fullDepsInfo, " myotherjar(minSdkVersion:(no version)) <- myjar") + ensureListContains(t, fullDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external) <- myjar") flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex", "android_common_myapex_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n") - ensureListContains(t, flatDepsInfo, " myjar(minSdkVersion:(no version))") - ensureListContains(t, flatDepsInfo, " mylib(minSdkVersion:(no version))") - ensureListContains(t, flatDepsInfo, " mylib2(minSdkVersion:(no version))") - ensureListContains(t, flatDepsInfo, " myotherjar(minSdkVersion:(no version))") - ensureListContains(t, flatDepsInfo, " mysharedjar(minSdkVersion:(no version)) (external)") + ensureListContains(t, flatDepsInfo, "myjar(minSdkVersion:(no version))") + ensureListContains(t, flatDepsInfo, "mylib(minSdkVersion:(no version))") + ensureListContains(t, flatDepsInfo, "mylib2(minSdkVersion:(no version))") + ensureListContains(t, flatDepsInfo, "myotherjar(minSdkVersion:(no version))") + ensureListContains(t, flatDepsInfo, "mysharedjar(minSdkVersion:(no version)) (external)") } func TestDefaults(t *testing.T) { @@ -894,14 +894,14 @@ func TestApexWithExplicitStubsDependency(t *testing.T) { ensureNotContains(t, libFooStubsLdFlags, "libbar.so") fullDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/fulllist.txt").Args["content"], "\\n") - ensureListContains(t, fullDepsInfo, "mylib(minSdkVersion:(no version)) <- myapex2") - ensureListContains(t, fullDepsInfo, "libbaz(minSdkVersion:(no version)) <- mylib") - ensureListContains(t, fullDepsInfo, "libfoo(minSdkVersion:(no version)) (external) <- mylib") + ensureListContains(t, fullDepsInfo, " mylib(minSdkVersion:(no version)) <- myapex2") + ensureListContains(t, fullDepsInfo, " libbaz(minSdkVersion:(no version)) <- mylib") + ensureListContains(t, fullDepsInfo, " libfoo(minSdkVersion:(no version)) (external) <- mylib") flatDepsInfo := strings.Split(ctx.ModuleForTests("myapex2", "android_common_myapex2_image").Output("depsinfo/flatlist.txt").Args["content"], "\\n") - ensureListContains(t, flatDepsInfo, " mylib(minSdkVersion:(no version))") - ensureListContains(t, flatDepsInfo, " libbaz(minSdkVersion:(no version))") - ensureListContains(t, flatDepsInfo, " libfoo(minSdkVersion:(no version)) (external)") + ensureListContains(t, flatDepsInfo, "mylib(minSdkVersion:(no version))") + ensureListContains(t, flatDepsInfo, "libbaz(minSdkVersion:(no version))") + ensureListContains(t, flatDepsInfo, "libfoo(minSdkVersion:(no version)) (external)") } func TestApexWithRuntimeLibsDependency(t *testing.T) { diff --git a/scripts/update-apex-allowed-deps.sh b/scripts/update-apex-allowed-deps.sh new file mode 100755 index 000000000..872d74670 --- /dev/null +++ b/scripts/update-apex-allowed-deps.sh @@ -0,0 +1,39 @@ +#!/bin/bash -e +# +# The script to run locally to re-generate global allowed list of dependencies +# for updatable modules. + +if [ ! -e "build/envsetup.sh" ]; then + echo "ERROR: $0 must be run from the top of the tree" + exit 1 +fi + +source build/envsetup.sh > /dev/null || exit 1 + +readonly OUT_DIR=$(get_build_var OUT_DIR) + +readonly ALLOWED_DEPS_FILE="build/soong/apex/allowed_deps.txt" +readonly NEW_ALLOWED_DEPS_FILE="${OUT_DIR}/soong/apex/depsinfo/new-allowed-deps.txt" + +# If the script is run after droidcore failure, ${NEW_ALLOWED_DEPS_FILE} +# should already be built. If running the script manually, make sure it exists. +m "${NEW_ALLOWED_DEPS_FILE}" -j + +cat > "${ALLOWED_DEPS_FILE}" << EndOfFileComment +# A list of allowed dependencies for all updatable modules. +# +# The list tracks all direct and transitive dependencies that end up within any +# of the updatable binaries; specifically excluding external dependencies +# required to compile those binaries. This prevents potential regressions in +# case a new dependency is not aware of the different functional and +# non-functional requirements being part of an updatable module, for example +# setting correct min_sdk_version. +# +# To update the list, run: +# repo-root$ build/soong/scripts/update-apex-allowed-deps.sh +# +# See go/apex-allowed-deps-error for more details. +# TODO(b/157465465): introduce automated quality signals and remove this list. +EndOfFileComment + +cat "${NEW_ALLOWED_DEPS_FILE}" >> "${ALLOWED_DEPS_FILE}"