diff options
Diffstat (limited to 'build/apex')
| -rw-r--r-- | build/apex/Android.bp | 46 | ||||
| -rw-r--r-- | build/apex/art.rc | 29 | ||||
| -rwxr-xr-x | build/apex/art_apex_test.py | 44 | ||||
| -rw-r--r-- | build/apex/manifest-art.json | 6 | ||||
| -rwxr-xr-x | build/apex/runtests.sh | 29 |
5 files changed, 128 insertions, 26 deletions
diff --git a/build/apex/Android.bp b/build/apex/Android.bp index fb071f19f3..d5349b6229 100644 --- a/build/apex/Android.bp +++ b/build/apex/Android.bp @@ -59,7 +59,6 @@ art_runtime_base_native_shared_libs_minus_libart = [ // TODO(b/124476339): Clean up the following libraries once "required" // dependencies work with APEX libraries. "libart-compiler", - "libartservice", "libdt_fd_forward", "libdt_socket", "libjdwp", @@ -167,6 +166,8 @@ art_tools_host_only_binaries = [ ] // Core Java libraries. +// This list must be the same as art-bootclasspath-fragment because it's that which is pulled in +// through bootclasspath_fragments below. (com.android.art-device-defaults-minus-odrefresh) libcore_java_libs = [ "core-oj", "core-libart", @@ -251,6 +252,13 @@ art_module_apex_defaults { }, } +prebuilt_etc { + name: "com.android.art.init.rc", + src: "art.rc", + filename: "init.rc", + installable: false, +} + // Default values shared by device ART APEXes. apex_defaults { name: "com.android.art-device-defaults-minus-odrefresh", @@ -263,11 +271,15 @@ apex_defaults { bootclasspath_fragments: ["art-bootclasspath-fragment"], systemserverclasspath_fragments: ["art-systemserverclasspath-fragment"], compat_configs: ["libcore-platform-compat-config"], - java_libs: libcore_java_libs, native_shared_libs: art_runtime_base_native_shared_libs + art_runtime_base_native_device_only_shared_libs + libcore_native_shared_libs, + jni_libs: [ + "libartservice", + ], binaries: [ + "art_boot", + "art_exec", "artd", ], multilib: { @@ -287,7 +299,7 @@ apex_defaults { ], prebuilts: [ "art-linker-config", - "com.android.art.artd.init.rc", + "com.android.art.init.rc", "current_sdkinfo", ], // ART APEXes depend on bouncycastle which is disabled for PDK builds. @@ -298,9 +310,6 @@ apex_defaults { enabled: false, }, }, - // Indicates that pre-installed version of this apex can be compressed. - // Whether it actually will be compressed is controlled on per-device basis. - compressible: true, } apex_defaults { @@ -321,6 +330,9 @@ apex_defaults { art_runtime_run_test_libs + art_runtime_debug_native_shared_libs + libcore_debug_native_shared_libs, + jni_libs: [ + "libartserviced", + ], multilib: { both: { binaries: art_tools_debug_binaries_both + @@ -358,6 +370,7 @@ apex_test { file_contexts: ":com.android.art-file_contexts", certificate: ":com.android.art.certificate", installable: false, + compressible: false, } apex_test { @@ -395,6 +408,7 @@ apex { // ART gtests with dependencies on internal ART APEX libraries. art_gtests = [ + "art_artd_tests", "art_cmdline_tests", "art_compiler_tests", "art_dex2oat_tests", @@ -403,6 +417,7 @@ art_gtests = [ "art_dexdump_tests", "art_dexlayout_tests", "art_dexlist_tests", + "art_disassembler_tests", "art_dexoptanalyzer_tests", "art_imgdiag_tests", "art_libartbase_tests", @@ -415,7 +430,6 @@ art_gtests = [ "art_oatdump_tests", "art_odrefresh_tests", "art_profman_tests", - "art_runtime_compiler_tests", "art_runtime_tests", "art_sigchain_tests", ] @@ -430,7 +444,21 @@ apex_test { certificate: ":com.android.art.certificate", tests: art_gtests, binaries: ["signal_dumper"], // Need signal_dumper for run-tests. + // Mark this test APEX as non-updatable, as its contains + // additional files (used only for testing) that would not pass + // dependency checks performed on updatable APEXes (see + // go/apex-allowed-deps-error). updatable: false, + // Because this APEX is non-updatable, some of its native shared + // libraries (implicitly added as dependencies) are eligible to + // the symlink optimization. As we want this APEX to be + // self-contained (for testing purposes), we want to package + // these dependencies in this APEX, instead of symbolic links to + // their counterparts on the `system` partition, which may not + // even exist, as in the case of `libbacktrace` (see b/232790938 + // and b/233357459). Marking this APEX as "future updatable" + // disables all symlink optimizations for it. + future_updatable: true, } // TODO: Do this better. art_apex_test_host will disable host builds when @@ -505,6 +533,8 @@ python_binary_host { art_check_apex_gen_stem = "$(location art-apex-tester)" + " --deapexer $(location deapexer)" + " --debugfs $(location debugfs_static)" + + " --fsckerofs $(location fsck.erofs)" + + " --blkid $(location blkid_static)" + " --tmpdir $(genDir)" // The non-flattened APEXes are always checked, as they are always generated @@ -514,8 +544,10 @@ genrule_defaults { defaults: ["art_module_source_build_genrule_defaults"], tools: [ "art-apex-tester", + "blkid_static", "deapexer", "debugfs_static", + "fsck.erofs", ], } diff --git a/build/apex/art.rc b/build/apex/art.rc new file mode 100644 index 0000000000..563ee970a9 --- /dev/null +++ b/build/apex/art.rc @@ -0,0 +1,29 @@ +# Copyright (C) 2023 The Android Open Source Project +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +# A lazy service that is started and stopped dynamically as needed. +service artd /apex/com.android.art/bin/artd + interface aidl artd + disabled # Prevents the service from automatically starting at boot. + oneshot # Prevents the service from automatically restarting each time it is stopped. + class core + user artd + group artd + capabilities DAC_OVERRIDE DAC_READ_SEARCH FOWNER CHOWN + +# Run at boot in Android U and later. +service art_boot /apex/com.android.art/bin/art_boot + disabled # Started explicitly from system/core/rootdir/init.rc + oneshot + class core diff --git a/build/apex/art_apex_test.py b/build/apex/art_apex_test.py index 428baf4ab9..c2549cc93e 100755 --- a/build/apex/art_apex_test.py +++ b/build/apex/art_apex_test.py @@ -44,7 +44,7 @@ BITNESS_ALL = [BITNESS_32, BITNESS_64, BITNESS_MULTILIB, BITNESS_AUTO] # Architectures supported by APEX packages. ARCHS_32 = ["arm", "x86"] -ARCHS_64 = ["arm64", "x86_64"] +ARCHS_64 = ["arm64", "riscv64", "x86_64"] # Multilib options MULTILIB_32 = '32' @@ -65,12 +65,14 @@ def isEnvTrue(var): return var in os.environ and os.environ[var] == 'true' -def extract_apex(apex_path, deapexer_path, debugfs_path, tmpdir): +def extract_apex(apex_path, deapexer_path, debugfs_path, fsckerofs_path, + blkid_path, tmpdir): _, apex_name = os.path.split(apex_path) extract_path = os.path.join(tmpdir, apex_name) if os.path.exists(extract_path): shutil.rmtree(extract_path) subprocess.check_call([deapexer_path, '--debugfs', debugfs_path, + '--fsckerofs', fsckerofs_path, '--blkid', blkid_path, 'extract', apex_path, extract_path], stdout=subprocess.DEVNULL) return extract_path @@ -217,6 +219,8 @@ class Checker: return False, 'Could not find %s' if fs_object.is_dir: return False, '%s is a directory' + if fs_object.is_symlink: + return False, '%s is a symlink' return True, '' def is_dir(self, path): @@ -272,17 +276,22 @@ class Checker: def check_art_test_executable(self, filename, multilib=None): dirs = self.arch_dirs_for_path(ART_TEST_DIR, multilib) if not dirs: - self.fail('ART test binary missing: %s', filename) + self.fail('Directories for ART test binary missing: %s', filename) + return for dir in dirs: test_path = '%s/%s' % (dir, filename) self._expected_file_globs.add(test_path) - if not self._provider.get(test_path).is_exec: + file_obj = self._provider.get(test_path) + if not file_obj: + self.fail('ART test binary missing: %s', test_path) + elif not file_obj.is_exec: self.fail('%s is not executable', test_path) def check_art_test_data(self, filename): dirs = self.arch_dirs_for_path(ART_TEST_DIR) if not dirs: - self.fail('ART test data missing: %s', filename) + self.fail('Directories for ART test data missing: %s', filename) + return for dir in dirs: if not self.check_file('%s/%s' % (dir, filename)): return @@ -471,7 +480,6 @@ class ReleaseChecker: self._checker.check_native_library('libart-disassembler') self._checker.check_native_library('libartbase') self._checker.check_native_library('libartpalette') - self._checker.check_native_library('libartservice') self._checker.check_native_library('libarttools') self._checker.check_native_library('libdt_fd_forward') self._checker.check_native_library('libopenjdkjvm') @@ -504,7 +512,6 @@ class ReleaseChecker: # catch invalid dependencies on /system or other APEXes that should go # through an exported library with stubs (b/128708192 tracks implementing a # better approach for that). - self._checker.check_native_library('libbacktrace') self._checker.check_native_library('libbase') self._checker.check_native_library('libc++') self._checker.check_native_library('libdt_socket') @@ -513,7 +520,6 @@ class ReleaseChecker: self._checker.check_native_library('liblzma') self._checker.check_native_library('libnpt') self._checker.check_native_library('libunwindstack') - self._checker.check_native_library('libziparchive') # Allow extra dependencies that appear in ASAN builds. self._checker.check_optional_native_library('libclang_rt.asan*') @@ -544,14 +550,16 @@ class ReleaseTargetChecker: # removed in Android R. # Check binaries for ART. + self._checker.check_executable('art_boot') + self._checker.check_executable('art_exec') self._checker.check_executable('artd') self._checker.check_executable('oatdump') self._checker.check_executable("odrefresh") self._checker.check_symlinked_multilib_executable('dex2oat') # Check internal libraries for ART. + self._checker.check_native_library('libartservice') self._checker.check_native_library('libperfetto_hprof') - self._checker.check_prefer64_library('artd-aidl-ndk') # Check internal Java libraries self._checker.check_java_library("service-art") @@ -637,6 +645,7 @@ class DebugTargetChecker: self._checker.check_symlinked_multilib_executable('dex2oatd') # Check ART internal libraries. + self._checker.check_native_library('libartserviced') self._checker.check_native_library('libperfetto_hprofd') # Check internal native library dependencies. @@ -664,6 +673,7 @@ class TestingTargetChecker: def run(self): # Check ART test binaries. + self._checker.check_art_test_executable('art_artd_tests') self._checker.check_art_test_executable('art_cmdline_tests') self._checker.check_art_test_executable('art_compiler_tests') self._checker.check_art_test_executable('art_dex2oat_tests') @@ -673,6 +683,7 @@ class TestingTargetChecker: self._checker.check_art_test_executable('art_dexlayout_tests') self._checker.check_art_test_executable('art_dexlist_tests') self._checker.check_art_test_executable('art_dexoptanalyzer_tests') + self._checker.check_art_test_executable('art_disassembler_tests') self._checker.check_art_test_executable('art_imgdiag_tests') self._checker.check_art_test_executable('art_libartbase_tests') self._checker.check_art_test_executable('art_libartpalette_tests') @@ -684,7 +695,6 @@ class TestingTargetChecker: self._checker.check_art_test_executable('art_oatdump_tests') self._checker.check_art_test_executable('art_odrefresh_tests') self._checker.check_art_test_executable('art_profman_tests') - self._checker.check_art_test_executable('art_runtime_compiler_tests') self._checker.check_art_test_executable('art_runtime_tests') self._checker.check_art_test_executable('art_sigchain_tests') @@ -698,6 +708,7 @@ class TestingTargetChecker: # Check ART jar files which are needed for gtests. self._checker.check_art_test_data('art-gtest-jars-AbstractMethod.jar') + self._checker.check_art_test_data('art-gtest-jars-ArrayClassWithUnresolvedComponent.dex') self._checker.check_art_test_data('art-gtest-jars-MyClassNatives.jar') self._checker.check_art_test_data('art-gtest-jars-Main.jar') self._checker.check_art_test_data('art-gtest-jars-ProtoCompare.jar') @@ -749,6 +760,7 @@ class TestingTargetChecker: self._checker.check_art_test_data('art-gtest-jars-MainEmptyUncompressed.jar') self._checker.check_art_test_data('art-gtest-jars-Dex2oatVdexTestDex.jar') self._checker.check_art_test_data('art-gtest-jars-Dex2oatVdexPublicSdkDex.dex') + self._checker.check_art_test_data('art-gtest-jars-SuperWithAccessChecks.dex') class NoSuperfluousBinariesChecker: @@ -889,6 +901,12 @@ def art_apex_test_main(test_args): if not test_args.debugfs: logging.error("Need debugfs.") return 1 + if not test_args.fsckerofs: + logging.error("Need fsck.erofs.") + return 1 + if not test_args.blkid: + logging.error("Need blkid.") + return 1 if test_args.host: # Host APEX. @@ -928,7 +946,7 @@ def art_apex_test_main(test_args): # Extract the apex. It would be nice to use the output from "deapexer list" # to avoid this work, but it doesn't provide info about executable bits. apex_dir = extract_apex(test_args.apex, test_args.deapexer, test_args.debugfs, - test_args.tmpdir) + test_args.fsckerofs, test_args.blkid, test_args.tmpdir) apex_provider = TargetApexProvider(apex_dir) except (zipfile.BadZipFile, zipfile.LargeZipFile) as e: logging.error('Failed to create provider: %s', e) @@ -1014,6 +1032,8 @@ def art_apex_test_default(test_parser): test_args = test_parser.parse_args(['unused']) # For consistency. test_args.debugfs = '%s/bin/debugfs' % host_out + test_args.fsckerofs = '%s/bin/fsck.erofs' % host_out + test_args.blkid = '%s/bin/blkid_static' % host_out test_args.tmpdir = '.' test_args.tree = False test_args.list = False @@ -1069,6 +1089,8 @@ if __name__ == "__main__": parser.add_argument('--tmpdir', help='Directory for temp files') parser.add_argument('--deapexer', help='Path to deapexer') parser.add_argument('--debugfs', help='Path to debugfs') + parser.add_argument('--fsckerofs', help='Path to fsck.erofs') + parser.add_argument('--blkid', help='Path to blkid') parser.add_argument('--bitness', help='Bitness to check', choices=BITNESS_ALL, default=BITNESS_AUTO) diff --git a/build/apex/manifest-art.json b/build/apex/manifest-art.json index 9f2962e94a..4f20be67d2 100644 --- a/build/apex/manifest-art.json +++ b/build/apex/manifest-art.json @@ -1,6 +1,10 @@ { "name": "com.android.art", - "version": 330400000, + + // Placeholder module version to be replaced during build. + // Do not change! + "version": 0, + "provideNativeLibs": [ "libjdwp.so" ], diff --git a/build/apex/runtests.sh b/build/apex/runtests.sh index a452fe619a..cdbb7c0645 100755 --- a/build/apex/runtests.sh +++ b/build/apex/runtests.sh @@ -59,14 +59,27 @@ if [ ! -d $ANDROID_BUILD_TOP/frameworks/base ]; then export TARGET_BUILD_UNBUNDLED=true fi -have_deapexer_p=false +deapex_binaries=( + blkid_static + deapexer + debugfs_static + fsck.erofs +) + +have_deapex_binaries=false if [[ "$TARGET_FLATTEN_APEX" != true ]]; then - if [ ! -e "$HOST_OUT/bin/deapexer" -o ! -e "$HOST_OUT/bin/debugfs_static" ] ; then - say "Could not find deapexer and/or debugfs_static, building now." - build/soong/soong_ui.bash --make-mode deapexer debugfs_static-host || \ - die "Cannot build deapexer and debugfs_static" + have_deapex_binaries=true + for f in ${deapex_binaries[@]}; do + if [ ! -e "$HOST_OUT/bin/$f" ]; then + have_deapex_binaries=false + fi + done + if $have_deapex_binaries; then :; else + deapex_targets=( ${deapex_binaries[@]/%/-host} ) + say "Building host binaries for deapexer: ${deapex_targets[*]}" + build/soong/soong_ui.bash --make-mode ${deapex_targets[@]} || \ + die "Failed to build: ${deapex_targets[*]}" fi - have_deapexer_p=true fi # Fail early. @@ -203,9 +216,11 @@ for apex_module in ${apex_modules[@]}; do apex_path="$PRODUCT_OUT/system/apex/${apex_module}.apex" fi fi - if $have_deapexer_p; then + if $have_deapex_binaries; then art_apex_test_args="$art_apex_test_args --deapexer $HOST_OUT/bin/deapexer" art_apex_test_args="$art_apex_test_args --debugfs $HOST_OUT/bin/debugfs_static" + art_apex_test_args="$art_apex_test_args --fsckerofs $HOST_OUT/bin/fsck.erofs" + art_apex_test_args="$art_apex_test_args --blkid $HOST_OUT/bin/blkid_static" fi case $apex_module in (*.debug) test_only_args="--flavor debug";; |