Repository: android/platform_build
Branch: main
Commit: 045a3d6a3e35
Files: 1380
Total size: 7.0 MB
Directory structure:
gitextract_4wb4gfr7/
├── .gitignore
├── Android.bp
├── Changes.md
├── CleanSpec.mk
├── Deprecation.md
├── OWNERS
├── PREUPLOAD.cfg
├── README.md
├── Usage.txt
├── backported_fixes/
│ ├── Android.bp
│ ├── OWNERS
│ ├── applied_fixes/
│ │ └── ki350037023.txtpb
│ ├── backported_fixes.proto
│ ├── src/
│ │ └── java/
│ │ └── com/
│ │ └── android/
│ │ └── build/
│ │ └── backportedfixes/
│ │ ├── CombineBackportedFixes.java
│ │ ├── WriteBackportedFixesPropFile.java
│ │ └── common/
│ │ └── Parser.java
│ └── tests/
│ └── java/
│ └── com/
│ └── android/
│ └── build/
│ └── backportedfixes/
│ ├── CombineBackportedFixesTest.java
│ ├── WriteBackportedFixesPropFileTest.java
│ └── common/
│ └── ParserTest.java
├── banchanHelp.sh
├── buildspec.mk.default
├── ci/
│ ├── Android.bp
│ ├── AndroidTest.xml.template
│ ├── build_context.py
│ ├── build_device_and_tests
│ ├── build_metadata
│ ├── build_test_suites
│ ├── build_test_suites.py
│ ├── build_test_suites_local_test.py
│ ├── build_test_suites_test.py
│ ├── buildbot.py
│ ├── ci_test_lib.py
│ ├── dump_product_config
│ ├── metrics_agent.py
│ ├── optimized_targets.py
│ ├── optimized_targets_test.py
│ ├── test_discovery_agent.py
│ └── test_mapping_module_retriever.py
├── common/
│ ├── core.mk
│ ├── json.mk
│ ├── math.mk
│ └── strings.mk
├── core/
│ ├── LINUX_KERNEL_COPYING
│ ├── Makefile
│ ├── OWNERS
│ ├── WINPTHREADS_COPYING
│ ├── aapt2.mk
│ ├── aapt_flags.mk
│ ├── allowed_ndk_types.mk
│ ├── android_manifest.mk
│ ├── android_soong_config_vars.mk
│ ├── app_certificate_validate.mk
│ ├── app_prebuilt_internal.mk
│ ├── art_config.mk
│ ├── artifact_path_requirements.mk
│ ├── autogen_test_config.mk
│ ├── base_rules.mk
│ ├── binary.mk
│ ├── board_config.mk
│ ├── board_config_wifi.mk
│ ├── board_config_wpa_supplicant.mk
│ ├── build-system.html
│ ├── build_id.mk
│ ├── build_rro_package.mk
│ ├── cc_prebuilt_internal.mk
│ ├── ccache.mk
│ ├── check_elf_file.mk
│ ├── checktree
│ ├── clang/
│ │ ├── HOST_x86.mk
│ │ ├── HOST_x86_64.mk
│ │ ├── TARGET_arm.mk
│ │ ├── TARGET_arm64.mk
│ │ ├── TARGET_riscv64.mk
│ │ ├── TARGET_x86.mk
│ │ ├── TARGET_x86_64.mk
│ │ ├── config.mk
│ │ └── tidy.mk
│ ├── cleanbuild.mk
│ ├── cleanspec.mk
│ ├── clear_vars.mk
│ ├── combo/
│ │ ├── HOST_darwin.mk
│ │ ├── HOST_linux.mk
│ │ ├── TARGET_linux-arm.mk
│ │ ├── TARGET_linux-arm64.mk
│ │ ├── TARGET_linux-riscv64.mk
│ │ ├── TARGET_linux-x86.mk
│ │ ├── TARGET_linux-x86_64.mk
│ │ ├── javac.mk
│ │ └── select.mk
│ ├── config.mk
│ ├── config_sanitizers.mk
│ ├── configure_module_stem.mk
│ ├── copy_headers.mk
│ ├── cxx_stl_setup.mk
│ ├── definitions.mk
│ ├── deprecation.mk
│ ├── dex_preopt.mk
│ ├── dex_preopt_config.mk
│ ├── dex_preopt_config_merger.py
│ ├── dex_preopt_odex_install.mk
│ ├── distdir.mk
│ ├── dumpconfig.mk
│ ├── dumpvar.mk
│ ├── dupcheck.sh
│ ├── dynamic_binary.mk
│ ├── empty_test_config.xml
│ ├── envsetup.mk
│ ├── executable.mk
│ ├── executable_internal.mk
│ ├── executable_prefer_symlink.mk
│ ├── filter_symbols.sh
│ ├── force_aapt2.mk
│ ├── fuzz_test.mk
│ ├── generate_enforce_rro.mk
│ ├── header_library.mk
│ ├── header_library_internal.mk
│ ├── host_executable.mk
│ ├── host_executable_internal.mk
│ ├── host_java_library.mk
│ ├── host_java_library_common.mk
│ ├── host_prebuilt.mk
│ ├── host_shared_library.mk
│ ├── host_shared_library_internal.mk
│ ├── host_static_library.mk
│ ├── host_static_library_internal.mk
│ ├── install_jni_libs.mk
│ ├── install_jni_libs_internal.mk
│ ├── instrumentation_test_config_template.xml
│ ├── jacoco.mk
│ ├── java.mk
│ ├── java_common.mk
│ ├── java_host_test_config_template.xml
│ ├── java_host_unit_test_config_template.xml
│ ├── java_library.mk
│ ├── java_prebuilt_internal.mk
│ ├── java_renderscript.mk
│ ├── java_test_config_template.xml
│ ├── layoutlib_data.mk
│ ├── link_type.mk
│ ├── local_current_sdk.mk
│ ├── local_systemsdk.mk
│ ├── local_vendor_product.mk
│ ├── main.mk
│ ├── misc_prebuilt_internal.mk
│ ├── module_arch_supported.mk
│ ├── multi_prebuilt.mk
│ ├── multilib.mk
│ ├── native_benchmark_test_config_template.xml
│ ├── native_host_test_config_template.xml
│ ├── native_test.mk
│ ├── native_test_config_template.xml
│ ├── ninja_config.mk
│ ├── node_fns.mk
│ ├── notice_files.mk
│ ├── os_licensing.mk
│ ├── pack_dyn_relocs_setup.mk
│ ├── package.mk
│ ├── package_internal.mk
│ ├── packaging/
│ │ └── flags.mk
│ ├── pathmap.mk
│ ├── phony_package.mk
│ ├── prebuilt.mk
│ ├── prebuilt_internal.mk
│ ├── process_wrapper.sh
│ ├── process_wrapper_gdb.cmds
│ ├── process_wrapper_gdb.sh
│ ├── product-graph.mk
│ ├── product.mk
│ ├── product_config.mk
│ ├── product_config.rbc
│ ├── product_validation_checks.mk
│ ├── proguard/
│ │ ├── checknotnull.flags
│ │ └── kotlin.flags
│ ├── proguard.flags
│ ├── proguard.jacoco.flags
│ ├── proguard_basic_keeps.flags
│ ├── project_definitions.mk
│ ├── python_binary_host_mobly_test_config_template.xml
│ ├── python_binary_host_test_config_template.xml
│ ├── ravenwood_test_config_template.xml
│ ├── rbe.mk
│ ├── release_config.mk
│ ├── release_config.scl
│ ├── robolectric_test_config_template.xml
│ ├── root.mk
│ ├── rust_device_benchmark_config_template.xml
│ ├── rust_device_test_config_template.xml
│ ├── rust_host_benchmark_config_template.xml
│ ├── rust_host_test_config_template.xml
│ ├── sbom.mk
│ ├── sdk_check.mk
│ ├── shared_library.mk
│ ├── shared_library_internal.mk
│ ├── shell_test_config_template.xml
│ ├── soong_android_app_set.mk
│ ├── soong_app_prebuilt.mk
│ ├── soong_cc_rust_prebuilt.mk
│ ├── soong_config.mk
│ ├── soong_droiddoc_prebuilt.mk
│ ├── soong_extra_config.mk
│ ├── soong_java_prebuilt.mk
│ ├── static_java_library.mk
│ ├── static_library.mk
│ ├── static_library_internal.mk
│ ├── suite_host_config.mk
│ ├── support_libraries.mk
│ ├── sysprop.mk
│ ├── sysprop_config.mk
│ ├── target_test_internal.mk
│ ├── tasks/
│ │ ├── README.dex_preopt_check.md
│ │ ├── art-host-tests.mk
│ │ ├── art.mk
│ │ ├── automotive-general-tests.mk
│ │ ├── automotive-sdv-tests.mk
│ │ ├── automotive-tests.mk
│ │ ├── autorepro.mk
│ │ ├── berberis_test.mk
│ │ ├── build_custom_images.mk
│ │ ├── catbox.mk
│ │ ├── check-abi-dump-list.mk
│ │ ├── csuite.mk
│ │ ├── cts.mk
│ │ ├── cts_root.mk
│ │ ├── device-platinum-tests.mk
│ │ ├── device-tests.mk
│ │ ├── dex_preopt_check.mk
│ │ ├── dts.mk
│ │ ├── find-shareduid-violation.mk
│ │ ├── fontchain_lint.mk
│ │ ├── general-tests.mk
│ │ ├── host-unit-tests.mk
│ │ ├── host_init_verifier.mk
│ │ ├── mcts.mk
│ │ ├── meta-lic.mk
│ │ ├── module-info.mk
│ │ ├── mts.mk
│ │ ├── multitree.mk
│ │ ├── oem_image.mk
│ │ ├── offline-sdk-docs.mk
│ │ ├── owners.mk
│ │ ├── performance-tests.mk
│ │ ├── platform_availability_check.mk
│ │ ├── prebuilt_tradefed.mk
│ │ ├── sdk-addon.mk
│ │ ├── sts.mk
│ │ ├── tools/
│ │ │ ├── build_custom_image.mk
│ │ │ ├── compatibility.mk
│ │ │ └── package-modules.mk
│ │ ├── tradefed-tests-list.mk
│ │ ├── vendor_module_check.mk
│ │ ├── vts-core-tests.mk
│ │ ├── with-license.mk
│ │ └── wvts.mk
│ ├── use_lld_setup.mk
│ └── version_util.mk
├── envsetup.sh
├── help.sh
├── navbar.md
├── packaging/
│ ├── distdir.mk
│ ├── main.mk
│ └── main_soong_only.mk
├── rbesetup.sh
├── shell_utils.sh
├── tapasHelp.sh
├── target/
│ ├── board/
│ │ ├── BoardConfigGsiCommon.mk
│ │ ├── BoardConfigMainlineCommon.mk
│ │ ├── BoardConfigPixelCommon.mk
│ │ ├── android-info.mk
│ │ ├── generic/
│ │ │ ├── AndroidBoard.mk
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system_ext.prop
│ │ ├── generic_64bitonly_x86_64/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system.prop
│ │ ├── generic_arm64/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ ├── sepolicy/
│ │ │ │ ├── OWNERS
│ │ │ │ ├── file.te
│ │ │ │ └── file_contexts
│ │ │ └── system_ext.prop
│ │ ├── generic_arm64_plus_armv7/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ └── device.mk
│ │ ├── generic_riscv64/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system_ext.prop
│ │ ├── generic_x86/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system_ext.prop
│ │ ├── generic_x86_64/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system_ext.prop
│ │ ├── generic_x86_64_arm64/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system_ext.prop
│ │ ├── generic_x86_arm/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── README.txt
│ │ │ ├── device.mk
│ │ │ └── system_ext.prop
│ │ ├── go_defaults.prop
│ │ ├── go_defaults_512.prop
│ │ ├── go_defaults_common.prop
│ │ ├── gsi_arm64/
│ │ │ └── BoardConfig.mk
│ │ ├── gsi_system_ext.prop
│ │ ├── gsi_system_ext_user.prop
│ │ ├── linux_bionic/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── mainline_arm64/
│ │ │ ├── BoardConfig.mk
│ │ │ ├── bluetooth/
│ │ │ │ └── bdroid_buildcfg.h
│ │ │ └── sepolicy/
│ │ │ ├── OWNERS
│ │ │ ├── file.te
│ │ │ └── file_contexts
│ │ ├── mainline_sdk/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── mainline_x86/
│ │ │ └── BoardConfig.mk
│ │ ├── mainline_x86_64/
│ │ │ └── BoardConfig.mk
│ │ ├── mainline_x86_arm/
│ │ │ └── BoardConfig.mk
│ │ ├── module_arm/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── module_arm64/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── module_arm64only/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── module_riscv64/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── module_x86/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── module_x86_64/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ ├── module_x86_64only/
│ │ │ ├── BoardConfig.mk
│ │ │ └── README.md
│ │ └── ndk/
│ │ ├── BoardConfig.mk
│ │ └── README.md
│ └── product/
│ ├── AndroidProducts.mk
│ ├── OWNERS
│ ├── angle_default.mk
│ ├── aosp_64bitonly_x86_64.mk
│ ├── aosp_arm.mk
│ ├── aosp_arm64.mk
│ ├── aosp_arm64_fullmte.mk
│ ├── aosp_arm64_plus_armv7.mk
│ ├── aosp_base.mk
│ ├── aosp_base_telephony.mk
│ ├── aosp_product.mk
│ ├── aosp_riscv64.mk
│ ├── aosp_x86.mk
│ ├── aosp_x86_64.mk
│ ├── aosp_x86_arm.mk
│ ├── app_function_extensions.mk
│ ├── base.mk
│ ├── base_product.mk
│ ├── base_system.mk
│ ├── base_system_ext.mk
│ ├── base_vendor.mk
│ ├── build_variables.mk
│ ├── cfi-common.mk
│ ├── core_64_bit.mk
│ ├── core_64_bit_only.mk
│ ├── core_minimal.mk
│ ├── core_no_zygote.mk
│ ├── default_art_config.mk
│ ├── developer_gsi_keys.mk
│ ├── empty-preloaded-classes
│ ├── empty-profile
│ ├── emulated_storage.mk
│ ├── full.manifest.xml
│ ├── full.mk
│ ├── full_base.mk
│ ├── full_base_telephony.mk
│ ├── full_x86.mk
│ ├── fullmte.mk
│ ├── generic/
│ │ ├── Android.bp
│ │ ├── OWNERS
│ │ └── erofs_compress_hints.txt
│ ├── generic.mk
│ ├── generic_no_telephony.mk
│ ├── generic_ramdisk.mk
│ ├── generic_system.mk
│ ├── generic_system_arm64.mk
│ ├── generic_system_x86.mk
│ ├── generic_system_x86_64.mk
│ ├── generic_system_x86_arm.mk
│ ├── generic_x86.mk
│ ├── go_defaults.mk
│ ├── go_defaults_512.mk
│ ├── go_defaults_common.mk
│ ├── gsi/
│ │ ├── 28.txt
│ │ ├── 29.txt
│ │ ├── 30.txt
│ │ ├── 31.txt
│ │ ├── 32.txt
│ │ ├── 33.txt
│ │ ├── 34.txt
│ │ ├── Android.bp
│ │ ├── OWNERS
│ │ ├── current.txt
│ │ ├── gsi_skip_mount.cfg
│ │ ├── init.gsi.rc
│ │ ├── init.vndk-nodef.rc
│ │ └── testkey_rsa2048.pem
│ ├── gsi_release.mk
│ ├── handheld_product.mk
│ ├── handheld_system.mk
│ ├── handheld_system_ext.mk
│ ├── handheld_vendor.mk
│ ├── hsum_common.mk
│ ├── languages_default.mk
│ ├── languages_full.mk
│ ├── large_screen_common.mk
│ ├── linux_bionic.mk
│ ├── mainline_sdk.mk
│ ├── mainline_system_arm64.mk
│ ├── mainline_system_x86.mk
│ ├── mainline_system_x86_64.mk
│ ├── mainline_system_x86_arm.mk
│ ├── media_product.mk
│ ├── media_system.mk
│ ├── media_system_ext.mk
│ ├── media_vendor.mk
│ ├── memtag-common.mk
│ ├── module_arm.mk
│ ├── module_arm64.mk
│ ├── module_arm64only.mk
│ ├── module_common.mk
│ ├── module_riscv64.mk
│ ├── module_x86.mk
│ ├── module_x86_64.mk
│ ├── module_x86_64only.mk
│ ├── ndk.mk
│ ├── non_ab_device.mk
│ ├── product_launched_with_k.mk
│ ├── product_launched_with_l.mk
│ ├── product_launched_with_l_mr1.mk
│ ├── product_launched_with_m.mk
│ ├── product_launched_with_n.mk
│ ├── product_launched_with_n_mr1.mk
│ ├── product_launched_with_o.mk
│ ├── product_launched_with_o_mr1.mk
│ ├── product_launched_with_p.mk
│ ├── profile_boot_common.mk
│ ├── ramdisk_stub.mk
│ ├── runtime_libart.mk
│ ├── sdk.mk
│ ├── sdk_with_runtime_apis.mk
│ ├── security/
│ │ ├── Android.bp
│ │ ├── README
│ │ ├── bluetooth.pk8
│ │ ├── bluetooth.x509.pem
│ │ ├── cts_uicc_2021.pk8
│ │ ├── cts_uicc_2021.x509.pem
│ │ ├── fsverity-release.x509.der
│ │ ├── media.pk8
│ │ ├── media.x509.pem
│ │ ├── networkstack.pk8
│ │ ├── networkstack.x509.pem
│ │ ├── nfc.pk8
│ │ ├── nfc.x509.pem
│ │ ├── platform.pk8
│ │ ├── platform.x509.pem
│ │ ├── sdk_sandbox.pk8
│ │ ├── sdk_sandbox.x509.pem
│ │ ├── shared.pk8
│ │ ├── shared.x509.pem
│ │ ├── testkey.pk8
│ │ └── testkey.x509.pem
│ ├── sysconfig/
│ │ ├── Android.bp
│ │ ├── initial-package-stopped-states-aosp.xml
│ │ ├── preinstalled-packages-platform-aosp-product.xml
│ │ ├── preinstalled-packages-platform-full-base.xml
│ │ ├── preinstalled-packages-platform-generic-system.xml
│ │ ├── preinstalled-packages-platform-handheld-product.xml
│ │ ├── preinstalled-packages-platform-handheld-system.xml
│ │ └── preinstalled-packages-platform-telephony-product.xml
│ ├── telephony.mk
│ ├── telephony_product.mk
│ ├── telephony_system.mk
│ ├── telephony_system_ext.mk
│ ├── telephony_vendor.mk
│ ├── updatable_apex.mk
│ ├── userspace_reboot.mk
│ ├── virtual_ab_ota/
│ │ ├── OWNERS
│ │ ├── README.md
│ │ ├── android_t_baseline.mk
│ │ ├── compression.mk
│ │ ├── compression_retrofit.mk
│ │ ├── compression_with_xor.mk
│ │ ├── launch.mk
│ │ ├── launch_with_vendor_ramdisk.mk
│ │ ├── plus_non_ab.mk
│ │ ├── retrofit.mk
│ │ └── vabc_features.mk
│ ├── window_extensions.mk
│ └── window_extensions_base.mk
├── teams/
│ ├── Android.bp
│ └── OWNERS
├── tests/
│ ├── artifact_path_requirements/
│ │ ├── inherit1.rbc
│ │ ├── inherit2.rbc
│ │ ├── inherit3.rbc
│ │ ├── inherit4.rbc
│ │ ├── product.rbc
│ │ └── test.rbc
│ ├── b_tests.sh
│ ├── board.rbc
│ ├── board_input_vars.rbc
│ ├── conversion_error.rbc
│ ├── envsetup_tests.sh
│ ├── include1.rbc
│ ├── inherits_in_regular_variables/
│ │ ├── inherit1.rbc
│ │ ├── product.rbc
│ │ └── test.rbc
│ ├── input_variables.rbc
│ ├── lunch_tests.sh
│ ├── part1.rbc
│ ├── prefixed_sort_order/
│ │ ├── base-secondary.rbc
│ │ ├── base.rbc
│ │ ├── product.rbc
│ │ └── test.rbc
│ ├── product.rbc
│ ├── roboleaf_tests.sh
│ ├── run.rbc
│ ├── single_value_inheritance/
│ │ ├── inherit1.rbc
│ │ ├── inherit2.rbc
│ │ ├── product.rbc
│ │ └── test.rbc
│ ├── single_value_inheritance_2/
│ │ ├── a.rbc
│ │ ├── b.rbc
│ │ ├── c.rbc
│ │ ├── d.rbc
│ │ ├── product.rbc
│ │ └── test.rbc
│ └── version_defaults.rbc
└── tools/
├── Android.bp
├── aconfig/
│ ├── .editorconfig
│ ├── .gitignore
│ ├── Cargo.toml
│ ├── MODULE_LICENSE_APACHE2
│ ├── OWNERS
│ ├── PREUPLOAD.cfg
│ ├── TEST_MAPPING
│ ├── aconfig/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── build.rs
│ │ ├── src/
│ │ │ ├── codegen/
│ │ │ │ ├── cpp.rs
│ │ │ │ ├── java.rs
│ │ │ │ ├── mod.rs
│ │ │ │ └── rust.rs
│ │ │ ├── commands.rs
│ │ │ ├── dump.rs
│ │ │ ├── main.rs
│ │ │ ├── storage/
│ │ │ │ ├── flag_info.rs
│ │ │ │ ├── flag_table.rs
│ │ │ │ ├── flag_value.rs
│ │ │ │ ├── mod.rs
│ │ │ │ └── package_table.rs
│ │ │ └── test.rs
│ │ ├── templates/
│ │ │ ├── CustomFeatureFlags.java.template
│ │ │ ├── ExportedFlags.java.template
│ │ │ ├── FakeFeatureFlagsImpl.java.template
│ │ │ ├── FeatureFlags.java.template
│ │ │ ├── FeatureFlagsImpl.deviceConfig.java.template
│ │ │ ├── FeatureFlagsImpl.exported.java.template
│ │ │ ├── FeatureFlagsImpl.new_storage.java.template
│ │ │ ├── FeatureFlagsImpl.test_mode.java.template
│ │ │ ├── Flags.java.template
│ │ │ ├── cpp_exported_header.template
│ │ │ ├── cpp_source_file.template
│ │ │ ├── rust.template
│ │ │ └── rust_test.template
│ │ └── tests/
│ │ ├── AconfigHostTest.java
│ │ ├── AconfigTest.java
│ │ ├── AndroidManifest.xml
│ │ ├── aconfig_exported_mode_test.cpp
│ │ ├── aconfig_exported_mode_test.rs
│ │ ├── aconfig_force_read_only_mode_test.cpp
│ │ ├── aconfig_force_read_only_mode_test.rs
│ │ ├── aconfig_prod_mode_test.rs
│ │ ├── aconfig_test.cpp
│ │ ├── aconfig_test_mode_test.rs
│ │ ├── aconfig_test_test_variant.cpp
│ │ ├── first.values
│ │ ├── read_only_test.aconfig
│ │ ├── read_only_test.values
│ │ ├── second.values
│ │ ├── storage_test_1.aconfig
│ │ ├── storage_test_1.values
│ │ ├── storage_test_2.aconfig
│ │ ├── storage_test_2.values
│ │ ├── storage_test_4.aconfig
│ │ ├── storage_test_4.values
│ │ ├── test.aconfig
│ │ ├── test_exported.aconfig
│ │ ├── test_force_read_only.aconfig
│ │ ├── test_second_package.aconfig
│ │ └── third.values
│ ├── aconfig_device_paths/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── mainline_aconfig_flags_paths.txt
│ │ ├── partition_aconfig_flags_paths.txt
│ │ ├── src/
│ │ │ ├── DeviceProtosTemplate.java
│ │ │ ├── DeviceProtosTestUtilTemplate.java
│ │ │ ├── HostDeviceProtosTemplate.java
│ │ │ └── lib.rs
│ │ └── test/
│ │ ├── Android.bp
│ │ ├── AndroidManifest.xml
│ │ └── src/
│ │ └── DeviceProtosTestUtilTest.java
│ ├── aconfig_flags/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── flags.aconfig
│ │ └── src/
│ │ └── lib.rs
│ ├── aconfig_protos/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── build.rs
│ │ ├── jarjar-nano-rules.txt
│ │ ├── protos/
│ │ │ ├── aconfig.proto
│ │ │ └── aconfig_internal.proto
│ │ └── src/
│ │ └── lib.rs
│ ├── aconfig_storage_file/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── aconfig_storage_file.cpp
│ │ ├── build.rs
│ │ ├── include/
│ │ │ └── aconfig_storage/
│ │ │ └── aconfig_storage_file.hpp
│ │ ├── protos/
│ │ │ └── aconfig_storage_metadata.proto
│ │ ├── src/
│ │ │ ├── flag_info.rs
│ │ │ ├── flag_table.rs
│ │ │ ├── flag_value.rs
│ │ │ ├── lib.rs
│ │ │ ├── main.rs
│ │ │ ├── package_table.rs
│ │ │ ├── protos.rs
│ │ │ ├── sip_hasher13.rs
│ │ │ └── test_utils.rs
│ │ ├── srcs/
│ │ │ └── android/
│ │ │ └── aconfig/
│ │ │ └── storage/
│ │ │ ├── AconfigStorageException.java
│ │ │ ├── ByteBufferReader.java
│ │ │ ├── FileType.java
│ │ │ ├── FlagTable.java
│ │ │ ├── FlagType.java
│ │ │ ├── FlagValueList.java
│ │ │ ├── PackageTable.java
│ │ │ ├── SipHasher13.java
│ │ │ ├── StorageFileProvider.java
│ │ │ └── TableUtils.java
│ │ └── tests/
│ │ ├── Android.bp
│ │ ├── AndroidManifest.xml
│ │ ├── AndroidStorageJaveTest.xml
│ │ ├── data/
│ │ │ ├── v1/
│ │ │ │ ├── flag_v1.info
│ │ │ │ └── flag_v1.val
│ │ │ └── v2/
│ │ │ ├── flag_v2.info
│ │ │ └── flag_v2.val
│ │ ├── jarjar.txt
│ │ ├── srcs/
│ │ │ ├── ByteBufferReaderTest.java
│ │ │ ├── FlagTableTest.java
│ │ │ ├── FlagValueListTest.java
│ │ │ ├── PackageTableTest.java
│ │ │ ├── SipHasher13Test.java
│ │ │ ├── StorageFileProviderTest.java
│ │ │ └── TestDataUtils.java
│ │ └── storage_file_test.cpp
│ ├── aconfig_storage_read_api/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── aconfig_storage_read_api.cpp
│ │ ├── build.rs
│ │ ├── include/
│ │ │ └── aconfig_storage/
│ │ │ └── aconfig_storage_read_api.hpp
│ │ ├── src/
│ │ │ ├── flag_info_query.rs
│ │ │ ├── flag_table_query.rs
│ │ │ ├── flag_value_query.rs
│ │ │ ├── lib.rs
│ │ │ ├── mapped_file.rs
│ │ │ └── package_table_query.rs
│ │ ├── srcs/
│ │ │ ├── android/
│ │ │ │ ├── aconfig/
│ │ │ │ │ └── storage/
│ │ │ │ │ ├── AconfigStorageReadAPI.java
│ │ │ │ │ ├── FlagReadContext.java
│ │ │ │ │ └── PackageReadContext.java
│ │ │ │ └── os/
│ │ │ │ └── flagging/
│ │ │ │ ├── PlatformAconfigPackage.java
│ │ │ │ └── PlatformAconfigPackageInternal.java
│ │ │ └── lib.rs
│ │ └── tests/
│ │ ├── AconfigStorageReadFunctionalTest.xml
│ │ ├── Android.bp
│ │ ├── AndroidManifest.xml
│ │ ├── data/
│ │ │ ├── v1/
│ │ │ │ ├── flag_v1.info
│ │ │ │ └── flag_v1.val
│ │ │ └── v2/
│ │ │ ├── flag_v2.info
│ │ │ └── flag_v2.val
│ │ ├── functional/
│ │ │ └── srcs/
│ │ │ ├── AconfigStorageReadAPITest.java
│ │ │ ├── PlatformAconfigPackageInternalTest.java
│ │ │ └── PlatformAconfigPackageTest.java
│ │ ├── storage_read_api_test.cpp
│ │ └── storage_read_api_test.rs
│ ├── aconfig_storage_write_api/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── aconfig_storage_write_api.cpp
│ │ ├── build.rs
│ │ ├── include/
│ │ │ └── aconfig_storage/
│ │ │ └── aconfig_storage_write_api.hpp
│ │ ├── src/
│ │ │ ├── flag_info_update.rs
│ │ │ ├── flag_value_update.rs
│ │ │ ├── lib.rs
│ │ │ ├── mapped_file.rs
│ │ │ └── test_utils.rs
│ │ └── tests/
│ │ ├── Android.bp
│ │ ├── flag.info
│ │ ├── flag.val
│ │ ├── storage_write_api_test.cpp
│ │ └── storage_write_api_test.rs
│ ├── aflags/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ └── src/
│ │ ├── aconfig_storage_source.rs
│ │ ├── device_config_source.rs
│ │ ├── load_protos.rs
│ │ └── main.rs
│ ├── convert_finalized_flags/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── extended_flags_list_35.txt
│ │ └── src/
│ │ ├── lib.rs
│ │ └── main.rs
│ ├── exported_flag_check/
│ │ ├── Android.bp
│ │ ├── Cargo.toml
│ │ ├── allow_flag_list.txt
│ │ ├── allow_package_list.txt
│ │ ├── src/
│ │ │ ├── main.rs
│ │ │ └── utils.rs
│ │ └── tests/
│ │ ├── api-signature-file.txt
│ │ ├── finalized-flags.txt
│ │ ├── flags.declarations
│ │ ├── flags.protobuf
│ │ ├── flags.values
│ │ └── generate-flags-protobuf.sh
│ ├── fake_device_config/
│ │ ├── Android.bp
│ │ └── src/
│ │ └── android/
│ │ ├── os/
│ │ │ ├── Build.java
│ │ │ └── flagging/
│ │ │ ├── AconfigPackage.java
│ │ │ ├── AconfigPackageInternal.java
│ │ │ ├── PlatformAconfigPackage.java
│ │ │ └── PlatformAconfigPackageInternal.java
│ │ └── util/
│ │ └── Log.java
│ └── overrideflags/
│ └── overrideflags.py
├── acp/
│ ├── Android.bp
│ ├── README
│ └── acp.c
├── apicheck/
│ ├── Android.bp
│ └── etc/
│ └── apicheck
├── atree/
│ ├── Android.bp
│ ├── atree.cpp
│ ├── files.cpp
│ ├── files.h
│ ├── fs.cpp
│ ├── fs.h
│ └── options.h
├── auto_gen_test_config.py
├── auto_gen_test_config_test.py
├── brillo-clang-format
├── build-runfiles.cc
├── canoninja/
│ ├── README.md
│ ├── canoninja.go
│ ├── canoninja_test.go
│ ├── cmd/
│ │ └── canoninja.go
│ └── go.mod
├── characteristics_rro_generator.py
├── check-flagged-apis/
│ ├── Android.bp
│ ├── OWNERS
│ ├── check-flagged-apis.sh
│ └── src/
│ └── com/
│ └── android/
│ └── checkflaggedapis/
│ ├── CheckFlaggedApisTest.kt
│ └── Main.kt
├── check_elf_file.py
├── check_identical_lib.sh
├── check_radio_versions.py
├── compare_builds.py
├── compliance/
│ ├── Android.bp
│ ├── README.md
│ ├── cmd/
│ │ ├── checkmetadata/
│ │ │ ├── checkmetadata.go
│ │ │ └── checkmetadata_test.go
│ │ ├── checkshare/
│ │ │ ├── checkshare.go
│ │ │ └── checkshare_test.go
│ │ ├── dumpgraph/
│ │ │ ├── dumpgraph.go
│ │ │ └── dumpgraph_test.go
│ │ ├── dumpresolutions/
│ │ │ ├── dumpresolutions.go
│ │ │ └── dumpresolutions_test.go
│ │ ├── htmlnotice/
│ │ │ ├── htmlnotice.go
│ │ │ └── htmlnotice_test.go
│ │ ├── listshare/
│ │ │ ├── listshare.go
│ │ │ └── listshare_test.go
│ │ ├── rtrace/
│ │ │ ├── rtrace.go
│ │ │ └── rtrace_test.go
│ │ ├── shippedlibs/
│ │ │ ├── shippedlibs.go
│ │ │ └── shippedlibs_test.go
│ │ ├── testdata/
│ │ │ ├── README.md
│ │ │ ├── firstparty/
│ │ │ │ ├── FIRST_PARTY_LICENSE
│ │ │ │ ├── METADATA
│ │ │ │ ├── application.meta_lic
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ └── bin3.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ ├── highest.apex.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── liba.so.meta_lic
│ │ │ │ ├── libb.so.meta_lic
│ │ │ │ ├── libc.a.meta_lic
│ │ │ │ └── libd.so.meta_lic
│ │ │ ├── notice/
│ │ │ │ ├── METADATA
│ │ │ │ ├── NOTICE_LICENSE
│ │ │ │ ├── application.meta_lic
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ └── bin3.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ ├── highest.apex.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── liba.so.meta_lic
│ │ │ │ ├── libb.so.meta_lic
│ │ │ │ ├── libc.a.meta_lic
│ │ │ │ └── libd.so.meta_lic
│ │ │ ├── proprietary/
│ │ │ │ ├── METADATA
│ │ │ │ ├── PROPRIETARY_LICENSE
│ │ │ │ ├── application.meta_lic
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ └── bin3.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ ├── highest.apex.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── liba.so.meta_lic
│ │ │ │ ├── libb.so.meta_lic
│ │ │ │ ├── libc.a.meta_lic
│ │ │ │ └── libd.so.meta_lic
│ │ │ ├── reciprocal/
│ │ │ │ ├── METADATA
│ │ │ │ ├── RECIPROCAL_LICENSE
│ │ │ │ ├── application.meta_lic
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ └── bin3.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ ├── highest.apex.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── liba.so.meta_lic
│ │ │ │ ├── libb.so.meta_lic
│ │ │ │ ├── libc.a.meta_lic
│ │ │ │ └── libd.so.meta_lic
│ │ │ ├── regressconcur/
│ │ │ │ ├── README.md
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ ├── bin3.meta_lic
│ │ │ │ │ ├── bin4.meta_lic
│ │ │ │ │ ├── bin5.meta_lic
│ │ │ │ │ ├── bin6.meta_lic
│ │ │ │ │ ├── bin7.meta_lic
│ │ │ │ │ ├── bin8.meta_lic
│ │ │ │ │ └── bin9.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── lib1.a.meta_lic
│ │ │ │ ├── lib2.a.meta_lic
│ │ │ │ ├── lib3.a.meta_lic
│ │ │ │ ├── lib4.a.meta_lic
│ │ │ │ ├── lib5.a.meta_lic
│ │ │ │ ├── lib6.a.meta_lic
│ │ │ │ ├── lib7.a.meta_lic
│ │ │ │ ├── lib8.a.meta_lic
│ │ │ │ └── lib9.a.meta_lic
│ │ │ ├── regressgpl1/
│ │ │ │ ├── README.md
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ └── bin3.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── libapache.so.meta_lic
│ │ │ │ ├── libc++.so.meta_lic
│ │ │ │ └── libgpl.so.meta_lic
│ │ │ ├── regressgpl2/
│ │ │ │ ├── README.md
│ │ │ │ ├── bin/
│ │ │ │ │ ├── bin1.meta_lic
│ │ │ │ │ ├── bin2.meta_lic
│ │ │ │ │ └── bin3.meta_lic
│ │ │ │ ├── container.zip.meta_lic
│ │ │ │ └── lib/
│ │ │ │ ├── libapache.so.meta_lic
│ │ │ │ ├── libc++.so.meta_lic
│ │ │ │ └── libgpl.so.meta_lic
│ │ │ └── restricted/
│ │ │ ├── METADATA
│ │ │ ├── METADATA.android
│ │ │ ├── RESTRICTED_LICENSE
│ │ │ ├── application.meta_lic
│ │ │ ├── bin/
│ │ │ │ ├── bin1.meta_lic
│ │ │ │ ├── bin2.meta_lic
│ │ │ │ └── bin3.meta_lic
│ │ │ ├── container.zip.meta_lic
│ │ │ ├── highest.apex.meta_lic
│ │ │ └── lib/
│ │ │ ├── liba.so.meta_lic
│ │ │ ├── libb.so.meta_lic
│ │ │ ├── libc.a.meta_lic
│ │ │ └── libd.so.meta_lic
│ │ ├── textnotice/
│ │ │ ├── textnotice.go
│ │ │ └── textnotice_test.go
│ │ └── xmlnotice/
│ │ ├── xmlnotice.go
│ │ └── xmlnotice_test.go
│ ├── condition.go
│ ├── condition_test.go
│ ├── conditionset.go
│ ├── conditionset_test.go
│ ├── doc.go
│ ├── go.mod
│ ├── go.work
│ ├── graph.go
│ ├── noticeindex.go
│ ├── policy_policy.go
│ ├── policy_policy_test.go
│ ├── policy_resolve.go
│ ├── policy_resolve_test.go
│ ├── policy_resolvenotices.go
│ ├── policy_resolvenotices_test.go
│ ├── policy_resolveprivacy.go
│ ├── policy_resolveprivacy_test.go
│ ├── policy_resolveshare.go
│ ├── policy_resolveshare_test.go
│ ├── policy_shareprivacyconflicts.go
│ ├── policy_shareprivacyconflicts_test.go
│ ├── policy_shipped.go
│ ├── policy_shipped_test.go
│ ├── policy_walk.go
│ ├── policy_walk_test.go
│ ├── projectmetadata/
│ │ ├── Android.bp
│ │ ├── projectmetadata.go
│ │ └── projectmetadata_test.go
│ ├── readgraph.go
│ ├── readgraph_test.go
│ ├── resolution.go
│ ├── resolutionset.go
│ ├── resolutionset_test.go
│ ├── test_util.go
│ └── testfs/
│ ├── Android.bp
│ └── testfs.go
├── dependency_mapper/
│ ├── Android.bp
│ ├── OWNERS
│ ├── README.md
│ ├── proto/
│ │ └── dependency.proto
│ ├── src/
│ │ └── com/
│ │ └── android/
│ │ └── dependencymapper/
│ │ ├── ClassDependenciesVisitor.java
│ │ ├── ClassDependencyAnalyzer.java
│ │ ├── ClassDependencyData.java
│ │ ├── ClassRelevancyFilter.java
│ │ ├── DependencyMapper.java
│ │ ├── JavaSourceAnalyzer.java
│ │ ├── JavaSourceData.java
│ │ ├── Main.java
│ │ └── Utils.java
│ └── tests/
│ ├── res/
│ │ ├── testdata/
│ │ │ ├── annotation/
│ │ │ │ ├── AnnotationUsage.java
│ │ │ │ ├── RuntimeAnnotation.java
│ │ │ │ └── SourceAnnotation.java
│ │ │ ├── constants/
│ │ │ │ ├── ConstantDefinition.java
│ │ │ │ └── ConstantUsage.java
│ │ │ ├── inheritance/
│ │ │ │ ├── BaseClass.java
│ │ │ │ ├── BaseImpl.java
│ │ │ │ └── InheritanceUsage.java
│ │ │ └── methods/
│ │ │ ├── FieldUsage.java
│ │ │ ├── MethodUsage.java
│ │ │ ├── ReferenceClass1.java
│ │ │ └── ReferenceClass2.java
│ │ └── testfiles/
│ │ ├── dependency-mapper-test-data.jar
│ │ └── sources.rsp
│ └── src/
│ └── com/
│ └── android/
│ └── dependencymapper/
│ ├── ClassDependencyAnalyzerTest.java
│ ├── ClassRelevancyFilterTest.java
│ ├── DependencyMapperTest.java
│ ├── JavaSourceAnalyzerTest.java
│ └── UtilsTest.java
├── docker/
│ ├── .gitignore
│ ├── Dockerfile
│ └── README.md
├── droiddoc/
│ ├── Android.bp
│ ├── LICENSE
│ ├── README
│ ├── templates-pdk/
│ │ ├── assets/
│ │ │ ├── android-developer-core.css
│ │ │ ├── android-developer-docs-devguide.css
│ │ │ ├── android-developer-docs.css
│ │ │ ├── android-developer-docs.js
│ │ │ ├── android-developer-reference.js
│ │ │ ├── android-developer-resource-browser.css
│ │ │ ├── android-developer-resource-browser.js
│ │ │ ├── carousel.js
│ │ │ ├── customizations.js
│ │ │ ├── design/
│ │ │ │ ├── default.css
│ │ │ │ └── default.js
│ │ │ ├── jquery-history.js
│ │ │ ├── microtemplate.js
│ │ │ ├── prettify.js
│ │ │ ├── search_autocomplete.js
│ │ │ ├── style.css
│ │ │ └── yui-3.3.0-reset-min.css
│ │ ├── components/
│ │ │ └── masthead.cs
│ │ ├── customizations.cs
│ │ ├── data.hdf
│ │ ├── docpage.cs
│ │ ├── footer.cs
│ │ ├── head_tag.cs
│ │ ├── header_tabs.cs
│ │ ├── jd_lists_unified.cs
│ │ ├── sampleindex.cs
│ │ ├── sdkpage.cs
│ │ └── trailer.cs
│ └── test/
│ ├── generics/
│ │ └── src/
│ │ └── com/
│ │ └── android/
│ │ └── generics/
│ │ ├── AbsListView.java
│ │ ├── Adapter.java
│ │ ├── AdapterView.java
│ │ ├── Bar.java
│ │ ├── Foo.java
│ │ ├── FooBar.java
│ │ ├── Iface.java
│ │ ├── ListAdapter.java
│ │ ├── TestComparable.java
│ │ └── TestEnum.java
│ └── stubs/
│ ├── expected/
│ │ └── com/
│ │ └── android/
│ │ └── stubs/
│ │ ├── Annot.java
│ │ ├── InterfaceEnum.java
│ │ ├── Parent.java
│ │ ├── SomeEnum.java
│ │ ├── Types.java
│ │ ├── a/
│ │ │ ├── A.java
│ │ │ └── SomeInterface.java
│ │ └── b/
│ │ └── B.java
│ ├── func.sh
│ ├── run.sh
│ └── src/
│ └── com/
│ └── android/
│ └── stubs/
│ ├── Annot.java
│ ├── InterfaceEnum.java
│ ├── Parent.java
│ ├── SomeEnum.java
│ ├── Types.java
│ ├── a/
│ │ ├── A.java
│ │ └── SomeInterface.java
│ ├── b/
│ │ └── B.java
│ └── hidden/
│ ├── Hidden.java
│ ├── HiddenOuter.java
│ └── PackagePrivate.java
├── edit_monitor/
│ ├── Android.bp
│ ├── OWNERS
│ ├── daemon_manager.py
│ ├── daemon_manager_test.py
│ ├── edit_monitor.py
│ ├── edit_monitor_integration_test.py
│ ├── edit_monitor_test.py
│ ├── main.py
│ ├── proto/
│ │ └── edit_event.proto
│ ├── utils.py
│ └── utils_test.py
├── envsetup/
│ ├── run_envsetup_tests
│ └── spam_for_lunch
├── event_log_tags.py
├── exercise_compare_builds
├── extract_kernel.py
├── fat16copy.py
├── filelistdiff/
│ ├── Android.bp
│ ├── OWNERS
│ ├── allowlist
│ ├── allowlist_next
│ └── file_list_diff.py
├── fileslist_util.py
├── finalization/
│ ├── OWNERS
│ ├── README.md
│ ├── build-step-0-and-m.sh
│ ├── build-step-0.sh
│ ├── build-step-1-and-2.sh
│ ├── build-step-1-and-m.sh
│ ├── build-step-1.sh
│ ├── build_soong_java_droidstubs.go.apply_hack.diff
│ ├── build_soong_java_droidstubs.go.revert_hack.diff
│ ├── cleanup.sh
│ ├── command-line-options.sh
│ ├── dryrun-cleanup.sh
│ ├── dryrun-step-1-and-2.sh
│ ├── dryrun-step-1.sh
│ ├── environment.sh
│ ├── finalize-sdk-rel.sh
│ ├── finalize-sdk-resources.sh
│ ├── finalize-vintf-resources.sh
│ ├── frameworks_base.apply_hack.diff
│ ├── frameworks_base.revert_hack.diff
│ ├── localonly-steps.sh
│ ├── step-0.sh
│ ├── step-1.sh
│ └── step-2.sh
├── find_static_candidates.py
├── findleaves.py
├── fixlinebreaks.sh
├── fs_config/
│ ├── Android.bp
│ ├── OWNERS
│ ├── README.md
│ ├── end_to_end_test/
│ │ ├── config.fs
│ │ ├── product_fs_config_dirs
│ │ ├── product_fs_config_files
│ │ ├── run_test.sh
│ │ ├── system_fs_config_dirs
│ │ ├── system_fs_config_files
│ │ ├── vendor_fs_config_dirs
│ │ └── vendor_fs_config_files
│ ├── fs_config.c
│ ├── fs_config.go
│ ├── fs_config_generator.py
│ ├── pylintrc
│ └── test_fs_config_generator.py
├── generate-enforce-rro-android-manifest.py
├── generate-notice-files.py
├── generate-self-extracting-archive.py
├── generate_gts_shared_report.py
├── ide_query/
│ ├── OWNERS
│ ├── cc_analyzer/
│ │ ├── Android.bp
│ │ ├── README.md
│ │ ├── analyzer.cc
│ │ ├── analyzer.h
│ │ ├── builtin_headers.cc
│ │ ├── builtin_headers.h
│ │ ├── include_scanner.cc
│ │ ├── include_scanner.h
│ │ └── main.cc
│ ├── cc_analyzer_proto/
│ │ ├── Android.bp
│ │ ├── cc_analyzer.pb.go
│ │ ├── cc_analyzer.proto
│ │ └── regen.sh
│ ├── go.mod
│ ├── go.work
│ ├── go.work.sum
│ ├── ide_query.go
│ ├── ide_query.sh
│ ├── ide_query_proto/
│ │ ├── ide_query.pb.go
│ │ ├── ide_query.proto
│ │ └── regen.sh
│ └── prober_scripts/
│ ├── cpp/
│ │ ├── Android.bp
│ │ ├── foo.proto
│ │ └── general.cc
│ ├── cpp_suite.textpb
│ ├── ide_query.out
│ ├── jvm/
│ │ ├── Android.bp
│ │ ├── Bar.java
│ │ ├── Foo.java
│ │ ├── ide_query.out
│ │ ├── other/
│ │ │ └── Other.java
│ │ └── suite.textpb
│ └── regen.sh
├── java-event-log-tags.py
├── libhost/
│ ├── Android.bp
│ ├── CopyFile.c
│ └── include/
│ └── host/
│ └── CopyFile.h
├── list_files.py
├── lunchable
├── merge-event-log-tags.py
├── missing_soong_module_info.py
├── mk2bp_catalog.py
├── mk2bp_partition.py
├── normalize_path.py
├── otatools_package/
│ └── Android.bp
├── perf/
│ ├── benchmarks
│ ├── format_benchmarks
│ ├── pretty.py
│ └── utils.py
├── post_process_props.py
├── post_process_props_unittest.xml
├── print_module_licenses.sh
├── product_config/
│ ├── Android.bp
│ ├── MANIFEST.MF
│ ├── TEST_MANIFEST.MF
│ ├── inherit_tree.py
│ ├── src/
│ │ └── com/
│ │ └── android/
│ │ └── build/
│ │ └── config/
│ │ ├── CommandException.java
│ │ ├── ConfigBase.java
│ │ ├── ConvertMakeToGenericConfig.java
│ │ ├── CsvParser.java
│ │ ├── DumpConfigParser.java
│ │ ├── ErrorReporter.java
│ │ ├── Errors.java
│ │ ├── FlatConfig.java
│ │ ├── FlattenConfig.java
│ │ ├── GenericConfig.java
│ │ ├── Kati.java
│ │ ├── KatiCommand.java
│ │ ├── KatiCommandImpl.java
│ │ ├── KatiImpl.java
│ │ ├── Main.java
│ │ ├── MakeConfig.java
│ │ ├── MakeWriter.java
│ │ ├── Options.java
│ │ ├── OutputChecker.java
│ │ ├── Position.java
│ │ ├── RegexSet.java
│ │ ├── Str.java
│ │ ├── Value.java
│ │ └── VarType.java
│ ├── test/
│ │ └── com/
│ │ └── android/
│ │ └── build/
│ │ └── config/
│ │ ├── CsvParserTest.java
│ │ ├── ErrorReporterTest.java
│ │ ├── OptionsTest.java
│ │ ├── PositionTest.java
│ │ ├── TestErrors.java
│ │ └── TestRunner.java
│ └── test.sh
├── protos/
│ ├── Android.bp
│ └── metadata_file.proto
├── rbcrun/
│ ├── Android.bp
│ ├── README.md
│ ├── go.mod
│ ├── go.sum
│ ├── host.go
│ ├── host_test.go
│ ├── rbcrun/
│ │ └── rbcrun.go
│ └── testdata/
│ ├── bzl_loads_scl.bzl
│ ├── bzl_loads_scl_2.bzl
│ ├── file_ops.star
│ ├── load.star
│ ├── module1.star
│ ├── module2.star
│ ├── scl_incorrectly_loads_bzl.scl
│ ├── shell.star
│ └── test_scl.scl
├── record-finalized-flags/
│ ├── .gitignore
│ ├── Android.bp
│ ├── Cargo.toml
│ ├── OWNERS
│ ├── src/
│ │ ├── api_signature_files.rs
│ │ ├── finalized_flags.rs
│ │ ├── flag_values.rs
│ │ └── main.rs
│ └── tests/
│ ├── api-signature-file.txt
│ ├── finalized-flags.txt
│ ├── flags.declarations
│ ├── flags.protobuf
│ ├── flags.values
│ └── generate-flags-protobuf.sh
├── releasetools/
│ ├── Android.bp
│ ├── OWNERS
│ ├── add_img_to_target_files.py
│ ├── apex_utils.py
│ ├── blockimgdiff.py
│ ├── build_image.py
│ ├── build_super_image.py
│ ├── care_map_pb2.py
│ ├── check_ota_package_signature.py
│ ├── check_partition_sizes.py
│ ├── check_target_files_signatures.py
│ ├── check_target_files_vintf.py
│ ├── common.py
│ ├── create_brick_ota.py
│ ├── edify_generator.py
│ ├── find_shareduid_violation.py
│ ├── fsverity_metadata_generator.py
│ ├── images.py
│ ├── img_from_target_files.py
│ ├── jarjar-rules.txt
│ ├── make_recovery_patch.py
│ ├── merge/
│ │ ├── Android.bp
│ │ ├── OWNERS
│ │ ├── merge_builds.py
│ │ ├── merge_compatibility_checks.py
│ │ ├── merge_dexopt.py
│ │ ├── merge_meta.py
│ │ ├── merge_target_files.py
│ │ ├── merge_utils.py
│ │ ├── test_merge_compatibility_checks.py
│ │ ├── test_merge_meta.py
│ │ └── test_merge_utils.py
│ ├── merge_ota.py
│ ├── non_ab_ota.py
│ ├── ota_from_raw_img.py
│ ├── ota_from_target_files.py
│ ├── ota_metadata.proto
│ ├── ota_metadata_pb2.py
│ ├── ota_package_parser.py
│ ├── ota_signing_utils.py
│ ├── ota_utils.py
│ ├── payload_signer.py
│ ├── pylintrc
│ ├── rangelib.py
│ ├── sign_apex.py
│ ├── sign_target_files_apks.py
│ ├── sparse_img.py
│ ├── target_files_diff.py
│ ├── test_add_img_to_target_files.py
│ ├── test_apex_utils.py
│ ├── test_blockimgdiff.py
│ ├── test_build_image.py
│ ├── test_check_partition_sizes.py
│ ├── test_check_target_files_vintf.py
│ ├── test_common.py
│ ├── test_merge_ota.py
│ ├── test_non_ab_ota.py
│ ├── test_ota_from_target_files.py
│ ├── test_ota_utils.py
│ ├── test_rangelib.py
│ ├── test_sign_apex.py
│ ├── test_sign_target_files_apks.py
│ ├── test_utils.py
│ ├── test_validate_target_files.py
│ ├── test_verity_utils.py
│ ├── testdata/
│ │ ├── TestApp.apk
│ │ ├── apexkeys_framework.txt
│ │ ├── apexkeys_framework_conflict.txt
│ │ ├── apexkeys_merge.txt
│ │ ├── apexkeys_vendor.txt
│ │ ├── apkcerts_framework.txt
│ │ ├── apkcerts_merge.txt
│ │ ├── apkcerts_vendor.txt
│ │ ├── foo.apex
│ │ ├── has_apk.apex
│ │ ├── media.x509.pem
│ │ ├── merge_config_framework_item_list
│ │ ├── payload_signer.sh
│ │ ├── platform.x509.pem
│ │ ├── signing_helper.sh
│ │ ├── testkey.key
│ │ ├── testkey.pk8
│ │ ├── testkey.pubkey.pem
│ │ ├── testkey.x509.pem
│ │ ├── testkey_EC.key
│ │ ├── testkey_RSA4096.key
│ │ ├── testkey_mincrypt
│ │ ├── testkey_with_passwd.key
│ │ ├── testkey_with_passwd.pk8
│ │ ├── testkey_with_passwd.x509.pem
│ │ ├── verity.x509.pem
│ │ ├── verity_mincrypt
│ │ └── vintf/
│ │ ├── kernel/
│ │ │ └── SYSTEM/
│ │ │ └── etc/
│ │ │ └── vintf/
│ │ │ └── compatibility_matrix.1.xml
│ │ ├── matrix_incompat/
│ │ │ └── SYSTEM/
│ │ │ └── etc/
│ │ │ └── vintf/
│ │ │ └── compatibility_matrix.1.xml
│ │ ├── sku_compat/
│ │ │ ├── ODM/
│ │ │ │ └── etc/
│ │ │ │ └── vintf/
│ │ │ │ └── manifest_sku.xml
│ │ │ └── SYSTEM/
│ │ │ └── etc/
│ │ │ └── vintf/
│ │ │ └── compatibility_matrix.1.xml
│ │ └── sku_incompat/
│ │ ├── ODM/
│ │ │ └── etc/
│ │ │ └── vintf/
│ │ │ └── manifest_sku.xml
│ │ └── SYSTEM/
│ │ └── etc/
│ │ └── vintf/
│ │ └── compatibility_matrix.1.xml
│ ├── validate_target_files.py
│ └── verity_utils.py
├── sbom/
│ ├── Android.bp
│ ├── compliance_metadata.py
│ ├── gen_notice_xml.py
│ ├── gen_sbom.py
│ ├── generate-sbom-framework_res.py
│ ├── generate-sbom.py
│ ├── sbom_data.py
│ ├── sbom_data_test.py
│ ├── sbom_writers.py
│ ├── sbom_writers_test.py
│ └── testdata/
│ ├── expected_json_sbom.spdx.json
│ ├── expected_tagvalue_sbom.spdx
│ ├── expected_tagvalue_sbom_doc_describes_file.spdx
│ └── expected_tagvalue_sbom_unbundled.spdx
├── signapk/
│ ├── Android.bp
│ ├── OWNERS
│ ├── SignApk.mf
│ ├── src/
│ │ └── com/
│ │ └── android/
│ │ └── signapk/
│ │ ├── CountingOutputStream.java
│ │ └── SignApk.java
│ └── test/
│ └── run
├── signtos/
│ ├── Android.bp
│ ├── SignTos.java
│ └── SignTos.mf
├── soong_to_convert.py
├── stub_diff_analyzer.py
├── test_extract_kernel.py
├── test_post_process_props.py
├── tool_event_logger/
│ ├── Android.bp
│ ├── OWNERS
│ ├── proto/
│ │ └── tool_event.proto
│ ├── tool_event_logger.py
│ └── tool_event_logger_test.py
├── warn/
│ ├── .pylintrc
│ ├── OWNERS
│ ├── __init__.py
│ ├── android_project_list.py
│ ├── chrome_project_list.py
│ ├── cpp_warn_patterns.py
│ ├── html_writer.py
│ ├── java_warn_patterns.py
│ ├── make_warn_patterns.py
│ ├── other_warn_patterns.py
│ ├── severity.py
│ ├── tidy_warn_patterns.py
│ ├── warn.py
│ └── warn_common.py
├── warn.py
├── whichgit
├── zipalign/
│ ├── Android.bp
│ ├── OWNERS
│ ├── README.txt
│ ├── ZipAlign.cpp
│ ├── ZipAlignMain.cpp
│ ├── ZipEntry.cpp
│ ├── ZipEntry.h
│ ├── ZipFile.cpp
│ ├── ZipFile.h
│ ├── include/
│ │ └── ZipAlign.h
│ └── tests/
│ └── src/
│ └── align_test.cpp
└── ziptime/
├── Android.bp
├── README.txt
├── ZipEntry.cpp
├── ZipEntry.h
├── ZipFile.cpp
├── ZipFile.h
└── ZipTime.cpp
================================================
FILE CONTENTS
================================================
================================================
FILE: .gitignore
================================================
*.iml
*.pyc
*.swp
blueprint/
kati/
soong/
================================================
FILE: Android.bp
================================================
// Copyright 2024 Google Inc. All rights reserved.
//
// 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.
package {
default_applicable_licenses: ["Android-Apache-2.0"],
}
// Package the minimal files required to run envsetup.sh in the test
// environment.
genrule {
name: "envsetup_minimum.zip",
visibility: [
"//build/make/tests:__subpackages__",
],
tools: [
"soong_zip",
],
srcs: [
"envsetup.sh",
"shell_utils.sh",
"core/envsetup.mk",
],
out: ["envsetup.zip"],
cmd: "$(location soong_zip) -o $(out) -D build/make",
}
================================================
FILE: Changes.md
================================================
# Build System Changes for Android.mk/Android.bp Writers
## Soong genrules are now sandboxed
Previously, soong genrules could access any files in the source tree, without specifying them as
inputs. This makes them incorrect in incremental builds, and incompatible with RBE and Bazel.
Now, genrules are sandboxed so they can only access their listed srcs. Modules denylisted in
genrule/allowlists.go are exempt from this. You can also set `BUILD_BROKEN_GENRULE_SANDBOXING`
in board config to disable this behavior.
## Partitions are no longer affected by previous builds
Partition builds used to include everything in their staging directories, and building an
individual module will install it to the staging directory. Thus, previously, `m mymodule` followed
by `m` would cause `mymodule` to be presinstalled on the device, even if it wasn't listed in
`PRODUCT_PACKAGES`.
This behavior has been changed, and now the partition images only include what they'd have if you
did a clean build. This behavior can be disabled by setting the
`BUILD_BROKEN_INCORRECT_PARTITION_IMAGES` environment variable or board config variable.
Manually adding make rules that build to the staging directories without going through the make
module system will not be compatible with this change. This includes many usages of
`LOCAL_POST_INSTALL_CMD`.
## Perform validation of Soong plugins
Each Soong plugin will require manual work to migrate to Bazel. In order to
minimize the manual work outside of build/soong, we are restricting plugins to
those that exist today and those in vendor or hardware directories.
If you need to extend the build system via a plugin, please reach out to the
build team via email android-building@googlegroups.com (external) for any
questions, or see [go/soong](http://go/soong) (internal).
To omit the validation, `BUILD_BROKEN_PLUGIN_VALIDATION` expects a
space-separated list of plugins to omit from the validation. This must be set
within a product configuration .mk file, board config .mk file, or buildspec.mk.
## Python 2 to 3 migration
Python 2 has been completely removed from the build. Please migrate any remaining usages to
Python 3, and remove any version-specific properties from bp files.
## Stop referencing sysprop_library directly from cc modules
For the migration to Bazel, we are no longer mapping sysprop_library targets
to their generated `cc_library` counterparts when dependning on them from a
cc module. Instead, directly depend on the generated module by prefixing the
module name with `lib`. For example, depending on the following module:
```
sysprop_library {
name: "foo",
srcs: ["foo.sysprop"],
}
```
from a module named `bar` can be done like so:
```
cc_library {
name: "bar",
srcs: ["bar.cc"],
deps: ["libfoo"],
}
```
Failure to do this will result in an error about a missing variant.
## Gensrcs starts disallowing depfile property
To migrate all gensrcs to Bazel, we are restricting the use of depfile property
because Bazel requires specifying the dependencies directly.
To fix existing uses, remove depfile and directly specify all the dependencies
in .bp files. For example:
```
gensrcs {
name: "framework-cppstream-protos",
tools: [
"aprotoc",
"protoc-gen-cppstream",
],
cmd: "mkdir -p $(genDir)/$(in) " +
"&& $(location aprotoc) " +
" --plugin=$(location protoc-gen-cppstream) " +
" -I . " +
" $(in) ",
srcs: [
"bar.proto",
],
output_extension: "srcjar",
}
```
where `bar.proto` imports `external.proto` would become
```
gensrcs {
name: "framework-cppstream-protos",
tools: [
"aprotoc",
"protoc-gen-cpptream",
],
tool_files: [
"external.proto",
],
cmd: "mkdir -p $(genDir)/$(in) " +
"&& $(location aprotoc) " +
" --plugin=$(location protoc-gen-cppstream) " +
" $(in) ",
srcs: [
"bar.proto",
],
output_extension: "srcjar",
}
```
as in https://android-review.googlesource.com/c/platform/frameworks/base/+/2125692/.
`BUILD_BROKEN_DEPFILE` can be used to allowlist usage of depfile in `gensrcs`.
If `depfile` is needed for generating javastream proto, `java_library` with `proto.type`
set `stream` is the alternative solution. Sees
https://android-review.googlesource.com/c/platform/packages/modules/Permission/+/2118004/
for an example.
## Genrule starts disallowing directory inputs
To better specify the inputs to the build, we are restricting use of directories
as inputs to genrules.
To fix existing uses, change inputs to specify the inputs and update the command
accordingly. For example:
```
genrule: {
name: "foo",
srcs: ["bar"],
cmd: "cp $(location bar)/*.xml $(gendir)",
...
}
```
would become
```
genrule: {
name: "foo",
srcs: ["bar/*.xml"],
cmd: "cp $(in) $(gendir)",
...
}
```
`BUILD_BROKEN_INPUT_DIR_MODULES` can be used to allowlist specific directories
with genrules that have input directories.
## Dexpreopt starts enforcing `` checks (for Java modules)
In order to construct correct class loader context for dexpreopt, build system
needs to know about the shared library dependencies of Java modules listed in
the `` tags in the manifest. Since the build system does not have
access to the manifest contents, that information must be present in the build
files. In simple cases Soong is able to infer it from its knowledge of Java SDK
libraries and the `libs` property in Android.bp, but in more complex cases it is
necessary to add the missing information in Android.bp/Android.mk manually.
To specify a list of libraries for a given modules, use:
* Android.bp properties: `uses_libs`, `optional_uses_libs`
* Android.mk variables: `LOCAL_USES_LIBRARIES`, `LOCAL_OPTIONAL_USES_LIBRARIES`
If a library is in `libs`, it usually should *not* be added to the above
properties, and Soong should be able to infer the `` tag. But
sometimes a library also needs additional information in its
Android.bp/Android.mk file (e.g. when it is a `java_library` rather than a
`java_sdk_library`, or when the library name is different from its module name,
or when the module is defined in Android.mk rather than Android.bp). In such
cases it is possible to tell the build system that the library provides a
`` with a given name (however, this is discouraged and will be
deprecated in the future, and it is recommended to fix the underlying problem):
* Android.bp property: `provides_uses_lib`
* Android.mk variable: `LOCAL_PROVIDES_USES_LIBRARY`
It is possible to disable the check on a per-module basis. When doing that it is
also recommended to disable dexpreopt, as disabling a failed check will result
in incorrect class loader context recorded in the .odex file, which will cause
class loader context mismatch and dexopt at first boot.
* Android.bp property: `enforce_uses_lib`
* Android.mk variable: `LOCAL_ENFORCE_USES_LIBRARIES`
Finally, it is possible to globally disable the check:
* For a given product: `PRODUCT_BROKEN_VERIFY_USES_LIBRARIES := true`
* On the command line: `RELAX_USES_LIBRARY_CHECK=true`
The environment variable overrides the product variable, so it is possible to
disable the check for a product, but quickly re-enable it for a local build.
## `LOCAL_REQUIRED_MODULES` requires listed modules to exist {#BUILD_BROKEN_MISSING_REQUIRED_MODULES}
Modules listed in `LOCAL_REQUIRED_MODULES`, `LOCAL_HOST_REQUIRED_MODULES` and
`LOCAL_TARGET_REQUIRED_MODULES` need to exist unless `ALLOW_MISSING_DEPENDENCIES`
is set.
To temporarily relax missing required modules check, use:
`BUILD_BROKEN_MISSING_REQUIRED_MODULES := true`
## Changes in system properties settings
### Product variables
System properties for each of the partition is supposed to be set via following
product config variables.
For system partition,
* `PRODUCT_SYSTEM_PROPERTIES`
* `PRODUCT_SYSTEM_DEFAULT_PROPERTIES` is highly discouraged. Will be deprecated.
For vendor partition,
* `PRODUCT_VENDOR_PROPERTIES`
* `PRODUCT_PROPERTY_OVERRIDES` is highly discouraged. Will be deprecated.
* `PRODUCT_DEFAULT_PROPERTY_OVERRIDES` is also discouraged. Will be deprecated.
For odm partition,
* `PRODUCT_ODM_PROPERTIES`
For system_ext partition,
* `PRODUCT_SYSTEM_EXT_PROPERTIES`
For product partition,
* `PRODUCT_PRODUCT_PROPERTIES`
### Duplication is not allowed within a partition
For each partition, having multiple sysprop assignments for the same name is
prohibited. For example, the following will now trigger an error:
`PRODUCT_VENDOR_PROPERTIES += foo=true foo=false`
Having duplication across partitions are still allowed. So, the following is
not an error:
`PRODUCT_VENDOR_PROPERTIES += foo=true`
`PRODUCT_SYSTEM_PROPERTIES += foo=false`
In that case, the final value is determined at runtime. The precedence is
* product
* odm
* vendor
* system_ext
* system
So, `foo` becomes `true` because vendor has higher priority than system.
To temporarily turn the build-time restriction off, use
`BUILD_BROKEN_DUP_SYSPROP := true`
### Optional assignments
System properties can now be set as optional using the new syntax:
`name ?= value`
Then the system property named `name` gets the value `value` only when there
is no other non-optional assignments having the same name. For example, the
following is allowed and `foo` gets `true`
`PRODUCT_VENDOR_PROPERTIES += foo=true foo?=false`
Note that the order between the optional and the non-optional assignments
doesn't matter. The following gives the same result as above.
`PRODUCT_VENDOR_PROPERTIES += foo?=false foo=true`
Optional assignments can be duplicated and in that case their order matters.
Specifically, the last one eclipses others.
`PRODUCT_VENDOR_PROPERTIES += foo?=apple foo?=banana foo?=mango`
With above, `foo` becomes `mango` since its the last one.
Note that this behavior is different from the previous behavior of preferring
the first one. To go back to the original behavior for compatability reason,
use:
`BUILD_BROKEN_DUP_SYSPROP := true`
## ELF prebuilts in `PRODUCT_COPY_FILES` {#BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES}
ELF prebuilts in `PRODUCT_COPY_FILES` that are installed into these paths are an
error:
* `/bin/*`
* `/lib/*`
* `/lib64/*`
Define prebuilt modules and add them to `PRODUCT_PACKAGES` instead.
To temporarily relax this check and restore the behavior prior to this change,
set `BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES := true` in `BoardConfig.mk`.
## COPY_HEADERS usage now produces warnings {#copy_headers}
We've considered `BUILD_COPY_HEADERS`/`LOCAL_COPY_HEADERS` to be deprecated for
a long time, and the places where it's been able to be used have shrinked over
the last several releases. Equivalent functionality is not available in Soong.
See the [build/soong/docs/best_practices.md#headers] for more information about
how best to handle headers in Android.
## `m4` is not available on `$PATH`
There is a prebuilt of it available in prebuilts/build-tools, and a make
variable `M4` that contains the path.
Beyond the direct usage, whenever you use bison or flex directly, they call m4
behind the scene, so you must set the M4 environment variable (and depend upon
it for incremental build correctness):
```
$(intermediates)/foo.c: .KATI_IMPLICIT_OUTPUTS := $(intermediates)/foo.h
$(intermediates)/foo.c: $(LOCAL_PATH)/foo.y $(M4) $(BISON) $(BISON_DATA)
M4=$(M4) $(BISON) ...
```
## Rules executed within limited environment
With `ALLOW_NINJA_ENV=false` (soon to be the default), ninja, and all the
rules/actions executed within it will only have access to a limited number of
environment variables. Ninja does not track when environment variables change
in order to trigger rebuilds, so changing behavior based on arbitrary variables
is not safe with incremental builds.
Kati and Soong can safely use environment variables, so the expectation is that
you'd embed any environment variables that you need to use within the command
line generated by those tools. See the [export section](#export_keyword) below
for examples.
For a temporary workaround, you can set `ALLOW_NINJA_ENV=true` in your
environment to restore the previous behavior, or set
`BUILD_BROKEN_NINJA_USES_ENV_VAR := ...` in your `BoardConfig.mk`
to allow specific variables to be passed through until you've fixed the rules.
## LOCAL_C_INCLUDES outside the source/output trees are an error {#BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS}
Include directories are expected to be within the source tree (or in the output
directory, generated during the build). This has been checked in some form
since Oreo, but now has better checks.
There's now a `BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS` variable, that when set, will
turn these errors into warnings temporarily. I don't expect this to last more
than a release, since they're fairly easy to clean up.
Neither of these cases are supported by Soong, and will produce errors when
converting your module.
### Absolute paths
This has been checked since Oreo. The common reason to hit this is because a
makefile is calculating a path, and ran abspath/realpath/etc. This is a problem
because it makes your build non-reproducible. It's very unlikely that your
source path is the same on every machine.
### Using `../` to leave the source/output directories
This is the new check that has been added. In every case I've found, this has
been a mistake in the Android.mk -- assuming that `LOCAL_C_INCLUDES` (which is
relative to the top of the source tree) acts like `LOCAL_SRC_FILES` (which is
relative to `LOCAL_PATH`).
Since this usually isn't a valid path, you can almost always just remove the
offending line.
## `BOARD_HAL_STATIC_LIBRARIES` and `LOCAL_HAL_STATIC_LIBRARIES` are obsolete {#BOARD_HAL_STATIC_LIBRARIES}
Define proper HIDL / Stable AIDL HAL instead.
* For libhealthd, use health HAL. See instructions for implementing
health HAL:
* [hardware/interfaces/health/2.1/README.md] for health 2.1 HAL (recommended)
* [hardware/interfaces/health/1.0/README.md] for health 1.0 HAL
* For libdumpstate, use at least Dumpstate HAL 1.0.
## PRODUCT_STATIC_BOOT_CONTROL_HAL is obsolete {#PRODUCT_STATIC_BOOT_CONTROL_HAL}
`PRODUCT_STATIC_BOOT_CONTROL_HAL` was the workaround to allow sideloading with
statically linked boot control HAL, before shared library HALs were supported
under recovery. Android Q has added such support (HALs will be loaded in
passthrough mode), and the workarounds are being removed. Targets should build
and install the recovery variant of boot control HAL modules into recovery
image, similar to the ones installed for normal boot. See the change to
crosshatch for example of this:
* [device/google/crosshatch/bootctrl/Android.bp] for `bootctrl.sdm845` building
rules
* [device/google/crosshatch/device.mk] for installing `bootctrl.sdm845.recovery`
and `android.hardware.boot@1.0-impl.recovery` into recovery image
[device/google/crosshatch/bootctrl/Android.bp]: https://android.googlesource.com/device/google/crosshatch/+/master/bootctrl/Android.bp
[device/google/crosshatch/device.mk]: https://android.googlesource.com/device/google/crosshatch/+/master/device.mk
## Deprecation of `BUILD_*` module types
See [build/make/Deprecation.md](Deprecation.md) for the current status.
## `PRODUCT_HOST_PACKAGES` split from `PRODUCT_PACKAGES` {#PRODUCT_HOST_PACKAGES}
Previously, adding a module to `PRODUCT_PACKAGES` that supported both the host
and the target (`host_supported` in Android.bp; two modules with the same name
in Android.mk) would cause both to be built and installed. In many cases you
only want either the host or target versions to be built/installed by default,
and would be over-building with both. So `PRODUCT_PACKAGES` will be changing to
just affect target modules, while `PRODUCT_HOST_PACKAGES` is being added for
host modules.
Functional differences between `PRODUCT_PACKAGES` and `PRODUCT_HOST_PACKAGES`:
* `PRODUCT_HOST_PACKAGES` does not have `_ENG`/`_DEBUG` variants, as that's a
property of the target, not the host.
* `PRODUCT_HOST_PACKAGES` does not support `LOCAL_MODULE_OVERRIDES`.
* `PRODUCT_HOST_PACKAGES` requires listed modules to exist, and be host
modules. (Unless `ALLOW_MISSING_DEPENDENCIES` is set)
This is still an active migration, so currently it still uses
`PRODUCT_PACKAGES` to make installation decisions, but verifies that if we used
`PRODUCT_HOST_PACKAGES`, it would trigger installation for all of the same host
packages. This check ignores shared libraries, as those are not normally
necessary in `PRODUCT_*PACKAGES`, and tended to be over-built (especially the
32-bit variants).
Future changes will switch installation decisions to `PRODUCT_HOST_PACKAGES`
for host modules, error when there's a host-only module in `PRODUCT_PACKAGES`,
and do some further cleanup where `LOCAL_REQUIRED_MODULES` are still merged
between host and target modules with the same name.
## `*.c.arm` / `*.cpp.arm` deprecation {#file_arm}
In Android.mk files, you used to be able to change LOCAL_ARM_MODE for each
source file by appending `.arm` to the end of the filename in
`LOCAL_SRC_FILES`.
Soong does not support this uncommonly used behavior, instead expecting those
files to be split out into a separate static library that chooses `arm` over
`thumb` for the entire library. This must now also be done in Android.mk files.
## Windows cross-compiles no longer supported in Android.mk
Modules that build for Windows (our only `HOST_CROSS` OS currently) must now be
defined in `Android.bp` files.
## `LOCAL_MODULE_TAGS := eng debug` are obsolete {#LOCAL_MODULE_TAGS}
`LOCAL_MODULE_TAGS` value `eng` and `debug` are now obsolete. They allowed
modules to specify that they should always be installed on `-eng`, or `-eng`
and `-userdebug` builds. This conflicted with the ability for products to
specify which modules should be installed, effectively making it impossible to
build a stripped down product configuration that did not include those modules.
For the equivalent functionality, specify the modules in `PRODUCT_PACKAGES_ENG`
or `PRODUCT_PACKAGES_DEBUG` in the appropriate product makefiles.
Core android packages like `su` got added to the list in
`build/make/target/product/base_system.mk`, but for device-specific modules
there are often better base product makefiles to use instead.
## `USER` deprecation {#USER}
`USER` will soon be `nobody` in many cases due to the addition of a sandbox
around the Android build. Most of the time you shouldn't need to know the
identity of the user running the build, but if you do, it's available in the
make variable `BUILD_USERNAME` for now.
Similarly, the `hostname` tool will also be returning a more consistent value
of `android-build`. The real value is available as `BUILD_HOSTNAME`.
## `BUILD_NUMBER` removal from Android.mk {#BUILD_NUMBER}
`BUILD_NUMBER` should not be used directly in Android.mk files, as it would
trigger them to be re-read every time the `BUILD_NUMBER` changes (which it does
on every build server build). If possible, just remove the use so that your
builds are more reproducible. If you do need it, use `BUILD_NUMBER_FROM_FILE`:
``` make
$(LOCAL_BUILT_MODULE):
mytool --build_number $(BUILD_NUMBER_FROM_FILE) -o $@
```
That will expand out to a subshell that will read the current `BUILD_NUMBER`
whenever it's run. It will not re-run your command if the build number has
changed, so incremental builds will have the build number from the last time
the particular output was rebuilt.
## `DIST_DIR`, `dist_goal`, and `dist-for-goals` {#dist}
`DIST_DIR` and `dist_goal` are no longer available when reading Android.mk
files (or other build tasks). Always use `dist-for-goals` instead, which takes
a PHONY goal, and a list of files to copy to `$DIST_DIR`. Whenever `dist` is
specified, and the goal would be built (either explicitly on the command line,
or as a dependency of something on the command line), that file will be copied
into `$DIST_DIR`. For example,
``` make
$(call dist-for-goals,foo,bar/baz)
```
will copy `bar/baz` into `$DIST_DIR/baz` when `m foo dist` is run.
#### FILE_NAME_TAG {#FILE_NAME_TAG}
To embed the `BUILD_NUMBER` (or for local builds, `eng.${USER}`), include
`FILE_NAME_TAG_PLACEHOLDER` in the destination:
``` make
# you can use dist-for-goals-with-filenametag function
$(call dist-for-goals-with-filenametag,foo,bar.zip)
# or use FILE_NAME_TAG_PLACEHOLDER manually
$(call dist-for-goals,foo,bar.zip:baz-FILE_NAME_TAG_PLACEHOLDER.zip)
```
Which will produce `$DIST_DIR/baz-1234567.zip` on build servers which set
`BUILD_NUMBER=1234567`, or `$DIST_DIR/baz-eng.builder.zip` for local builds.
If you just want to append `BUILD_NUMBER` at the end of basename, use
`dist-for-goals-with-filenametag` instead of `dist-for-goals`.
#### Renames during copy
Instead of specifying just a file, a destination name can be specified,
including subdirectories:
``` make
$(call dist-for-goals,foo,bar/baz:logs/foo.log)
```
will copy `bar/baz` into `$DIST_DIR/logs/foo.log` when `m foo dist` is run.
## `.PHONY` rule enforcement {#phony_targets}
There are several new warnings/errors meant to ensure the proper use of
`.PHONY` targets in order to improve the speed and reliability of incremental
builds.
`.PHONY`-marked targets are often used as shortcuts to provide "friendly" names
for real files to be built, but any target marked with `.PHONY` is also always
considered dirty, needing to be rebuilt every build. This isn't a problem for
aliases or one-off user-requested operations, but if real builds steps depend
on a `.PHONY` target, it can get quite expensive for what should be a tiny
build.
``` make
...mk:42: warning: PHONY target "out/.../foo" looks like a real file (contains a "/")
```
Between this warning and the next, we're requiring that `.PHONY` targets do not
have "/" in them, and real file targets do have a "/". This makes it more
obvious when reading makefiles what is happening, and will help the build
system differentiate these in the future too.
``` make
...mk:42: warning: writing to readonly directory: "kernel-modules"
```
This warning will show up for one of two reasons:
1. The target isn't intended to be a real file, and should be marked with
`.PHONY`. This would be the case for this example.
2. The target is a real file, but it's outside the output directories. All
outputs from the build system should be within the output directory,
otherwise `m clean` is unable to clean the build, and future builds may not
work properly.
``` make
...mk:42: warning: real file "out/.../foo" depends on PHONY target "buildbins"
```
If the first target isn't intended to be a real file, then it should be marked
with `.PHONY`, which will satisfy this warning. This isn't the case for this
example, as we require `.PHONY` targets not to have '/' in them.
If the second (PHONY) target is a real file, it may unnecessarily be marked
with `.PHONY`.
### `.PHONY` and calling other build systems
One common pattern (mostly outside AOSP) that we've seen hit these warning is
when building with external build systems (firmware, bootloader, kernel, etc).
Those are often marked as `.PHONY` because the Android build system doesn't
have enough dependencies to know when to run the other build system again
during an incremental build.
We recommend to build these outside of Android, and deliver prebuilts into the
Android tree instead of decreasing the speed and reliability of the incremental
Android build.
In cases where that's not desired, to preserve the speed of Android
incrementals, over-specifying dependencies is likely a better option than
marking it with `.PHONY`:
``` make
out/target/.../zImage: $(sort $(shell find -L $(KERNEL_SRCDIR)))
...
```
For reliability, many of these other build systems do not guarantee the same
level of incremental build assurances as the Android Build is attempting to do
-- without custom checks, Make doesn't rebuild objects when CFLAGS change, etc.
In order to fix this, our recommendation is to do clean builds for each of
these external build systems every time anything they rely on changes. For
relatively smaller builds (like the kernel), this may be reasonable as long as
you're not trying to actively debug the kernel.
## `export` and `unexport` deprecation {#export_keyword}
The `export` and `unexport` keywords are obsolete, and will throw errors when
used.
Device specific configuration should not be able to affect common core build
steps -- we're looking at triggering build steps to be invalidated if the set
of environment variables they can access changes. If device specific
configuration is allowed to change those, switching devices with the same
output directory could become significantly more expensive than it already can
be.
If used during Android.mk files, and later tasks, it is increasingly likely
that they are being used incorrectly. Attempting to change the environment for
a single build step, and instead setting it for hundreds of thousands.
It is not recommended to just move the environment variable setting outside of
the build (in vendorsetup.sh, or some other configuration script or wrapper).
We expect to limit the environment variables that the build respects in the
future, others will be cleared. (There will be methods to get custom variables
into the build, just not to every build step)
Instead, write the export commands into the rule command lines themselves:
``` make
$(intermediates)/generated_output.img:
rm -rf $@
export MY_ENV_A="$(MY_A)"; make ...
```
If you want to set many environment variables, and/or use them many times,
write them out to a script and source the script:
``` make
envsh := $(intermediates)/env.sh
$(envsh):
rm -rf $@
echo 'export MY_ENV_A="$(MY_A)"' >$@
echo 'export MY_ENV_B="$(MY_B)"' >>$@
$(intermediates)/generated_output.img: PRIVATE_ENV := $(envsh)
$(intermediates)/generated_output.img: $(envsh) a/b/c/package.sh
rm -rf $@
source $(PRIVATE_ENV); make ...
source $(PRIVATE_ENV); a/b/c/package.sh ...
```
## Implicit make rules are obsolete {#implicit_rules}
Implicit rules look something like the following:
``` make
$(TARGET_OUT_SHARED_LIBRARIES)/%_vendor.so: $(TARGET_OUT_SHARED_LIBRARIES)/%.so
...
%.o : %.foo
...
```
These can have wide ranging effects across unrelated modules, so they're now obsolete. Instead, use static pattern rules, which are similar, but explicitly match the specified outputs:
``` make
libs := $(foreach lib,libfoo libbar,$(TARGET_OUT_SHARED_LIBRARIES)/$(lib)_vendor.so)
$(libs): %_vendor.so: %.so
...
files := $(wildcard $(LOCAL_PATH)/*.foo)
gen := $(patsubst $(LOCAL_PATH)/%.foo,$(intermediates)/%.o,$(files))
$(gen): %.o : %.foo
...
```
## Removing '/' from Valid Module Names {#name_slash}
The build system uses module names in path names in many places. Having an
extra '/' or '../' being inserted can cause problems -- and not just build
breaks, but stranger invalid behavior.
In every case we've seen, the fix is relatively simple: move the directory into
`LOCAL_MODULE_RELATIVE_PATH` (or `LOCAL_MODULE_PATH` if you're still using it).
If this causes multiple modules to be named the same, use unique module names
and `LOCAL_MODULE_STEM` to change the installed file name:
``` make
include $(CLEAR_VARS)
LOCAL_MODULE := ver1/code.bin
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/firmware
...
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := ver2/code.bin
LOCAL_MODULE_PATH := $(TARGET_OUT_ETC)/firmware
...
include $(BUILD_PREBUILT)
```
Can be rewritten as:
```
include $(CLEAR_VARS)
LOCAL_MODULE := ver1_code.bin
LOCAL_MODULE_STEM := code.bin
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/firmware/ver1
...
include $(BUILD_PREBUILT)
include $(CLEAR_VARS)
LOCAL_MODULE := ver2_code.bin
LOCAL_MODULE_STEM := code.bin
LOCAL_MODULE_PATH := $(TARGET_OUT_VENDOR)/firmware/ver2
...
include $(BUILD_PREBUILT)
```
You just need to make sure that any other references (`PRODUCT_PACKAGES`,
`LOCAL_REQUIRED_MODULES`, etc) are converted to the new names.
## Valid Module Names {#name}
We've adopted lexical requirements very similar to [Bazel's
requirements](https://docs.bazel.build/versions/master/build-ref.html#name) for
target names. Valid characters are `a-z`, `A-Z`, `0-9`, and the special
characters `_.+-=,@~`. This currently applies to `LOCAL_PACKAGE_NAME`,
`LOCAL_MODULE`, and `LOCAL_MODULE_SUFFIX`, and `LOCAL_MODULE_STEM*`.
Many other characters already caused problems if you used them, so we don't
expect this to have a large effect.
## PATH Tools {#PATH_Tools}
The build has started restricting the external host tools usable inside the
build. This will help ensure that build results are reproducible across
different machines, and catch mistakes before they become larger issues.
To start with, this includes replacing the $PATH with our own directory of
tools, mirroring that of the host PATH. The only difference so far is the
removal of the host GCC tools. Anything that is not explicitly in the
configuration as allowed will continue functioning, but will generate a log
message. This is expected to become more restrictive over time.
The configuration is located in build/soong/ui/build/paths/config.go, and
contains all the common tools in use in many builds. Anything not in that list
will currently print a warning in the `$OUT_DIR/soong.log` file, including the
command and arguments used, and the process tree in order to help locate the
usage.
In order to fix any issues brought up by these checks, the best way to fix them
is to use tools checked into the tree -- either as prebuilts, or building them
as host tools during the build.
As a temporary measure, you can set `TEMPORARY_DISABLE_PATH_RESTRICTIONS=true`
in your environment to temporarily turn off the error checks and allow any tool
to be used (with logging). Beware that GCC didn't work well with the interposer
used for logging, so this may not help in all cases.
## Deprecating / obsoleting envsetup.sh variables in Makefiles
It is not required to source envsetup.sh before running a build. Many scripts,
including a majority of our automated build systems, do not do so. Make will
transparently make every environment variable available as a make variable.
This means that relying on environment variables only set up in envsetup.sh will
produce different output for local users and scripted users.
Many of these variables also include absolute path names, which we'd like to
keep out of the generated files, so that you don't need to do a full rebuild if
you move the source tree.
To fix this, we're marking the variables that are set in envsetup.sh as
deprecated in the makefiles. This will trigger a warning every time one is read
(or written) inside Kati. Once all the warnings have been removed for a
particular variable, we'll switch it to obsolete, and any references will become
errors.
### envsetup.sh variables with make equivalents
| instead of | use |
|--------------------------------------------------------------|----------------------|
| OUT {#OUT} | PRODUCT_OUT |
| ANDROID_HOST_OUT {#ANDROID_HOST_OUT} | HOST_OUT |
| ANDROID_PRODUCT_OUT {#ANDROID_PRODUCT_OUT} | PRODUCT_OUT |
| ANDROID_HOST_OUT_TESTCASES {#ANDROID_HOST_OUT_TESTCASES} | HOST_OUT_TESTCASES |
| ANDROID_TARGET_OUT_TESTCASES {#ANDROID_TARGET_OUT_TESTCASES} | TARGET_OUT_TESTCASES |
All of the make variables may be relative paths from the current directory, or
absolute paths if the output directory was specified as an absolute path. If you
need an absolute variable, convert it to absolute during a rule, so that it's
not expanded into the generated ninja file:
``` make
$(PRODUCT_OUT)/gen.img: my/src/path/gen.sh
export PRODUCT_OUT=$$(cd $(PRODUCT_OUT); pwd); cd my/src/path; ./gen.sh -o $${PRODUCT_OUT}/gen.img
```
### ANDROID_BUILD_TOP {#ANDROID_BUILD_TOP}
In Android.mk files, you can always assume that the current directory is the
root of the source tree, so this can just be replaced with '.' (which is what
$TOP is hardcoded to), or removed entirely. If you need an absolute path, see
the instructions above.
### Stop using PATH directly {#PATH}
This isn't only set by envsetup.sh, but it is modified by it. Due to that it's
rather easy for this to change between different shells, and it's not ideal to
reread the makefiles every time this changes.
In most cases, you shouldn't need to touch PATH at all. When you need to have a
rule reference a particular binary that's part of the source tree or outputs,
it's preferrable to just use the path to the file itself (since you should
already be adding that as a dependency).
Depending on the rule, passing the file path itself may not be feasible due to
layers of unchangable scripts/binaries. In that case, be sure to add the
dependency, but modify the PATH within the rule itself:
``` make
$(TARGET): myscript my/path/binary
PATH=my/path:$$PATH myscript -o $@
```
### Stop using PYTHONPATH directly {#PYTHONPATH}
Like PATH, this isn't only set by envsetup.sh, but it is modified by it. Due to
that it's rather easy for this to change between different shells, and it's not
ideal to reread the makefiles every time.
The best solution here is to start switching to Soong's python building support,
which packages the python interpreter, libraries, and script all into one file
that no longer needs PYTHONPATH. See fontchain_lint for examples of this:
* [external/fonttools/Lib/fontTools/Android.bp] for python_library_host
* [frameworks/base/Android.bp] for python_binary_host
* [frameworks/base/data/fonts/Android.mk] to execute the python binary
If you still need to use PYTHONPATH, do so within the rule itself, just like
path:
``` make
$(TARGET): myscript.py $(sort $(shell find my/python/lib -name '*.py'))
PYTHONPATH=my/python/lib:$$PYTHONPATH myscript.py -o $@
```
### Stop using PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE directly {#PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE}
Specify Framework Compatibility Matrix Version in device manifest by adding a `target-level`
attribute to the root element ``. If `PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE`
is 26 or 27, you can add `"target-level"="1"` to your device manifest instead.
### Stop using USE_CLANG_PLATFORM_BUILD {#USE_CLANG_PLATFORM_BUILD}
Clang is the default and only supported Android compiler, so there is no reason
for this option to exist.
### Stop using clang property
The clang property has been deleted from Soong. To fix any build errors, remove the clang
property from affected Android.bp files using bpmodify.
``` make
go run bpmodify.go -w -m=module_name -remove-property=true -property=clang filepath
```
`BUILD_BROKEN_CLANG_PROPERTY` can be used as temporarily workaround
### Stop using clang_cflags and clang_asflags
clang_cflags and clang_asflags are deprecated.
To fix any build errors, use bpmodify to either
- move the contents of clang_asflags/clang_cflags into asflags/cflags or
- delete clang_cflags/as_flags as necessary
To Move the contents:
``` make
go run bpmodify.go -w -m=module_name -move-property=true -property=clang_cflags -new-location=cflags filepath
```
To Delete:
``` make
go run bpmodify.go -w -m=module_name -remove-property=true -property=clang_cflags filepath
```
`BUILD_BROKEN_CLANG_ASFLAGS` and `BUILD_BROKEN_CLANG_CFLAGS` can be used as temporarily workarounds
### Other envsetup.sh variables {#other_envsetup_variables}
* ANDROID_TOOLCHAIN
* ANDROID_TOOLCHAIN_2ND_ARCH
* ANDROID_DEV_SCRIPTS
* ANDROID_EMULATOR_PREBUILTS
* ANDROID_PRE_BUILD_PATHS
These are all exported from envsetup.sh, but don't have clear equivalents within
the makefile system. If you need one of them, you'll have to set up your own
version.
## Soong config variables
### Soong config string variables must list all values they can be set to
In order to facilitate the transition to bazel, all soong_config_string_variables
must only be set to a value listed in their `values` property, or an empty string.
It is a build error otherwise.
Example Android.bp:
```
soong_config_string_variable {
name: "my_string_variable",
values: [
"foo",
"bar",
],
}
soong_config_module_type {
name: "my_cc_defaults",
module_type: "cc_defaults",
config_namespace: "my_namespace",
variables: ["my_string_variable"],
properties: [
"shared_libs",
"static_libs",
],
}
```
Product config:
```
$(call soong_config_set,my_namespace,my_string_variable,baz) # Will be an error as baz is not listed in my_string_variable's values.
```
[build/soong/Changes.md]: https://android.googlesource.com/platform/build/soong/+/master/Changes.md
[build/soong/docs/best_practices.md#headers]: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers
[external/fonttools/Lib/fontTools/Android.bp]: https://android.googlesource.com/platform/external/fonttools/+/master/Lib/fontTools/Android.bp
[frameworks/base/Android.bp]: https://android.googlesource.com/platform/frameworks/base/+/master/Android.bp
[frameworks/base/data/fonts/Android.mk]: https://android.googlesource.com/platform/frameworks/base/+/master/data/fonts/Android.mk
[hardware/interfaces/health/1.0/README.md]: https://android.googlesource.com/platform/hardware/interfaces/+/master/health/1.0/README.md
[hardware/interfaces/health/2.1/README.md]: https://android.googlesource.com/platform/hardware/interfaces/+/master/health/2.1/README.md
================================================
FILE: CleanSpec.mk
================================================
# Copyright (C) 2007 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.
#
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# For example:
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmediaplayerservice_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libmedia_jni_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
$(call add-clean-step, find $(PRODUCT_OUT) -name "*.apk" | xargs rm)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/*/LINKED)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/iself)
$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/lsd)
$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/apriori)
$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/isprelinked)
$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/soslim)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/*.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/system/lib/*.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/YouTube*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libstagefright_omx_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/librtp_jni_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/android-info.txt)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/JAVA_LIBRARIES/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates)
# ICS MR2!!!!!!!!!!!!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES/libbcinfo_intermediates)
# WAIT, I MEAN JELLY BEAN!!!!!!!!!!!!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Changing where ro.carrier value is instantiated for system/build.prop
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Now we switched to build against Mac OS X SDK 10.6
$(call add-clean-step, rm -rf $(OUT_DIR)/host/darwin-x86/obj)
$(call add-clean-step, rm -f $(OUT_DIR)/versions_checked.mk)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
# JB MR2!!!!!!! AND *NO*, THIS WILL NOT BE K-WHATEVER.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Start of "K" development!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# GCC 4.7
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
# Wait, back to some JB development!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# And on to KLP...
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# KLP now based off API 18.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# Clean up around the /system/app -> /system/priv-app migration
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
# Clean up old location of generated Java files from aidl
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/framework_intermediates/src)
# Clean up ApplicationsProvider which is being removed.
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/ApplicationsProvider_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/ApplicationsProvider.apk)
# Clean up Moto OMA DM client which isn't ready yet.
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin.dev_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin.diagmon_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.pluginhelper_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.plugin_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/com.android.omadm.service.api_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/DMService_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/SprintDM_intermediates)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/DMService.apk)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/SprintDM.apk)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/omadm)
# GCC 4.8
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/SHARED_LIBRARIES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/EXECUTABLES)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/lib/*.o)
# KLP I mean KitKat now API 19.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# 4.4.1
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# 4.4.2
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# "L" and beyond.
# Make libart the default runtime
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Rename persist.sys.dalvik.vm.lib to allow new default
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# KKWT development
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# L development
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# L development
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# Add ro.product.cpu.abilist{32,64} to build.prop.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Unset TARGET_PREFER_32_BIT_APPS for 64 bit targets.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Adding dalvik.vm.dex2oat-flags to eng builds
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Unset TARGET_PREFER_32_BIT_APPS for 64 bit targets.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Switching the x86 emulator over to a 64 bit primary zygote.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
# Rename persist.sys.dalvik.vm.lib.1 to allow new default
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Switching PRODUCT_RUNTIMES default for some devices
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Switching to 32-bit-by-default host multilib build
$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES))
# KKWT has become API 20
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# ims-common.jar added to BOOTCLASSPATH
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/ETC/init.environ.rc_intermediates)
# Change ro.zygote for core_64_bit.mk from zygote32_64 to zygote64_32
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# Adding dalvik.vm.dex2oat-Xms, dalvik.vm.dex2oat-Xmx
# dalvik.vm.image-dex2oat-Xms, and dalvik.vm.image-dex2oat-Xmx
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system)
# Switch host builds to Clang by default
$(call add-clean-step, rm -rf $(OUT_DIR)/host)
# Adding dalvik.vm.dex2oat-filter
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# API 21?
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# API 21!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# API 22!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# Move to libc++ as the default STL.
$(call add-clean-step, rm -rf $(OUT_DIR))
# dex2oat instruction-set changes
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# Make GNU++11 the default standard version. This requires a cleanspec because
# char16_t/char32_t will be real types now instead of typedefs, which means
# an ABI change since the names will mangle differently.
$(call add-clean-step, rm -rf $(OUT_DIR))
# 5.1!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# Remove ro.product.locale.language/country and add ro.product.locale
# instead.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# On to MNC
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# Adding dalvik.vm.usejit
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# Rename dalvik.vm.usejit to debug.dalvik.vm.usejit
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# Revert rename dalvik.vm.usejit to debug.dalvik.vm.usejit
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# Change from interpret-only to verify-at-runtime.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/default.prop)
# New York, New York!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# 23 is becoming alive!!!
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
# Change PLATFORM_VERSION from NYC to N
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*)
# $(PRODUCT_OUT)/recovery/root/sdcard goes from symlink to folder.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/recovery/root/sdcard)
# Add BOARD_USES_SYSTEM_OTHER_ODEX
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/*)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/previous_overlays.txt)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/current_packages.txt)
$(call add-clean-step, rm -rf $(HOST_OUT_INTERMEDIATES)/include)
$(call add-clean-step, rm -rf $(HOST_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
$(call add-clean-step, rm -rf $(HOST_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/previous_gen_java_config.mk)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/current_gen_java_config.mk)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*/package-res.apk)
$(call add-clean-step, rm -rf $(TARGET_OUT_INTERMEDIATES)/APPS/*/package-res.apk)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
$(call add-clean-step, rm -rf $(HOST_OUT_TESTCASES))
$(call add-clean-step, rm -rf $(TARGET_OUT_TESTCASES))
$(call add-clean-step, rm -rf $(TARGET_OUT_ETC)/init)
# Libraries are moved from {system|vendor}/lib to ./lib/framework, ./lib/vndk, etc.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
# Revert that move
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/lib*)
# Sanitized libraries now live in a different location.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/lib*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/vendor/lib*)
# Soong module variant change, remove obsolete intermediates
$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates)
# Version checking moving to Soong
$(call add-clean-step, rm -rf $(OUT_DIR)/versions_checked.mk)
# Vendor tests were being installed into /vendor/bin accidentally
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/nativetest*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/nativetest*)
# Jack is no longer the default compiler, remove the intermediates
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/*/*/classes*.jack)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/*/*/jack*)
# Move adbd from $(PRODUCT_OUT)/root/sbin to $(PRODUCT_OUT)/system/bin
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/root/sbin/adbd)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/sbin/adbd)
# Soong linux -> linux_glibc rename
$(call add-clean-step, find $(SOONG_OUT_DIR)/.intermediates -name 'linux_x86*' | xargs rm -rf)
$(call add-clean-step, find $(SOONG_OUT_DIR)/.intermediates -name 'linux_common*' | xargs rm -rf)
# Remove old aidl/logtags files that may be in the generated source directory
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/*/*_intermediates/src)
$(call add-clean-step, rm -f $(OUT_DIR)/target/common/obj/*/*_intermediates/java-source-list)
$(call add-clean-step, rm -rf $(OUT_DIR)/host/common/obj/*/*_intermediates/src)
$(call add-clean-step, rm -f $(OUT_DIR)/host/common/obj/*/*_intermediates/java-source-list)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/APPS/*/flat-res)
# Remove old VNDK directories without version
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib/vndk-sp)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/vndk)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib64/vndk-sp)
# Remove old dex output directories
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/with-local/)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/no-local/)
$(call add-clean-step, rm -rf $(HOST_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/with-local/)
$(call add-clean-step, rm -rf $(HOST_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/no-local/)
# Remove legacy VINTF metadata files
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/manifest.xml)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/manifest.xml)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/manifest.xml)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/vendor/compatibility_matrix.xml)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/compatibility_matrix.xml)
# Remove DisplayCutoutEmulation overlays
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/overlay/DisplayCutoutEmulationWide)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/overlay/DisplayCutoutEmulationNarrow)
# Remove obsolete intermedates src files
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/*/*_intermediates/src/RenderScript.stamp*)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/java-source-list)
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/JAVA_LIBRARIES/*_intermediates/java-source-list)
$(call add-clean-step, rm -rf $(OUT_DOCS)/*-timestamp)
$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/APPS/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/JAVA_LIBRARIES/*_intermediates/src)
$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/APPS/*_intermediates/java-source-list)
$(call add-clean-step, rm -rf $(TARGET_COMMON_OUT_ROOT)/obj_asan/JAVA_LIBRARIES/*_intermediates/java-source-list)
# Remove stale init.noenforce.rc
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/gsi/init.noenforce.rc)
# Clean up Launcher3 which has been replaced with Launcher3QuickStep
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/Launcher3)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/Launcher3)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/Launcher3_intermediates)
# Remove old merged AndroidManifest.xml location
$(call add-clean-step, rm -rf $(TARGET_OUT_COMMON_INTERMEDIATES)/APPS/*_intermediates/AndroidManifest.xml)
$(call add-clean-step, find $(PRODUCT_OUT) -type f -name "vr_hwc*" -print0 | xargs -0 rm -f)
$(call add-clean-step, rm -rf $(SOONG_OUT_DIR)/.intermediates/system/vold)
# Remove product-services related files / images
$(call add-clean-step, find $(PRODUCT_OUT) -type f -name "*product-services*" -print0 | xargs -0 rm -rf)
$(call add-clean-step, find $(PRODUCT_OUT) -type d -name "*product-services*" -print0 | xargs -0 rm -rf)
$(call add-clean-step, find $(PRODUCT_OUT) -type l -name "*product-services*" -print0 | xargs -0 rm -rf)
# Remove obsolete recovery etc files
$(call add-clean-step, rm -rf $(TARGET_RECOVERY_ROOT_OUT)/etc)
# Remove *_OUT_INTERMEDIATE_LIBRARIES
$(call add-clean-step, rm -rf $(addsuffix /lib,\
$(HOST_OUT_INTERMEDIATES) $(2ND_HOST_OUT_INTERMEDIATES) \
$(HOST_CROSS_OUT_INTERMEDIATES) $(2ND_HOST_CROSS_OUT_INTERMEDIATES) \
$(TARGET_OUT_INTERMEDIATES) $(2ND_TARGET_OUT_INTERMEDIATES)))
# Remove strip.sh intermediates to save space
$(call add-clean-step, find $(OUT_DIR) \( -name "*.so.debug" -o -name "*.so.dynsyms" -o -name "*.so.funcsyms" -o -name "*.so.keep_symbols" -o -name "*.so.mini_debuginfo.xz" \) -print0 | xargs -0 rm -f)
# Clean up old ninja files
$(call add-clean-step, rm -f $(OUT_DIR)/build-*-dist*.ninja)
$(call add-clean-step, rm -f $(HOST_OUT)/*ts/host-libprotobuf-java-*.jar)
$(call add-clean-step, find $(OUT_DIR)/target/product/mainline_arm64/system -type f -name "*.*dex" -print0 | xargs -0 rm -f)
# Clean up aidegen
$(call add-clean-step, rm -f $(HOST_OUT)/bin/aidegen)
# Remove perfprofd
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/perfprofd)
# Remove incorrectly created directories in the source tree
$(call add-clean-step, find system/app system/priv-app system/framework system_other -depth -type d -print0 | xargs -0 rmdir)
$(call add-clean-step, rm -f .d)
# Remove obsolete apps
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/*)
# Remove corrupt generated rule due to using toybox's sed
$(call add-clean-step, rm -rf $(SOONG_OUT_DIR)/.intermediates/system/core/init/generated_stub_builtin_function_map)
# Clean up core JNI libraries moved to runtime apex
$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libjavacore.so)
$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libopenjdk.so)
$(call add-clean-step, rm -f $(PRODUCT_OUT)/system/lib*/libexpat.so)
# Merge product_services into product
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/product_services)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/product_services)
# Clean up old location of hiddenapi files
$(call add-clean-step, rm -f $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/hiddenapi*)
# Clean up previous default location of RROs
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/overlay)
# Remove ART artifacts installed only by modules `art-runtime` and
# `art-tools` in /system on target.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dalvikvm)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dalvikvm32)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dalvikvm64)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dex2oat)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dex2oatd)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dexdiag)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dexdump)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dexlist)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dexoptanalyzer)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/dexoptanalyzerd)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/oatdump)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/profman)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/profmand)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libadbconnection.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libadbconnectiond.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libart-compiler.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libartd-compiler.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libart-dexlayout.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libartd-dexlayout.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libart-disassembler.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libart.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libartd.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libartbase.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libartbased.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libdexfile.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libdexfiled.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libdexfile_external.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libdexfile_support.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libdt_fd_forward.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libdt_socket.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libjdwp.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libnpt.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libopenjdkd.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libopenjdkjvm.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libopenjdkjvmd.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libopenjdkjvmti.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libopenjdkjvmtid.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libprofile.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libprofiled.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libtombstoned_client.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libvixl.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libvixld.so)
# Clean up old location of dexpreopted boot jars
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/dex_bootjars)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/dex_bootjars_input)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libnpt.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*)
# Clean up old testcase files
$(call add-clean-step, rm -rf $(TARGET_OUT_TESTCASES)/*)
$(call add-clean-step, rm -rf $(HOST_OUT_TESTCASES)/*)
$(call add-clean-step, rm -rf $(HOST_CROSS_OUT_TESTCASES)/*)
$(call add-clean-step, rm -rf $(TARGET_OUT_DATA)/*)
$(call add-clean-step, rm -rf $(HOST_OUT)/vts/*)
$(call add-clean-step, rm -rf $(HOST_OUT)/framework/vts-tradefed.jar)
# Clean up old location of system_other.avbpubkey
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/security/avb/)
# Clean up bufferhub files
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/hw/android.frameworks.bufferhub@1.0-service)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/android.frameworks.bufferhub@1.0-service.rc)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/super.img)
$(call add-clean-step, find $(PRODUCT_OUT) -type f -name "generated_*_image_info.txt" -print0 | xargs -0 rm -f)
# Clean up libicuuc.so and libicui18n.so
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libicu*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/target/common/obj/framework.aidl)
# Clean up adb_debug.propr
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/adb_debug.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libjavacrypto.so)
# Clean up old verity tools.
$(call add-clean-step, rm -rf $(HOST_OUT_JAVA_LIBRARIES)/BootSignature.jar)
$(call add-clean-step, rm -rf $(HOST_OUT_JAVA_LIBRARIES)/VeritySigner.jar)
$(call add-clean-step, rm -rf $(HOST_OUT_EXECUTABLES)/build_verity_metadata.py)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libc_malloc*)
# Clean up old location of soft OMX plugins
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libstagefright_soft*)
# Move odm build.prop to /odm/etc/.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/odm/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/odm/build.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex)
# Remove libcameraservice and libcamera_client from base_system
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libcameraservice.so)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/libcamera_client.so)
# Move product and system_ext to root for emulators
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/product)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/system_ext)
# link_type and jni_link_type files are no longer needed
$(call add-clean-step, find $(OUT_DIR) -type f -name "*link_type" -print0 | xargs -0 rm -f)
# import_includes and export_includes files are no longer needed
$(call add-clean-step, find $(OUT_DIR) -type f -name "import_includes" -o -name "export_includes" -print0 | xargs -0 rm -f)
# Recreate product and system_ext partitions for emulator
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*product*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*system_ext*)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/product)
$(call add-clean-step, rm -rf $(OUT_DIR)/target/product/generic*/*/system_ext)
# Move GSI-specific files from /system to /system/system_ext
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/init.gsi.rc)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/init/config/)
# Move fuzz targets from /data/fuzz/* to /data/fuzz//* for device, and
# /fuzz/* to /fuzz//* on host.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/fuzz/*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/symbols/data/fuzz/*)
$(call add-clean-step, rm -rf $(HOST_OUT)/fuzz/*)
$(call add-clean-step, rm -rf $(SOONG_OUT_DIR)/host/*/fuzz/*)
# Change file layout of system_other
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system_other)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex)
# Migrate preopt files to system_other for some devices
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/*/*app/*/oat)
# Migrate preopt files from system_other for some devices
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system_other)
# Remove Android Core Library artifacts from the system partition, now
# that they live in the ART APEX (b/142944799).
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*.jar)
# Remove symlinks for VNDK apexes
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/vndk-*)
# Switch to symlinks for VNDK libs
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/lib*/vndk-*)
# Remove Android Core Library artifacts from the system partition
# again, as the original change removing them was reverted.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/framework/*.jar)
# Remove cas@1.1 from the vendor partition
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/bin/hw/android.hardware.cas@1.1*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/init/android.hardware.cas@1.1*)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/etc/vintf/manifest/android.hardware.cas@1.1*)
# Remove com.android.cellbroadcast apex for Go devices
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex/com.android.cellbroadcast.apex)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/apex/com.android.cellbroadcast)
# Remove CellBroadcastLegacyApp for Go devices
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/CellBroadcastLegacyApp)
# Remove MediaProvider after moving into APEX
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/MediaProvider)
# The core image variant has been renamed to ""
$(call add-clean-step, find $(SOONG_OUT_DIR)/.intermediates -type d -name "android_*_core*" -print0 | xargs -0 rm -rf)
# Remove 'media' command
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/bin/media)
# Remove CtsShim apks from system partition, since the have been moved inside
# the cts shim apex. Also remove the cts shim apex prebuilt since it has been
# removed in flattened apexs configurations.
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/CtsShimPrivPrebuilt)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/app/CtsShimPrebuilt)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/apex/com.android.apex.cts.shim.apex)
# Remove vendor and recovery variants, the directory name has changed.
$(call add-clean-step, find $(SOONG_OUT_DIR)/.intermediates -type d -name "android_*_recovery*" -print0 | xargs -0 rm -rf)
$(call add-clean-step, find $(SOONG_OUT_DIR)/.intermediates -type d -name "android_*_vendor*" -print0 | xargs -0 rm -rf)
# Remove PermissionController after moving into APEX
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/priv-app/*PermissionController)
# Clean up VTS-Core and VTS10 related artifacts.
$(call add-clean-step, rm -rf $(HOST_OUT)/vts-core/*)
$(call add-clean-step, rm -rf $(HOST_OUT)/framework/vts-core-tradefed.jar)
$(call add-clean-step, rm -rf $(HOST_OUT)/vts10/*)
$(call add-clean-step, rm -rf $(HOST_OUT)/framework/vts10-tradefed.jar)
# Clean up VTS again as VTS-Core will be renamed to VTS
$(call add-clean-step, rm -rf $(HOST_OUT)/vts/*)
$(call add-clean-step, rm -rf $(HOST_OUT)/framework/vts-tradefed.jar)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor/default.prop)
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/system/etc/prop.default)
# Workaround for Soong not being able to rebuild the host binary if its
# JNI dependencies change: b/170389375
$(call add-clean-step, rm -rf $(OUT_DIR)/soong/host/*/lib*/libconscrypt_openjdk_jni.so)
# vendor-ramdisk renamed to vendor_ramdisk
$(call add-clean-step, rm -rf $(PRODUCT_OUT)/vendor-ramdisk)
# Common R directory has been removed.
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/R)
# Most of SOONG_HOST_OUT_EXECUTABLES has been moved to HOST_OUT_EXECUTABLES
$(call add-clean-step, rm -rf $(SOONG_HOST_OUT))
# More of SOONG_HOST_OUT_EXECUTABLES has been moved to HOST_OUT_EXECUTABLES
$(call add-clean-step, rm -rf $(SOONG_HOST_OUT))
# More of SOONG_HOST_OUT_EXECUTABLES has been moved to HOST_OUT_EXECUTABLES
$(call add-clean-step, rm -rf $(SOONG_HOST_OUT))
# Last of SOONG_HOST_OUT_EXECUTABLES has been moved to HOST_OUT_EXECUTABLES
# Don't use SOONG_HOST_OUT, it is now an alias for HOST_OUT.
$(call add-clean-step, rm -rf $(OUT_DIR)/soong/host)
# Clear out tools/metalava Bazel output dir
$(call add-clean-step, rm -rf $(OUT_DIR)/bazel/output/execroot/__main__/bazel-out/mixed_builds_product-*/bin/tools/metalava)
# Clear out rustc compiler intermediates after reverting rust compiler/linker split.
$(call add-clean-step, find $(OUT_DIR) -name "*.rsp.whole.a" -print0 | xargs -0 /bin/bash -c 'rm -f $$$${@}; rm -f $$$${@/.rsp.whole.a/.rsp.a}; rm -f $$$${@/.rsp.whole.a/.rsp}')
# Remove obsolete java compilation artifacts
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/)
$(call add-clean-step, find $(OUT_DIR) -type f -name "*.jar" -print0 | xargs -0 rm -f)
# Remove obsolete java compilation artifacts
$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/)
$(call add-clean-step, find $(OUT_DIR) -type f -name "*.jar" -print0 | xargs -0 rm -f)
# Remove obsolete dexpreopt_config artifacts
$(call add-clean-step, rm -f $(PRODUCT_OUT)/dexpreopt_config/dexpreopt.config)
$(call add-clean-step, rm -f $(PRODUCT_OUT)/dexpreopt_config/dexpreopt_soong.config)
# Clear out Soong .intermediates directory regarding removal of hashed subdir
$(call add-clean-step, rm -rf $(OUT_DIR)/soong/.intermediates)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
================================================
FILE: Deprecation.md
================================================
# Deprecation of Make
We've made significant progress converting AOSP from Make to Soong (Android.mk
to Android.bp), and we're ready to start turning off pieces of Make. If you
have any problems converting, please contact us via:
* The [android-building@googlegroups.com] group.
* Our [public bug tracker](https://issuetracker.google.com/issues/new?component=381517).
* Or privately through your existing contacts at Google.
## Status
[build/make/core/deprecation.mk] is the source of truth, but for easy browsing:
| Module type | State |
| -------------------------------- | --------- |
| `BUILD_AUX_EXECUTABLE` | Obsolete |
| `BUILD_AUX_STATIC_LIBRARY` | Obsolete |
| `BUILD_COPY_HEADERS` | Error |
| `BUILD_HOST_EXECUTABLE` | Error |
| `BUILD_HOST_FUZZ_TEST` | Obsolete |
| `BUILD_HOST_NATIVE_TEST` | Obsolete |
| `BUILD_HOST_SHARED_LIBRARY` | Error |
| `BUILD_HOST_SHARED_TEST_LIBRARY` | Obsolete |
| `BUILD_HOST_STATIC_LIBRARY` | Error |
| `BUILD_HOST_STATIC_TEST_LIBRARY` | Obsolete |
| `BUILD_HOST_TEST_CONFIG` | Obsolete |
| `BUILD_NATIVE_BENCHMARK` | Obsolete |
| `BUILD_SHARED_TEST_LIBRARY` | Obsolete |
| `BUILD_STATIC_TEST_LIBRARY` | Obsolete |
| `BUILD_TARGET_TEST_CONFIG` | Obsolete |
| `BUILD_*` | Available |
## Module Type Deprecation Process
We'll be turning off `BUILD_*` module types as all of the users are removed
from AOSP (and Google's internal trees). The process will go something like
this, using `BUILD_PACKAGE` as an example:
* Prerequisite: all common users of `BUILD_PACKAGE` have been removed (some
device-specific ones may remain).
* `BUILD_PACKAGE` will be moved from `AVAILABLE_BUILD_MODULE_TYPES` to
`DEFAULT_WARNING_BUILD_MODULE_TYPES` in [build/make/core/deprecation.mk]. This
will make referring to `BUILD_PACKAGE` a warning.
* Any devices that still have warnings will have
`BUILD_BROKEN_USES_BUILD_PACKAGE := true` added to their `BoardConfig.mk`.
* `BUILD_PACKAGE` will be switched from `DEFAULT_WARNING_BUILD_MODULE_TYPES` to
`DEFAULT_ERROR_BUILD_MODULE_TYPES`, which will turn referring to
`BUILD_PACKAGE` into an error unless the device has overridden it.
* At some later point, after all devices in AOSP no longer set
`BUILD_BROKEN_USES_BUILD_PACKAGE`, `BUILD_PACKAGE` will be moved from
`DEFAULT_ERROR_BUILD_MODULE_TYPES` to `OBSOLETE_BUILD_MODULE_TYPES` and the
code will be removed. It will no longer be possible to use `BUILD_PACKAGE`.
In most cases, we expect module types to stay in the default warning state for
about two weeks before becoming an error by default. Then it will spend some
amount of time in the default error state before moving to obsolete -- we'll
try and keep that around for a while, but other development may cause those to
break, and the fix may to be to obsolete them. There is no expectation that the
`BUILD_BROKEN_USES_BUILD_*` workarounds will work in a future release, it's a
short-term workaround.
Just to be clear, the above process will happen on the AOSP master branch. So
if you're following Android releases, none of the deprecation steps will be in
Android Q, and the 2020 release will have jumped directly to the end for many
module types.
[android-building@googlegroups.com]: https://groups.google.com/forum/#!forum/android-building
[build/make/core/deprecation.mk]: /core/deprecation.mk
================================================
FILE: OWNERS
================================================
include platform/build/soong:/OWNERS
# Since this file affects all Android developers, lock it down. There is still
# round the world timzeone coverage.
per-file envsetup.sh = joeo@google.com, jingwen@google.com
per-file shell_utils.sh = joeo@google.com, jingwen@google.com
================================================
FILE: PREUPLOAD.cfg
================================================
[Hook Scripts]
do_not_use_DO_NOT_MERGE = ${REPO_ROOT}/build/soong/scripts/check_do_not_merge.sh ${PREUPLOAD_COMMIT}
[Builtin Hooks]
ktfmt = true
================================================
FILE: README.md
================================================
# Android Make Build System
This is the Makefile-based portion of the Android Build System.
For documentation on how to run a build, see [Usage.txt](Usage.txt)
For a list of behavioral changes useful for Android.mk writers see
[Changes.md](Changes.md)
For an outdated reference on Android.mk files, see
[build-system.html](/core/build-system.html). Our Android.mk files look similar,
but are entirely different from the Android.mk files used by the NDK build
system. When searching for documentation elsewhere, ensure that it is for the
platform build system -- most are not.
This Makefile-based system is in the process of being replaced with [Soong], a
new build system written in Go. During the transition, all of these makefiles
are read by [Kati], and generate a ninja file instead of being executed
directly. That's combined with a ninja file read by Soong so that the build
graph of the two systems can be combined and run as one.
[Kati]: https://github.com/google/kati
[Soong]: https://android.googlesource.com/platform/build/soong/+/master
================================================
FILE: Usage.txt
================================================
Android build system usage:
m [-j] [] [=...]
Ways to specify what to build:
The common way to specify what to build is to set that information in the
environment via:
# Set up the shell environment.
source build/envsetup.sh # Run "hmm" after sourcing for more info
# Select the device and variant to target. If no argument is given, it
# will list choices and prompt.
lunch [-] # Selects the device and variant to target.
# Invoke the configured build.
m [] [] [=...]
is the device that the created image is intended to be run on.
This is saved in the shell environment as $TARGET_PRODUCT by `lunch`.
is one of "user", "userdebug", or "eng", and controls the
amount of debugging to be added into the generated image.
This gets saved in the shell environment as $TARGET_BUILD_VARIANT by
`lunch`.
Each of , , and = is optional.
If no targets are specified, the build system will build the images
for the configured product and variant.
A target may be a file path. For example, out/host/linux-x86/bin/adb .
Note that when giving a relative file path as a target, that path is
interpreted relative to the root of the source tree (rather than relative
to the current working directory).
A target may also be any other target defined within a Makefile. Run
`m help` to view the names of some common targets.
To view the modules and targets defined in a particular directory, look for:
files named *.mk (most commonly Android.mk)
these files are defined in Make syntax
files named Android.bp
these files are defined in Blueprint syntax
During a build, a few log files are generated in ${OUT} (or ${DIST_DIR}/logs
for dist builds):
verbose.log.gz
every command run, along with its outputs. This is similar to the
previous `m showcommands` option.
error.log
list of actions that failed during the build, and their outputs.
soong.log
verbose debug information from soong_ui
For now, the full (extremely large) compiled list of targets can be found
(after running the build once), split among these two files:
${OUT}/build-*.ninja
${OUT}/soong/build.ninja
If you find yourself interacting with these files, you are encouraged to
provide a more convenient tool for browsing targets, and to mention the
tool here.
Targets that adjust an existing build:
dist Copy into ${DIST_DIR} the portion of the build
that must be distributed
Flags
-j Run processes at once
-j Autodetect the number of processes to run at once,
and run that many
Variables
Variables can either be set in the surrounding shell environment or can be
passed as command-line arguments. For example:
export I_AM_A_SHELL_VAR=1
I_AM_ANOTHER_SHELL_VAR=2 m droid I_AM_A_MAKE_VAR=3
Here are some common variables and their meanings:
TARGET_PRODUCT The to build # as described above
TARGET_BUILD_VARIANT The to build # as described above
DIST_DIR The directory in which to place the distribution
artifacts.
OUT_DIR The directory in which to place non-distribution
artifacts.
There is not yet known a convenient method by which to discover the full
list of supported variables. Please mention it here when there is.
================================================
FILE: backported_fixes/Android.bp
================================================
// Copyright 2024 Google Inc. All rights reserved.
//
// 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.
package {
default_applicable_licenses: ["Android-Apache-2.0"],
default_team: "trendy_team_android_media_reliability",
}
genrule {
name: "applied_backported_fixes",
tools: ["applied_backported_fixes_property_writer"],
srcs: [":applied_backported_fix_binpbs"],
out: ["applied_backported_fixes.prop"],
cmd: "$(location applied_backported_fixes_property_writer)" +
" -p $(location applied_backported_fixes.prop)" +
" $(in)",
}
filegroup {
name: "backported_fixes_proto_file",
srcs: [
"backported_fixes.proto",
],
}
java_library {
name: "backported_fixes_proto",
srcs: ["backported_fixes.proto"],
host_supported: true,
sdk_version: "current",
}
java_library {
name: "backported_fixes_common",
srcs: ["src/java/com/android/build/backportedfixes/common/*.java"],
static_libs: [
"backported_fixes_proto",
"guava",
],
host_supported: true,
}
java_test_host {
name: "backported_fixes_common_test",
srcs: ["tests/java/com/android/build/backportedfixes/common/*.java"],
static_libs: [
"backported_fixes_common",
"backported_fixes_proto",
"junit",
"truth",
"truth-liteproto-extension",
"truth-proto-extension",
],
test_options: {
unit_test: true,
},
test_suites: ["general-tests"],
}
java_library {
name: "backported_fixes_main_lib",
srcs: ["src/java/com/android/build/backportedfixes/*.java"],
static_libs: [
"backported_fixes_common",
"backported_fixes_proto",
"jcommander",
"guava",
],
host_supported: true,
}
java_binary_host {
name: "applied_backported_fixes_property_writer",
main_class: "com.android.build.backportedfixes.WriteBackportedFixesPropFile",
static_libs: [
"backported_fixes_main_lib",
],
}
java_binary_host {
name: "backported_fixes_combiner",
main_class: "com.android.build.backportedfixes.CombineBackportedFixes",
static_libs: [
"backported_fixes_main_lib",
],
}
// Combines BackportedFix binary proto files into a single BackportedFixes binary proto file.
genrule_defaults {
name: "default_backported_fixes_combiner",
tools: ["backported_fixes_combiner"],
cmd: "$(location backported_fixes_combiner)" +
" -o $(out)" +
" $(in)",
}
java_test_host {
name: "backported_fixes_main_lib_test",
srcs: ["tests/java/com/android/build/backportedfixes/*.java"],
static_libs: [
"backported_fixes_main_lib",
"backported_fixes_proto",
"junit",
"truth",
],
test_options: {
unit_test: true,
},
test_suites: ["general-tests"],
}
// Converts BackprotedFix text protos to binary protos
genrule_defaults {
name: "default_backported_fix_binpbs",
tools: ["aprotoc"],
tool_files: [
":backported_fixes_proto_file",
],
cmd: "$(location aprotoc) " +
" --encode=com.android.build.backportedfixes.BackportedFix" +
" $(location :backported_fixes_proto_file)" +
" < $(in)" +
" > $(out); echo $(out)",
}
gensrcs {
name: "applied_backported_fix_binpbs",
defaults: ["default_backported_fix_binpbs"],
output_extension: "binpb",
srcs: [
"applied_fixes/*.txtpb",
],
}
================================================
FILE: backported_fixes/OWNERS
================================================
essick@google.com
nchalko@google.com
portmannc@google.com
================================================
FILE: backported_fixes/applied_fixes/ki350037023.txtpb
================================================
# Copyright (C) 2024 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.
#
# proto-file: ../backported_fixes.proto
# proto-message: BackportedFix
known_issue: 350037023
alias: 1
================================================
FILE: backported_fixes/backported_fixes.proto
================================================
// Copyright (C) 2024 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.
syntax = "proto2";
package com.android.build.backportedfixes;
option java_multiple_files = true;
// A list of backported fixes.
message BackportedFixes {
repeated BackportedFix fixes = 1;
}
// A known issue approved for reporting Build.getBackportedFixStatus
message BackportedFix {
// The issue id from the public bug tracker
// https://issuetracker.google.com/issues/{known_issue}
optional int64 known_issue = 1;
// The alias for the known issue.
// 1 - 1023 are valid aliases
// Must be unique across all backported fixes.
optional int32 alias = 2;
}
================================================
FILE: backported_fixes/src/java/com/android/build/backportedfixes/CombineBackportedFixes.java
================================================
/*
* Copyright (C) 2024 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.
*/
package com.android.build.backportedfixes;
import com.android.build.backportedfixes.common.Parser;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.converters.FileConverter;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
/** Creates a BackportedFixes binary proto file from a list of BackportedFix proto binary files. */
public final class CombineBackportedFixes {
@Parameter(description = "BackportedFix proto binary files",
converter = FileConverter.class,
required = true)
List fixFiles;
@Parameter(description = "Write the BackportedFixes proto binary to this file",
names = {"--out","-o"},
converter = FileConverter.class,
required = true)
File outFile;
public static void main(String... argv) throws Exception {
CombineBackportedFixes main = new CombineBackportedFixes();
JCommander.newBuilder().addObject(main).build().parse(argv);
main.run();
}
CombineBackportedFixes() {
}
private void run() throws Exception {
try (var out = new FileOutputStream(outFile)) {
var fixes = Parser.parseBackportedFixFiles(fixFiles);
writeBackportedFixes(fixes, out);
}
}
static void writeBackportedFixes(BackportedFixes fixes, OutputStream out)
throws IOException {
fixes.writeTo(out);
}
}
================================================
FILE: backported_fixes/src/java/com/android/build/backportedfixes/WriteBackportedFixesPropFile.java
================================================
/*
* Copyright (C) 2024 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.
*/
package com.android.build.backportedfixes;
import static java.nio.charset.StandardCharsets.UTF_8;
import com.android.build.backportedfixes.common.Parser;
import com.beust.jcommander.JCommander;
import com.beust.jcommander.Parameter;
import com.beust.jcommander.converters.FileConverter;
import com.google.common.io.Files;
import java.io.File;
import java.io.PrintWriter;
import java.io.Writer;
import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;
/**
* Creates backported fix properties file.
*
*
Writes BitSet of backported fix aliases from a list of BackportedFix proto binary files and
* writes the property {@value PROPERTY_NAME} to a file.
*/
public final class WriteBackportedFixesPropFile {
private static final String PROPERTY_NAME = "ro.build.backported_fixes.alias_bitset.long_list";
@Parameter(description = "BackportedFix proto binary files",
converter = FileConverter.class,
required = true)
List fixFiles;
@Parameter(description = "The file to write the property value to.",
names = {"--property_file", "-p"},
converter = FileConverter.class,
required = true)
File propertyFile;
public static void main(String... argv) throws Exception {
WriteBackportedFixesPropFile main = new WriteBackportedFixesPropFile();
JCommander.newBuilder().addObject(main).build().parse(argv);
main.run();
}
WriteBackportedFixesPropFile() {
}
private void run() throws Exception {
try (var out = Files.newWriter(propertyFile, UTF_8)) {
var fixes = Parser.parseBackportedFixFiles(fixFiles);
writeFixesAsAliasBitSet(fixes, out);
}
}
static void writeFixesAsAliasBitSet(BackportedFixes fixes, Writer out) {
PrintWriter printWriter = new PrintWriter(out);
printWriter.println("# The following backported fixes have been applied");
for (var f : fixes.getFixesList()) {
printWriter.printf("# https://issuetracker.google.com/issues/%d with alias %d",
f.getKnownIssue(), f.getAlias());
printWriter.println();
}
var bsArray = Parser.getBitSetArray(
fixes.getFixesList().stream().mapToInt(BackportedFix::getAlias).toArray());
String bsString = Arrays.stream(bsArray).mapToObj(Long::toString).collect(
Collectors.joining(","));
printWriter.printf("%s=%s", PROPERTY_NAME, bsString);
printWriter.println();
if (printWriter.checkError()) {
throw new RuntimeException("There was an error writing to " + out.toString());
}
}
}
================================================
FILE: backported_fixes/src/java/com/android/build/backportedfixes/common/Parser.java
================================================
/*
* Copyright (C) 2024 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.
*/
package com.android.build.backportedfixes.common;
import static com.google.common.base.Preconditions.checkNotNull;
import com.android.build.backportedfixes.BackportedFix;
import com.android.build.backportedfixes.BackportedFixes;
import com.google.common.base.Throwables;
import com.google.common.collect.ImmutableList;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.BitSet;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collector;
import java.util.stream.Collectors;
/** Static utilities for working with {@link BackportedFixes}. */
public final class Parser {
/** Creates list of FileInputStreams for a list of files. */
public static ImmutableList getFileInputStreams(List fixFiles) throws
FileNotFoundException {
var streams = ImmutableList.builder();
for (var f : fixFiles) {
streams.add(new FileInputStream(f));
}
return streams.build();
}
/** Converts a list of backported fix aliases into a long array representing a {@link BitSet} */
public static long[] getBitSetArray(int[] aliases) {
BitSet bs = new BitSet();
for (int a : aliases) {
bs.set(a);
}
return bs.toLongArray();
}
/**
* Creates a {@link BackportedFixes} from a list of {@link BackportedFix} binary proto streams.
*/
public static BackportedFixes parseBackportedFixFiles(List fixFiles)
throws IOException {
try {
return fixFiles.stream().map(Parser::tunelFileInputStream)
.map(Parser::tunnelParse)
.sorted(Comparator.comparing(BackportedFix::getKnownIssue))
.collect(fixCollector());
} catch (TunnelException e) {
throw e.rethrow(FileNotFoundException.class, IOException.class);
}
}
private static Collector fixCollector() {
return Collectors.collectingAndThen(Collectors.toList(), fixList -> {
var result = BackportedFixes.newBuilder();
result.addAllFixes(fixList);
return result.build();
});
}
private static FileInputStream tunelFileInputStream(File file) throws TunnelException {
try {
return new FileInputStream(file);
} catch (FileNotFoundException e) {
throw new TunnelException(e);
}
}
private static BackportedFix tunnelParse(InputStream s) throws TunnelException {
try {
var fix = BackportedFix.parseFrom(s);
s.close();
return fix;
} catch (IOException e) {
throw new TunnelException(e);
}
}
private static class TunnelException extends RuntimeException {
TunnelException(Exception cause) {
super("If you see this TunnelException something went wrong. It should always be rethrown as the cause.", cause);
}
RuntimeException rethrow(Class exceptionClazz) throws X {
checkNotNull(exceptionClazz);
Throwables.throwIfInstanceOf(getCause(), exceptionClazz);
throw exception(
getCause(),
"rethrow(%s) doesn't match underlying exception", exceptionClazz);
}
public RuntimeException rethrow(
Class exceptionClazz1, Class exceptionClazz2) throws X1, X2 {
checkNotNull(exceptionClazz1);
checkNotNull(exceptionClazz2);
Throwables.throwIfInstanceOf(getCause(), exceptionClazz1);
Throwables.throwIfInstanceOf(getCause(), exceptionClazz2);
throw exception(
getCause(),
"rethrow(%s, %s) doesn't match underlying exception",
exceptionClazz1,
exceptionClazz2);
}
private static ClassCastException exception(
Throwable cause, String message, Object... formatArgs) {
ClassCastException result = new ClassCastException(String.format(message, formatArgs));
result.initCause(cause);
return result;
}
}
private Parser() {
}
}
================================================
FILE: backported_fixes/tests/java/com/android/build/backportedfixes/CombineBackportedFixesTest.java
================================================
/*
* Copyright (C) 2024 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.
*/
package com.android.build.backportedfixes;
import com.google.common.truth.Truth;
import org.junit.Test;
import java.io.ByteArrayOutputStream;
import java.io.IOException;
/** Tests for {@link CombineBackportedFixes}. */
public class CombineBackportedFixesTest {
@Test
public void writeBackportedFixes_default() throws IOException {
// Not much of a test, but there is not much to test.
BackportedFixes fixes = BackportedFixes.newBuilder()
.addFixes(BackportedFix.newBuilder().setKnownIssue(123).build())
.build();
var result = new ByteArrayOutputStream();
CombineBackportedFixes.writeBackportedFixes(fixes, result);
Truth.assertThat(BackportedFixes.parseFrom(result.toByteArray()))
.isEqualTo(fixes);
}
}
================================================
FILE: backported_fixes/tests/java/com/android/build/backportedfixes/WriteBackportedFixesPropFileTest.java
================================================
/*
* Copyright (C) 2024 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.
*/
package com.android.build.backportedfixes;
import com.google.common.truth.Truth;
import org.junit.Test;
import java.io.PrintWriter;
import java.io.StringWriter;
/** Tests for {@link WriteBackportedFixesPropFile}. */
public class WriteBackportedFixesPropFileTest {
@Test
public void writeFixesAsAliasBitSet_default() {
BackportedFixes fixes = BackportedFixes.newBuilder().build();
var result = new StringWriter();
WriteBackportedFixesPropFile.writeFixesAsAliasBitSet(fixes, new PrintWriter(result));
Truth.assertThat(result.toString())
.isEqualTo("""
# The following backported fixes have been applied
ro.build.backported_fixes.alias_bitset.long_list=
""");
}
@Test
public void writeFixesAsAliasBitSet_some() {
BackportedFixes fixes = BackportedFixes.newBuilder()
.addFixes(BackportedFix.newBuilder().setKnownIssue(1234L).setAlias(1))
.addFixes(BackportedFix.newBuilder().setKnownIssue(3L).setAlias(65))
.addFixes(BackportedFix.newBuilder().setKnownIssue(4L).setAlias(67))
.build();
var result = new StringWriter();
WriteBackportedFixesPropFile.writeFixesAsAliasBitSet(fixes, new PrintWriter(result));
Truth.assertThat(result.toString())
.isEqualTo("""
# The following backported fixes have been applied
# https://issuetracker.google.com/issues/1234 with alias 1
# https://issuetracker.google.com/issues/3 with alias 65
# https://issuetracker.google.com/issues/4 with alias 67
ro.build.backported_fixes.alias_bitset.long_list=2,10
""");
}
}
================================================
FILE: backported_fixes/tests/java/com/android/build/backportedfixes/common/ParserTest.java
================================================
/*
* Copyright (C) 2024 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.
*/
package com.android.build.backportedfixes.common;
import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.extensions.proto.ProtoTruth.assertThat;
import com.android.build.backportedfixes.BackportedFix;
import com.android.build.backportedfixes.BackportedFixes;
import com.google.common.collect.ImmutableList;
import org.junit.Rule;
import org.junit.Test;
import org.junit.rules.TemporaryFolder;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.nio.file.Files;
/** Tests for {@link Parser}.*/
public class ParserTest {
@Rule
public TemporaryFolder mTempFolder = new TemporaryFolder();
@Test
public void getFileInputStreams() throws IOException {
var results = Parser.getFileInputStreams(
ImmutableList.of(Files.createTempFile("test", null).toFile()));
assertThat(results).isNotEmpty();
}
@Test
public void getBitSetArray_empty() {
var results = Parser.getBitSetArray(new int[]{});
assertThat(results).isEmpty();
}
@Test
public void getBitSetArray_2_3_64() {
var results = Parser.getBitSetArray(new int[]{2,3,64});
assertThat(results).asList().containsExactly(12L,1L).inOrder();
}
@Test
public void parseBackportedFixFiles_empty() throws IOException {
var result = Parser.parseBackportedFixFiles(ImmutableList.of());
assertThat(result).isEqualTo(BackportedFixes.getDefaultInstance());
}
@Test
public void parseBackportedFixFiles_oneBlank() throws IOException {
var result = Parser.parseBackportedFixFiles(ImmutableList.of(mTempFolder.newFile()));
assertThat(result).isEqualTo(
BackportedFixes.newBuilder()
.addFixes(BackportedFix.getDefaultInstance())
.build());
}
@Test
public void parseBackportedFixFiles_two() throws IOException {
BackportedFix ki123 = BackportedFix.newBuilder()
.setKnownIssue(123)
.setAlias(1)
.build();
BackportedFix ki456 = BackportedFix.newBuilder()
.setKnownIssue(456)
.setAlias(2)
.build();
var result = Parser.parseBackportedFixFiles(
ImmutableList.of(tempFile(ki456), tempFile(ki123)));
assertThat(result).isEqualTo(
BackportedFixes.newBuilder()
.addFixes(ki123)
.addFixes(ki456)
.build());
}
private File tempFile(BackportedFix fix) throws IOException {
File f = mTempFolder.newFile();
try (FileOutputStream out = new FileOutputStream(f)) {
fix.writeTo(out);
return f;
}
}
}
================================================
FILE: banchanHelp.sh
================================================
#!/bin/bash
# locate some directories
cd "$(dirname $0)"
SCRIPT_DIR="${PWD}"
cd ../..
TOP="${PWD}"
message='usage: banchan ... [|arm|x86|arm64|x86_64] [eng|userdebug|user]
banchan selects individual APEX modules to be built by the Android build system.
Like "tapas", "banchan" does not request the building of images for a device but
instead configures it for an unbundled build of the given modules, suitable for
installing on any api-compatible device.
The difference from "tapas" is that "banchan" sets the appropriate products etc
for building APEX modules rather than apps (APKs).
The module names should match apex{} modules in Android.bp files, typically
starting with "com.android.".
The product argument should be a product name ending in "_", where
is one of arm, x86, arm64, x86_64. It can also be just an arch, in which case
the standard product for building modules with that architecture is used, i.e.
module_.
The usage of the other arguments matches that of the rest of the platform
build system and can be found by running `m help`'
echo "$message"
================================================
FILE: buildspec.mk.default
================================================
#
# Copyright (C) 2007 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.
#
######################################################################
# This is a do-nothing template file. To use it, copy it to a file
# named "buildspec.mk" in the root directory, and uncomment or change
# the variables necessary for your desired configuration. The file
# "buildspec.mk" should never be checked in to source control.
######################################################################
# Choose a product to build for. Look in the products directory for ones
# that work.
ifndef TARGET_PRODUCT
#TARGET_PRODUCT:=generic
endif
# Choose a variant to build. If you don't pick one, the default is eng.
# User is what we ship. Userdebug is that, with a few flags turned on
# for debugging. Eng has lots of extra tools for development.
ifndef TARGET_BUILD_VARIANT
#TARGET_BUILD_VARIANT:=user
#TARGET_BUILD_VARIANT:=userdebug
#TARGET_BUILD_VARIANT:=eng
endif
# Choose a targeted release. If you don't pick one, the default is the
# soonest future release.
ifndef TARGET_PLATFORM_RELEASE
#TARGET_PLATFORM_RELEASE:=OPR1
endif
# Choose additional targets to always install, even when building
# minimal targets like "make droid". This takes simple target names
# like "Browser" or "MyApp", the names used by LOCAL_MODULE or
# LOCAL_PACKAGE_NAME. Modules listed here will always be installed in
# /system, even if they'd usually go in /data.
ifndef CUSTOM_MODULES
#CUSTOM_MODULES:=
endif
# Set this to debug or release if you care. Otherwise, it defaults to release.
ifndef TARGET_BUILD_TYPE
#TARGET_BUILD_TYPE:=release
endif
# Uncomment this if you want the host tools built in debug mode. Otherwise
# it defaults to release.
ifndef HOST_BUILD_TYPE
#HOST_BUILD_TYPE:=debug
endif
# Turn on debugging for selected modules. If DEBUG_MODULE_ is set
# to a non-empty value, the appropriate HOST_/TARGET_CUSTOM_DEBUG_CFLAGS
# will be added to LOCAL_CFLAGS when building the module.
#DEBUG_MODULE_ModuleName:=true
# Specify the extra CFLAGS to use when building a module whose
# DEBUG_MODULE_ variable is set. Host and device flags are handled
# separately.
#HOST_CUSTOM_DEBUG_CFLAGS:=
#TARGET_CUSTOM_DEBUG_CFLAGS:=
# Choose additional locales, like "en_US" or "it_IT", to add to any
# built product. Any locales that appear in CUSTOM_LOCALES but not in
# the locale list for the selected product will be added to the end
# of PRODUCT_LOCALES.
ifndef CUSTOM_LOCALES
#CUSTOM_LOCALES:=
endif
# If you have a special place to put your ouput files, set this, otherwise
# it goes to /out
#OUT_DIR:=/tmp/stuff
# If you want to always set certain system properties, add them to this list.
# E.g., "ADDITIONAL_BUILD_PROPERTIES += ro.prop1=5 prop2=value"
# This mechanism does not currently support values containing spaces.
#ADDITIONAL_BUILD_PROPERTIES +=
# If you want to reduce the system.img size by several meg, and are willing to
# lose access to CJK (and other) character sets, define NO_FALLBACK_FONT:=true
ifndef NO_FALLBACK_FONT
#NO_FALLBACK_FONT:=true
endif
# OVERRIDE_RUNTIMES allows you to locally override PRODUCT_RUNTIMES.
#
# To only build ART, use "runtime_libart_default"
# To use Dalvik but also include ART, use "runtime_libdvm_default runtime_libart"
# To use ART but also include Dalvik, use "runtime_libart_default runtime_libdvm"
ifndef OVERRIDE_RUNTIMES
#OVERRIDE_RUNTIMES:=runtime_libart_default
#OVERRIDE_RUNTIMES:=runtime_libdvm_default runtime_libart
#OVERRIDE_RUNTIMES:=runtime_libart_default runtime_libdvm
endif
# when the build system changes such that this file must be updated, this
# variable will be changed. After you have modified this file with the new
# changes (see buildspec.mk.default), update this to the new value from
# buildspec.mk.default.
BUILD_ENV_SEQUENCE_NUMBER := 13
================================================
FILE: ci/Android.bp
================================================
// Copyright 2024 Google Inc. All rights reserved.
//
// 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.
package {
default_applicable_licenses: ["Android-Apache-2.0"],
default_team: "trendy_team_adte",
}
python_test_host {
name: "build_test_suites_test",
main: "build_test_suites_test.py",
pkg_path: "testdata",
srcs: [
"build_test_suites_test.py",
],
libs: [
"build_test_suites_lib",
"pyfakefs",
"ci_test_lib",
],
test_options: {
unit_test: true,
},
data: [
":py3-cmd",
],
}
// This test is only intended to be run locally since it's slow, not hermetic,
// and requires a lot of system state. It is therefore not marked as `unit_test`
// and is not part of any test suite. Note that we also don't want to run this
// test with Bazel since that would require disabling sandboxing and explicitly
// passing in all the env vars we depend on via the command-line. The test
// target could be configured to do so but it's not worth doing seeing that
// we're moving away from Bazel.
python_test_host {
name: "build_test_suites_local_test",
main: "build_test_suites_local_test.py",
srcs: [
"build_test_suites_local_test.py",
],
libs: [
"build_test_suites_lib",
"pyfakefs",
"ci_test_lib",
],
test_config_template: "AndroidTest.xml.template",
test_options: {
unit_test: false,
},
}
python_test_host {
name: "optimized_targets_test",
main: "optimized_targets_test.py",
pkg_path: "testdata",
srcs: [
"optimized_targets_test.py",
],
libs: [
"build_test_suites_lib",
"pyfakefs",
],
test_options: {
unit_test: true,
},
data: [
":py3-cmd",
],
}
python_binary_host {
name: "build_test_suites",
srcs: [
"build_test_suites.py",
"optimized_targets.py",
"test_mapping_module_retriever.py",
"build_context.py",
"test_discovery_agent.py",
"metrics_agent.py",
"buildbot.py",
],
main: "build_test_suites.py",
libs: [
"soong-metrics-proto-py",
],
}
python_library_host {
name: "build_test_suites_lib",
srcs: [
"build_test_suites.py",
"optimized_targets.py",
"test_mapping_module_retriever.py",
"build_context.py",
"test_discovery_agent.py",
"metrics_agent.py",
"buildbot.py",
],
libs: [
"soong-metrics-proto-py",
],
}
python_library_host {
name: "ci_test_lib",
srcs: [
"ci_test_lib.py",
],
}
================================================
FILE: ci/AndroidTest.xml.template
================================================
================================================
FILE: ci/build_context.py
================================================
# Copyright 2024, 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.
"""Container class for build context with utility functions."""
import re
class BuildContext:
def __init__(self, build_context_dict: dict[str, any]):
self.enabled_build_features = set()
for opt in build_context_dict.get('enabledBuildFeatures', []):
self.enabled_build_features.add(opt.get('name'))
self.test_infos = set()
for test_info_dict in build_context_dict.get('testContext', dict()).get(
'testInfos', []
):
self.test_infos.add(self.TestInfo(test_info_dict))
def build_target_used(self, target: str) -> bool:
return any(test.build_target_used(target) for test in self.test_infos)
class TestInfo:
_DOWNLOAD_OPTS = {
'test-config-only-zip',
'test-zip-file-filter',
'extra-host-shared-lib-zip',
'sandbox-tests-zips',
'additional-files-filter',
'cts-package-name',
}
def __init__(self, test_info_dict: dict[str, any]):
self.is_test_mapping = False
self.test_mapping_test_groups = set()
self.file_download_options = set()
self.name = test_info_dict.get('name')
self.command = test_info_dict.get('command')
self.extra_options = test_info_dict.get('extraOptions')
for opt in test_info_dict.get('extraOptions', []):
key = opt.get('key')
if key == 'test-mapping-test-group':
self.is_test_mapping = True
self.test_mapping_test_groups.update(opt.get('values', set()))
if key in self._DOWNLOAD_OPTS:
self.file_download_options.update(opt.get('values', set()))
def build_target_used(self, target: str) -> bool:
# For all of a targets' outputs, check if any of the regexes used by tests
# to download artifacts would match it. If any of them do then this target
# is necessary.
regex = r'\b(%s)\b' % re.escape(target)
return any(re.search(regex, opt) for opt in self.file_download_options)
================================================
FILE: ci/build_device_and_tests
================================================
#!/usr/bin/env bash
#
# Copyright 2024, 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.
set -euo pipefail
build/soong/soong_ui.bash --make-mode build_test_suites
$(build/soong/soong_ui.bash --dumpvar-mode HOST_OUT)/bin/build_test_suites --device-build $@
================================================
FILE: ci/build_metadata
================================================
#/bin/bash
# Copyright 2024, 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.
set -x
source build/make/shell_utils.sh
export TARGET_PRODUCT=aosp_arm64
export TARGET_RELEASE=trunk_staging
export TARGET_BUILD_VARIANT=eng
import_build_vars \
OUT_DIR \
DIST_DIR \
HOST_OUT_EXECUTABLES \
|| exit $?
TARGETS=(
all_teams
source_tree_size
release_config_metadata
)
# Build modules
build/soong/bin/m dist ${TARGETS[@]} || exit $?
# List all source files in the tree
( \
$HOST_OUT_EXECUTABLES/source_tree_size -o $DIST_DIR/all_source_tree_files.pb \
&& gzip -fn $DIST_DIR/all_source_tree_files.pb \
) || exit $?
================================================
FILE: ci/build_test_suites
================================================
#!/usr/bin/env bash
#
# Copyright 2024, 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.
set -euo pipefail
build/soong/soong_ui.bash --make-mode build_test_suites
$(build/soong/soong_ui.bash --dumpvar-mode HOST_OUT)/bin/build_test_suites $@
================================================
FILE: ci/build_test_suites.py
================================================
# Copyright 2024, 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.
"""Build script for the CI `test_suites` target."""
import argparse
from dataclasses import dataclass
import json
import logging
import os
import pathlib
import re
import subprocess
import sys
from typing import Callable
from build_context import BuildContext
import optimized_targets
import metrics_agent
import test_discovery_agent
REQUIRED_ENV_VARS = frozenset(['TARGET_PRODUCT', 'TARGET_RELEASE', 'TOP', 'DIST_DIR'])
SOONG_UI_EXE_REL_PATH = 'build/soong/soong_ui.bash'
LOG_PATH = 'logs/build_test_suites.log'
# Currently, this prevents the removal of those tags when they exist. In the future we likely
# want the script to supply 'dist directly
REQUIRED_BUILD_TARGETS = frozenset(['dist', 'droid', 'checkbuild'])
class Error(Exception):
def __init__(self, message):
super().__init__(message)
class BuildFailureError(Error):
def __init__(self, return_code):
super().__init__(f'Build command failed with return code: f{return_code}')
self.return_code = return_code
class BuildPlanner:
"""Class in charge of determining how to optimize build targets.
Given the build context and targets to build it will determine a final list of
targets to build along with getting a set of packaging functions to package up
any output zip files needed by the build.
"""
def __init__(
self,
build_context: BuildContext,
args: argparse.Namespace,
target_optimizations: dict[str, optimized_targets.OptimizedBuildTarget],
):
self.build_context = build_context
self.args = args
self.target_optimizations = target_optimizations
def create_build_plan(self):
if 'optimized_build' not in self.build_context.enabled_build_features:
return BuildPlan(set(self.args.extra_targets), set())
if not self.build_context.test_infos:
logging.warning('Build context has no test infos, skipping optimizations.')
for target in self.args.extra_targets:
get_metrics_agent().report_unoptimized_target(target, 'BUILD_CONTEXT has no test infos.')
return BuildPlan(set(self.args.extra_targets), set())
build_targets = set()
packaging_commands_getters = []
# In order to roll optimizations out differently between test suites and
# device builds, we have separate flags.
enable_discovery = (('test_suites_zip_test_discovery'
in self.build_context.enabled_build_features
and not self.args.device_build
) or (
'device_zip_test_discovery'
in self.build_context.enabled_build_features
and self.args.device_build
)) and not self.args.test_discovery_info_mode
logging.info(f'Discovery mode is enabled= {enable_discovery}')
preliminary_build_targets = self._collect_preliminary_build_targets(enable_discovery)
for target in preliminary_build_targets:
target_optimizer_getter = self.target_optimizations.get(target, None)
if not target_optimizer_getter:
build_targets.add(target)
continue
target_optimizer = target_optimizer_getter(
target, self.build_context, self.args
)
build_targets.update(target_optimizer.get_build_targets())
packaging_commands_getters.append(
target_optimizer.get_package_outputs_commands
)
return BuildPlan(build_targets, packaging_commands_getters)
def _collect_preliminary_build_targets(self, enable_discovery: bool):
build_targets = set()
try:
test_discovery_zip_regexes = self._get_test_discovery_zip_regexes()
logging.info(f'Discovered test discovery regexes: {test_discovery_zip_regexes}')
except test_discovery_agent.TestDiscoveryError as e:
optimization_rationale = e.message
logging.warning(f'Unable to perform test discovery: {optimization_rationale}')
for target in self.args.extra_targets:
get_metrics_agent().report_unoptimized_target(target, optimization_rationale)
return self._legacy_collect_preliminary_build_targets()
for target in self.args.extra_targets:
if target in REQUIRED_BUILD_TARGETS:
build_targets.add(target)
get_metrics_agent().report_unoptimized_target(target, 'Required build target.')
continue
# If nothing is discovered without error, that means nothing is needed.
if not test_discovery_zip_regexes:
get_metrics_agent().report_optimized_target(target)
continue
regex = r'\b(%s.*)\b' % re.escape(target)
for opt in test_discovery_zip_regexes:
try:
if re.search(regex, opt):
get_metrics_agent().report_unoptimized_target(target, 'Test artifact used.')
build_targets.add(target)
# proceed to next target evaluation
break
get_metrics_agent().report_optimized_target(target)
except Exception as e:
# In case of exception report as unoptimized
build_targets.add(target)
get_metrics_agent().report_unoptimized_target(target, f'Error in parsing test discovery output for {target}: {repr(e)}')
logging.error(f'unable to parse test discovery output: {repr(e)}')
break
# If discovery is not enabled, return the original list
if not enable_discovery:
return self._legacy_collect_preliminary_build_targets()
return build_targets
def _legacy_collect_preliminary_build_targets(self):
build_targets = set()
for target in self.args.extra_targets:
if self._unused_target_exclusion_enabled(
target
) and not self.build_context.build_target_used(target):
continue
build_targets.add(target)
return build_targets
def _unused_target_exclusion_enabled(self, target: str) -> bool:
return (
f'{target}_unused_exclusion'
in self.build_context.enabled_build_features
)
def _get_test_discovery_zip_regexes(self) -> set[str]:
build_target_regexes = set()
for test_info in self.build_context.test_infos:
tf_command = self._build_tf_command(test_info)
discovery_agent = test_discovery_agent.TestDiscoveryAgent(tradefed_args=tf_command)
for regex in discovery_agent.discover_test_zip_regexes():
build_target_regexes.add(regex)
return build_target_regexes
def _build_tf_command(self, test_info) -> list[str]:
command = [test_info.command]
for extra_option in test_info.extra_options:
if not extra_option.get('key'):
continue
arg_key = '--' + extra_option.get('key')
if arg_key == '--build-id':
command.append(arg_key)
command.append(os.environ.get('BUILD_NUMBER'))
continue
if extra_option.get('values'):
for value in extra_option.get('values'):
command.append(arg_key)
command.append(value)
else:
command.append(arg_key)
return command
@dataclass(frozen=True)
class BuildPlan:
build_targets: set[str]
packaging_commands_getters: list[Callable[[], list[list[str]]]]
def build_test_suites(argv: list[str]) -> int:
"""Builds all test suites passed in, optimizing based on the build_context content.
Args:
argv: The command line arguments passed in.
Returns:
The exit code of the build.
"""
get_metrics_agent().analysis_start()
try:
args = parse_args(argv)
check_required_env()
build_context = BuildContext(load_build_context())
build_planner = BuildPlanner(
build_context, args, optimized_targets.OPTIMIZED_BUILD_TARGETS
)
build_plan = build_planner.create_build_plan()
except:
raise
finally:
get_metrics_agent().analysis_end()
try:
execute_build_plan(build_plan)
except BuildFailureError as e:
logging.error('Build command failed! Check build_log for details.')
return e.return_code
finally:
get_metrics_agent().end_reporting()
return 0
def parse_args(argv: list[str]) -> argparse.Namespace:
argparser = argparse.ArgumentParser()
argparser.add_argument(
'extra_targets', nargs='*', help='Extra test suites to build.'
)
argparser.add_argument(
'--device-build',
action='store_true',
help='Flag to indicate running a device build.',
)
argparser.add_argument(
'--test_discovery_info_mode',
action='store_true',
help='Flag to enable running test discovery in info only mode.',
)
return argparser.parse_args(argv)
def check_required_env():
"""Check for required env vars.
Raises:
RuntimeError: If any required env vars are not found.
"""
missing_env_vars = sorted(v for v in REQUIRED_ENV_VARS if v not in os.environ)
if not missing_env_vars:
return
t = ','.join(missing_env_vars)
raise Error(f'Missing required environment variables: {t}')
def load_build_context():
build_context_path = pathlib.Path(os.environ.get('BUILD_CONTEXT', ''))
if build_context_path.is_file():
try:
with open(build_context_path, 'r') as f:
return json.load(f)
except json.decoder.JSONDecodeError as e:
raise Error(f'Failed to load JSON file: {build_context_path}')
logging.info('No BUILD_CONTEXT found, skipping optimizations.')
return empty_build_context()
def empty_build_context():
return {'enabledBuildFeatures': []}
def execute_build_plan(build_plan: BuildPlan):
build_command = []
build_command.append(get_top().joinpath(SOONG_UI_EXE_REL_PATH))
build_command.append('--make-mode')
build_command.extend(build_plan.build_targets)
logging.info(f'Running build command: {build_command}')
try:
run_command(build_command)
except subprocess.CalledProcessError as e:
raise BuildFailureError(e.returncode) from e
get_metrics_agent().packaging_start()
try:
for packaging_commands_getter in build_plan.packaging_commands_getters:
for packaging_command in packaging_commands_getter():
run_command(packaging_command)
except subprocess.CalledProcessError as e:
raise BuildFailureError(e.returncode) from e
finally:
get_metrics_agent().packaging_end()
def get_top() -> pathlib.Path:
return pathlib.Path(os.environ['TOP'])
def run_command(args: list[str], stdout=None):
subprocess.run(args=args, check=True, stdout=stdout)
def get_metrics_agent():
return metrics_agent.MetricsAgent.instance()
def main(argv):
dist_dir = os.environ.get('DIST_DIR')
if dist_dir:
log_file = pathlib.Path(dist_dir) / LOG_PATH
logging.basicConfig(
level=logging.DEBUG,
format='%(asctime)s %(levelname)s %(message)s',
filename=log_file,
)
sys.exit(build_test_suites(argv))
if __name__ == '__main__':
main(sys.argv[1:])
================================================
FILE: ci/build_test_suites_local_test.py
================================================
# Copyright 2024, 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.
"""Integration tests for build_test_suites that require a local build env."""
import os
import pathlib
import shutil
import signal
import subprocess
import tempfile
import time
import ci_test_lib
class BuildTestSuitesLocalTest(ci_test_lib.TestCase):
def setUp(self):
self.top_dir = pathlib.Path(os.environ['ANDROID_BUILD_TOP']).resolve()
self.executable = self.top_dir.joinpath('build/make/ci/build_test_suites')
self.process_session = ci_test_lib.TemporaryProcessSession(self)
self.temp_dir = ci_test_lib.TestTemporaryDirectory.create(self)
def build_subprocess_args(self, build_args: list[str]):
env = os.environ.copy()
env['TOP'] = str(self.top_dir)
env['OUT_DIR'] = self.temp_dir
args = ([self.executable] + build_args,)
kwargs = {
'cwd': self.top_dir,
'env': env,
'text': True,
}
return (args, kwargs)
def run_build(self, build_args: list[str]) -> subprocess.CompletedProcess:
args, kwargs = self.build_subprocess_args(build_args)
return subprocess.run(
*args,
**kwargs,
check=True,
capture_output=True,
timeout=5 * 60,
)
def assert_children_alive(self, children: list[int]):
for c in children:
self.assertTrue(ci_test_lib.process_alive(c))
def assert_children_dead(self, children: list[int]):
for c in children:
self.assertFalse(ci_test_lib.process_alive(c))
def test_fails_for_invalid_arg(self):
invalid_arg = '--invalid-arg'
with self.assertRaises(subprocess.CalledProcessError) as cm:
self.run_build([invalid_arg])
self.assertIn(invalid_arg, cm.exception.stderr)
def test_builds_successfully(self):
self.run_build(['nothing'])
def test_can_interrupt_build(self):
args, kwargs = self.build_subprocess_args(['general-tests'])
p = self.process_session.create(args, kwargs)
# TODO(lucafarsi): Replace this (and other instances) with a condition.
time.sleep(5) # Wait for the build to get going.
self.assertIsNone(p.poll()) # Check that the process is still alive.
children = query_child_pids(p.pid)
self.assert_children_alive(children)
p.send_signal(signal.SIGINT)
p.wait()
time.sleep(5) # Wait for things to die out.
self.assert_children_dead(children)
def test_can_kill_build_process_group(self):
args, kwargs = self.build_subprocess_args(['general-tests'])
p = self.process_session.create(args, kwargs)
time.sleep(5) # Wait for the build to get going.
self.assertIsNone(p.poll()) # Check that the process is still alive.
children = query_child_pids(p.pid)
self.assert_children_alive(children)
os.killpg(os.getpgid(p.pid), signal.SIGKILL)
p.wait()
time.sleep(5) # Wait for things to die out.
self.assert_children_dead(children)
# TODO(hzalek): Replace this with `psutils` once available in the tree.
def query_child_pids(parent_pid: int) -> set[int]:
p = subprocess.run(
['pgrep', '-P', str(parent_pid)],
check=True,
capture_output=True,
text=True,
)
return {int(pid) for pid in p.stdout.splitlines()}
if __name__ == '__main__':
ci_test_lib.main()
================================================
FILE: ci/build_test_suites_test.py
================================================
# Copyright 2024, 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.
"""Tests for build_test_suites.py"""
import argparse
import functools
from importlib import resources
import json
import multiprocessing
import os
import pathlib
import shutil
import signal
import stat
import subprocess
import sys
import tempfile
import textwrap
import time
from typing import Callable
import unittest
from unittest import mock
from build_context import BuildContext
import build_test_suites
import ci_test_lib
import optimized_targets
from pyfakefs import fake_filesystem_unittest
import metrics_agent
import test_discovery_agent
class BuildTestSuitesTest(fake_filesystem_unittest.TestCase):
def setUp(self):
self.setUpPyfakefs()
os_environ_patcher = mock.patch.dict('os.environ', {})
self.addCleanup(os_environ_patcher.stop)
self.mock_os_environ = os_environ_patcher.start()
subprocess_run_patcher = mock.patch('subprocess.run')
self.addCleanup(subprocess_run_patcher.stop)
self.mock_subprocess_run = subprocess_run_patcher.start()
metrics_agent_finalize_patcher = mock.patch('metrics_agent.MetricsAgent.end_reporting')
self.addCleanup(metrics_agent_finalize_patcher.stop)
self.mock_metrics_agent_end = metrics_agent_finalize_patcher.start()
self._setup_working_build_env()
def test_missing_target_release_env_var_raises(self):
del os.environ['TARGET_RELEASE']
with self.assert_raises_word(build_test_suites.Error, 'TARGET_RELEASE'):
build_test_suites.main([])
def test_missing_target_product_env_var_raises(self):
del os.environ['TARGET_PRODUCT']
with self.assert_raises_word(build_test_suites.Error, 'TARGET_PRODUCT'):
build_test_suites.main([])
def test_missing_top_env_var_raises(self):
del os.environ['TOP']
with self.assert_raises_word(build_test_suites.Error, 'TOP'):
build_test_suites.main([])
def test_missing_dist_dir_env_var_raises(self):
del os.environ['DIST_DIR']
with self.assert_raises_word(build_test_suites.Error, 'DIST_DIR'):
build_test_suites.main([])
def test_invalid_arg_raises(self):
invalid_args = ['--invalid_arg']
with self.assertRaisesRegex(SystemExit, '2'):
build_test_suites.main(invalid_args)
def test_build_failure_returns(self):
self.mock_subprocess_run.side_effect = subprocess.CalledProcessError(
42, None
)
with self.assertRaisesRegex(SystemExit, '42'):
build_test_suites.main([])
def test_incorrectly_formatted_build_context_raises(self):
build_context = self.fake_top.joinpath('build_context')
build_context.touch()
os.environ['BUILD_CONTEXT'] = str(build_context)
with self.assert_raises_word(build_test_suites.Error, 'JSON'):
build_test_suites.main([])
def test_build_success_returns(self):
with self.assertRaisesRegex(SystemExit, '0'):
build_test_suites.main([])
def assert_raises_word(self, cls, word):
return self.assertRaisesRegex(cls, rf'\b{word}\b')
def _setup_working_build_env(self):
self.fake_top = pathlib.Path('/fake/top')
self.fake_top.mkdir(parents=True)
self.soong_ui_dir = self.fake_top.joinpath('build/soong')
self.soong_ui_dir.mkdir(parents=True, exist_ok=True)
self.logs_dir = self.fake_top.joinpath('dist/logs')
self.logs_dir.mkdir(parents=True, exist_ok=True)
self.soong_ui = self.soong_ui_dir.joinpath('soong_ui.bash')
self.soong_ui.touch()
self.mock_os_environ.update({
'TARGET_RELEASE': 'release',
'TARGET_PRODUCT': 'product',
'TOP': str(self.fake_top),
'DIST_DIR': str(self.fake_top.joinpath('dist')),
})
self.mock_subprocess_run.return_value = 0
class RunCommandIntegrationTest(ci_test_lib.TestCase):
def setUp(self):
self.temp_dir = ci_test_lib.TestTemporaryDirectory.create(self)
# Copy the Python executable from 'non-code' resources and make it
# executable for use by tests that launch a subprocess. Note that we don't
# use Python's native `sys.executable` property since that is not set when
# running via the embedded launcher.
base_name = 'py3-cmd'
dest_file = self.temp_dir.joinpath(base_name)
with resources.as_file(
resources.files('testdata').joinpath(base_name)
) as p:
shutil.copy(p, dest_file)
dest_file.chmod(dest_file.stat().st_mode | stat.S_IEXEC)
self.python_executable = dest_file
self._managed_processes = []
def tearDown(self):
self._terminate_managed_processes()
def test_raises_on_nonzero_exit(self):
with self.assertRaises(Exception):
build_test_suites.run_command([
self.python_executable,
'-c',
textwrap.dedent(f"""\
import sys
sys.exit(1)
"""),
])
def test_streams_stdout(self):
def run_slow_command(stdout_file, marker):
with open(stdout_file, 'w') as f:
build_test_suites.run_command(
[
self.python_executable,
'-c',
textwrap.dedent(f"""\
import time
print('{marker}', end='', flush=True)
# Keep process alive until we check stdout.
time.sleep(10)
"""),
],
stdout=f,
)
marker = 'Spinach'
stdout_file = self.temp_dir.joinpath('stdout.txt')
p = self.start_process(target=run_slow_command, args=[stdout_file, marker])
self.assert_file_eventually_contains(stdout_file, marker)
def test_propagates_interruptions(self):
def run(pid_file):
build_test_suites.run_command([
self.python_executable,
'-c',
textwrap.dedent(f"""\
import os
import pathlib
import time
pathlib.Path('{pid_file}').write_text(str(os.getpid()))
# Keep the process alive for us to explicitly interrupt it.
time.sleep(10)
"""),
])
pid_file = self.temp_dir.joinpath('pid.txt')
p = self.start_process(target=run, args=[pid_file])
subprocess_pid = int(read_eventual_file_contents(pid_file))
os.kill(p.pid, signal.SIGINT)
p.join()
self.assert_process_eventually_dies(p.pid)
self.assert_process_eventually_dies(subprocess_pid)
def start_process(self, *args, **kwargs) -> multiprocessing.Process:
p = multiprocessing.Process(*args, **kwargs)
self._managed_processes.append(p)
p.start()
return p
def assert_process_eventually_dies(self, pid: int):
try:
wait_until(lambda: not ci_test_lib.process_alive(pid))
except TimeoutError as e:
self.fail(f'Process {pid} did not die after a while: {e}')
def assert_file_eventually_contains(self, file: pathlib.Path, substring: str):
wait_until(lambda: file.is_file() and file.stat().st_size > 0)
self.assertIn(substring, read_file_contents(file))
def _terminate_managed_processes(self):
for p in self._managed_processes:
if not p.is_alive():
continue
# We terminate the process with `SIGINT` since using `terminate` or
# `SIGKILL` doesn't kill any grandchild processes and we don't have
# `psutil` available to easily query all children.
os.kill(p.pid, signal.SIGINT)
class BuildPlannerTest(unittest.TestCase):
class TestOptimizedBuildTarget(optimized_targets.OptimizedBuildTarget):
def __init__(
self, target, build_context, args, output_targets, packaging_commands
):
super().__init__(target, build_context, args)
self.output_targets = output_targets
self.packaging_commands = packaging_commands
def get_build_targets_impl(self):
return self.output_targets
def get_package_outputs_commands_impl(self):
return self.packaging_commands
def get_enabled_flag(self):
return f'{self.target}_enabled'
def setUp(self):
test_discovery_agent_patcher = mock.patch('test_discovery_agent.TestDiscoveryAgent.discover_test_zip_regexes')
self.addCleanup(test_discovery_agent_patcher.stop)
self.mock_test_discovery_agent_end = test_discovery_agent_patcher.start()
def test_build_optimization_off_builds_everything(self):
build_targets = {'target_1', 'target_2'}
build_planner = self.create_build_planner(
build_context=self.create_build_context(optimized_build_enabled=False),
build_targets=build_targets,
)
build_plan = build_planner.create_build_plan()
self.assertSetEqual(build_targets, build_plan.build_targets)
def test_build_optimization_off_doesnt_package(self):
build_targets = {'target_1', 'target_2'}
build_planner = self.create_build_planner(
build_context=self.create_build_context(optimized_build_enabled=False),
build_targets=build_targets,
)
build_plan = build_planner.create_build_plan()
for packaging_command in self.run_packaging_commands(build_plan):
self.assertEqual(len(packaging_command), 0)
def test_build_optimization_on_optimizes_target(self):
build_targets = {'target_1', 'target_2'}
build_planner = self.create_build_planner(
build_targets=build_targets,
build_context=self.create_build_context(
enabled_build_features=[{'name': self.get_target_flag('target_1')}],
test_context=self.get_test_context('target_1'),
),
)
build_plan = build_planner.create_build_plan()
expected_targets = {self.get_optimized_target_name('target_1'), 'target_2'}
self.assertSetEqual(expected_targets, build_plan.build_targets)
def test_build_optimization_on_packages_target(self):
build_targets = {'target_1', 'target_2'}
optimized_target_name = self.get_optimized_target_name('target_1')
packaging_commands = [[f'packaging {optimized_target_name}']]
build_planner = self.create_build_planner(
build_targets=build_targets,
build_context=self.create_build_context(
enabled_build_features=[{'name': self.get_target_flag('target_1')}],
test_context=self.get_test_context('target_1'),
),
packaging_commands=packaging_commands,
)
build_plan = build_planner.create_build_plan()
self.assertIn(packaging_commands, self.run_packaging_commands(build_plan))
def test_individual_build_optimization_off_doesnt_optimize(self):
build_targets = {'target_1', 'target_2'}
build_planner = self.create_build_planner(
build_targets=build_targets,
)
build_plan = build_planner.create_build_plan()
self.assertSetEqual(build_targets, build_plan.build_targets)
def test_individual_build_optimization_off_doesnt_package(self):
build_targets = {'target_1', 'target_2'}
packaging_commands = [['packaging command']]
build_planner = self.create_build_planner(
build_targets=build_targets,
packaging_commands=packaging_commands,
)
build_plan = build_planner.create_build_plan()
for packaging_command in self.run_packaging_commands(build_plan):
self.assertEqual(len(packaging_command), 0)
def test_target_output_used_target_built(self):
build_target = 'test_target'
build_planner = self.create_build_planner(
build_targets={build_target},
build_context=self.create_build_context(
test_context=self.get_test_context(build_target),
enabled_build_features=[{'name': 'test_target_unused_exclusion'}],
),
)
build_plan = build_planner.create_build_plan()
self.assertSetEqual(build_plan.build_targets, {build_target})
def test_target_regex_used_target_built(self):
build_target = 'test_target'
test_context = self.get_test_context(build_target)
test_context['testInfos'][0]['extraOptions'] = [{
'key': 'additional-files-filter',
'values': [f'.*{build_target}.*\.zip'],
}]
build_planner = self.create_build_planner(
build_targets={build_target},
build_context=self.create_build_context(
test_context=test_context,
enabled_build_features=[{'name': 'test_target_unused_exclusion'}],
),
)
build_plan = build_planner.create_build_plan()
self.assertSetEqual(build_plan.build_targets, {build_target})
def test_target_output_not_used_target_not_built(self):
build_target = 'test_target'
test_context = self.get_test_context(build_target)
test_context['testInfos'][0]['extraOptions'] = []
build_planner = self.create_build_planner(
build_targets={build_target},
build_context=self.create_build_context(
test_context=test_context,
enabled_build_features=[{'name': 'test_target_unused_exclusion'}],
),
)
build_plan = build_planner.create_build_plan()
self.assertSetEqual(build_plan.build_targets, set())
def test_target_regex_matching_not_too_broad(self):
build_target = 'test_target'
test_context = self.get_test_context(build_target)
test_context['testInfos'][0]['extraOptions'] = [{
'key': 'additional-files-filter',
'values': [f'.*a{build_target}.*\.zip'],
}]
build_planner = self.create_build_planner(
build_targets={build_target},
build_context=self.create_build_context(
test_context=test_context,
enabled_build_features=[{'name': 'test_target_unused_exclusion'}],
),
)
build_plan = build_planner.create_build_plan()
self.assertSetEqual(build_plan.build_targets, set())
def create_build_planner(
self,
build_targets: set[str],
build_context: BuildContext = None,
args: argparse.Namespace = None,
target_optimizations: dict[
str, optimized_targets.OptimizedBuildTarget
] = None,
packaging_commands: list[list[str]] = [],
) -> build_test_suites.BuildPlanner:
if not build_context:
build_context = self.create_build_context()
if not args:
args = self.create_args(extra_build_targets=build_targets)
if not target_optimizations:
target_optimizations = self.create_target_optimizations(
build_context,
build_targets,
packaging_commands,
)
return build_test_suites.BuildPlanner(
build_context, args, target_optimizations
)
def create_build_context(
self,
optimized_build_enabled: bool = True,
enabled_build_features: list[dict[str, str]] = [],
test_context: dict[str, any] = {},
) -> BuildContext:
build_context_dict = {}
build_context_dict['enabledBuildFeatures'] = enabled_build_features
if optimized_build_enabled:
build_context_dict['enabledBuildFeatures'].append(
{'name': 'optimized_build'}
)
build_context_dict['testContext'] = test_context
return BuildContext(build_context_dict)
def create_args(
self, extra_build_targets: set[str] = set()
) -> argparse.Namespace:
parser = argparse.ArgumentParser()
parser.add_argument('extra_targets', nargs='*')
return parser.parse_args(extra_build_targets)
def create_target_optimizations(
self,
build_context: BuildContext,
build_targets: set[str],
packaging_commands: list[list[str]] = [],
):
target_optimizations = dict()
for target in build_targets:
target_optimizations[target] = functools.partial(
self.TestOptimizedBuildTarget,
output_targets={self.get_optimized_target_name(target)},
packaging_commands=packaging_commands,
)
return target_optimizations
def get_target_flag(self, target: str):
return f'{target}_enabled'
def get_optimized_target_name(self, target: str):
return f'{target}_optimized'
def get_test_context(self, target: str):
return {
'testInfos': [
{
'name': 'atp_test',
'target': 'test_target',
'branch': 'branch',
'extraOptions': [{
'key': 'additional-files-filter',
'values': [f'{target}.zip'],
}],
'command': '/tf/command',
'extraBuildTargets': [
'extra_build_target',
],
},
],
}
def run_packaging_commands(self, build_plan: build_test_suites.BuildPlan):
return [
packaging_command_getter()
for packaging_command_getter in build_plan.packaging_commands_getters
]
def wait_until(
condition_function: Callable[[], bool],
timeout_secs: float = 3.0,
polling_interval_secs: float = 0.1,
):
"""Waits until a condition function returns True."""
start_time_secs = time.time()
while not condition_function():
if time.time() - start_time_secs > timeout_secs:
raise TimeoutError(
f'Condition not met within timeout: {timeout_secs} seconds'
)
time.sleep(polling_interval_secs)
def read_file_contents(file: pathlib.Path) -> str:
with open(file, 'r') as f:
return f.read()
def read_eventual_file_contents(file: pathlib.Path) -> str:
wait_until(lambda: file.is_file() and file.stat().st_size > 0)
return read_file_contents(file)
if __name__ == '__main__':
ci_test_lib.main()
================================================
FILE: ci/buildbot.py
================================================
# Copyright 2024, 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.
"""Utilities for interacting with buildbot, with a simulation in a local environment"""
import os
import sys
# Check that the script is running from the root of the tree. Prevents subtle
# errors later, and CI always runs from the root of the tree.
if not os.path.exists("build/make/ci/buildbot.py"):
raise Exception("CI script must be run from the root of the tree instead of: "
+ os.getcwd())
# Check that we are using the hermetic interpreter
if "prebuilts/build-tools/" not in sys.executable:
raise Exception("CI script must be run using the hermetic interpreter from "
+ "prebuilts/build-tools instead of: " + sys.executable)
def OutDir():
"Get the out directory. Will create it if needed."
result = os.environ.get("OUT_DIR", "out")
os.makedirs(result, exist_ok=True)
return result
def DistDir():
"Get the dist directory. Will create it if needed."
result = os.environ.get("DIST_DIR", os.path.join(OutDir(), "dist"))
os.makedirs(result, exist_ok=True)
return result
================================================
FILE: ci/ci_test_lib.py
================================================
# Copyright 2024, 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.
"""Testing utilities for tests in the CI package."""
import logging
import os
import unittest
import subprocess
import pathlib
import shutil
import tempfile
# Export the TestCase class to reduce the number of imports tests have to list.
TestCase = unittest.TestCase
def process_alive(pid):
"""Check For the existence of a pid."""
try:
os.kill(pid, 0)
except OSError:
return False
return True
class TemporaryProcessSession:
def __init__(self, test_case: TestCase):
self._created_processes = []
test_case.addCleanup(self.cleanup)
def create(self, args, kwargs):
p = subprocess.Popen(*args, **kwargs, start_new_session=True)
self._created_processes.append(p)
return p
def cleanup(self):
for p in self._created_processes:
if not process_alive(p.pid):
return
os.killpg(os.getpgid(p.pid), signal.SIGKILL)
class TestTemporaryDirectory:
def __init__(self, delete: bool, ):
self._delete = delete
@classmethod
def create(cls, test_case: TestCase, delete: bool = True):
temp_dir = TestTemporaryDirectory(delete)
temp_dir._dir = pathlib.Path(tempfile.mkdtemp())
test_case.addCleanup(temp_dir.cleanup)
return temp_dir._dir
def get_dir(self):
return self._dir
def cleanup(self):
if not self._delete:
return
shutil.rmtree(self._dir, ignore_errors=True)
def main():
# Disable logging since it breaks the TF Python test output parser.
# TODO(hzalek): Use TF's `test-output-file` option to re-enable logging.
logging.getLogger().disabled = True
unittest.main()
================================================
FILE: ci/dump_product_config
================================================
#!prebuilts/build-tools/linux-x86/bin/py3-cmd -B
# Copyright 2024, 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.
"""Script to collect all of the make variables from all product config combos.
This script must be run from the root of the source tree.
See GetArgs() below or run dump_product_config for more information.
"""
import argparse
import asyncio
import contextlib
import csv
import dataclasses
import json
import multiprocessing
import os
import subprocess
import sys
import time
from typing import List, Dict, Tuple, Optional
import buildbot
# We have some BIG variables
csv.field_size_limit(sys.maxsize)
class DataclassJSONEncoder(json.JSONEncoder):
"""JSONEncoder for our custom types."""
def default(self, o):
if dataclasses.is_dataclass(o):
return dataclasses.asdict(o)
return super().default(o)
def GetProducts():
"""Get the all of the available TARGET_PRODUCT values."""
try:
stdout = subprocess.check_output(["build/soong/bin/list_products"], text=True)
except subprocess.CalledProcessError:
sys.exit(1)
return [s.strip() for s in stdout.splitlines() if s.strip()]
def GetReleases(product):
"""For a given product, get the release configs available to it."""
if True:
# Hard code the list
mainline_products = [
"module_arm",
"module_x86",
"module_arm64",
"module_riscv64",
"module_x86_64",
"module_arm64only",
"module_x86_64only",
]
if product in mainline_products:
return ["trunk_staging", "trunk", "mainline"]
else:
return ["trunk_staging", "trunk", "next"]
else:
# Get it from the build system
try:
stdout = subprocess.check_output(["build/soong/bin/list_releases", product], text=True)
except subprocess.CalledProcessError:
sys.exit(1)
return [s.strip() for s in stdout.splitlines() if s.strip()]
def GenerateAllLunchTargets():
"""Generate the full list of lunch targets."""
for product in GetProducts():
for release in GetReleases(product):
for variant in ["user", "userdebug", "eng"]:
yield (product, release, variant)
async def ParallelExec(parallelism, tasks):
'''
ParallelExec takes a parallelism number, and an iterator of tasks to run.
Then it will run all the tasks, but a maximum of parallelism will be run at
any given time. The tasks must be async functions that accept one argument,
which will be an integer id of the worker that they're running on.
'''
tasks = iter(tasks)
overall_start = time.monotonic()
# lists so they can be modified from the inner function
total_duration = [0]
count = [0]
async def dispatch(worker):
while True:
try:
task = next(tasks)
item_start = time.monotonic()
await task(worker)
now = time.monotonic()
item_duration = now - item_start
count[0] += 1
total_duration[0] += item_duration
sys.stderr.write(f"Timing: Items processed: {count[0]}, Wall time: {now-overall_start:0.1f} sec, Throughput: {(now-overall_start)/count[0]:0.3f} sec per item, Average duration: {total_duration[0]/count[0]:0.1f} sec\n")
except StopIteration:
return
await asyncio.gather(*[dispatch(worker) for worker in range(parallelism)])
async def DumpProductConfigs(out, generator, out_dir):
"""Collects all of the product config data and store it in file."""
# Write the outer json list by hand so we can stream it
out.write("[")
try:
first_result = [True] # a list so it can be modified from the inner function
def run(lunch):
async def curried(worker):
sys.stderr.write(f"running: {'-'.join(lunch)}\n")
result = await DumpOneProductConfig(lunch, os.path.join(out_dir, f"lunchable_{worker}"))
if first_result[0]:
out.write("\n")
first_result[0] = False
else:
out.write(",\n")
result.dumpToFile(out)
sys.stderr.write(f"finished: {'-'.join(lunch)}\n")
return curried
await ParallelExec(multiprocessing.cpu_count(), (run(lunch) for lunch in generator))
finally:
# Close the json regardless of how we exit
out.write("\n]\n")
@dataclasses.dataclass(frozen=True)
class Variable:
"""A variable name, value and where it was set."""
name: str
value: str
location: str
@dataclasses.dataclass(frozen=True)
class ProductResult:
product: str
release: str
variant: str
board_includes: List[str]
product_includes: Dict[str, List[str]]
product_graph: List[Tuple[str, str]]
board_vars: List[Variable]
product_vars: List[Variable]
def dumpToFile(self, f):
json.dump(self, f, sort_keys=True, indent=2, cls=DataclassJSONEncoder)
@dataclasses.dataclass(frozen=True)
class ProductError:
product: str
release: str
variant: str
error: str
def dumpToFile(self, f):
json.dump(self, f, sort_keys=True, indent=2, cls=DataclassJSONEncoder)
def NormalizeInheritGraph(lists):
"""Flatten the inheritance graph to a simple list for easier querying."""
result = set()
for item in lists:
for i in range(len(item)):
result.add((item[i+1] if i < len(item)-1 else "", item[i]))
return sorted(list(result))
def ParseDump(lunch, filename) -> ProductResult:
"""Parses the csv and returns a tuple of the data."""
def diff(initial, final):
return [after for after in final.values() if
initial.get(after.name, Variable(after.name, "", "")).value != after.value]
product_initial = {}
product_final = {}
board_initial = {}
board_final = {}
inherit_product = [] # The stack of inherit-product calls
product_includes = {} # Other files included by each of the properly imported files
board_includes = [] # Files included by boardconfig
with open(filename) as f:
phase = ""
for line in csv.reader(f):
if line[0] == "phase":
phase = line[1]
elif line[0] == "val":
# TOOD: We should skip these somewhere else.
if line[3].startswith("_ALL_RELEASE_FLAGS"):
continue
if line[3].startswith("PRODUCTS."):
continue
if phase == "PRODUCTS":
if line[2] == "initial":
product_initial[line[3]] = Variable(line[3], line[4], line[5])
if phase == "PRODUCT-EXPAND":
if line[2] == "final":
product_final[line[3]] = Variable(line[3], line[4], line[5])
if phase == "BOARD":
if line[2] == "initial":
board_initial[line[3]] = Variable(line[3], line[4], line[5])
if line[2] == "final":
board_final[line[3]] = Variable(line[3], line[4], line[5])
elif line[0] == "imported":
imports = [s.strip() for s in line[1].split()]
if imports:
inherit_product.append(imports)
inc = [s.strip() for s in line[2].split()]
for f in inc:
product_includes.setdefault(imports[0], []).append(f)
elif line[0] == "board_config_files":
board_includes += [s.strip() for s in line[1].split()]
return ProductResult(
product = lunch[0],
release = lunch[1],
variant = lunch[2],
product_vars = diff(product_initial, product_final),
board_vars = diff(board_initial, board_final),
product_graph = NormalizeInheritGraph(inherit_product),
product_includes = product_includes,
board_includes = board_includes
)
async def DumpOneProductConfig(lunch, out_dir) -> ProductResult | ProductError:
"""Print a single config's lunch info to stdout."""
product, release, variant = lunch
dumpconfig_file = os.path.join(out_dir, f"{product}-{release}-{variant}.csv")
# Run get_build_var to bootstrap soong_ui for this target
env = dict(os.environ)
env["TARGET_PRODUCT"] = product
env["TARGET_RELEASE"] = release
env["TARGET_BUILD_VARIANT"] = variant
env["OUT_DIR"] = out_dir
process = await asyncio.create_subprocess_exec(
"build/soong/bin/get_build_var",
"TARGET_PRODUCT",
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env=env
)
stdout, _ = await process.communicate()
stdout = stdout.decode()
if process.returncode != 0:
return ProductError(
product = product,
release = release,
variant = variant,
error = stdout
)
else:
# Run kati to extract the data
process = await asyncio.create_subprocess_exec(
"prebuilts/build-tools/linux-x86/bin/ckati",
"-f",
"build/make/core/dumpconfig.mk",
f"TARGET_PRODUCT={product}",
f"TARGET_RELEASE={release}",
f"TARGET_BUILD_VARIANT={variant}",
f"DUMPCONFIG_FILE={dumpconfig_file}",
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
env=env
)
stdout, _ = await process.communicate()
if process.returncode != 0:
stdout = stdout.decode()
return ProductError(
product = product,
release = release,
variant = variant,
error = stdout
)
else:
# Parse and record the output
return ParseDump(lunch, dumpconfig_file)
def GetArgs():
"""Parse command line arguments."""
parser = argparse.ArgumentParser(
description="Collect all of the make variables from product config.",
epilog="NOTE: This script must be run from the root of the source tree.")
parser.add_argument("--lunch", nargs="*")
parser.add_argument("--dist", action="store_true")
return parser.parse_args()
async def main():
args = GetArgs()
out_dir = buildbot.OutDir()
if args.dist:
cm = open(os.path.join(buildbot.DistDir(), "all_product_config.json"), "w")
else:
cm = contextlib.nullcontext(sys.stdout)
with cm as out:
if args.lunch:
lunches = [lunch.split("-") for lunch in args.lunch]
fail = False
for i in range(len(lunches)):
if len(lunches[i]) != 3:
sys.stderr.write(f"Malformed lunch targets: {args.lunch[i]}\n")
fail = True
if fail:
sys.exit(1)
if len(lunches) == 1:
result = await DumpOneProductConfig(lunches[0], out_dir)
result.dumpToFile(out)
out.write("\n")
else:
await DumpProductConfigs(out, lunches, out_dir)
else:
# All configs mode. This will exec single config mode in parallel
# for each lunch combo. Write output to $DIST_DIR.
await DumpProductConfigs(out, GenerateAllLunchTargets(), out_dir)
if __name__ == "__main__":
asyncio.run(main())
# vim: set syntax=python ts=4 sw=4 sts=4:
================================================
FILE: ci/metrics_agent.py
================================================
# Copyright 2024, 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.
"""MetricsAgent is a singleton class that collects metrics for optimized build."""
from enum import Enum
import time
import metrics_pb2
import os
import logging
class MetricsAgent:
_SOONG_METRICS_PATH = 'logs/soong_metrics'
_DIST_DIR = 'DIST_DIR'
_instance = None
def __init__(self):
raise RuntimeError(
'MetricsAgent cannot be instantialized, use instance() instead'
)
@classmethod
def instance(cls):
if not cls._instance:
cls._instance = cls.__new__(cls)
cls._instance._proto = metrics_pb2.OptimizedBuildMetrics()
cls._instance._init_proto()
cls._instance._target_results = dict()
return cls._instance
def _init_proto(self):
self._proto.analysis_perf.name = 'Optimized build analysis time.'
self._proto.packaging_perf.name = 'Optimized build total packaging time.'
def analysis_start(self):
self._proto.analysis_perf.start_time = time.time_ns()
def analysis_end(self):
self._proto.analysis_perf.real_time = (
time.time_ns() - self._proto.analysis_perf.start_time
)
def packaging_start(self):
self._proto.packaging_perf.start_time = time.time_ns()
def packaging_end(self):
self._proto.packaging_perf.real_time = (
time.time_ns() - self._proto.packaging_perf.start_time
)
def report_optimized_target(self, name: str):
target_result = metrics_pb2.OptimizedBuildMetrics.TargetOptimizationResult()
target_result.name = name
target_result.optimized = True
self._target_results[name] = target_result
def report_unoptimized_target(self, name: str, optimization_rationale: str):
target_result = metrics_pb2.OptimizedBuildMetrics.TargetOptimizationResult()
target_result.name = name
target_result.optimization_rationale = optimization_rationale
target_result.optimized = False
self._target_results[name] = target_result
def target_packaging_start(self, name: str):
target_result = self._target_results.get(name)
target_result.packaging_perf.start_time = time.time_ns()
self._target_results[name] = target_result
def target_packaging_end(self, name: str):
target_result = self._target_results.get(name)
target_result.packaging_perf.real_time = (
time.time_ns() - target_result.packaging_perf.start_time
)
def add_target_artifact(
self,
target_name: str,
artifact_name: str,
size: int,
included_modules: set[str],
):
target_result = self.target_results.get(target_name)
artifact = (
metrics_pb2.OptimizedBuildMetrics.TargetOptimizationResult.OutputArtifact()
)
artifact.name = artifact_name
artifact.size = size
for module in included_modules:
artifact.included_modules.add(module)
target_result.output_artifacts.add(artifact)
def end_reporting(self):
for target_result in self._target_results.values():
self._proto.target_result.append(target_result)
soong_metrics_proto = metrics_pb2.MetricsBase()
# Read in existing metrics that should have been written out by the soong
# build command so that we don't overwrite them.
with open(os.path.join(os.environ[self._DIST_DIR], self._SOONG_METRICS_PATH), 'rb') as f:
soong_metrics_proto.ParseFromString(f.read())
soong_metrics_proto.optimized_build_metrics.CopyFrom(self._proto)
logging.info(soong_metrics_proto)
with open(os.path.join(os.environ[self._DIST_DIR], self._SOONG_METRICS_PATH), 'wb') as f:
f.write(soong_metrics_proto.SerializeToString())
================================================
FILE: ci/optimized_targets.py
================================================
#
# Copyright 2024, 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.
from abc import ABC
import argparse
import functools
import json
import logging
import os
import pathlib
import subprocess
from build_context import BuildContext
import test_mapping_module_retriever
class OptimizedBuildTarget(ABC):
"""A representation of an optimized build target.
This class will determine what targets to build given a given build_cotext and
will have a packaging function to generate any necessary output zips for the
build.
"""
_SOONG_UI_BASH_PATH = 'build/soong/soong_ui.bash'
_PREBUILT_SOONG_ZIP_PATH = 'prebuilts/build-tools/linux-x86/bin/soong_zip'
def __init__(
self,
target: str,
build_context: BuildContext,
args: argparse.Namespace,
):
self.target = target
self.build_context = build_context
self.args = args
def get_build_targets(self) -> set[str]:
features = self.build_context.enabled_build_features
if self.get_enabled_flag() in features:
self.modules_to_build = self.get_build_targets_impl()
return self.modules_to_build
self.modules_to_build = {self.target}
return {self.target}
def get_package_outputs_commands(self) -> list[list[str]]:
features = self.build_context.enabled_build_features
if self.get_enabled_flag() in features:
return self.get_package_outputs_commands_impl()
return []
def get_package_outputs_commands_impl(self) -> list[list[str]]:
raise NotImplementedError(
'get_package_outputs_commands_impl not implemented in'
f' {type(self).__name__}'
)
def get_enabled_flag(self):
raise NotImplementedError(
f'get_enabled_flag not implemented in {type(self).__name__}'
)
def get_build_targets_impl(self) -> set[str]:
raise NotImplementedError(
f'get_build_targets_impl not implemented in {type(self).__name__}'
)
def _generate_zip_options_for_items(
self,
prefix: str = '',
relative_root: str = '',
list_files: list[str] | None = None,
files: list[str] | None = None,
directories: list[str] | None = None,
) -> list[str]:
if not list_files and not files and not directories:
raise RuntimeError(
f'No items specified to be added to zip! Prefix: {prefix}, Relative'
f' root: {relative_root}'
)
command_segment = []
# These are all soong_zip options so consult soong_zip --help for specifics.
if prefix:
command_segment.append('-P')
command_segment.append(prefix)
if relative_root:
command_segment.append('-C')
command_segment.append(relative_root)
if list_files:
for list_file in list_files:
command_segment.append('-l')
command_segment.append(list_file)
if files:
for file in files:
command_segment.append('-f')
command_segment.append(file)
if directories:
for directory in directories:
command_segment.append('-D')
command_segment.append(directory)
return command_segment
def _query_soong_vars(
self, src_top: pathlib.Path, soong_vars: list[str]
) -> dict[str, str]:
process_result = subprocess.run(
args=[
f'{src_top / self._SOONG_UI_BASH_PATH}',
'--dumpvars-mode',
f'--abs-vars={" ".join(soong_vars)}',
],
env=os.environ,
check=False,
capture_output=True,
text=True,
)
if not process_result.returncode == 0:
logging.error('soong dumpvars command failed! stderr:')
logging.error(process_result.stderr)
raise RuntimeError('Soong dumpvars failed! See log for stderr.')
if not process_result.stdout:
raise RuntimeError(
'Necessary soong variables ' + soong_vars + ' not found.'
)
try:
return {
line.split('=')[0]: line.split('=')[1].strip("'")
for line in process_result.stdout.strip().split('\n')
}
except IndexError as e:
raise RuntimeError(
'Error parsing soong dumpvars output! See output here:'
f' {process_result.stdout}',
e,
)
def _base_zip_command(
self, src_top: pathlib.Path, dist_dir: pathlib.Path, name: str
) -> list[str]:
return [
f'{src_top / self._PREBUILT_SOONG_ZIP_PATH }',
'-d',
'-o',
f'{dist_dir / name}',
]
class NullOptimizer(OptimizedBuildTarget):
"""No-op target optimizer.
This will simply build the same target it was given and do nothing for the
packaging step.
"""
def __init__(self, target):
self.target = target
def get_build_targets(self):
return {self.target}
def get_package_outputs_commands(self):
return []
class ChangeInfo:
def __init__(self, change_info_file_path):
try:
with open(change_info_file_path) as change_info_file:
change_info_contents = json.load(change_info_file)
except json.decoder.JSONDecodeError:
logging.error(f'Failed to load CHANGE_INFO: {change_info_file_path}')
raise
self._change_info_contents = change_info_contents
def find_changed_files(self) -> set[str]:
changed_files = set()
for change in self._change_info_contents['changes']:
project_path = change.get('projectPath') + '/'
for revision in change.get('revisions'):
for file_info in revision.get('fileInfos'):
changed_files.add(project_path + file_info.get('path'))
return changed_files
class GeneralTestsOptimizer(OptimizedBuildTarget):
"""general-tests optimizer
This optimizer reads in the list of changed files from the file located in
env[CHANGE_INFO] and uses this list alongside the normal TEST MAPPING logic to
determine what test mapping modules will run for the given changes. It then
builds those modules and packages them in the same way general-tests.zip is
normally built.
"""
# List of modules that are built alongside general-tests as dependencies.
_REQUIRED_MODULES = frozenset([
'cts-tradefed',
'vts-tradefed',
'compatibility-host-util',
'general-tests-shared-libs',
])
def get_build_targets_impl(self) -> set[str]:
change_info_file_path = os.environ.get('CHANGE_INFO')
if not change_info_file_path:
logging.info(
'No CHANGE_INFO env var found, general-tests optimization disabled.'
)
return {'general-tests'}
test_infos = self.build_context.test_infos
test_mapping_test_groups = set()
for test_info in test_infos:
is_test_mapping = test_info.is_test_mapping
current_test_mapping_test_groups = test_info.test_mapping_test_groups
uses_general_tests = test_info.build_target_used('general-tests')
if uses_general_tests and not is_test_mapping:
logging.info(
'Test uses general-tests.zip but is not test-mapping, general-tests'
' optimization disabled.'
)
return {'general-tests'}
if is_test_mapping:
test_mapping_test_groups.update(current_test_mapping_test_groups)
change_info = ChangeInfo(change_info_file_path)
changed_files = change_info.find_changed_files()
test_mappings = test_mapping_module_retriever.GetTestMappings(
changed_files, set()
)
modules_to_build = set(self._REQUIRED_MODULES)
modules_to_build.update(
test_mapping_module_retriever.FindAffectedModules(
test_mappings, changed_files, test_mapping_test_groups
)
)
return modules_to_build
def get_package_outputs_commands_impl(self):
src_top = pathlib.Path(os.environ.get('TOP', os.getcwd()))
dist_dir = pathlib.Path(os.environ.get('DIST_DIR'))
soong_vars = self._query_soong_vars(
src_top,
[
'HOST_OUT_TESTCASES',
'TARGET_OUT_TESTCASES',
'PRODUCT_OUT',
'SOONG_HOST_OUT',
'HOST_OUT',
],
)
host_out_testcases = pathlib.Path(soong_vars.get('HOST_OUT_TESTCASES'))
target_out_testcases = pathlib.Path(soong_vars.get('TARGET_OUT_TESTCASES'))
product_out = pathlib.Path(soong_vars.get('PRODUCT_OUT'))
soong_host_out = pathlib.Path(soong_vars.get('SOONG_HOST_OUT'))
host_out = pathlib.Path(soong_vars.get('HOST_OUT'))
host_paths = []
target_paths = []
host_config_files = []
target_config_files = []
for module in self.modules_to_build:
# The required modules are handled separately, no need to package.
if module in self._REQUIRED_MODULES:
continue
host_path = host_out_testcases / module
if os.path.exists(host_path):
host_paths.append(host_path)
self._collect_config_files(src_top, host_path, host_config_files)
target_path = target_out_testcases / module
if os.path.exists(target_path):
target_paths.append(target_path)
self._collect_config_files(src_top, target_path, target_config_files)
if not os.path.exists(host_path) and not os.path.exists(target_path):
logging.info(f'No host or target build outputs found for {module}.')
zip_commands = []
zip_commands.extend(
self._get_zip_test_configs_zips_commands(
src_top,
dist_dir,
host_out,
product_out,
host_config_files,
target_config_files,
)
)
zip_command = self._base_zip_command(src_top, dist_dir, 'general-tests.zip')
# Add host testcases.
if host_paths:
zip_command.extend(
self._generate_zip_options_for_items(
prefix='host',
relative_root=f'{src_top / soong_host_out}',
directories=host_paths,
)
)
# Add target testcases.
if target_paths:
zip_command.extend(
self._generate_zip_options_for_items(
prefix='target',
relative_root=f'{src_top / product_out}',
directories=target_paths,
)
)
# TODO(lucafarsi): Push this logic into a general-tests-minimal build command
# Add necessary tools. These are also hardcoded in general-tests.mk.
framework_path = soong_host_out / 'framework'
zip_command.extend(
self._generate_zip_options_for_items(
prefix='host/tools',
relative_root=str(framework_path),
files=[
f"{framework_path / 'cts-tradefed.jar'}",
f"{framework_path / 'compatibility-host-util.jar'}",
f"{framework_path / 'vts-tradefed.jar'}",
],
)
)
zip_commands.append(zip_command)
return zip_commands
def _collect_config_files(
self,
src_top: pathlib.Path,
root_dir: pathlib.Path,
config_files: list[str],
):
for root, dirs, files in os.walk(src_top / root_dir):
for file in files:
if file.endswith('.config'):
config_files.append(root_dir / file)
def _get_zip_test_configs_zips_commands(
self,
src_top: pathlib.Path,
dist_dir: pathlib.Path,
host_out: pathlib.Path,
product_out: pathlib.Path,
host_config_files: list[str],
target_config_files: list[str],
) -> tuple[list[str], list[str]]:
"""Generate general-tests_configs.zip and general-tests_list.zip.
general-tests_configs.zip contains all of the .config files that were
built and general-tests_list.zip contains a text file which lists
all of the .config files that are in general-tests_configs.zip.
general-tests_configs.zip is organized as follows:
/
host/
testcases/
test_1.config
test_2.config
...
target/
testcases/
test_1.config
test_2.config
...
So the process is we write out the paths to all the host config files into
one
file and all the paths to the target config files in another. We also write
the paths to all the config files into a third file to use for
general-tests_list.zip.
Args:
dist_dir: dist directory.
host_out: host out directory.
product_out: product out directory.
host_config_files: list of all host config files.
target_config_files: list of all target config files.
Returns:
The commands to generate general-tests_configs.zip and
general-tests_list.zip
"""
with open(
f"{host_out / 'host_general-tests_list'}", 'w'
) as host_list_file, open(
f"{product_out / 'target_general-tests_list'}", 'w'
) as target_list_file, open(
f"{host_out / 'general-tests_list'}", 'w'
) as list_file:
for config_file in host_config_files:
host_list_file.write(f'{config_file}' + '\n')
list_file.write('host/' + os.path.relpath(config_file, host_out) + '\n')
for config_file in target_config_files:
target_list_file.write(f'{config_file}' + '\n')
list_file.write(
'target/' + os.path.relpath(config_file, product_out) + '\n'
)
zip_commands = []
tests_config_zip_command = self._base_zip_command(
src_top, dist_dir, 'general-tests_configs.zip'
)
tests_config_zip_command.extend(
self._generate_zip_options_for_items(
prefix='host',
relative_root=str(host_out),
list_files=[f"{host_out / 'host_general-tests_list'}"],
)
)
tests_config_zip_command.extend(
self._generate_zip_options_for_items(
prefix='target',
relative_root=str(product_out),
list_files=[f"{product_out / 'target_general-tests_list'}"],
),
)
zip_commands.append(tests_config_zip_command)
tests_list_zip_command = self._base_zip_command(
src_top, dist_dir, 'general-tests_list.zip'
)
tests_list_zip_command.extend(
self._generate_zip_options_for_items(
relative_root=str(host_out),
files=[f"{host_out / 'general-tests_list'}"],
)
)
zip_commands.append(tests_list_zip_command)
return zip_commands
def get_enabled_flag(self):
return 'general_tests_optimized'
@classmethod
def get_optimized_targets(cls) -> dict[str, OptimizedBuildTarget]:
return {'general-tests': functools.partial(cls)}
OPTIMIZED_BUILD_TARGETS = {}
OPTIMIZED_BUILD_TARGETS.update(GeneralTestsOptimizer.get_optimized_targets())
================================================
FILE: ci/optimized_targets_test.py
================================================
# Copyright 2024, 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.
"""Tests for optimized_targets.py"""
import json
import logging
import os
import pathlib
import re
import subprocess
import textwrap
import unittest
from unittest import mock
from build_context import BuildContext
import optimized_targets
from pyfakefs import fake_filesystem_unittest
class GeneralTestsOptimizerTest(fake_filesystem_unittest.TestCase):
def setUp(self):
self.setUpPyfakefs()
os_environ_patcher = mock.patch.dict('os.environ', {})
self.addCleanup(os_environ_patcher.stop)
self.mock_os_environ = os_environ_patcher.start()
self._setup_working_build_env()
self._write_change_info_file()
test_mapping_dir = pathlib.Path('/project/path/file/path')
test_mapping_dir.mkdir(parents=True)
self._write_test_mapping_file()
def _setup_working_build_env(self):
self.change_info_file = pathlib.Path('/tmp/change_info')
self._write_soong_ui_file()
self._host_out_testcases = pathlib.Path('/tmp/top/host_out_testcases')
self._host_out_testcases.mkdir(parents=True)
self._target_out_testcases = pathlib.Path('/tmp/top/target_out_testcases')
self._target_out_testcases.mkdir(parents=True)
self._product_out = pathlib.Path('/tmp/top/product_out')
self._product_out.mkdir(parents=True)
self._soong_host_out = pathlib.Path('/tmp/top/soong_host_out')
self._soong_host_out.mkdir(parents=True)
self._host_out = pathlib.Path('/tmp/top/host_out')
self._host_out.mkdir(parents=True)
self._dist_dir = pathlib.Path('/tmp/top/out/dist')
self._dist_dir.mkdir(parents=True)
self.mock_os_environ.update({
'CHANGE_INFO': str(self.change_info_file),
'TOP': '/tmp/top',
'DIST_DIR': '/tmp/top/out/dist',
})
def _write_soong_ui_file(self):
soong_path = pathlib.Path('/tmp/top/build/soong')
soong_path.mkdir(parents=True)
with open(os.path.join(soong_path, 'soong_ui.bash'), 'w') as f:
f.write("""
#/bin/bash
echo HOST_OUT_TESTCASES='/tmp/top/host_out_testcases'
echo TARGET_OUT_TESTCASES='/tmp/top/target_out_testcases'
echo PRODUCT_OUT='/tmp/top/product_out'
echo SOONG_HOST_OUT='/tmp/top/soong_host_out'
echo HOST_OUT='/tmp/top/host_out'
""")
os.chmod(os.path.join(soong_path, 'soong_ui.bash'), 0o666)
def _write_change_info_file(self):
change_info_contents = {
'changes': [{
'projectPath': '/project/path',
'revisions': [{
'fileInfos': [{
'path': 'file/path/file_name',
}],
}],
}]
}
with open(self.change_info_file, 'w') as f:
json.dump(change_info_contents, f)
def _write_test_mapping_file(self):
test_mapping_contents = {
'test-mapping-group': [
{
'name': 'test_mapping_module',
},
],
}
with open('/project/path/file/path/TEST_MAPPING', 'w') as f:
json.dump(test_mapping_contents, f)
def test_general_tests_optimized(self):
optimizer = self._create_general_tests_optimizer()
build_targets = optimizer.get_build_targets()
expected_build_targets = set(
optimized_targets.GeneralTestsOptimizer._REQUIRED_MODULES
)
expected_build_targets.add('test_mapping_module')
self.assertSetEqual(build_targets, expected_build_targets)
def test_no_change_info_no_optimization(self):
del os.environ['CHANGE_INFO']
optimizer = self._create_general_tests_optimizer()
build_targets = optimizer.get_build_targets()
self.assertSetEqual(build_targets, {'general-tests'})
def test_mapping_groups_unused_module_not_built(self):
test_context = self._create_test_context()
test_context['testInfos'][0]['extraOptions'] = [
{
'key': 'additional-files-filter',
'values': ['general-tests.zip'],
},
{
'key': 'test-mapping-test-group',
'values': ['unused-test-mapping-group'],
},
]
optimizer = self._create_general_tests_optimizer(
build_context=self._create_build_context(test_context=test_context)
)
build_targets = optimizer.get_build_targets()
expected_build_targets = set(
optimized_targets.GeneralTestsOptimizer._REQUIRED_MODULES
)
self.assertSetEqual(build_targets, expected_build_targets)
def test_general_tests_used_by_non_test_mapping_test_no_optimization(self):
test_context = self._create_test_context()
test_context['testInfos'][0]['extraOptions'] = [{
'key': 'additional-files-filter',
'values': ['general-tests.zip'],
}]
optimizer = self._create_general_tests_optimizer(
build_context=self._create_build_context(test_context=test_context)
)
build_targets = optimizer.get_build_targets()
self.assertSetEqual(build_targets, {'general-tests'})
def test_malformed_change_info_raises(self):
with open(self.change_info_file, 'w') as f:
f.write('not change info')
optimizer = self._create_general_tests_optimizer()
with self.assertRaises(json.decoder.JSONDecodeError):
build_targets = optimizer.get_build_targets()
def test_malformed_test_mapping_raises(self):
with open('/project/path/file/path/TEST_MAPPING', 'w') as f:
f.write('not test mapping')
optimizer = self._create_general_tests_optimizer()
with self.assertRaises(json.decoder.JSONDecodeError):
build_targets = optimizer.get_build_targets()
@mock.patch('subprocess.run')
def test_packaging_outputs_success(self, subprocess_run):
subprocess_run.return_value = self._get_soong_vars_output()
optimizer = self._create_general_tests_optimizer()
self._set_up_build_outputs(['test_mapping_module'])
targets = optimizer.get_build_targets()
package_commands = optimizer.get_package_outputs_commands()
self._verify_soong_zip_commands(package_commands, ['test_mapping_module'])
@mock.patch('subprocess.run')
def test_get_soong_dumpvars_fails_raises(self, subprocess_run):
subprocess_run.return_value = self._get_soong_vars_output(return_code=-1)
optimizer = self._create_general_tests_optimizer()
self._set_up_build_outputs(['test_mapping_module'])
targets = optimizer.get_build_targets()
with self.assertRaisesRegex(RuntimeError, 'Soong dumpvars failed!'):
package_commands = optimizer.get_package_outputs_commands()
@mock.patch('subprocess.run')
def test_get_soong_dumpvars_bad_output_raises(self, subprocess_run):
subprocess_run.return_value = self._get_soong_vars_output(
stdout='This output is bad'
)
optimizer = self._create_general_tests_optimizer()
self._set_up_build_outputs(['test_mapping_module'])
targets = optimizer.get_build_targets()
with self.assertRaisesRegex(
RuntimeError, 'Error parsing soong dumpvars output'
):
package_commands = optimizer.get_package_outputs_commands()
def _create_general_tests_optimizer(self, build_context: BuildContext = None):
if not build_context:
build_context = self._create_build_context()
return optimized_targets.GeneralTestsOptimizer(
'general-tests', build_context, None
)
def _create_build_context(
self,
general_tests_optimized: bool = True,
test_context: dict[str, any] = None,
) -> BuildContext:
if not test_context:
test_context = self._create_test_context()
build_context_dict = {}
build_context_dict['enabledBuildFeatures'] = [{'name': 'optimized_build'}]
if general_tests_optimized:
build_context_dict['enabledBuildFeatures'].append(
{'name': 'general_tests_optimized'}
)
build_context_dict['testContext'] = test_context
return BuildContext(build_context_dict)
def _create_test_context(self):
return {
'testInfos': [
{
'name': 'atp_test',
'target': 'test_target',
'branch': 'branch',
'extraOptions': [
{
'key': 'additional-files-filter',
'values': ['general-tests.zip'],
},
{
'key': 'test-mapping-test-group',
'values': ['test-mapping-group'],
},
],
'command': '/tf/command',
'extraBuildTargets': [
'extra_build_target',
],
},
],
}
def _get_soong_vars_output(
self, return_code: int = 0, stdout: str = ''
) -> subprocess.CompletedProcess:
return_value = subprocess.CompletedProcess(args=[], returncode=return_code)
if not stdout:
stdout = textwrap.dedent(f"""\
HOST_OUT_TESTCASES='{self._host_out_testcases}'
TARGET_OUT_TESTCASES='{self._target_out_testcases}'
PRODUCT_OUT='{self._product_out}'
SOONG_HOST_OUT='{self._soong_host_out}'
HOST_OUT='{self._host_out}'""")
return_value.stdout = stdout
return return_value
def _set_up_build_outputs(self, targets: list[str]):
for target in targets:
host_dir = self._host_out_testcases / target
host_dir.mkdir()
(host_dir / f'{target}.config').touch()
(host_dir / f'test_file').touch()
target_dir = self._target_out_testcases / target
target_dir.mkdir()
(target_dir / f'{target}.config').touch()
(target_dir / f'test_file').touch()
def _verify_soong_zip_commands(self, commands: list[str], targets: list[str]):
"""Verify the structure of the zip commands.
Zip commands have to start with the soong_zip binary path, then are followed
by a couple of options and the name of the file being zipped. Depending on
which zip we are creating look for a few essential items being added in
those zips.
Args:
commands: list of command lists
targets: list of targets expected to be in general-tests.zip
"""
for command in commands:
self.assertEqual(
'/tmp/top/prebuilts/build-tools/linux-x86/bin/soong_zip',
command[0],
)
self.assertEqual('-d', command[1])
self.assertEqual('-o', command[2])
match (command[3]):
case '/tmp/top/out/dist/general-tests_configs.zip':
self.assertIn(f'{self._host_out}/host_general-tests_list', command)
self.assertIn(
f'{self._product_out}/target_general-tests_list', command
)
return
case '/tmp/top/out/dist/general-tests_list.zip':
self.assertIn('-f', command)
self.assertIn(f'{self._host_out}/general-tests_list', command)
return
case '/tmp/top/out/dist/general-tests.zip':
for target in targets:
self.assertIn(f'{self._host_out_testcases}/{target}', command)
self.assertIn(f'{self._target_out_testcases}/{target}', command)
self.assertIn(
f'{self._soong_host_out}/framework/cts-tradefed.jar', command
)
self.assertIn(
f'{self._soong_host_out}/framework/compatibility-host-util.jar',
command,
)
self.assertIn(
f'{self._soong_host_out}/framework/vts-tradefed.jar', command
)
return
case _:
self.fail(f'malformed command: {command}')
if __name__ == '__main__':
# Setup logging to be silent so unit tests can pass through TF.
logging.disable(logging.ERROR)
unittest.main()
================================================
FILE: ci/test_discovery_agent.py
================================================
# Copyright 2024, 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.
"""Test discovery agent that uses TradeFed to discover test artifacts."""
import glob
import json
import logging
import os
import subprocess
class TestDiscoveryAgent:
"""Test discovery agent."""
_TRADEFED_PREBUILT_JAR_RELATIVE_PATH = (
"vendor/google_tradefederation/prebuilts/filegroups/google-tradefed/"
)
_TRADEFED_NO_POSSIBLE_TEST_DISCOVERY_KEY = "NoPossibleTestDiscovery"
_TRADEFED_TEST_ZIP_REGEXES_LIST_KEY = "TestZipRegexes"
_TRADEFED_DISCOVERY_OUTPUT_FILE_NAME = "test_discovery_agent.txt"
def __init__(
self,
tradefed_args: list[str],
test_mapping_zip_path: str = "",
tradefed_jar_revelant_files_path: str = _TRADEFED_PREBUILT_JAR_RELATIVE_PATH,
):
self.tradefed_args = tradefed_args
self.test_mapping_zip_path = test_mapping_zip_path
self.tradefed_jar_relevant_files_path = tradefed_jar_revelant_files_path
def discover_test_zip_regexes(self) -> list[str]:
"""Discover test zip regexes from TradeFed.
Returns:
A list of test zip regexes that TF is going to try to pull files from.
"""
test_discovery_output_file_name = os.path.join(
os.environ.get('TOP'), 'out', self._TRADEFED_DISCOVERY_OUTPUT_FILE_NAME
)
with open(
test_discovery_output_file_name, mode="w+t"
) as test_discovery_output_file:
java_args = []
java_args.append("prebuilts/jdk/jdk21/linux-x86/bin/java")
java_args.append("-cp")
java_args.append(
self.create_classpath(self.tradefed_jar_relevant_files_path)
)
java_args.append(
"com.android.tradefed.observatory.TestZipDiscoveryExecutor"
)
java_args.extend(self.tradefed_args)
env = os.environ.copy()
env.update({"DISCOVERY_OUTPUT_FILE": test_discovery_output_file.name})
logging.info(f"Calling test discovery with args: {java_args}")
try:
result = subprocess.run(args=java_args, env=env, text=True, check=True)
logging.info(f"Test zip discovery output: {result.stdout}")
except subprocess.CalledProcessError as e:
raise TestDiscoveryError(
f"Failed to run test discovery, strout: {e.stdout}, strerr:"
f" {e.stderr}, returncode: {e.returncode}"
)
data = json.loads(test_discovery_output_file.read())
logging.info(f"Test discovery result file content: {data}")
if (
self._TRADEFED_NO_POSSIBLE_TEST_DISCOVERY_KEY in data
and data[self._TRADEFED_NO_POSSIBLE_TEST_DISCOVERY_KEY]
):
raise TestDiscoveryError("No possible test discovery")
if (
data[self._TRADEFED_TEST_ZIP_REGEXES_LIST_KEY] is None
or data[self._TRADEFED_TEST_ZIP_REGEXES_LIST_KEY] is []
):
raise TestDiscoveryError("No test zip regexes returned")
return data[self._TRADEFED_TEST_ZIP_REGEXES_LIST_KEY]
def discover_test_modules(self) -> list[str]:
"""Discover test modules from TradeFed.
Returns:
A list of test modules that TradeFed is going to execute based on the
TradeFed test args.
"""
return []
def create_classpath(self, directory):
"""Creates a classpath string from all .jar files in the given directory.
Args:
directory: The directory to search for .jar files.
Returns:
A string representing the classpath, with jar files separated by the
OS-specific path separator (e.g., ':' on Linux/macOS, ';' on Windows).
"""
jar_files = glob.glob(os.path.join(directory, "*.jar"))
return os.pathsep.join(jar_files)
class TestDiscoveryError(Exception):
"""A TestDiscoveryErrorclass."""
def __init__(self, message):
super().__init__(message)
self.message = message
================================================
FILE: ci/test_mapping_module_retriever.py
================================================
# Copyright 2024, 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.
"""
Simple parsing code to scan test_mapping files and determine which
modules are needed to build for the given list of changed files.
TODO(lucafarsi): Deduplicate from artifact_helper.py
"""
# TODO(lucafarsi): Share this logic with the original logic in
# test_mapping_test_retriever.py
import json
import os
import re
from typing import Any
# Regex to extra test name from the path of test config file.
TEST_NAME_REGEX = r'(?:^|.*/)([^/]+)\.config'
# Key name for TEST_MAPPING imports
KEY_IMPORTS = 'imports'
KEY_IMPORT_PATH = 'path'
# Name of TEST_MAPPING file.
TEST_MAPPING = 'TEST_MAPPING'
# Pattern used to identify double-quoted strings and '//'-format comments in
# TEST_MAPPING file, but only double-quoted strings are included within the
# matching group.
_COMMENTS_RE = re.compile(r'(\"(?:[^\"\\]|\\.)*\"|(?=//))(?://.*)?')
def FilterComments(test_mapping_file: str) -> str:
"""Remove comments in TEST_MAPPING file to valid format.
Only '//' is regarded as comments.
Args:
test_mapping_file: Path to a TEST_MAPPING file.
Returns:
Valid json string without comments.
"""
return re.sub(_COMMENTS_RE, r'\1', test_mapping_file)
def GetTestMappings(paths: set[str],
checked_paths: set[str]) -> dict[str, dict[str, Any]]:
"""Get the affected TEST_MAPPING files.
TEST_MAPPING files in source code are packaged into a build artifact
`test_mappings.zip`. Inside the zip file, the path of each TEST_MAPPING file
is preserved. From all TEST_MAPPING files in the source code, this method
locates the affected TEST_MAPPING files based on the given paths list.
A TEST_MAPPING file may also contain `imports` that import TEST_MAPPING files
from a different location, e.g.,
"imports": [
{
"path": "../folder2"
}
]
In that example, TEST_MAPPING files inside ../folder2 (relative to the
TEST_MAPPING file containing that imports section) and its parent directories
will also be included.
Args:
paths: A set of paths with related TEST_MAPPING files for given changes.
checked_paths: A set of paths that have been checked for TEST_MAPPING file
already. The set is updated after processing each TEST_MAPPING file. It's
used to prevent infinite loop when the method is called recursively.
Returns:
A dictionary of Test Mapping containing the content of the affected
TEST_MAPPING files, indexed by the path containing the TEST_MAPPING file.
"""
test_mappings = {}
# Search for TEST_MAPPING files in each modified path and its parent
# directories.
all_paths = set()
for path in paths:
dir_names = path.split(os.path.sep)
all_paths |= set(
[os.path.sep.join(dir_names[:i + 1]) for i in range(len(dir_names))])
# Add root directory to the paths to search for TEST_MAPPING file.
all_paths.add('')
all_paths.difference_update(checked_paths)
checked_paths |= all_paths
# Try to load TEST_MAPPING file in each possible path.
for path in all_paths:
try:
test_mapping_file = os.path.join(os.path.join(os.getcwd(), path), 'TEST_MAPPING')
# Read content of TEST_MAPPING file.
content = FilterComments(open(test_mapping_file, "r").read())
test_mapping = json.loads(content)
test_mappings[path] = test_mapping
import_paths = set()
for import_detail in test_mapping.get(KEY_IMPORTS, []):
import_path = import_detail[KEY_IMPORT_PATH]
# Try the import path as absolute path.
import_paths.add(import_path)
# Try the import path as relative path based on the test mapping file
# containing the import.
norm_import_path = os.path.normpath(os.path.join(path, import_path))
import_paths.add(norm_import_path)
import_paths.difference_update(checked_paths)
if import_paths:
import_test_mappings = GetTestMappings(import_paths, checked_paths)
test_mappings.update(import_test_mappings)
except (KeyError, FileNotFoundError, NotADirectoryError):
# TEST_MAPPING file doesn't exist in path
pass
return test_mappings
def FindAffectedModules(
test_mappings: dict[str, Any],
changed_files: set[str],
test_mapping_test_groups: set[str],
) -> set[str]:
"""Find affected test modules.
Find the affected set of test modules that would run in a test mapping run based on the given test mappings, changed files, and test mapping test group.
Args:
test_mappings: A set of test mappings returned by GetTestMappings in the following format:
{
'test_mapping_file_path': {
'group_name' : [
'name': 'module_name',
],
}
}
changed_files: A set of files changed for the given run.
test_mapping_test_groups: A set of test mapping test groups that are being considered for the given run.
Returns:
A set of test module names which would run for a test mapping test run with the given parameters.
"""
modules = set()
for test_mapping in test_mappings.values():
for group_name, group in test_mapping.items():
# If a module is not in any of the test mapping groups being tested skip
# it.
if group_name not in test_mapping_test_groups:
continue
for entry in group:
module_name = entry.get('name')
if not module_name:
continue
file_patterns = entry.get('file_patterns')
if not file_patterns:
modules.add(module_name)
continue
if matches_file_patterns(file_patterns, changed_files):
modules.add(module_name)
return modules
def MatchesFilePatterns(
file_patterns: list[set], changed_files: set[str]
) -> bool:
"""Checks if any of the changed files match any of the file patterns.
Args:
file_patterns: A list of file patterns to match against.
changed_files: A set of files to check against the file patterns.
Returns:
True if any of the changed files match any of the file patterns.
"""
return any(re.search(pattern, "|".join(changed_files)) for pattern in file_patterns)
================================================
FILE: common/core.mk
================================================
#
# Copyright (C) 2018 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.
#
# Only use ANDROID_BUILD_SHELL to wrap around bash.
# DO NOT use other shells such as zsh.
ifdef ANDROID_BUILD_SHELL
SHELL := $(ANDROID_BUILD_SHELL)
else
# Use bash, not whatever shell somebody has installed as /bin/sh
# This is repeated from main.mk, since envsetup.sh runs this file
# directly.
SHELL := /bin/bash
endif
# Utility variables.
empty :=
space := $(empty) $(empty)
comma := ,
# Note that make will eat the newline just before endef.
define newline
endef
# The pound character "#"
define pound
#
endef
# Unfortunately you can't simply define backslash as \ or \\.
backslash := \a
backslash := $(patsubst %a,%,$(backslash))
TOP :=$= .
TOPDIR :=$=
# Prevent accidentally changing these variables
.KATI_READONLY := SHELL empty space comma newline pound backslash
# Basic warning/error wrappers. These will be redefined to include the local
# module information when reading Android.mk files.
define pretty-warning
$(warning $(1))
endef
define pretty-error
$(error $(1))
endef
================================================
FILE: common/json.mk
================================================
4space :=$= $(space)$(space)$(space)$(space)
invert_bool =$= $(if $(strip $(1)),,true)
# Converts a list to a JSON list.
# $1: List separator.
# $2: List.
_json_list =$= [$(if $(2),"$(subst $(1),"$(comma)",$(2))")]
# Converts a space-separated list to a JSON list.
json_list =$= $(call _json_list,$(space),$(1))
# Converts a comma-separated list to a JSON list.
csv_to_json_list =$= $(call _json_list,$(comma),$(1))
# Adds or removes 4 spaces from _json_indent
json_increase_indent =$= $(eval _json_indent := $$(_json_indent)$$(4space))
json_decrease_indent =$= $(eval _json_indent := $$(subst _,$$(space),$$(patsubst %____,%,$$(subst $$(space),_,$$(_json_indent)))))
# 1: Key name
# 2: Value
add_json_val =$= $(eval _json_contents := $$(_json_contents)$$(_json_indent)"$$(strip $$(1))": $$(strip $$(2))$$(comma)$$(newline))
add_json_str =$= $(call add_json_val,$(1),"$(strip $(2))")
add_json_list =$= $(call add_json_val,$(1),$(call json_list,$(patsubst %,%,$(2))))
add_json_csv =$= $(call add_json_val,$(1),$(call csv_to_json_list,$(strip $(2))))
add_json_bool =$= $(call add_json_val,$(1),$(if $(strip $(2)),true,false))
add_json_map =$= $(eval _json_contents := $$(_json_contents)$$(_json_indent)"$$(strip $$(1))": {$$(newline))$(json_increase_indent)
add_json_map_anon =$= $(eval _json_contents := $$(_json_contents)$$(_json_indent){$$(newline))$(json_increase_indent)
end_json_map =$= $(json_decrease_indent)$(eval _json_contents := $$(_json_contents)$$(if $$(filter %$$(comma),$$(lastword $$(_json_contents))),__SV_END)$$(_json_indent)},$$(newline))
add_json_array =$= $(eval _json_contents := $$(_json_contents)$$(_json_indent)"$$(strip $$(1))": [$$(newline))$(json_increase_indent)
end_json_array =$= $(json_decrease_indent)$(eval _json_contents := $$(_json_contents)$$(if $$(filter %$$(comma),$$(lastword $$(_json_contents))),__SV_END)$$(_json_indent)],$$(newline))
# Clears _json_contents to start a new json file
json_start =$= $(eval _json_contents := {$$(newline))$(eval _json_indent := $$(4space))
# Adds the trailing close brace to _json_contents, and removes any trailing commas if necessary
json_end =$= $(eval _json_contents := $$(subst $$(comma)$$(newline)__SV_END,$$(newline),$$(_json_contents)__SV_END}$$(newline)))
json_contents =$= $(_json_contents)
================================================
FILE: common/math.mk
================================================
#
# Copyright (C) 2017 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.
#
###########################################################
# Basic math functions for non-negative integers <= 100
#
# (SDK versions for example)
###########################################################
__MATH_POS_NUMBERS := 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 \
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 \
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 \
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 \
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
__MATH_NUMBERS := 0 $(__MATH_POS_NUMBERS)
__MATH_ONE_NUMBERS := 0 1 2 3 4 5 6 7 8 9
math-error = $(call pretty-error,$(1))
math-expect :=
math-expect-true :=
math-expect :=
math-expect-error :=
# Run the math tests with:
# make -f ${ANDROID_BUILD_TOP}/build/make/common/math.mk RUN_MATH_TESTS=true
# $(get_build_var CKATI) -f ${ANDROID_BUILD_TOP}//build/make/common/math.mk RUN_MATH_TESTS=true
ifdef RUN_MATH_TESTS
ifndef empty
empty :=
space := $(empty) $(empty)
endif
MATH_TEST_FAILURE :=
MATH_TEST_ERROR :=
math-error = $(if $(MATH_TEST_ERROR),,$(eval MATH_TEST_ERROR:=$(1)))
define math-expect
$(eval got:=$$$1) \
$(if $(subst $(got),,$(2))$(subst $(2),,$(got))$(MATH_TEST_ERROR), \
$(if $(MATH_TEST_ERROR),$(warning $(MATH_TEST_ERROR)),$(warning $$$1 '$(got)' != '$(2)')) \
$(eval MATH_TEST_FAILURE := true)) \
$(eval MATH_TEST_ERROR :=) \
$(eval got:=)
endef
math-expect-true = $(call math-expect,$(1),true)
math-expect-false = $(call math-expect,$(1),)
define math-expect-error
$(eval got:=$$$1) \
$(if $(subst $(MATH_TEST_ERROR),,$(2))$(subst $(2),,$(MATH_TEST_ERROR)), \
$(warning '$(MATH_TEST_ERROR)' != '$(2)') \
$(eval MATH_TEST_FAILURE := true)) \
$(eval MATH_TEST_ERROR :=) \
$(eval got:=)
endef
endif
# Returns true if $(1) is a non-negative integer <= 100, otherwise returns nothing.
define math_is_number_in_100
$(strip \
$(if $(1),,$(call math-error,Argument missing)) \
$(if $(word 2,$(1)),$(call math-error,Multiple words in a single argument: $(1))) \
$(if $(filter $(1),$(__MATH_NUMBERS)),true))
endef
# Same with math_is_number_in_100, but no limit.
define _math_ext_is_number
$(strip \
$(if $(1),,$(call math-error,Argument missing)) \
$(if $(word 2,$(1)),$(call math-error,Multiple words in a single argument: $(1))) \
$(eval should_empty:=$(1)) \
$(foreach num,$(__MATH_ONE_NUMBERS),\
$(eval should_empty:=$(subst $(num),$(empty),$(should_empty)))) \
$(if $(should_empty),,true))
endef
# Returns true if $(1) is a non-negative integer.
define math_is_number
$(strip $(if $(call math_is_number_in_100,$(1)),true,$(call _math_ext_is_number,$(1))))
endef
# Returns true if $(1) is a positive or negative integer.
define math_is_int
$(call math_is_number,$(patsubst -%,%,$(1)))
endef
define math_is_zero
$(strip \
$(if $(word 2,$(1)),$(call math-error,Multiple words in a single argument: $(1))) \
$(if $(filter 0,$(1)),true))
endef
$(call math-expect-true,(call math_is_number,0))
$(call math-expect-true,(call math_is_number,2))
$(call math-expect-true,(call math_is_number,202412))
$(call math-expect-false,(call math_is_number,foo))
$(call math-expect-false,(call math_is_number,-1))
$(call math-expect-true,(call math_is_int,50))
$(call math-expect-true,(call math_is_int,-1))
$(call math-expect-true,(call math_is_int,-528))
$(call math-expect-true,(call math_is_int,-0))
$(call math-expect-false,(call math_is_int,--1))
$(call math-expect-false,(call math_is_int,-))
$(call math-expect-error,(call math_is_number,1 2),Multiple words in a single argument: 1 2)
$(call math-expect-error,(call math_is_number,no 2),Multiple words in a single argument: no 2)
$(call math-expect-true,(call math_is_zero,0))
$(call math-expect-false,(call math_is_zero,1))
$(call math-expect-false,(call math_is_zero,foo))
$(call math-expect-error,(call math_is_zero,1 2),Multiple words in a single argument: 1 2)
$(call math-expect-error,(call math_is_zero,no 2),Multiple words in a single argument: no 2)
define _math_check_valid
$(if $(call math_is_number_in_100,$(1)),,$(call math-error,Only non-negative integers <= 100 are supported (not $(1))))
endef
$(call math-expect,(call _math_check_valid,0))
$(call math-expect,(call _math_check_valid,1))
$(call math-expect,(call _math_check_valid,100))
$(call math-expect-error,(call _math_check_valid,-1),Only non-negative integers <= 100 are supported (not -1))
$(call math-expect-error,(call _math_check_valid,101),Only non-negative integers <= 100 are supported (not 101))
$(call math-expect-error,(call _math_check_valid,),Argument missing)
$(call math-expect-error,(call _math_check_valid,1 2),Multiple words in a single argument: 1 2)
# return a list containing integers ranging from [$(1),$(2)]
define int_range_list
$(strip \
$(call _math_check_valid,$(1))$(call _math_check_valid,$(2)) \
$(if $(call math_is_zero,$(1)),0)\
$(wordlist $(if $(call math_is_zero,$(1)),1,$(1)),$(2),$(__MATH_POS_NUMBERS)))
endef
$(call math-expect,(call int_range_list,0,1),0 1)
$(call math-expect,(call int_range_list,1,1),1)
$(call math-expect,(call int_range_list,1,2),1 2)
$(call math-expect,(call int_range_list,2,1),)
$(call math-expect-error,(call int_range_list,1,101),Only non-negative integers <= 100 are supported (not 101))
# Split an integer into a list of digits
define _math_number_to_list
$(strip \
$(if $(call _math_ext_is_number,$(1)),,\
$(call math-error,Only non-negative integers are supported (not $(1)))) \
$(eval num_list:=$(1)) \
$(foreach num,$(__MATH_ONE_NUMBERS),\
$(eval num_list:=$(subst $(num),$(space)$(num),$(num_list)))) \
$(if $(filter $(words $(num_list)),$(__MATH_ONE_NUMBERS)),,\
$(call math-error,Only non-negative integers with less than 9 digits are supported (not $(1)))) \
$(if $(filter 0,$(word 1,$(num_list))),\
$(call math-error,Only non-negative integers without leading zeros are supported (not $(1)))) \
$(num_list))
endef
$(call math-expect,(call _math_number_to_list,123),1 2 3)
$(call math-expect-error,(call _math_number_to_list,123 456),Multiple words in a single argument: 123 456)
$(call math-expect-error,(call _math_number_to_list,-123),Only non-negative integers are supported (not -123))
$(call math-expect-error,(call _math_number_to_list,002),Only non-negative integers without leading zeros are supported (not 002))
$(call math-expect-error,(call _math_number_to_list,1234567890),Only non-negative integers with less than 9 digits are supported (not 1234567890))
# Compare 1-digit integer $(1) and $(2).
# Returns 1 if $(1) > $(2), -1 if $(1) < $(2), nothing if equals.
define _math_1digit_comp
$(strip \
$(if $(filter $(1),$(2)),,\
$(if $(filter $(1),$(firstword $(filter $(1) $(2),$(__MATH_ONE_NUMBERS)))),-1,1)))
endef
$(call math-expect,(call _math_1digit_comp,1,1))
$(call math-expect,(call _math_1digit_comp,0,9),-1)
$(call math-expect,(call _math_1digit_comp,3,1),1)
# Compare the same $(3)-digit-length integers $(1) and $(2) that are split into a list of digits.
# Returns 1 if $(1) > $(2), -1 if $(1) < $(2), nothing if equals.
define _math_list_comp
$(strip \
$(eval ans:=) \
$(foreach num,$(call int_range_list,1,$(3)),\
$(if $(ans),,$(eval ans:=$(call _math_1digit_comp,$(word $(num),$(1)),$(word $(num),$(2)))))) \
$(ans))
endef
# Compare any two non-negative integers $(1) and $(2).
# Returns 1 if $(1) > $(2), -1 if $(1) < $(2), nothing if equals.
define _math_ext_comp
$(strip \
$(eval num_list1:=$(call _math_number_to_list,$(1))) \
$(eval len1:=$(words $(num_list1))) \
$(eval num_list2:=$(call _math_number_to_list,$(2))) \
$(eval len2:=$(words $(num_list2))) \
$(eval comp:=$(call _math_1digit_comp,$(len1),$(len2))) \
$(if $(comp),$(comp),$(call _math_list_comp,$(num_list1),$(num_list2),$(len1))))
endef
$(call math-expect,(call _math_ext_comp,5,10),-1)
$(call math-expect,(call _math_ext_comp,12345,12345))
$(call math-expect,(call _math_ext_comp,500,5),1)
$(call math-expect,(call _math_ext_comp,202404,202504),-1)
# Returns the greater of $1 or $2.
# If $1 or $2 is not a positive integer, then an error is generated.
define math_max
$(strip \
$(if $(filter truetrue,$(call math_is_number_in_100,$(1))$(call math_is_number_in_100,$(2))),\
$(lastword $(filter $(1) $(2),$(__MATH_NUMBERS))),\
$(if $(filter 1,$(call _math_ext_comp,$(1),$(2))),$(1),$(2))))
endef
# Returns the lesser of $1 or $2.
define math_min
$(strip \
$(if $(filter truetrue,$(call math_is_number_in_100,$(1))$(call math_is_number_in_100,$(2))),\
$(firstword $(filter $(1) $(2),$(__MATH_NUMBERS))),\
$(if $(filter -1,$(call _math_ext_comp,$(1),$(2))),$(1),$(2))))
endef
$(call math-expect-error,(call math_max),Argument missing)
$(call math-expect-error,(call math_max,1),Argument missing)
$(call math-expect-error,(call math_max,1 2,3),Multiple words in a single argument: 1 2)
$(call math-expect-error,(call math_min,1,2 3),Multiple words in a single argument: 2 3)
$(call math-expect,(call math_max,0,1),1)
$(call math-expect,(call math_max,1,0),1)
$(call math-expect,(call math_max,1,1),1)
$(call math-expect,(call math_max,5,42),42)
$(call math-expect,(call math_max,42,5),42)
$(call math-expect,(call math_min,0,1),0)
$(call math-expect,(call math_min,1,0),0)
$(call math-expect,(call math_min,1,1),1)
$(call math-expect,(call math_min,7,32),7)
$(call math-expect,(call math_min,32,7),7)
$(call math-expect,(call math_max,32759,7),32759)
$(call math-expect,(call math_max,7,32759),32759)
$(call math-expect,(call math_max,202404,202505),202505)
$(call math-expect,(call math_max,202404,202404),202404)
$(call math-expect,(call math_min,8908527,32),32)
$(call math-expect,(call math_min,32,8908527),32)
$(call math-expect,(call math_min,202404,202505),202404)
$(call math-expect,(call math_min,202404,202404),202404)
define math_gt_or_eq
$(if $(filter $(1),$(call math_max,$(1),$(2))),true)
endef
define math_gt
$(if $(call math_gt_or_eq,$(2),$(1)),,true)
endef
define math_lt_or_eq
$(if $(call math_gt_or_eq,$(2),$(1)),true)
endef
define math_lt
$(if $(call math_gt_or_eq,$(1),$(2)),,true)
endef
$(call math-expect-true,(call math_gt_or_eq, 2, 1))
$(call math-expect-true,(call math_gt_or_eq, 1, 1))
$(call math-expect-false,(call math_gt_or_eq, 1, 2))
$(call math-expect-true,(call math_gt, 4, 3))
$(call math-expect-false,(call math_gt, 5, 5))
$(call math-expect-false,(call math_gt, 6, 7))
$(call math-expect-true,(call math_lt_or_eq, 11, 11))
$(call math-expect-false,(call math_lt_or_eq, 25, 15))
$(call math-expect-true,(call math_lt_or_eq, 9, 16))
$(call math-expect-false,(call math_lt, 1, 0))
$(call math-expect-false,(call math_lt, 8, 8))
$(call math-expect-true,(call math_lt, 10, 11))
$(call math-expect-true,(call math_gt_or_eq, 2573904, 2573900))
$(call math-expect-true,(call math_gt_or_eq, 12345, 12345))
$(call math-expect-false,(call math_gt_or_eq, 56, 2780))
# $1 is the variable name to increment
define inc_and_print
$(strip $(eval $(1) := $($(1)) .)$(words $($(1))))
endef
ifdef RUN_MATH_TESTS
a :=
$(call math-expect,(call inc_and_print,a),1)
$(call math-expect,(call inc_and_print,a),2)
$(call math-expect,(call inc_and_print,a),3)
$(call math-expect,(call inc_and_print,a),4)
endif
# Returns the words in $2 that are numbers and are less than $1
define numbers_less_than
$(strip \
$(foreach n,$2, \
$(if $(call math_is_number,$(n)), \
$(if $(call math_lt,$(n),$(1)), \
$(n)))))
endef
$(call math-expect,(call numbers_less_than,0,0 1 2 3),)
$(call math-expect,(call numbers_less_than,1,0 2 1 3),0)
$(call math-expect,(call numbers_less_than,2,0 2 1 3),0 1)
$(call math-expect,(call numbers_less_than,3,0 2 1 3),0 2 1)
$(call math-expect,(call numbers_less_than,4,0 2 1 3),0 2 1 3)
$(call math-expect,(call numbers_less_than,3,0 2 1 3 2),0 2 1 2)
$(call math-expect,(call numbers_less_than,100,0 1000 50 101 100),0 50)
# Returns the words in $2 that are numbers and are greater or equal to $1
define numbers_greater_or_equal_to
$(strip \
$(foreach n,$2, \
$(if $(call math_is_number,$(n)), \
$(if $(call math_gt_or_eq,$(n),$(1)), \
$(n)))))
endef
$(call math-expect,(call numbers_greater_or_equal_to,4,0 1 2 3),)
$(call math-expect,(call numbers_greater_or_equal_to,3,0 2 1 3),3)
$(call math-expect,(call numbers_greater_or_equal_to,2,0 2 1 3),2 3)
$(call math-expect,(call numbers_greater_or_equal_to,1,0 2 1 3),2 1 3)
$(call math-expect,(call numbers_greater_or_equal_to,0,0 2 1 3),0 2 1 3)
$(call math-expect,(call numbers_greater_or_equal_to,1,0 2 1 3 2),2 1 3 2)
# 10,001 = 10 ** 4 + 1, contains 10,001 x's, so 1 more than 10,000 (future) API level
_INT_LIMIT_WORDS := x $(foreach a,0 1 2 3 4 5 6 7 8 9,$(foreach b,0 1 2 3 4 5 6 7 8 9,\
$(foreach c,0 1 2 3 4 5 6 7 8 9,x x x x x x x x x x)))
define _int_encode
$(if $(filter $(words x $(_INT_LIMIT_WORDS)),$(words $(wordlist 1,$(1),x $(_INT_LIMIT_WORDS)))),\
$(call math-error,integer greater than $(words $(_INT_LIMIT_WORDS)) is not supported!),\
$(wordlist 1,$(1),$(_INT_LIMIT_WORDS)))
endef
# _int_max returns the maximum of the two arguments
# input: two (x) lists; output: one (x) list
# integer cannot be passed in directly. It has to be converted using _int_encode.
define _int_max
$(subst xx,x,$(join $(1),$(2)))
endef
# first argument is greater than second argument
# output: non-empty if true
# integer cannot be passed in directly. It has to be converted using _int_encode.
define _int_greater-than
$(filter-out $(words $(2)),$(words $(call _int_max,$(1),$(2))))
endef
# first argument equals to second argument
# output: non-empty if true
# integer cannot be passed in directly. It has to be converted using _int_encode.
define _int_equal
$(filter $(words $(1)),$(words $(2)))
endef
# first argument is greater than or equal to second argument
# output: non-empty if true
# integer cannot be passed in directly. It has to be converted using _int_encode.
define _int_greater-or-equal
$(call _int_greater-than,$(1),$(2))$(call _int_equal,$(1),$(2))
endef
define int_plus
$(words $(call _int_encode,$(1)) $(call _int_encode,$(2)))
endef
$(call math-expect,(call int_plus,0,0),0)
$(call math-expect,(call int_plus,0,1),1)
$(call math-expect,(call int_plus,1,0),1)
$(call math-expect,(call int_plus,1,100),101)
$(call math-expect,(call int_plus,100,100),200)
define int_subtract
$(strip \
$(if $(call _int_greater-or-equal,$(call _int_encode,$(1)),$(call _int_encode,$(2))),\
$(words $(filter-out xx,$(join $(call _int_encode,$(1)),$(call _int_encode,$(2))))),\
$(call math-error,subtract underflow $(1) - $(2))))
endef
$(call math-expect,(call int_subtract,0,0),0)
$(call math-expect,(call int_subtract,1,0),1)
$(call math-expect,(call int_subtract,1,1),0)
$(call math-expect,(call int_subtract,100,1),99)
$(call math-expect,(call int_subtract,200,100),100)
$(call math-expect-error,(call int_subtract,0,1),subtract underflow 0 - 1)
define int_multiply
$(words $(foreach a,$(call _int_encode,$(1)),$(call _int_encode,$(2))))
endef
$(call math-expect,(call int_multiply,0,0),0)
$(call math-expect,(call int_multiply,1,0),0)
$(call math-expect,(call int_multiply,1,1),1)
$(call math-expect,(call int_multiply,100,1),100)
$(call math-expect,(call int_multiply,1,100),100)
$(call math-expect,(call int_multiply,4,100),400)
$(call math-expect,(call int_multiply,100,4),400)
define int_divide
$(if $(filter 0,$(2)),$(call math-error,division by zero is not allowed!),$(strip \
$(if $(call _int_greater-or-equal,$(call _int_encode,$(1)),$(call _int_encode,$(2))), \
$(call int_plus,$(call int_divide,$(call int_subtract,$(1),$(2)),$(2)),1),0)))
endef
$(call math-expect,(call int_divide,1,1),1)
$(call math-expect,(call int_divide,200,1),200)
$(call math-expect,(call int_divide,200,3),66)
$(call math-expect,(call int_divide,1,2),0)
$(call math-expect-error,(call int_divide,0,0),division by zero is not allowed!)
$(call math-expect-error,(call int_divide,1,0),division by zero is not allowed!)
ifdef RUN_MATH_TESTS
ifdef MATH_TEST_FAILURE
math-tests:
@echo FAIL
@false
else
math-tests:
@echo PASS
endif
.PHONY: math-tests
endif
================================================
FILE: common/strings.mk
================================================
#
# Copyright (C) 2018 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.
#
###########################################################
## Convert to lower case without requiring a shell, which isn't cacheable.
##
## $(1): string
###########################################################
to-lower=$(subst A,a,$(subst B,b,$(subst C,c,$(subst D,d,$(subst E,e,$(subst F,f,$(subst G,g,$(subst H,h,$(subst I,i,$(subst J,j,$(subst K,k,$(subst L,l,$(subst M,m,$(subst N,n,$(subst O,o,$(subst P,p,$(subst Q,q,$(subst R,r,$(subst S,s,$(subst T,t,$(subst U,u,$(subst V,v,$(subst W,w,$(subst X,x,$(subst Y,y,$(subst Z,z,$1))))))))))))))))))))))))))
###########################################################
## Convert to upper case without requiring a shell, which isn't cacheable.
##
## $(1): string
###########################################################
to-upper=$(subst a,A,$(subst b,B,$(subst c,C,$(subst d,D,$(subst e,E,$(subst f,F,$(subst g,G,$(subst h,H,$(subst i,I,$(subst j,J,$(subst k,K,$(subst l,L,$(subst m,M,$(subst n,N,$(subst o,O,$(subst p,P,$(subst q,Q,$(subst r,R,$(subst s,S,$(subst t,T,$(subst u,U,$(subst v,V,$(subst w,W,$(subst x,X,$(subst y,Y,$(subst z,Z,$1))))))))))))))))))))))))))
# Test to-lower and to-upper
lower := abcdefghijklmnopqrstuvwxyz-_
upper := ABCDEFGHIJKLMNOPQRSTUVWXYZ-_
ifneq ($(lower),$(call to-lower,$(upper)))
$(error to-lower sanity check failure)
endif
ifneq ($(upper),$(call to-upper,$(lower)))
$(error to-upper sanity check failure)
endif
lower :=
upper :=
###########################################################
## Returns true if $(1) and $(2) are equal. Returns
## the empty string if they are not equal.
###########################################################
define streq
$(strip $(if $(strip $(1)),\
$(if $(strip $(2)),\
$(if $(filter-out __,_$(subst $(strip $(1)),,$(strip $(2)))$(subst $(strip $(2)),,$(strip $(1)))_),,true), \
),\
$(if $(strip $(2)),\
,\
true)\
))
endef
###########################################################
## Convert "a b c" into "a:b:c"
###########################################################
define normalize-path-list
$(subst $(space),:,$(strip $(1)))
endef
###########################################################
## Convert "a b c" into "a,b,c"
###########################################################
define normalize-comma-list
$(subst $(space),$(comma),$(strip $(1)))
endef
###########################################################
## Read the word out of a colon-separated list of words.
## This has the same behavior as the built-in function
## $(word n,str).
##
## The individual words may not contain spaces.
##
## $(1): 1 based index
## $(2): value of the form a:b:c...
###########################################################
define word-colon
$(word $(1),$(subst :,$(space),$(2)))
endef
###########################################################
## Read a colon-separated sublist out of a colon-separated
## list of words.
## This has similar behavior to the built-in function
## $(wordlist s,e,str) except both the input and output
## word lists are colon-separated.
##
## The individual words may not contain spaces.
##
## $(1): 1 based index start
## $(2): 1 based index end (can be 0)
## $(3): value of the form a:b:c...
###########################################################
define wordlist-colon
$(subst $(space),:,$(wordlist $(1),$(2),$(subst :,$(space),$(3))))
endef
###########################################################
## Convert "a=b c= d e = f = g h=" into "a=b c=d e= f=g h="
##
## $(1): list to collapse
## $(2): if set, separator word; usually "=", ":", or ":="
## Defaults to "=" if not set.
###########################################################
define collapse-pairs
$(strip \
$(eval _cpSEP := $(strip $(if $(2),$(2),=)))\
$(eval _cpLHS :=)\
$(eval _cpRET :=)\
$(foreach w,$(subst $(space)$(_cpSEP),$(_cpSEP),$(strip \
$(subst $(_cpSEP),$(space)$(_cpSEP)$(space),$(1)))),\
$(if $(findstring $(_cpSEP),$(w)),\
$(eval _cpRET += $(_cpLHS))$(eval _cpLHS := $(w)),\
$(eval _cpRET += $(_cpLHS)$(w))$(eval _cpLHS :=)))\
$(if $(_cpLHS),$(_cpRET)$(space)$(_cpLHS),$(_cpRET))\
$(eval _cpSEP :=)\
$(eval _cpLHS :=)\
$(eval _cpRET :=))
endef
# Sanity check for collapse-pairs.
ifneq (a=b c=d e= f=g h=,$(call collapse-pairs,a=b c= d e = f = g h=))
$(error collapse-pairs sanity check failure)
endif
ifneq (a:=b c:=d e:=f g:=h,$(call collapse-pairs,a:=b c:= d e :=f g := h,:=))
$(error collapse-pairs sanity check failure)
endif
###########################################################
## Given a list of pairs, if multiple pairs have the same
## first components, keep only the first pair.
##
## $(1): list of pairs
## $(2): the separator word, such as ":", "=", etc.
define uniq-pairs-by-first-component
$(eval _upbfc_fc_set :=)\
$(strip $(foreach w,$(1), $(eval _first := $(word 1,$(subst $(2),$(space),$(w))))\
$(if $(filter $(_upbfc_fc_set),$(_first)),,$(w)\
$(eval _upbfc_fc_set += $(_first)))))\
$(eval _upbfc_fc_set :=)\
$(eval _first:=)
endef
================================================
FILE: core/LINUX_KERNEL_COPYING
================================================
NOTE! This copyright does *not* cover user programs that use kernel
services by normal system calls - this is merely considered normal use
of the kernel, and does *not* fall under the heading of "derived work".
Also note that the GPL below is copyrighted by the Free Software
Foundation, but the instance of code that it refers to (the Linux
kernel) is copyrighted by me and others who actually wrote it.
Also note that the only valid version of the GPL as far as the kernel
is concerned is _this_ particular version of the license (ie v2, not
v2.2 or v3.x or whatever), unless explicitly otherwise stated.
Linus Torvalds
----------------------------------------
GNU GENERAL PUBLIC LICENSE
Version 2, June 1991
Copyright (C) 1989, 1991 Free Software Foundation, Inc.
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
Preamble
The licenses for most software are designed to take away your
freedom to share and change it. By contrast, the GNU General Public
License is intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users. This
General Public License applies to most of the Free Software
Foundation's software and to any other program whose authors commit to
using it. (Some other Free Software Foundation software is covered by
the GNU Library General Public License instead.) You can apply it to
your programs, too.
When we speak of free software, we are referring to freedom, not
price. Our General Public Licenses are designed to make sure that you
have the freedom to distribute copies of free software (and charge for
this service if you wish), that you receive source code or can get it
if you want it, that you can change the software or use pieces of it
in new free programs; and that you know you can do these things.
To protect your rights, we need to make restrictions that forbid
anyone to deny you these rights or to ask you to surrender the rights.
These restrictions translate to certain responsibilities for you if you
distribute copies of the software, or if you modify it.
For example, if you distribute copies of such a program, whether
gratis or for a fee, you must give the recipients all the rights that
you have. You must make sure that they, too, receive or can get the
source code. And you must show them these terms so they know their
rights.
We protect your rights with two steps: (1) copyright the software, and
(2) offer you this license which gives you legal permission to copy,
distribute and/or modify the software.
Also, for each author's protection and ours, we want to make certain
that everyone understands that there is no warranty for this free
software. If the software is modified by someone else and passed on, we
want its recipients to know that what they have is not the original, so
that any problems introduced by others will not reflect on the original
authors' reputations.
Finally, any free program is threatened constantly by software
patents. We wish to avoid the danger that redistributors of a free
program will individually obtain patent licenses, in effect making the
program proprietary. To prevent this, we have made it clear that any
patent must be licensed for everyone's free use or not licensed at all.
The precise terms and conditions for copying, distribution and
modification follow.
GNU GENERAL PUBLIC LICENSE
TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
0. This License applies to any program or other work which contains
a notice placed by the copyright holder saying it may be distributed
under the terms of this General Public License. The "Program", below,
refers to any such program or work, and a "work based on the Program"
means either the Program or any derivative work under copyright law:
that is to say, a work containing the Program or a portion of it,
either verbatim or with modifications and/or translated into another
language. (Hereinafter, translation is included without limitation in
the term "modification".) Each licensee is addressed as "you".
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running the Program is not restricted, and the output from the Program
is covered only if its contents constitute a work based on the
Program (independent of having been made by running the Program).
Whether that is true depends on what the Program does.
1. You may copy and distribute verbatim copies of the Program's
source code as you receive it, in any medium, provided that you
conspicuously and appropriately publish on each copy an appropriate
copyright notice and disclaimer of warranty; keep intact all the
notices that refer to this License and to the absence of any warranty;
and give any other recipients of the Program a copy of this License
along with the Program.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a fee.
2. You may modify your copy or copies of the Program or any portion
of it, thus forming a work based on the Program, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
a) You must cause the modified files to carry prominent notices
stating that you changed the files and the date of any change.
b) You must cause any work that you distribute or publish, that in
whole or in part contains or is derived from the Program or any
part thereof, to be licensed as a whole at no charge to all third
parties under the terms of this License.
c) If the modified program normally reads commands interactively
when run, you must cause it, when started running for such
interactive use in the most ordinary way, to print or display an
announcement including an appropriate copyright notice and a
notice that there is no warranty (or else, saying that you provide
a warranty) and that users may redistribute the program under
these conditions, and telling the user how to view a copy of this
License. (Exception: if the Program itself is interactive but
does not normally print such an announcement, your work based on
the Program is not required to print an announcement.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Program,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Program, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Program.
In addition, mere aggregation of another work not based on the Program
with the Program (or with a work based on the Program) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
3. You may copy and distribute the Program (or a work based on it,
under Section 2) in object code or executable form under the terms of
Sections 1 and 2 above provided that you also do one of the following:
a) Accompany it with the complete corresponding machine-readable
source code, which must be distributed under the terms of Sections
1 and 2 above on a medium customarily used for software interchange; or,
b) Accompany it with a written offer, valid for at least three
years, to give any third party, for a charge no more than your
cost of physically performing source distribution, a complete
machine-readable copy of the corresponding source code, to be
distributed under the terms of Sections 1 and 2 above on a medium
customarily used for software interchange; or,
c) Accompany it with the information you received as to the offer
to distribute corresponding source code. (This alternative is
allowed only for noncommercial distribution and only if you
received the program in object code or executable form with such
an offer, in accord with Subsection b above.)
The source code for a work means the preferred form of the work for
making modifications to it. For an executable work, complete source
code means all the source code for all modules it contains, plus any
associated interface definition files, plus the scripts used to
control compilation and installation of the executable. However, as a
special exception, the source code distributed need not include
anything that is normally distributed (in either source or binary
form) with the major components (compiler, kernel, and so on) of the
operating system on which the executable runs, unless that component
itself accompanies the executable.
If distribution of executable or object code is made by offering
access to copy from a designated place, then offering equivalent
access to copy the source code from the same place counts as
distribution of the source code, even though third parties are not
compelled to copy the source along with the object code.
4. You may not copy, modify, sublicense, or distribute the Program
except as expressly provided under this License. Any attempt
otherwise to copy, modify, sublicense or distribute the Program is
void, and will automatically terminate your rights under this License.
However, parties who have received copies, or rights, from you under
this License will not have their licenses terminated so long as such
parties remain in full compliance.
5. You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Program or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Program (or any work based on the
Program), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Program or works based on it.
6. Each time you redistribute the Program (or any work based on the
Program), the recipient automatically receives a license from the
original licensor to copy, distribute or modify the Program subject to
these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties to
this License.
7. If, as a consequence of a court judgment or allegation of patent
infringement or for any other reason (not limited to patent issues),
conditions are imposed on you (whether by court order, agreement or
otherwise) that contradict the conditions of this License, they do not
excuse you from the conditions of this License. If you cannot
distribute so as to satisfy simultaneously your obligations under this
License and any other pertinent obligations, then as a consequence you
may not distribute the Program at all. For example, if a patent
license would not permit royalty-free redistribution of the Program by
all those who receive copies directly or indirectly through you, then
the only way you could satisfy both it and this License would be to
refrain entirely from distribution of the Program.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system, which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
8. If the distribution and/or use of the Program is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Program under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
9. The Free Software Foundation may publish revised and/or new versions
of the General Public License from time to time. Such new versions will
be similar in spirit to the present version, but may differ in detail to
address new problems or concerns.
Each version is given a distinguishing version number. If the Program
specifies a version number of this License which applies to it and "any
later version", you have the option of following the terms and conditions
either of that version or of any later version published by the Free
Software Foundation. If the Program does not specify a version number of
this License, you may choose any version ever published by the Free Software
Foundation.
10. If you wish to incorporate parts of the Program into other free
programs whose distribution conditions are different, write to the author
to ask for permission. For software which is copyrighted by the Free
Software Foundation, write to the Free Software Foundation; we sometimes
make exceptions for this. Our decision will be guided by the two goals
of preserving the free status of all derivatives of our free software and
of promoting the sharing and reuse of software generally.
NO WARRANTY
11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN
OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS
TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE
PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
REPAIR OR CORRECTION.
12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
POSSIBILITY OF SUCH DAMAGES.
END OF TERMS AND CONDITIONS
How to Apply These Terms to Your New Programs
If you develop a new program, and you want it to be of the greatest
possible use to the public, the best way to achieve this is to make it
free software which everyone can redistribute and change under these terms.
To do so, attach the following notices to the program. It is safest
to attach them to the start of each source file to most effectively
convey the exclusion of warranty; and each file should have at least
the "copyright" line and a pointer to where the full notice is found.
Copyright (C)
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper mail.
If the program is interactive, make it output a short notice like this
when it starts in an interactive mode:
Gnomovision version 69, Copyright (C) year name of author
Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
This is free software, and you are welcome to redistribute it
under certain conditions; type `show c' for details.
The hypothetical commands `show w' and `show c' should show the appropriate
parts of the General Public License. Of course, the commands you use may
be called something other than `show w' and `show c'; they could even be
mouse-clicks or menu items--whatever suits your program.
You should also get your employer (if you work as a programmer) or your
school, if any, to sign a "copyright disclaimer" for the program, if
necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in the program
`Gnomovision' (which makes passes at compilers) written by James Hacker.
, 1 April 1989
Ty Coon, President of Vice
This General Public License does not permit incorporating your program into
proprietary programs. If your program is a subroutine library, you may
consider it more useful to permit linking proprietary applications with the
library. If this is what you want to do, use the GNU Library General
Public License instead of this License.
================================================
FILE: core/Makefile
================================================
# Put some miscellaneous rules here
# HACK: clear LOCAL_PATH from including last build target before calling
# intermedites-dir-for
LOCAL_PATH := $(BUILD_SYSTEM)
SYSTEM_NOTICE_DEPS :=
VENDOR_NOTICE_DEPS :=
UNMOUNTED_NOTICE_DEPS :=
UNMOUNTED_NOTICE_VENDOR_DEPS :=
ODM_NOTICE_DEPS :=
OEM_NOTICE_DEPS :=
PRODUCT_NOTICE_DEPS :=
SYSTEM_EXT_NOTICE_DEPS :=
VENDOR_DLKM_NOTICE_DEPS :=
ODM_DLKM_NOTICE_DEPS :=
SYSTEM_DLKM_NOTICE_DEPS :=
# IMAGES_TO_BUILD is a list of the partition .img files that will be created.
IMAGES_TO_BUILD:=
ifneq ($(BUILDING_BOOT_IMAGE),)
IMAGES_TO_BUILD += boot
endif
ifneq ($(BUILDING_CACHE_IMAGE),)
IMAGES_TO_BUILD += cache
endif
ifneq ($(BUILDING_DEBUG_BOOT_IMAGE),)
IMAGES_TO_BUILD += debug_boot
endif
ifneq ($(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
IMAGES_TO_BUILD += debug_vendor_boot
endif
ifneq ($(BUILDING_INIT_BOOT_IMAGE),)
IMAGES_TO_BUILD += init_boot
endif
ifneq ($(BUILDING_ODM_DLKM_IMAGE),)
IMAGES_TO_BUILD += odm_dlkm
endif
ifneq ($(BUILDING_ODM_IMAGE),)
IMAGES_TO_BUILD += odm
endif
ifneq ($(BUILDING_PRODUCT_IMAGE),)
IMAGES_TO_BUILD += product
endif
ifneq ($(BUILDING_RAMDISK_IMAGE),)
IMAGES_TO_BUILD += ramdisk
endif
ifneq ($(BUILDING_RECOVERY_IMAGE),)
IMAGES_TO_BUILD += recovery
endif
ifneq ($(BUILDING_SUPER_EMPTY_IMAGE),)
IMAGES_TO_BUILD += super_empty
endif
ifneq ($(BUILDING_SYSTEM_DLKM_IMAGE),)
IMAGES_TO_BUILD += system_dlkm
endif
ifneq ($(BUILDING_SYSTEM_EXT_IMAGE),)
IMAGES_TO_BUILD += system_ext
endif
ifneq ($(BUILDING_SYSTEM_IMAGE),)
IMAGES_TO_BUILD += system
endif
ifneq ($(BUILDING_SYSTEM_OTHER_IMAGE),)
IMAGES_TO_BUILD += system_other
endif
ifneq ($(BUILDING_USERDATA_IMAGE),)
IMAGES_TO_BUILD += userdata
endif
ifneq ($(BUILDING_VBMETA_IMAGE),)
IMAGES_TO_BUILD += vbmeta
endif
ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),)
IMAGES_TO_BUILD += vendor_boot
endif
ifneq ($(BUILDING_VENDOR_DLKM_IMAGE),)
IMAGES_TO_BUILD += vendor_dlkm
endif
ifneq ($(BUILDING_VENDOR_IMAGE),)
IMAGES_TO_BUILD += vendor
endif
ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),)
IMAGES_TO_BUILD += vendor_kernel_boot
endif
# Release & Aconfig Flags
# -----------------------------------------------------------------
include $(BUILD_SYSTEM)/packaging/flags.mk
# -----------------------------------------------------------------
# Define rules to copy PRODUCT_COPY_FILES defined by the product.
# PRODUCT_COPY_FILES contains words like :[:].
# is relative to $(PRODUCT_OUT), so it should look like,
# e.g., "system/etc/file.xml".
# The filter part means "only eval the copy-one-file rule if this
# src:dest pair is the first one to match the same dest"
#$(1): the src:dest pair
#$(2): the dest
define check-product-copy-files
$(if $(filter-out $(TARGET_COPY_OUT_SYSTEM_OTHER)/%,$(2)), \
$(if $(filter %.apk, $(2)),$(error \
Prebuilt apk found in PRODUCT_COPY_FILES: $(1), use BUILD_PREBUILT instead!))) \
$(if $(filter true,$(BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES)),, \
$(if $(filter $(TARGET_COPY_OUT_SYSTEM)/etc/vintf/% \
$(TARGET_COPY_OUT_SYSTEM)/manifest.xml \
$(TARGET_COPY_OUT_SYSTEM)/compatibility_matrix.xml,$(2)), \
$(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), use vintf_fragments instead!)) \
$(if $(filter $(TARGET_COPY_OUT_PRODUCT)/etc/vintf/%,$(2)), \
$(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
use PRODUCT_MANIFEST_FILES / DEVICE_PRODUCT_COMPATIBILITY_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
$(if $(filter $(TARGET_COPY_OUT_SYSTEM_EXT)/etc/vintf/%,$(2)), \
$(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
use vintf_compatibility_matrix / vintf_fragments instead!)) \
$(if $(filter $(TARGET_COPY_OUT_VENDOR)/etc/vintf/% \
$(TARGET_COPY_OUT_VENDOR)/manifest.xml \
$(TARGET_COPY_OUT_VENDOR)/compatibility_matrix.xml,$(2)), \
$(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
use DEVICE_MANIFEST_FILE / DEVICE_MATRIX_FILE / vintf_compatibility_matrix / vintf_fragments instead!)) \
$(if $(filter $(TARGET_COPY_OUT_ODM)/etc/vintf/% \
$(TARGET_COPY_OUT_ODM)/etc/manifest%,$(2)), \
$(error VINTF metadata found in PRODUCT_COPY_FILES: $(1), \
use ODM_MANIFEST_FILES / vintf_fragments instead!)) \
)
endef
# Phony target to check PRODUCT_COPY_FILES copy pairs don't contain ELF files
.PHONY: check-elf-prebuilt-product-copy-files
check-elf-prebuilt-product-copy-files:
check_elf_prebuilt_product_copy_files := true
ifneq (,$(filter true,$(BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES)))
check_elf_prebuilt_product_copy_files :=
endif
check_elf_prebuilt_product_copy_files_hint := \
found ELF prebuilt in PRODUCT_COPY_FILES, use cc_prebuilt_binary / cc_prebuilt_library_shared instead.
# filter out the duplicate : pairs.
unique_product_copy_files_pairs :=
$(foreach cf,$(PRODUCT_COPY_FILES), \
$(if $(filter $(unique_product_copy_files_pairs),$(cf)),,\
$(eval unique_product_copy_files_pairs += $(cf))))
unique_product_copy_files_destinations :=
product_copy_files_ignored :=
$(foreach cf,$(unique_product_copy_files_pairs), \
$(eval _src := $(call word-colon,1,$(cf))) \
$(eval _dest := $(call word-colon,2,$(cf))) \
$(call check-product-copy-files,$(cf),$(_dest)) \
$(if $(filter $(unique_product_copy_files_destinations),$(_dest)), \
$(eval product_copy_files_ignored += $(cf)), \
$(eval _fulldest := $(call append-path,$(PRODUCT_OUT),$(_dest))) \
$(if $(filter %.xml,$(_dest)),\
$(eval $(call copy-xml-file-checked,$(_src),$(_fulldest))),\
$(if $(and $(filter %.jar,$(_dest)),$(filter $(basename $(notdir $(_dest))),$(PRODUCT_LOADED_BY_PRIVILEGED_MODULES))),\
$(eval $(call copy-and-uncompress-dexs,$(_src),$(_fulldest))), \
$(if $(filter init%rc,$(notdir $(_dest)))$(filter %/etc/init/,$(dir $(_dest))),\
$(eval $(call copy-init-script-file-checked,$(_src),$(_fulldest))),\
$(if $(and $(filter true,$(check_elf_prebuilt_product_copy_files)), \
$(filter bin lib lib64,$(subst /,$(space),$(_dest)))), \
$(eval $(call copy-non-elf-file-checked,$(_src),$(_fulldest),$(check_elf_prebuilt_product_copy_files_hint))), \
$(eval $(call copy-one-file,$(_src),$(_fulldest))))))) \
$(eval unique_product_copy_files_destinations += $(_dest))))
# Dump a list of overriden (and ignored PRODUCT_COPY_FILES entries)
pcf_ignored_file := $(PRODUCT_OUT)/product_copy_files_ignored.txt
$(pcf_ignored_file): PRIVATE_IGNORED := $(sort $(product_copy_files_ignored))
$(pcf_ignored_file):
echo "$(PRIVATE_IGNORED)" | tr " " "\n" >$@
$(call declare-0p-target,$(pcf_ignored_file))
$(call dist-for-goals,droidcore-unbundled,$(pcf_ignored_file):logs/$(notdir $(pcf_ignored_file)))
pcf_ignored_file :=
product_copy_files_ignored :=
unique_product_copy_files_pairs :=
unique_product_copy_files_destinations :=
# Returns a list of EXTRA_INSTALL_ZIPS trios whose primary file is contained within $(1)
# The trios will contain the primary installed file : the directory to unzip the zip to : the zip
define relevant-extra-install-zips
$(strip $(foreach p,$(EXTRA_INSTALL_ZIPS), \
$(if $(filter $(call word-colon,1,$(p)),$(1)), \
$(p))))
endef
# Writes a text file that contains all of the files that will be inside a partition.
# All the file paths will be relative to the partition's staging directory.
# It will also take into account files inside zips listed in EXTRA_INSTALL_ZIPS.
#
# Arguments:
# $(1): Output file
# $(2): The partition's staging directory
# $(3): Files to include in the partition
define write-partition-file-list
$(1): PRIVATE_FILES := $(subst $(2)/,,$(filter $(2)/%,$(3)))
$(1): PRIVATE_EXTRA_INSTALL_ZIPS := $(call relevant-extra-install-zips,$(filter $(2)/%,$(3)))
$(1): $$(HOST_OUT_EXECUTABLES)/extra_install_zips_file_list $(foreach p,$(call relevant-extra-install-zips,$(filter $(2)/%,$(3))),$(call word-colon,3,$(p)))
@echo Writing $$@
rm -f $$@
echo -n > $$@
$$(foreach f,$$(PRIVATE_FILES),echo "$$(f)" >> $$@$$(newline))
$$(HOST_OUT_EXECUTABLES)/extra_install_zips_file_list $(2) $$(PRIVATE_EXTRA_INSTALL_ZIPS) >> $$@
endef
# -----------------------------------------------------------------
# Returns the max allowed size for an image suitable for hash verification
# (e.g., boot.img, recovery.img, etc).
# The value 69632 derives from MAX_VBMETA_SIZE + MAX_FOOTER_SIZE in $(AVBTOOL).
# $(1): partition size to flash the image
define get-hash-image-max-size
$(if $(1), \
$(if $(filter true,$(BOARD_AVB_ENABLE)), \
$(eval _hash_meta_size := 69632), \
$(eval _hash_meta_size := 0)) \
$(1)-$(_hash_meta_size))
endef
# -----------------------------------------------------------------
# Define rules to copy headers defined in copy_headers.mk
# If more than one makefile declared a header, print a warning,
# then copy the last one defined. This matches the previous make
# behavior.
has_dup_copy_headers :=
$(foreach dest,$(ALL_COPIED_HEADERS), \
$(eval _srcs := $(ALL_COPIED_HEADERS.$(dest).SRC)) \
$(eval _src := $(lastword $(_srcs))) \
$(if $(call streq,$(_src),$(_srcs)),, \
$(warning Duplicate header copy: $(dest)) \
$(warning _ Using $(_src)) \
$(warning __ from $(lastword $(ALL_COPIED_HEADERS.$(dest).MAKEFILE))) \
$(eval _makefiles := $$(wordlist 1,$(call int_subtract,$(words $(ALL_COPIED_HEADERS.$(dest).MAKEFILE)),1),$$(ALL_COPIED_HEADERS.$$(dest).MAKEFILE))) \
$(foreach src,$(wordlist 1,$(call int_subtract,$(words $(_srcs)),1),$(_srcs)), \
$(warning _ Ignoring $(src)) \
$(warning __ from $(firstword $(_makefiles))) \
$(eval _makefiles := $$(wordlist 2,9999,$$(_makefiles)))) \
$(eval has_dup_copy_headers := true)) \
$(eval $(call copy-one-header,$(_src),$(dest))))
all_copied_headers: $(ALL_COPIED_HEADERS)
ifdef has_dup_copy_headers
has_dup_copy_headers :=
$(error duplicate header copies are no longer allowed. For more information about headers, see: https://android.googlesource.com/platform/build/soong/+/master/docs/best_practices.md#headers)
endif
$(file >$(PRODUCT_OUT)/.copied_headers_list,$(TARGET_OUT_HEADERS) $(ALL_COPIED_HEADERS))
# -----------------------------------------------------------------
# docs/index.html
ifeq (,$(TARGET_BUILD_UNBUNDLED))
gen := $(OUT_DOCS)/index.html
ALL_DOCS += $(gen)
$(gen): frameworks/base/docs/docs-redirect-index.html
@mkdir -p $(dir $@)
@cp -f $< $@
endif
ndk_doxygen_out := $(OUT_NDK_DOCS)
ndk_headers := $(SOONG_OUT_DIR)/ndk/sysroot/usr/include
ndk_docs_src_dir := frameworks/native/docs
ndk_doxyfile := $(ndk_docs_src_dir)/Doxyfile
ifneq ($(wildcard $(ndk_docs_src_dir)),)
ndk_docs_srcs := $(addprefix $(ndk_docs_src_dir)/,\
$(call find-files-in-subdirs,$(ndk_docs_src_dir),"*",.))
$(ndk_doxygen_out)/index.html: $(ndk_docs_srcs) $(SOONG_OUT_DIR)/ndk.timestamp
@mkdir -p $(ndk_doxygen_out)
@echo "Generating NDK docs to $(ndk_doxygen_out)"
@( cat $(ndk_doxyfile); \
echo "INPUT=$(ndk_headers)"; \
echo "HTML_OUTPUT=$(ndk_doxygen_out)" \
) | doxygen -
$(call declare-1p-target,$(ndk_doxygen_out)/index.html,)
# Note: Not a part of the docs target because we don't have doxygen available.
# You can run this target locally if you have doxygen installed.
ndk-docs: $(ndk_doxygen_out)/index.html
.PHONY: ndk-docs
endif
INSTALLED_RECOVERYIMAGE_TARGET :=
# Build recovery image if
# BUILDING_RECOVERY_IMAGE && !BOARD_USES_RECOVERY_AS_BOOT && !BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT.
# If BOARD_USES_RECOVERY_AS_BOOT is true, leave empty because INSTALLED_BOOTIMAGE_TARGET is built
# with recovery resources.
# If BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is true, leave empty to build recovery resources
# but not the final recovery image.
ifdef BUILDING_RECOVERY_IMAGE
ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
ifneq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
INSTALLED_RECOVERYIMAGE_TARGET := $(PRODUCT_OUT)/recovery.img
endif
endif
endif
# Do this early because sysprop.mk depends on BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC.
ifeq (default,$(ENABLE_UFFD_GC))
BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC := $(OUT_DIR)/soong/dexpreopt/kernel_version_for_uffd_gc.txt
endif # ENABLE_UFFD_GC
include $(BUILD_SYSTEM)/sysprop.mk
# ----------------------------------------------------------------
# -----------------------------------------------------------------
# sdk-build.prop
#
# There are certain things in build.prop that we don't want to
# ship with the sdk; remove them.
# This must be a list of entire property keys followed by
# "=" characters, without any internal spaces.
sdk_build_prop_remove := \
ro.build.user= \
ro.build.host= \
ro.product.brand= \
ro.product.manufacturer= \
ro.product.device=
# TODO: Remove this soon-to-be obsolete property
sdk_build_prop_remove += ro.build.product=
INSTALLED_SDK_BUILD_PROP_TARGET := $(PRODUCT_OUT)/sdk/sdk-build.prop
$(INSTALLED_SDK_BUILD_PROP_TARGET): $(INSTALLED_BUILD_PROP_TARGET)
@echo SDK buildinfo: $@
@mkdir -p $(dir $@)
$(hide) grep -v "$(subst $(space),\|,$(strip \
$(sdk_build_prop_remove)))" $< > $@.tmp
$(hide) for x in $(strip $(sdk_build_prop_remove)); do \
echo "$$x"generic >> $@.tmp; done
$(hide) mv $@.tmp $@
$(call declare-0p-target,$(INSTALLED_SDK_BUILD_PROP_TARGET))
# -----------------------------------------------------------------
# declare recovery ramdisk files
ifeq ($(BUILDING_RECOVERY_IMAGE),true)
INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP := $(call intermediates-dir-for,PACKAGING,recovery)/ramdisk_files-timestamp
endif
# -----------------------------------------------------------------
# Declare vendor ramdisk fragments
INTERNAL_VENDOR_RAMDISK_FRAGMENTS :=
ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
ifneq (,$(filter recovery,$(BOARD_VENDOR_RAMDISK_FRAGMENTS)))
$(error BOARD_VENDOR_RAMDISK_FRAGMENTS must not contain "recovery" if \
BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT is set)
endif
INTERNAL_VENDOR_RAMDISK_FRAGMENTS += recovery
VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR := $(TARGET_RECOVERY_ROOT_OUT)
VENDOR_RAMDISK_FRAGMENT.recovery.FILES := $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
BOARD_VENDOR_RAMDISK_FRAGMENT.recovery.MKBOOTIMG_ARGS += --ramdisk_type RECOVERY
.KATI_READONLY := VENDOR_RAMDISK_FRAGMENT.recovery.STAGING_DIR
endif
# Validation check and assign default --ramdisk_type.
$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
$(if $(and $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)), \
$(error Must not specify KERNEL_MODULE_DIRS for prebuilt vendor ramdisk fragment "$(vendor_ramdisk_fragment)": $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS))) \
$(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragment-stage-$(vendor_ramdisk_fragment))) \
$(eval VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES :=) \
$(if $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
$(if $(filter --ramdisk_type,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)),, \
$(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_type DLKM))) \
)
# Create the "kernel module directory" to "vendor ramdisk fragment" inverse mapping.
$(foreach vendor_ramdisk_fragment,$(BOARD_VENDOR_RAMDISK_FRAGMENTS), \
$(foreach kmd,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).KERNEL_MODULE_DIRS), \
$(eval kmd_vrf := KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd)) \
$(if $($(kmd_vrf)),$(error Kernel module directory "$(kmd)" belongs to multiple vendor ramdisk fragments: "$($(kmd_vrf))" "$(vendor_ramdisk_fragment)", each kernel module directory should belong to exactly one or none vendor ramdisk fragment)) \
$(eval $(kmd_vrf) := $(vendor_ramdisk_fragment)) \
) \
)
INTERNAL_VENDOR_RAMDISK_FRAGMENTS += $(BOARD_VENDOR_RAMDISK_FRAGMENTS)
ifneq ($(BOARD_KERNEL_MODULES_16K),)
INTERNAL_VENDOR_RAMDISK_FRAGMENTS += 16K
endif
# Strip the list in case of any whitespace.
INTERNAL_VENDOR_RAMDISK_FRAGMENTS := \
$(strip $(INTERNAL_VENDOR_RAMDISK_FRAGMENTS))
# Assign --ramdisk_name for each vendor ramdisk fragment.
$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
$(if $(filter --ramdisk_name,$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)), \
$(error Must not specify --ramdisk_name for vendor ramdisk fragment: $(vendor_ramdisk_fragment))) \
$(eval BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS += --ramdisk_name $(vendor_ramdisk_fragment)) \
$(eval .KATI_READONLY := BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) \
)
# -----------------------------------------------------------------
# kernel modules
# Depmod requires a well-formed kernel version so 0.0 is used as a placeholder.
DEPMOD_STAGING_SUBDIR :=$= lib/modules/0.0
define copy-and-strip-kernel-module
$(2): $(1)
$(LLVM_STRIP) -o $(2) --strip-debug $(1)
endef
# $(1): modules list
# $(2): output dir
# $(3): mount point
# $(4): staging dir
# $(5): module load list
# $(6): module load list filename
# $(7): module archive
# $(8): staging dir for stripped modules
# $(9): module directory name
# $(10): extra modules that might be dependency of modules in this partition, but should not be copied to output dir
# $(11): mount point for extra modules
# Returns a list of src:dest pairs to install the modules using copy-many-files.
define build-image-kernel-modules
$(if $(9), \
$(eval _dir := $(9)/), \
$(eval _dir :=)) \
$(foreach module,$(1), \
$(eval _src := $(module)) \
$(if $(8), \
$(eval _src := $(8)/$(notdir $(module))) \
$(eval $(call copy-and-strip-kernel-module,$(module),$(_src)))) \
$(_src):$(2)/lib/modules/$(_dir)$(notdir $(module))) \
$(eval $(call build-image-kernel-modules-depmod,$(1),$(3),$(4),$(5),$(6),$(7),$(2),$(9),$(10),$(11))) \
$(4)/$(DEPMOD_STAGING_SUBDIR)/modules.dep:$(2)/lib/modules/$(_dir)modules.dep \
$(4)/$(DEPMOD_STAGING_SUBDIR)/modules.alias:$(2)/lib/modules/$(_dir)modules.alias \
$(4)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep:$(2)/lib/modules/$(_dir)modules.softdep \
$(4)/$(DEPMOD_STAGING_SUBDIR)/$(6):$(2)/lib/modules/$(_dir)$(6)
endef
# $(1): modules list
# $(2): mount point
# $(3): staging dir
# $(4): module load list
# $(5): module load list filename
# $(6): module archive
# $(7): output dir
# $(8): module directory name
# $(9): extra modules which should not be copied to output dir, but might be dependency of modules in this partition
# $(10): mount point for extra modules
# TODO(b/144844424): If a module archive is being used, this step (which
# generates obj/PACKAGING/.../modules.dep) also unzips the module archive into
# the output directory. This should be moved to a module with a
# LOCAL_POST_INSTALL_CMD so that if modules.dep is removed from the output dir,
# the archive modules are restored along with modules.dep.
define build-image-kernel-modules-depmod
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: .KATI_IMPLICIT_OUTPUTS := $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.alias $(3)/$(DEPMOD_STAGING_SUBDIR)/modules.softdep $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(DEPMOD)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULES := $(strip $(1))
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MODULES := $(strip $(9))
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MOUNT_POINT := $(2)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MOUNT_POINT := $(10)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules/$(8)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_EXTRA_MODULE_DIR := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(10)/lib/modules/$(8)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_STAGING_DIR := $(3)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_MODULES := $(strip $(4))
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_LOAD_FILE := $(3)/$(DEPMOD_STAGING_SUBDIR)/$(5)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_MODULE_ARCHIVE := $(6)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: PRIVATE_OUTPUT_DIR := $(7)
$(3)/$(DEPMOD_STAGING_SUBDIR)/modules.dep: $(1) $(6)
@echo depmod $$(PRIVATE_STAGING_DIR)
rm -rf $$(PRIVATE_STAGING_DIR)
mkdir -p $$(PRIVATE_MODULE_DIR)
$(if $(6),\
unzip -qoDD -d $$(PRIVATE_MODULE_DIR) $$(PRIVATE_MODULE_ARCHIVE); \
mkdir -p $$(PRIVATE_OUTPUT_DIR)/lib; \
cp -r $(3)/$(DEPMOD_STAGING_SUBDIR)/$(2)/lib/modules $$(PRIVATE_OUTPUT_DIR)/lib/; \
find $$(PRIVATE_MODULE_DIR) -type f -name '*.ko' | xargs basename -a > $$(PRIVATE_LOAD_FILE); \
)
$(if $(1),\
cp $$(PRIVATE_MODULES) $$(PRIVATE_MODULE_DIR)/; \
if [ -n "$$(PRIVATE_LOAD_MODULES)" ]; then basename -a $$(PRIVATE_LOAD_MODULES); fi > $$(PRIVATE_LOAD_FILE); \
)
# The ln -sf + find -delete sequence is to remove any modules in
# PRIVATE_EXTRA_MODULES which have same basename as MODULES in PRIVATE_MODULES
# Basically, it computes a set difference. When there is a duplicate module
# present in both directories, we want modules in PRIVATE_MODULES to take
# precedence. Since depmod does not provide any guarantee about ordering of
# dependency resolution, we achieve this by maually removing any duplicate
# modules with lower priority.
$(if $(9),\
mkdir -p $$(PRIVATE_EXTRA_MODULE_DIR); \
find $$(PRIVATE_EXTRA_MODULE_DIR) -maxdepth 1 -type f -name "*.ko" -delete; \
cp $$(PRIVATE_EXTRA_MODULES) $$(PRIVATE_EXTRA_MODULE_DIR); \
ln -sf $$(PRIVATE_MODULE_DIR)/*.ko $$(PRIVATE_EXTRA_MODULE_DIR); \
find $$(PRIVATE_EXTRA_MODULE_DIR) -type l -delete; \
)
$(DEPMOD) -b $$(PRIVATE_STAGING_DIR) 0.0
# Turn paths in modules.dep into absolute paths
sed -i.tmp -e 's|\([^: ]*lib/modules/[^: ]*\)|/\1|g' $$(PRIVATE_STAGING_DIR)/$$(DEPMOD_STAGING_SUBDIR)/modules.dep
touch $$(PRIVATE_LOAD_FILE)
endef
# $(1): staging dir
# $(2): modules list
# $(3): module load list
# $(4): module load list filename
# $(5): output dir
define module-load-list-copy-paths
$(eval $(call build-image-module-load-list,$(1),$(2),$(3),$(4))) \
$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4):$(5)/lib/modules/$(4)
endef
# $(1): staging dir
# $(2): modules list
# $(3): module load list
# $(4): module load list filename
define build-image-module-load-list
$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): PRIVATE_LOAD_MODULES := $(3)
$(1)/$(DEPMOD_STAGING_SUBDIR)/$(4): $(2)
@echo load-list $$(@)
@echo '$$(strip $$(notdir $$(PRIVATE_LOAD_MODULES)))' | tr ' ' '\n' > $$(@)
endef
# $(1): source options file
# $(2): destination pathname
# Returns a build rule that checks the syntax of and installs a kernel modules
# options file. Strip and squeeze any extra space and blank lines.
# For use via $(eval).
define build-image-kernel-modules-options-file
$(2): $(1)
@echo "libmodprobe options $$(@)"
$(hide) mkdir -p "$$(dir $$@)"
$(hide) rm -f "$$@"
$(hide) awk <"$$<" >"$$@" \
'/^#/ { print; next } \
NF == 0 { next } \
NF < 2 || $$$$1 != "options" \
{ print "Invalid options line " FNR ": " $$$$0 >"/dev/stderr"; \
exit_status = 1; next } \
{ $$$$1 = $$$$1; print } \
END { exit exit_status }'
endef
# $(1): source blocklist file
# $(2): destination pathname
# Returns a build rule that checks the syntax of and installs a kernel modules
# blocklist file. Strip and squeeze any extra space and blank lines.
# For use via $(eval).
define build-image-kernel-modules-blocklist-file
$(2): $(1)
@echo "libmodprobe blocklist $$(@)"
$(hide) mkdir -p "$$(dir $$@)"
$(hide) rm -f "$$@"
$(hide) awk <"$$<" >"$$@" \
'/^#/ { print; next } \
NF == 0 { next } \
NF != 2 || $$$$1 != "blocklist" \
{ print "Invalid blocklist line " FNR ": " $$$$0 >"/dev/stderr"; \
exit_status = 1; next } \
{ $$$$1 = $$$$1; print } \
END { exit exit_status }'
endef
# $(1): image name
# $(2): build output directory (TARGET_OUT_VENDOR, TARGET_RECOVERY_ROOT_OUT, etc)
# $(3): mount point
# $(4): module load filename
# $(5): stripped staging directory
# $(6): kernel module directory name (top is an out of band value for no directory)
# $(7): list of extra modules that might be dependency of modules in this partition
# $(8): mount point for extra modules. e.g. system
define build-image-kernel-modules-dir
$(if $(filter top,$(6)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(6))$(eval _sep :=_))\
$(if $(5),\
$(eval _stripped_staging_dir := $(5)$(_sep)$(_kver)),\
$(eval _stripped_staging_dir :=))\
$(if $(strip $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver))$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver))),\
$(if $(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),,\
$(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)))) \
$(if $(filter false,$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver))),\
$(eval BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver) :=),) \
$(eval _files := $(call build-image-kernel-modules,$(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)),$(2),$(3),$(call intermediates-dir-for,PACKAGING,depmod_$(1)$(_sep)$(_kver)),$(BOARD_$(1)_KERNEL_MODULES_LOAD$(_sep)$(_kver)),$(4),$(BOARD_$(1)_KERNEL_MODULES_ARCHIVE$(_sep)$(_kver)),$(_stripped_staging_dir),$(_kver),$(7),$(8))) \
$(call copy-many-files,$(_files)) \
$(eval _modules := $(BOARD_$(1)_KERNEL_MODULES$(_sep)$(_kver)) ANDROID-GEN ANDROID-GEN ANDROID-GEN ANDROID-GEN) \
$(eval KERNEL_MODULE_COPY_FILES += $(join $(addsuffix :,$(_modules)),$(_files)))) \
$(if $(_kver), \
$(eval _dir := $(_kver)/), \
$(eval _dir :=)) \
$(if $(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
$(eval $(call build-image-kernel-modules-options-file, \
$(BOARD_$(1)_KERNEL_MODULES_OPTIONS_FILE$(_sep)$(_kver)), \
$(2)/lib/modules/$(_dir)modules.options)) \
$(2)/lib/modules/$(_dir)modules.options) \
$(if $(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
$(eval $(call build-image-kernel-modules-blocklist-file, \
$(BOARD_$(1)_KERNEL_MODULES_BLOCKLIST_FILE$(_sep)$(_kver)), \
$(2)/lib/modules/$(_dir)modules.blocklist)) \
$(eval ALL_KERNEL_MODULES_BLOCKLIST += $(2)/lib/modules/$(_dir)modules.blocklist) \
$(2)/lib/modules/$(_dir)modules.blocklist)
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
define build-recovery-as-boot-load
$(if $(filter top,$(1)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(1))$(eval _sep :=_))\
$(if $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
$(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,ramdisk_module_list$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load,$(TARGET_RECOVERY_ROOT_OUT))))
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
define build-vendor-ramdisk-recovery-load
$(if $(filter top,$(1)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(1))$(eval _sep :=_))\
$(if $(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
$(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_RAMDISK_OUT))))
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
define build-vendor-kernel-ramdisk-recovery-load
$(if $(filter top,$(1)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(1))$(eval _sep :=_))\
$(if $(BOARD_VENDOR_KERNEL_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
$(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_kernel_ramdisk_recovery_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_KERNEL_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_KERNEL_RAMDISK_RECOVERY_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.recovery,$(TARGET_VENDOR_KERNEL_RAMDISK_OUT))))
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
define build-vendor-charger-load
$(if $(filter top,$(1)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(1))$(eval _sep :=_))\
$(if $(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
$(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_OUT_VENDOR))))
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
define build-vendor-ramdisk-charger-load
$(if $(filter top,$(1)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(1))$(eval _sep :=_))\
$(if $(BOARD_VENDOR_RAMDISK_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
$(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_ramdisk_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_RAMDISK_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_VENDOR_RAMDISK_OUT))))
endef
# $(1): kernel module directory name (top is an out of band value for no directory)
define build-vendor-kernel-ramdisk-charger-load
$(if $(filter top,$(1)),\
$(eval _kver :=)$(eval _sep :=),\
$(eval _kver := $(1))$(eval _sep :=_))\
$(if $(BOARD_VENDOR_KERNEL_RAMDISK_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),\
$(call copy-many-files,$(call module-load-list-copy-paths,$(call intermediates-dir-for,PACKAGING,vendor_kernel_ramdisk_charger_module_list$(_sep)$(_kver)),$(BOARD_VENDOR_KERNEL_RAMDISK_KERNEL_MODULES$(_sep)$(_kver)),$(BOARD_VENDOR_KERNEL_RAMDISK_CHARGER_KERNEL_MODULES_LOAD$(_sep)$(_kver)),modules.load.charger,$(TARGET_VENDOR_KERNEL_RAMDISK_OUT))))
endef
ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
# If there is no vendor boot partition, store vendor ramdisk kernel modules in the
# boot ramdisk.
BOARD_GENERIC_RAMDISK_KERNEL_MODULES += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES)
BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD += $(BOARD_VENDOR_RAMDISK_KERNEL_MODULES_LOAD)
endif
ifeq ($(BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD),)
BOARD_GENERIC_RAMDISK_KERNEL_MODULES_LOAD := $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
endif
ifneq ($(strip $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)),)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT), true)
BOARD_RECOVERY_KERNEL_MODULES += $(BOARD_GENERIC_RAMDISK_KERNEL_MODULES)
endif
endif
ifneq ($(BOARD_DO_NOT_STRIP_GENERIC_RAMDISK_MODULES),true)
GENERIC_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_generic_ramdisk_kernel_stripped)
else
GENERIC_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
endif
ifneq ($(BOARD_DO_NOT_STRIP_RECOVERY_MODULES),true)
RECOVERY_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_recovery_stripped)
else
RECOVERY_STRIPPED_MODULE_STAGING_DIR :=
endif
ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_MODULES),true)
VENDOR_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_stripped)
else
VENDOR_STRIPPED_MODULE_STAGING_DIR :=
endif
ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_RAMDISK_MODULES),true)
VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_ramdisk_stripped)
else
VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
endif
ifneq ($(BOARD_DO_NOT_STRIP_VENDOR_KERNEL_RAMDISK_MODULES),true)
VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_vendor_kernel_ramdisk_stripped)
else
VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR :=
endif
BOARD_KERNEL_MODULE_DIRS += top
# Default to not generating modules.load for kernel modules on system
# side. We should only load these modules if they are depended by vendor
# side modules.
ifeq ($(BOARD_SYSTEM_KERNEL_MODULES_LOAD),)
BOARD_SYSTEM_KERNEL_MODULES_LOAD := false
endif
$(foreach kmd,$(BOARD_KERNEL_MODULE_DIRS), \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,RECOVERY,$(TARGET_RECOVERY_ROOT_OUT),,modules.load.recovery,$(RECOVERY_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
$(eval vendor_ramdisk_fragment := $(KERNEL_MODULE_DIR_VENDOR_RAMDISK_FRAGMENT_$(kmd))) \
$(if $(vendor_ramdisk_fragment), \
$(eval output_dir := $(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR)) \
$(eval result_var := VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).FILES) \
$(eval ### else ###), \
$(eval output_dir := $(TARGET_VENDOR_RAMDISK_OUT)) \
$(eval result_var := ALL_DEFAULT_INSTALLED_MODULES)) \
$(eval $(result_var) += $(call build-image-kernel-modules-dir,VENDOR_RAMDISK,$(output_dir),,modules.load,$(VENDOR_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR_KERNEL_RAMDISK,$(TARGET_VENDOR_KERNEL_RAMDISK_OUT),,modules.load,$(VENDOR_KERNEL_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-recovery-load,$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-kernel-ramdisk-recovery-load,$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,VENDOR,$(if $(filter true,$(BOARD_USES_VENDOR_DLKMIMAGE)),$(TARGET_OUT_VENDOR_DLKM),$(TARGET_OUT_VENDOR)),vendor,modules.load,$(VENDOR_STRIPPED_MODULE_STAGING_DIR),$(kmd),$(BOARD_SYSTEM_KERNEL_MODULES),system)) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-charger-load,$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-ramdisk-charger-load,$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-vendor-kernel-ramdisk-charger-load,$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,ODM,$(if $(filter true,$(BOARD_USES_ODM_DLKMIMAGE)),$(TARGET_OUT_ODM_DLKM),$(TARGET_OUT_ODM)),odm,modules.load,,$(kmd))) \
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,SYSTEM,$(if $(filter true,$(BOARD_USES_SYSTEM_DLKMIMAGE)),$(TARGET_OUT_SYSTEM_DLKM),$(TARGET_OUT)),system,modules.load,,$(kmd))) \
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-recovery-as-boot-load,$(kmd))),\
$(eval ALL_DEFAULT_INSTALLED_MODULES += $(call build-image-kernel-modules-dir,GENERIC_RAMDISK,$(TARGET_RAMDISK_OUT),,modules.load,$(GENERIC_RAMDISK_STRIPPED_MODULE_STAGING_DIR),$(kmd)))))
ifeq ($(BOARD_SYSTEM_KERNEL_MODULES),)
ifneq ($(BOARD_SYSTEM_DLKM_SRC),)
ifneq ($(wildcard $(BOARD_SYSTEM_DLKM_SRC)/*),)
SYSTEM_KERNEL_MODULES := $(shell find $(BOARD_SYSTEM_DLKM_SRC) -type f)
SRC_SYSTEM_KERNEL_MODULES := $(SYSTEM_KERNEL_MODULES)
DST_SYSTEM_KERNEL_MODULES := $(patsubst $(BOARD_SYSTEM_DLKM_SRC)/%,:$(TARGET_OUT_SYSTEM_DLKM)/%,$(SRC_SYSTEM_KERNEL_MODULES))
SYSTEM_KERNEL_MODULE_COPY_PAIRS := $(join $(SRC_SYSTEM_KERNEL_MODULES),$(DST_SYSTEM_KERNEL_MODULES))
ALL_DEFAULT_INSTALLED_MODULES += $(call copy-many-files,$(SYSTEM_KERNEL_MODULE_COPY_PAIRS))
endif
endif
endif
# -----------------------------------------------------------------
# Cert-to-package mapping. Used by the post-build signing tools.
# Use a macro to add newline to each echo command
# $1 stem name of the package
# $2 certificate
# $3 private key
# $4 compressed
# $5 partition tag
# $6 output file
define _apkcerts_write_line
$(hide) echo 'name="$(1).apk" certificate="$2" private_key="$3"$(if $(4), compressed="$4")$(if $(5), partition="$5")' >> $6
endef
# -----------------------------------------------------------------
# Merge an individual apkcerts output into the final apkcerts.txt output.
# Use a macro to make it compatible with _apkcerts_write_line
# $1 apkcerts file to be merged
# $2 output file
define _apkcerts_merge
$(hide) cat $1 >> $2
endef
name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
name := $(name)-apkcerts
intermediates := \
$(call intermediates-dir-for,PACKAGING,apkcerts)
APKCERTS_FILE := $(intermediates)/$(name).txt
ifeq ($(RELEASE_APKCERTS_INSTALL_ONLY), true)
all_apkcerts_packages := $(filter $(call product-installed-modules,$(INTERNAL_PRODUCT)),$(PACKAGES))
else
all_apkcerts_packages := $(PACKAGES)
endif
all_apkcerts_files := $(sort $(foreach p,$(all_apkcerts_packages),$(PACKAGES.$(p).APKCERTS_FILE)))
$(APKCERTS_FILE): $(all_apkcerts_files)
# We don't need to really build all the modules.
# TODO: rebuild APKCERTS_FILE if any app change its cert.
$(APKCERTS_FILE):
@echo APK certs list: $@
@mkdir -p $(dir $@)
@rm -f $@
$(foreach p,$(sort $(all_apkcerts_packages)),\
$(if $(PACKAGES.$(p).APKCERTS_FILE),\
$(call _apkcerts_merge,$(PACKAGES.$(p).APKCERTS_FILE), $@),\
$(if $(PACKAGES.$(p).EXTERNAL_KEY),\
$(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),EXTERNAL,,$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@),\
$(call _apkcerts_write_line,$(PACKAGES.$(p).STEM),$(PACKAGES.$(p).CERTIFICATE),$(PACKAGES.$(p).PRIVATE_KEY),$(PACKAGES.$(p).COMPRESSED),$(PACKAGES.$(p).PARTITION),$@))))
$(if $(filter true,$(PRODUCT_FSVERITY_GENERATE_METADATA)),\
$(call _apkcerts_write_line,BuildManifest,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system,$@) \
$(if $(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),\
$(call _apkcerts_write_line,BuildManifestSystemExt,$(FSVERITY_APK_KEY_PATH).x509.pem,$(FSVERITY_APK_KEY_PATH).pk8,,system_ext,$@)))
# In case value of PACKAGES is empty.
$(hide) touch $@ && sort -u -o $@ $@
$(call declare-0p-target,$(APKCERTS_FILE))
.PHONY: apkcerts-list
apkcerts-list: $(APKCERTS_FILE)
intermediates := $(call intermediates-dir-for,PACKAGING,apexkeys)
APEX_KEYS_FILE := $(intermediates)/apexkeys.txt
all_apex_keys_files := $(sort $(foreach m,$(call product-installed-modules,$(INTERNAL_PRODUCT)),$(ALL_MODULES.$(m).APEX_KEYS_FILE)))
$(APEX_KEYS_FILE): $(all_apex_keys_files)
@mkdir -p $(dir $@)
@rm -f $@
$(hide) touch $@
$(hide) $(foreach file,$^,cat $(file) >> $@ $(newline))
all_apex_keys_files :=
$(call declare-0p-target,$(APEX_KEYS_FILE))
.PHONY: apexkeys.txt
apexkeys.txt: $(APEX_KEYS_FILE)
ifneq (,$(TARGET_BUILD_APPS))
$(call dist-for-goals, apps_only, $(APKCERTS_FILE):apkcerts.txt)
$(call dist-for-goals, apps_only, $(APEX_KEYS_FILE):apexkeys.txt)
endif
# -----------------------------------------------------------------
# build /product/etc/security/avb/system_other.avbpubkey if needed
ifdef BUILDING_SYSTEM_OTHER_IMAGE
ifeq ($(BOARD_AVB_ENABLE),true)
INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET := $(TARGET_OUT_PRODUCT_ETC)/security/avb/system_other.avbpubkey
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET)
endif # BOARD_AVB_ENABLE
endif # BUILDING_SYSTEM_OTHER_IMAGE
# -----------------------------------------------------------------
# Modules ready to be converted to Soong, ordered by how many
# modules depend on them.
SOONG_CONV := $(sort $(SOONG_CONV))
SOONG_CONV_DATA := $(call intermediates-dir-for,PACKAGING,soong_conversion)/soong_conv_data
$(SOONG_CONV_DATA):
@rm -f $@
@touch $@ # This file must be present even if SOONG_CONV is empty.
@$(foreach s,$(SOONG_CONV),echo "$(s),$(SOONG_CONV.$(s).TYPE),$(sort $(SOONG_CONV.$(s).PROBLEMS)),$(sort $(filter-out $(SOONG_ALREADY_CONV),$(SOONG_CONV.$(s).DEPS))),$(sort $(SOONG_CONV.$(s).MAKEFILES)),$(sort $(SOONG_CONV.$(s).INSTALLED))" >>$@;)
$(call declare-1p-target,$(SOONG_CONV_DATA),build)
SOONG_TO_CONVERT_SCRIPT := build/make/tools/soong_to_convert.py
SOONG_TO_CONVERT := $(PRODUCT_OUT)/soong_to_convert.txt
$(SOONG_TO_CONVERT): $(SOONG_CONV_DATA) $(SOONG_TO_CONVERT_SCRIPT)
@rm -f $@
$(hide) $(SOONG_TO_CONVERT_SCRIPT) $< >$@
$(call declare-1p-target,$(SOONG_TO_CONVERT),build)
$(call dist-for-goals,droidcore-unbundled,$(SOONG_TO_CONVERT))
MK2BP_CATALOG_SCRIPT := build/make/tools/mk2bp_catalog.py
PRODUCT_PACKAGES_TXT := $(PRODUCT_OUT)/product_packages.txt
MK2BP_REMAINING_HTML := $(PRODUCT_OUT)/mk2bp_remaining.html
$(MK2BP_REMAINING_HTML): PRIVATE_CODE_SEARCH_BASE_URL := "https://cs.android.com/android/platform/superproject/+/master:"
$(MK2BP_REMAINING_HTML): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
@rm -f $@
$(hide) $(MK2BP_CATALOG_SCRIPT) \
--device=$(TARGET_DEVICE) \
--product-packages=$(PRODUCT_PACKAGES_TXT) \
--title="Remaining Android.mk files for $(TARGET_DEVICE)-$(TARGET_BUILD_VARIANT)" \
--codesearch=$(PRIVATE_CODE_SEARCH_BASE_URL) \
--out-dir="$(OUT_DIR)" \
--mode=html \
> $@
$(call declare-1p-target,$(MK2BP_REMAINING_HTML),build)
$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_HTML))
MK2BP_REMAINING_CSV := $(PRODUCT_OUT)/mk2bp_remaining.csv
$(MK2BP_REMAINING_CSV): $(SOONG_CONV_DATA) $(MK2BP_CATALOG_SCRIPT) $(PRODUCT_PACKAGES_TXT)
@rm -f $@
$(hide) $(MK2BP_CATALOG_SCRIPT) \
--device=$(TARGET_DEVICE) \
--product-packages=$(PRODUCT_PACKAGES_TXT) \
--out-dir="$(OUT_DIR)" \
--mode=csv \
> $@
$(call declare-1p-target,$(MK2BP_REMAINING_CSV))
$(call dist-for-goals,droidcore-unbundled,$(MK2BP_REMAINING_CSV))
.PHONY: mk2bp_remaining
mk2bp_remaining: $(MK2BP_REMAINING_HTML) $(MK2BP_REMAINING_CSV)
# -----------------------------------------------------------------
# Modules use -Wno-error, or added default -Wall -Werror
WALL_WERROR := $(PRODUCT_OUT)/wall_werror.txt
$(WALL_WERROR):
@rm -f $@
echo "# Modules using -Wno-error" >> $@
for m in $(sort $(SOONG_MODULES_USING_WNO_ERROR) $(MODULES_USING_WNO_ERROR)); do echo $$m >> $@; done
echo "# Modules that allow warnings" >> $@
for m in $(sort $(SOONG_MODULES_WARNINGS_ALLOWED) $(MODULES_WARNINGS_ALLOWED)); do echo $$m >> $@; done
$(call declare-0p-target,$(WALL_WERROR))
$(call dist-for-goals,droidcore-unbundled,$(WALL_WERROR))
CERTIFICATE_VIOLATION_MODULES_FILENAME := $(PRODUCT_OUT)/certificate_violation_modules.txt
$(CERTIFICATE_VIOLATION_MODULES_FILENAME):
rm -f $@
$(foreach m,$(sort $(CERTIFICATE_VIOLATION_MODULES)), echo $(m) >> $@;)
$(call declare-0p-target,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
$(call dist-for-goals,droidcore,$(CERTIFICATE_VIOLATION_MODULES_FILENAME))
# -----------------------------------------------------------------
# The dev key is used to sign this package, and as the key required
# for future OTA packages installed by this system. Actual product
# deliverables will be re-signed by hand. We expect this file to
# exist with the suffixes ".x509.pem" and ".pk8".
DEFAULT_KEY_CERT_PAIR := $(strip $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
# Rules that need to be present for the all targets, even
# if they don't do anything.
.PHONY: systemimage
systemimage:
# -----------------------------------------------------------------
event_log_tags_file := $(TARGET_OUT)/etc/event-log-tags
# Include tags from all packages that we know about
all_event_log_tags_src := \
$(sort $(foreach m, $(ALL_MODULES), $(ALL_MODULES.$(m).EVENT_LOG_TAGS)))
# Include tags from all packages included in this product, plus all
# tags that are part of the system (ie, not in a vendor/ or device/
# directory).
event_log_tags_src := \
$(sort $(foreach m,\
$(call resolve-bitness-for-modules,TARGET,$(PRODUCT_PACKAGES)) \
$(call module-names-for-tag-list,user), \
$(ALL_MODULES.$(m).EVENT_LOG_TAGS)) \
$(filter-out vendor/% device/% out/%,$(all_event_log_tags_src)))
$(event_log_tags_file): PRIVATE_SRC_FILES := $(event_log_tags_src)
$(event_log_tags_file): $(event_log_tags_src) $(MERGETAGS)
$(hide) mkdir -p $(dir $@)
$(hide) $(MERGETAGS) -o $@ $(PRIVATE_SRC_FILES)
$(eval $(call declare-0p-target,$(event_log_tags_file)))
.PHONY: event-log-tags
event-log-tags: $(event_log_tags_file)
ALL_DEFAULT_INSTALLED_MODULES += $(event_log_tags_file)
# Initialize INSTALLED_FILES_OUTSIDE_IMAGES with the list of all device files,
# files installed in images will be filtered out later.
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out \
$(PRODUCT_OUT)/apex/% \
$(PRODUCT_OUT)/fake_packages/% \
$(PRODUCT_OUT)/testcases/%, \
$(filter $(PRODUCT_OUT)/%,$(ALL_DEFAULT_INSTALLED_MODULES)))
# #################################################################
# Targets for boot/OS images
# #################################################################
ifneq ($(strip $(TARGET_NO_BOOTLOADER)),true)
INSTALLED_BOOTLOADER_MODULE := $(PRODUCT_OUT)/bootloader
ifdef BOARD_PREBUILT_BOOTLOADER
$(eval $(call copy-one-file,$(BOARD_PREBUILT_BOOTLOADER),$(INSTALLED_BOOTLOADER_MODULE)))
$(call dist-for-goals,dist_files,$(INSTALLED_BOOTLOADER_MODULE))
endif # BOARD_PREBUILT_BOOTLOADER
ifeq ($(strip $(TARGET_BOOTLOADER_IS_2ND)),true)
INSTALLED_2NDBOOTLOADER_TARGET := $(PRODUCT_OUT)/2ndbootloader
else
INSTALLED_2NDBOOTLOADER_TARGET :=
endif
else
INSTALLED_BOOTLOADER_MODULE :=
INSTALLED_2NDBOOTLOADER_TARGET :=
endif # TARGET_NO_BOOTLOADER
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
INSTALLED_KERNEL_TARGET := $(foreach k,$(BOARD_KERNEL_BINARIES), \
$(PRODUCT_OUT)/$(k))
else
INSTALLED_KERNEL_TARGET := $(PRODUCT_OUT)/kernel
endif
else
INSTALLED_KERNEL_TARGET :=
endif
# -----------------------------------------------------------------
# the root dir
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_ROOT_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
INTERNAL_ROOT_FILES := $(filter $(TARGET_ROOT_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_ROOT := $(PRODUCT_OUT)/installed-files-root.txt
INSTALLED_FILES_JSON_ROOT := $(INSTALLED_FILES_FILE_ROOT:.txt=.json)
$(INSTALLED_FILES_FILE_ROOT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ROOT)
$(INSTALLED_FILES_FILE_ROOT) : $(INTERNAL_ROOT_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(TARGET_ROOT_OUT)
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_ROOT_OUT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_ROOT))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_ROOT))
#------------------------------------------------------------------
# dtb
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
INSTALLED_DTBIMAGE_TARGET := $(PRODUCT_OUT)/dtb.img
ifdef BOARD_PREBUILT_DTBIMAGE_DIR
$(INSTALLED_DTBIMAGE_TARGET) : $(sort $(wildcard $(BOARD_PREBUILT_DTBIMAGE_DIR)/*.dtb))
cat $^ > $@
endif
endif
# -----------------------------------------------------------------
# dtbo image
ifdef BOARD_PREBUILT_DTBOIMAGE
INSTALLED_DTBOIMAGE_TARGET := $(PRODUCT_OUT)/dtbo.img
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
cp $(BOARD_PREBUILT_DTBOIMAGE) $@
chmod +w $@
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
--partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_TARGET),$(BOARD_PREBUILT_DTBOIMAGE),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DTBOIMAGE_TARGET)
else
$(INSTALLED_DTBOIMAGE_TARGET): $(BOARD_PREBUILT_DTBOIMAGE)
cp $(BOARD_PREBUILT_DTBOIMAGE) $@
endif
endif # BOARD_PREBUILT_DTBOIMAGE
# -----------------------------------------------------------------
# -----------------------------------------------------------------
# the ramdisk
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_RAMDISK_IMAGE
INTERNAL_RAMDISK_FILES := $(filter $(TARGET_RAMDISK_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk.txt
INSTALLED_FILES_JSON_RAMDISK := $(INSTALLED_FILES_FILE_RAMDISK:.txt=.json)
$(INSTALLED_FILES_FILE_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RAMDISK)
$(INSTALLED_FILES_FILE_RAMDISK) : $(INTERNAL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(TARGET_RAMDISK_OUT)
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_RAMDISK_OUT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RAMDISK)))
$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RAMDISK)))
BUILT_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk.img
ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
# -l enables the legacy format used by the Linux kernel
COMPRESSION_COMMAND_DEPS := $(LZ4)
COMPRESSION_COMMAND := $(LZ4) -l -12 --favor-decSpeed
RAMDISK_EXT := .lz4
else
COMPRESSION_COMMAND_DEPS := $(GZIP)
COMPRESSION_COMMAND := $(GZIP)
RAMDISK_EXT := .gz
endif
ifneq ($(BOARD_KERNEL_MODULES_16K),)
TARGET_OUT_RAMDISK_16K := $(PRODUCT_OUT)/ramdisk_16k
BUILT_RAMDISK_16K_TARGET := $(PRODUCT_OUT)/ramdisk_16k.img
RAMDISK_16K_STAGING_DIR := $(call intermediates-dir-for,PACKAGING,depmod_ramdisk_16k)
ifneq ($(BOARD_SYSTEM_KERNEL_MODULES),)
SYSTEM_DLKM_MODULE_PATTERNS := $(foreach path,$(BOARD_SYSTEM_KERNEL_MODULES),%/$(notdir $(path)))
endif
# BOARD_KERNEL_MODULES_16K might contain duplicate modules under different path.
# for example, foo/bar/wifi.ko and foo/wifi.ko . To avoid build issues, de-dup
# module list on basename first.
BOARD_KERNEL_MODULES_16K := $(foreach \
pattern,\
$(sort $(foreach \
path,\
$(BOARD_KERNEL_MODULES_16K),\
%/$(notdir $(path)))\
),\
$(firstword $(filter $(pattern),$(BOARD_KERNEL_MODULES_16K))) \
)
# For non-GKI modules, strip them before install. As debug symbols take up
# significant space.
$(foreach \
file,\
$(filter-out $(SYSTEM_DLKM_MODULE_PATTERNS),$(BOARD_KERNEL_MODULES_16K)),\
$(eval \
$(call copy-and-strip-kernel-module,\
$(file),\
$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)) \
) \
) \
)
# For GKI modules, copy as-is without stripping, because stripping would
# remove the signature of kernel modules, and GKI modules must be signed
# for kernel to load them.
$(foreach \
file,\
$(filter $(SYSTEM_DLKM_MODULE_PATTERNS),$(BOARD_KERNEL_MODULES_16K)),\
$(eval \
$(call copy-one-file,\
$(file),\
$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)) \
) \
) \
)
BOARD_VENDOR_RAMDISK_FRAGMENT.16K.PREBUILT := $(BUILT_RAMDISK_16K_TARGET)
ifndef BOARD_KERNEL_MODULES_LOAD_16K
BOARD_KERNEL_MODULES_LOAD_16K := $(BOARD_KERNEL_MODULES_16K)
endif
$(BUILT_RAMDISK_16K_TARGET): $(DEPMOD) $(MKBOOTFS) $(EXTRACT_KERNEL) $(COMPRESSION_COMMAND_DEPS)
$(BUILT_RAMDISK_16K_TARGET): $(foreach file,$(BOARD_KERNEL_MODULES_16K),$(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/$(notdir $(file)))
$(DEPMOD) -b $(RAMDISK_16K_STAGING_DIR) 0.0
rm -f $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/modules.load
for MODULE in $(BOARD_KERNEL_MODULES_LOAD_16K); do \
basename $$MODULE >> $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0/modules.load ; \
done;
rm -rf $(TARGET_OUT_RAMDISK_16K)/lib/modules
mkdir -p $(TARGET_OUT_RAMDISK_16K)/lib/modules
KERNEL_RELEASE=`$(EXTRACT_KERNEL) --tools lz4:$(LZ4) --input $(BOARD_KERNEL_PATH_16K) --output-release` ;\
IS_16K_KERNEL=`$(EXTRACT_KERNEL) --tools lz4:$(LZ4) --input $(BOARD_KERNEL_PATH_16K) --output-config` ;\
if [[ "$$IS_16K_KERNEL" == *"CONFIG_ARM64_16K_PAGES=y"* ]]; then SUFFIX=_16k; fi ;\
cp -r $(RAMDISK_16K_STAGING_DIR)/lib/modules/0.0 $(TARGET_OUT_RAMDISK_16K)/lib/modules/$$KERNEL_RELEASE$$SUFFIX
$(MKBOOTFS) $(TARGET_OUT_RAMDISK_16K) | $(COMPRESSION_COMMAND) > $@
# Builds a ramdisk using modules defined in BOARD_KERNEL_MODULES_16K
ramdisk_16k: $(BUILT_RAMDISK_16K_TARGET)
.PHONY: ramdisk_16k
endif
# -----------------------------------------------------------------
# 16KB dtbo image
ifdef BOARD_PREBUILT_DTBOIMAGE_16KB
INSTALLED_DTBOIMAGE_16KB_TARGET := $(PRODUCT_OUT)/dtbo_16k.img
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_DTBOIMAGE_16KB_TARGET): $(BOARD_PREBUILT_DTBOIMAGE_16KB) $(AVBTOOL) $(BOARD_AVB_DTBO_KEY_PATH)
cp $(BOARD_PREBUILT_DTBOIMAGE_16KB) $@
chmod +w $@
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_DTBOIMG_PARTITION_SIZE)) \
--partition_name dtbo $(INTERNAL_AVB_DTBO_SIGNING_ARGS) \
$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)
$(call declare-1p-container,$(INSTALLED_DTBOIMAGE_16KB_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_DTBOIMAGE_16KB_TARGET),$(BOARD_PREBUILT_DTBOIMAGE_16KB),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_DTBOIMAGE_16KB_TARGET)
else
$(INSTALLED_DTBOIMAGE_16KB_TARGET): $(BOARD_PREBUILT_DTBOIMAGE_16KB)
cp $(BOARD_PREBUILT_DTBOIMAGE_16KB) $@
endif
endif # BOARD_PREBUILT_DTBOIMAGE_16KB
ramdisk_intermediates :=$= $(call intermediates-dir-for,PACKAGING,ramdisk)
$(eval $(call write-partition-file-list,$(ramdisk_intermediates)/file_list.txt,$(TARGET_RAMDISK_OUT),$(INTERNAL_RAMDISK_FILES)))
# The value of RAMDISK_NODE_LIST is defined in system/core/rootdir/Android.bp.
# This file contains /dev nodes description added to the generic ramdisk
# We just build this directly to the install location.
INSTALLED_RAMDISK_TARGET := $(BUILT_RAMDISK_TARGET)
$(INSTALLED_RAMDISK_TARGET): PRIVATE_DIRS := debug_ramdisk dev metadata mnt proc second_stage_resources sys
$(INSTALLED_RAMDISK_TARGET): $(MKBOOTFS) $(RAMDISK_NODE_LIST) $(INTERNAL_RAMDISK_FILES) $(INSTALLED_FILES_FILE_RAMDISK) | $(COMPRESSION_COMMAND_DEPS)
$(call pretty,"Target ramdisk: $@")
$(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/,$(PRIVATE_DIRS))
ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
$(hide) mkdir -p $(addprefix $(TARGET_RAMDISK_OUT)/first_stage_ramdisk/,$(PRIVATE_DIRS))
endif
$(hide) $(MKBOOTFS) -n $(RAMDISK_NODE_LIST) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
$(call declare-1p-container,$(INSTALLED_RAMDISK_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_RAMDISK_TARGET),$(INTERNAL_RAMDISK_FILE),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_RAMDISK_TARGET)
.PHONY: ramdisk-nodeps
ramdisk-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
@echo "make $@: ignoring dependencies"
$(hide) $(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $(INSTALLED_RAMDISK_TARGET)
endif # BUILDING_RAMDISK_IMAGE
# -----------------------------------------------------------------
# the boot image, which is a collection of other images.
# This is defined here since we may be building recovery as boot
# below and only want to define this once
ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
BUILT_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot,$(BOARD_KERNEL_BINARIES)), $(PRODUCT_OUT)/$(k).img)
else
BUILT_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
endif
INTERNAL_PREBUILT_BOOTIMAGE :=
my_installed_prebuilt_gki_apex := $(strip $(foreach package,$(PRODUCT_PACKAGES),$(if $(ALL_MODULES.$(package).EXTRACTED_BOOT_IMAGE),$(package))))
ifdef my_installed_prebuilt_gki_apex
ifneq (1,$(words $(my_installed_prebuilt_gki_apex))) # len(my_installed_prebuilt_gki_apex) > 1
$(error More than one prebuilt GKI APEXes are installed: $(my_installed_prebuilt_gki_apex))
endif # len(my_installed_prebuilt_gki_apex) > 1
ifdef BOARD_PREBUILT_BOOTIMAGE
$(error Must not define BOARD_PREBUILT_BOOTIMAGE because a prebuilt GKI APEX is installed: $(my_installed_prebuilt_gki_apex))
endif # BOARD_PREBUILT_BOOTIMAGE defined
my_apex_extracted_boot_image := $(ALL_MODULES.$(my_installed_prebuilt_gki_apex).EXTRACTED_BOOT_IMAGE)
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
$(eval $(call copy-one-file,$(my_apex_extracted_boot_image),$(INSTALLED_BOOTIMAGE_TARGET)))
$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
INTERNAL_PREBUILT_BOOTIMAGE := $(my_apex_extracted_boot_image)
else # my_installed_prebuilt_gki_apex not defined
# $1: boot image target
# returns the kernel used to make the bootimage
define bootimage-to-kernel
$(if $(BOARD_KERNEL_BINARIES),\
$(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $(1)))),\
$(INSTALLED_KERNEL_TARGET))
endef
ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
BOARD_KERNEL_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
endif
# $1: boot image file name
# $2: boot image variant (boot, boot-debug, boot-test-harness)
define get-bootimage-partition-size
$(BOARD_$(call to-upper,$(subst .img,,$(subst $(2),kernel,$(notdir $(1)))))_BOOTIMAGE_PARTITION_SIZE)
endef
# $1: partition size
define get-partition-size-argument
$(if $(1),--partition_size $(1),--dynamic_partition_size)
endef
# $1: output boot image target
# $2: input path to kernel binary
define build_boot_from_kernel_avb_enabled
$(eval kernel := $(2))
$(MKBOOTIMG) --kernel $(kernel) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot)))
$(AVBTOOL) add_hash_footer \
--image $(1) \
$(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) \
--salt `sha256sum "$(kernel)" | cut -d " " -f 1` \
--partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
endef
ifndef BOARD_PREBUILT_BOOTIMAGE
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
INTERNAL_BOOTIMAGE_ARGS := \
$(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
ifneq ($(BUILDING_INIT_BOOT_IMAGE),true)
INTERNAL_BOOTIMAGE_ARGS += --ramdisk $(INSTALLED_RAMDISK_TARGET)
endif
ifndef BUILDING_VENDOR_BOOT_IMAGE
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
INTERNAL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
endif
endif
INTERNAL_BOOTIMAGE_FILES := $(filter-out --%,$(INTERNAL_BOOTIMAGE_ARGS))
# kernel cmdline/base/pagesize in boot.
# - If using GKI, use GENERIC_KERNEL_CMDLINE. Remove kernel base and pagesize because they are
# device-specific.
# - If not using GKI:
# - If building vendor_boot, INTERNAL_KERNEL_CMDLINE, base and pagesize goes in vendor_boot.
# - Otherwise, put them in boot.
ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
ifdef GENERIC_KERNEL_CMDLINE
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(GENERIC_KERNEL_CMDLINE)"
endif
else ifndef BUILDING_VENDOR_BOOT_IMAGE # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_BOOTIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif
ifdef BOARD_KERNEL_BASE
INTERNAL_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
ifdef BOARD_KERNEL_PAGESIZE
INTERNAL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
endif # BUILDING_VENDOR_BOOT_IMAGE == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
INTERNAL_MKBOOTIMG_VERSION_ARGS := \
--os_version $(PLATFORM_VERSION_LAST_STABLE) \
--os_patch_level $(PLATFORM_SECURITY_PATCH)
# Define these only if we are building boot
ifdef BUILDING_BOOT_IMAGE
INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
ifeq ($(TARGET_BOOTIMAGE_USE_EXT2),true)
$(error TARGET_BOOTIMAGE_USE_EXT2 is not supported anymore)
endif # TARGET_BOOTIMAGE_USE_EXT2
$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
ifeq (true,$(BOARD_AVB_ENABLE))
# $1: boot image target
define build_boot_board_avb_enabled
$(eval kernel := $(call bootimage-to-kernel,$(1)))
$(call build_boot_from_kernel_avb_enabled,$(1),$(kernel))
endef
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH)
$(call pretty,"Target boot image: $@")
$(call build_boot_board_avb_enabled,$@)
$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
.PHONY: bootimage-nodeps
bootimage-nodeps: $(MKBOOTIMG) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
@echo "make $@: ignoring dependencies"
$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_board_avb_enabled,$(b)))
else # BOARD_AVB_ENABLE != true
# $1: boot image target
define build_boot_novboot
$(MKBOOTIMG) --kernel $(call bootimage-to-kernel,$(1)) $(INTERNAL_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_ARGS) --output $(1)
$(call assert-max-image-size,$1,$(call get-bootimage-partition-size,$(1),boot))
endef
$(INSTALLED_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_BOOTIMAGE_FILES)
$(call pretty,"Target boot image: $@")
$(call build_boot_novboot,$@)
$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_BOOTIMAGE_FILES),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
.PHONY: bootimage-nodeps
bootimage-nodeps: $(MKBOOTIMG)
@echo "make $@: ignoring dependencies"
$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(call build_boot_novboot,$(b)))
endif # BOARD_AVB_ENABLE
endif # BUILDING_BOOT_IMAGE
else # TARGET_NO_KERNEL == "true"
INSTALLED_BOOTIMAGE_TARGET :=
endif # TARGET_NO_KERNEL
else # BOARD_PREBUILT_BOOTIMAGE defined
INTERNAL_PREBUILT_BOOTIMAGE := $(BOARD_PREBUILT_BOOTIMAGE)
INSTALLED_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot.img
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_BOOTIMAGE_TARGET): PRIVATE_WORKING_DIR := $(call intermediates-dir-for,PACKAGING,prebuilt_bootimg)
$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH) $(UNPACK_BOOTIMG)
cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
$(UNPACK_BOOTIMG) --boot_img $(INTERNAL_PREBUILT_BOOTIMAGE) --out $(PRIVATE_WORKING_DIR)
chmod +w $@
$(AVBTOOL) add_hash_footer \
--image $@ \
--salt `sha256sum $(PRIVATE_WORKING_DIR)/kernel | cut -d " " -f 1` \
$(call get-partition-size-argument,$(BOARD_BOOTIMAGE_PARTITION_SIZE)) \
--partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",bool)
$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_BOOTIMAGE),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_BOOTIMAGE_TARGET)
else
$(INSTALLED_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_BOOTIMAGE)
cp $(INTERNAL_PREBUILT_BOOTIMAGE) $@
endif # BOARD_AVB_ENABLE
endif # BOARD_PREBUILT_BOOTIMAGE
endif # my_installed_prebuilt_gki_apex not defined
ifneq ($(BOARD_KERNEL_PATH_16K),)
BUILT_KERNEL_16K_TARGET := $(PRODUCT_OUT)/kernel_16k
$(eval $(call copy-one-file,$(BOARD_KERNEL_PATH_16K),$(BUILT_KERNEL_16K_TARGET)))
# Copies BOARD_KERNEL_PATH_16K to output directory as is
kernel_16k: $(BUILT_KERNEL_16K_TARGET)
.PHONY: kernel_16k
BUILT_BOOTIMAGE_16K_TARGET := $(PRODUCT_OUT)/boot_16k.img
BOARD_KERNEL_16K_BOOTIMAGE_PARTITION_SIZE := $(BOARD_BOOTIMAGE_PARTITION_SIZE)
$(BUILT_BOOTIMAGE_16K_TARGET): $(MKBOOTIMG) $(AVBTOOL) $(INTERNAL_BOOTIMAGE_FILES) $(BOARD_AVB_BOOT_KEY_PATH) $(BUILT_KERNEL_16K_TARGET)
$(call pretty,"Target boot 16k image: $@")
$(call build_boot_from_kernel_avb_enabled,$@,$(BUILT_KERNEL_16K_TARGET))
bootimage_16k: $(BUILT_BOOTIMAGE_16K_TARGET)
.PHONY: bootimage_16k
BUILT_BOOT_OTA_PACKAGE_16K := $(PRODUCT_OUT)/boot_ota_16k.zip
$(BUILT_BOOT_OTA_PACKAGE_16K): PRIVATE_BOOTIMAGE_TARGET := $(INSTALLED_BOOTIMAGE_TARGET)
$(BUILT_BOOT_OTA_PACKAGE_16K): PRIVATE_BOOTIMAGE_16KB_TARGET := $(BUILT_BOOTIMAGE_16K_TARGET)
$(BUILT_BOOT_OTA_PACKAGE_16K): $(OTA_FROM_RAW_IMG) \
$(DEFAULT_SYSTEM_DEV_CERTIFICATE).pk8 \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(BUILT_BOOTIMAGE_16K_TARGET) \
$(INSTALLED_DTBOIMAGE_16KB_TARGET) \
$(INSTALLED_DTBOIMAGE_TARGET)
$(OTA_FROM_RAW_IMG) --package_key $(DEFAULT_SYSTEM_DEV_CERTIFICATE) \
--max_timestamp `cat $(BUILD_DATETIME_FILE)` \
--path $(HOST_OUT) \
--partition_name $(if $(and $(INSTALLED_DTBOIMAGE_TARGET),\
$(INSTALLED_DTBOIMAGE_16KB_TARGET)),\
boot$(comma)dtbo,\
boot) \
--output $@ \
$(if $(BOARD_16K_OTA_USE_INCREMENTAL),\
$(PRIVATE_BOOTIMAGE_TARGET):$(PRIVATE_BOOTIMAGE_16KB_TARGET),\
$(PRIVATE_BOOTIMAGE_16KB_TARGET)\
)\
$(if $(and $(INSTALLED_DTBOIMAGE_TARGET),$(INSTALLED_DTBOIMAGE_16KB_TARGET)),\
$(INSTALLED_DTBOIMAGE_16KB_TARGET))
boototapackage_16k: $(BUILT_BOOT_OTA_PACKAGE_16K)
.PHONY: boototapackage_16k
BUILT_BOOT_OTA_PACKAGE_4K := $(PRODUCT_OUT)/boot_ota_4k.zip
$(BUILT_BOOT_OTA_PACKAGE_4K): $(OTA_FROM_RAW_IMG) \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(BUILT_BOOTIMAGE_16K_TARGET) \
$(DEFAULT_SYSTEM_DEV_CERTIFICATE).pk8 \
$(INSTALLED_DTBOIMAGE_TARGET) \
$(INSTALLED_DTBOIMAGE_16KB_TARGET)
$(OTA_FROM_RAW_IMG) --package_key $(DEFAULT_SYSTEM_DEV_CERTIFICATE) \
--max_timestamp `cat $(BUILD_DATETIME_FILE)` \
--path $(HOST_OUT) \
--partition_name $(if $(and $(INSTALLED_DTBOIMAGE_TARGET),\
$(INSTALLED_DTBOIMAGE_16KB_TARGET)),\
boot$(comma)dtbo,\
boot) \
--output $@ \
$(if $(BOARD_16K_OTA_USE_INCREMENTAL),\
$(BUILT_BOOTIMAGE_16K_TARGET):$(INSTALLED_BOOTIMAGE_TARGET),\
$(INSTALLED_BOOTIMAGE_TARGET)\
)\
$(if $(and $(INSTALLED_DTBOIMAGE_TARGET),$(INSTALLED_DTBOIMAGE_16KB_TARGET)),\
$(INSTALLED_DTBOIMAGE_TARGET))
boototapackage_4k: $(BUILT_BOOT_OTA_PACKAGE_4K)
.PHONY: boototapackage_4k
ifeq ($(BOARD_16K_OTA_MOVE_VENDOR),true)
$(eval $(call copy-one-file,$(BUILT_BOOT_OTA_PACKAGE_4K),$(TARGET_OUT_VENDOR)/boot_otas/boot_ota_4k.zip))
$(eval $(call copy-one-file,$(BUILT_BOOT_OTA_PACKAGE_16K),$(TARGET_OUT_VENDOR)/boot_otas/boot_ota_16k.zip))
ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_VENDOR)/boot_otas/boot_ota_4k.zip
ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT_VENDOR)/boot_otas/boot_ota_16k.zip
ifneq ($(BOARD_VENDOR_KERNEL_MODULES_2ND_STAGE_16KB_MODE),)
# Add the modules that need to be loaded in the Second Boot Stage
# to /vendor_dlkm/lib/modules/16k-mode
VENDOR_DLKM_16K_MODE_DIR := lib/modules/16k-mode
$(foreach module,$(BOARD_VENDOR_KERNEL_MODULES_2ND_STAGE_16KB_MODE), \
$(eval $(call copy-one-file,$(TARGET_KERNEL_DIR_16K)/$(module),\
$(TARGET_OUT_VENDOR_DLKM)/$(VENDOR_DLKM_16K_MODE_DIR)/$(module))))
ALL_DEFAULT_INSTALLED_MODULES += $(foreach module,$(BOARD_VENDOR_KERNEL_MODULES_2ND_STAGE_16KB_MODE),\
$(TARGET_OUT_VENDOR_DLKM)/$(VENDOR_DLKM_16K_MODE_DIR)/$(module))
endif # BOARD_VENDOR_KERNEL_MODULES_2ND_STAGE_16KB_MODE not empty
else
$(eval $(call copy-one-file,$(BUILT_BOOT_OTA_PACKAGE_4K),$(TARGET_OUT)/boot_otas/boot_ota_4k.zip))
$(eval $(call copy-one-file,$(BUILT_BOOT_OTA_PACKAGE_16K),$(TARGET_OUT)/boot_otas/boot_ota_16k.zip))
ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT)/boot_otas/boot_ota_4k.zip
ALL_DEFAULT_INSTALLED_MODULES += $(TARGET_OUT)/boot_otas/boot_ota_16k.zip
endif # BOARD_16K_OTA_MOVE_VENDOR == true
endif
my_apex_extracted_boot_image :=
my_installed_prebuilt_gki_apex :=
# -----------------------------------------------------------------
# init boot image
ifeq ($(BUILDING_INIT_BOOT_IMAGE),true)
INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_RAMDISK_TARGET)
INTERNAL_INIT_BOOT_IMAGE_ARGS := --ramdisk $(INSTALLED_RAMDISK_TARGET)
ifdef BOARD_KERNEL_PAGESIZE
INTERNAL_INIT_BOOT_IMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
$(call pretty,"Target init_boot image: $@")
$(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output "$@"
$(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
--salt $$(sha256sum $(BUILD_NUMBER_FILE) $(BUILD_DATETIME_FILE) | cut -d " " -f 1 | tr -d '\n') \
--partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_GENERIC_RAMDISK_BOOT_SIGNATURE),$(PRODUCT_OUT)/:/)
else
$(INSTALLED_INIT_BOOT_IMAGE_TARGET):
$(call pretty,"Target init_boot image: $@")
$(MKBOOTIMG) $(INTERNAL_INIT_BOOT_IMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) $(BOARD_MKBOOTIMG_INIT_ARGS) --output $@
$(call assert-max-image-size,$@,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE))
$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
endif
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
else # BUILDING_INIT_BOOT_IMAGE is not true
ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
INTERNAL_PREBUILT_INIT_BOOT_IMAGE := $(BOARD_PREBUILT_INIT_BOOT_IMAGE)
INSTALLED_INIT_BOOT_IMAGE_TARGET := $(PRODUCT_OUT)/init_boot.img
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $(AVBTOOL) $(BOARD_AVB_INIT_BOOT_KEY_PATH)
cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
chmod +w $@
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)) \
--partition_name init_boot $(INTERNAL_AVB_INIT_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)
$(call declare-1p-container,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),$(INTERNAL_PREBUILT_INIT_BOOT_IMAGE),$(PRODUCT_OUT)/:/)
else
$(INSTALLED_INIT_BOOT_IMAGE_TARGET): $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE)
cp $(INTERNAL_PREBUILT_INIT_BOOT_IMAGE) $@
$(call declare-1p-target,$(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
endif # BOARD_AVB_ENABLE
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_INIT_BOOT_IMAGE_TARGET)
else # BOARD_PREBUILT_INIT_BOOT_IMAGE not defined
INSTALLED_INIT_BOOT_IMAGE_TARGET :=
endif # BOARD_PREBUILT_INIT_BOOT_IMAGE
endif # BUILDING_INIT_BOOT_IMAGE is not true
# -----------------------------------------------------------------
# vendor boot image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
INTERNAL_VENDOR_RAMDISK_FILES := $(filter $(TARGET_VENDOR_RAMDISK_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
INTERNAL_VENDOR_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot)/vendor_ramdisk.cpio$(RAMDISK_EXT)
vendor_ramdisk_intermediates :=$= $(call intermediates-dir-for,PACKAGING,vendor_ramdisk)
$(eval $(call write-partition-file-list,$(vendor_ramdisk_intermediates)/file_list.txt,$(TARGET_VENDOR_RAMDISK_OUT),$(INTERNAL_VENDOR_RAMDISK_FILES)))
# Exclude recovery files in the default vendor ramdisk if including a standalone
# recovery ramdisk in vendor_boot.
ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
$(INTERNAL_VENDOR_RAMDISK_TARGET): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
$(INTERNAL_VENDOR_RAMDISK_TARGET): PRIVATE_ADDITIONAL_DIR := $(TARGET_RECOVERY_ROOT_OUT)
endif
endif
$(INTERNAL_VENDOR_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
$(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_RAMDISK_OUT) $(PRIVATE_ADDITIONAL_DIR) | $(COMPRESSION_COMMAND) > $@
INSTALLED_VENDOR_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk.img
$(INSTALLED_VENDOR_RAMDISK_TARGET): $(INTERNAL_VENDOR_RAMDISK_TARGET)
@echo "Target vendor ramdisk: $@"
$(copy-file-to-target)
$(call declare-1p-container,$(INSTALLED_VENDOR_RAMDISK_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_RAMDISK_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_RAMDISK_TARGET)
INSTALLED_FILES_FILE_VENDOR_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk.txt
INSTALLED_FILES_JSON_VENDOR_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_RAMDISK:.txt=.json)
$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_RAMDISK)
$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_TARGET)
$(INSTALLED_FILES_FILE_VENDOR_RAMDISK): $(INTERNAL_VENDOR_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_VENDOR_RAMDISK_OUT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_RAMDISK)))
$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_RAMDISK)))
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
# If we have vendor_kernel_boot partition, we migrate dtb image to that image
# and allow dtb in vendor_boot to be empty.
INTERNAL_VENDOR_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
endif
endif
ifdef BOARD_KERNEL_BASE
INTERNAL_VENDOR_BOOTIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
ifdef BOARD_KERNEL_PAGESIZE
INTERNAL_VENDOR_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif
ifneq (, $(INTERNAL_BOOTCONFIG)$(INTERNAL_BOOTCONFIG_FILE))
INTERNAL_VENDOR_BOOTCONFIG_TARGET := $(PRODUCT_OUT)/vendor-bootconfig.img
$(INTERNAL_VENDOR_BOOTCONFIG_TARGET):
rm -f $@
$(foreach param,$(INTERNAL_BOOTCONFIG), \
printf "%s\n" $(param) >> $@;)
cat $(INTERNAL_BOOTCONFIG_FILE) >> $@
INTERNAL_VENDOR_BOOTIMAGE_ARGS += --vendor_bootconfig $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
endif
# $(1): Build target name
# $(2): Staging dir to be compressed
# $(3): Build dependencies
define build-vendor-ramdisk-fragment-target
$(1): $(3) $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
$(MKBOOTFS) -d $(TARGET_OUT) $(2) | $(COMPRESSION_COMMAND) > $$@
endef
# $(1): Ramdisk name
define build-vendor-ramdisk-fragment
$(strip \
$(eval build_target := $(call intermediates-dir-for,PACKAGING,vendor_ramdisk_fragments)/$(1).cpio$(RAMDISK_EXT)) \
$(eval $(call build-vendor-ramdisk-fragment-target,$(build_target),$(VENDOR_RAMDISK_FRAGMENT.$(1).STAGING_DIR),$(VENDOR_RAMDISK_FRAGMENT.$(1).FILES))) \
$(build_target) \
)
endef
# $(1): Ramdisk name
# $(2): Prebuilt file path
define build-prebuilt-vendor-ramdisk-fragment
$(strip \
$(eval build_target := $(call intermediates-dir-for,PACKAGING,prebuilt_vendor_ramdisk_fragments)/$(1)) \
$(eval $(call copy-one-file,$(2),$(build_target))) \
$(build_target) \
)
endef
INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS :=
INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS :=
$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
$(eval prebuilt_vendor_ramdisk_fragment_file := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
$(if $(prebuilt_vendor_ramdisk_fragment_file), \
$(eval vendor_ramdisk_fragment_target := $(call build-prebuilt-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment),$(prebuilt_vendor_ramdisk_fragment_file))) \
$(eval ### else ###), \
$(eval vendor_ramdisk_fragment_target := $(call build-vendor-ramdisk-fragment,$(vendor_ramdisk_fragment)))) \
$(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS += $(vendor_ramdisk_fragment_target)) \
$(eval INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS += $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS) --vendor_ramdisk_fragment $(vendor_ramdisk_fragment_target)) \
)
INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET)
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOTIMAGE_KEY_PATH)
$(call pretty,"Target vendor_boot image: $@")
$(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
$(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
--salt $$(sha256sum $(BUILD_NUMBER_FILE) $(BUILD_DATETIME_FILE) | cut -d " " -f 1 | tr -d '\n') \
--partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
else
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET):
$(call pretty,"Target vendor_boot image: $@")
$(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
$(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
endif
$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_DTB_IMAGE_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS) $(INTERNAL_VENDOR_BOOTCONDIG_TARGET),$(PRODUCT_OUT)/:/)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
else # BUILDING_VENDOR_BOOT_IMAGE not defined, use prebuilt image
ifdef BOARD_PREBUILT_VENDOR_BOOTIMAGE
INTERNAL_PREBUILT_VENDOR_BOOTIMAGE := $(BOARD_PREBUILT_VENDOR_BOOTIMAGE)
INSTALLED_VENDOR_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot.img
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_VENDOR_BOOTIMAGE) $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_KEY_PATH)
cp $(INTERNAL_PREBUILT_VENDOR_BOOTIMAGE) $@
chmod +w $@
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
--partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
else
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET): $(INTERNAL_PREBUILT_VENDOR_BOOTIMAGE)
cp $(INTERNAL_PREBUILT_VENDOR_BOOTIMAGE) $@
endif # BOARD_AVB_ENABLE
$(call declare-1p-container,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET),$(INTERNAL_PREBUILT_VENDOR_BOOTIMAGE),$(PRODUCT_OUT)/:/)
endif # BOARD_PREBUILT_VENDOR_BOOTIMAGE
endif # BUILDING_VENDOR_BOOT_IMAGE
# -----------------------------------------------------------------
# vendor kernel boot image
ifeq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
INTERNAL_VENDOR_KERNEL_RAMDISK_FILES := $(filter $(TARGET_VENDOR_KERNEL_RAMDISK_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_kernel_boot)/vendor_kernel_ramdisk.cpio$(RAMDISK_EXT)
$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET): $(MKBOOTFS) $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) | $(COMPRESSION_COMMAND_DEPS)
$(hide) : $(words $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES))
$(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) | $(COMPRESSION_COMMAND) > $@
INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_kernel_ramdisk.img
$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
@echo "Target vendor kernel ramdisk: $@"
$(copy-file-to-target)
INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-kernel-ramdisk.txt
INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK:.txt=.json)
$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK)
$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_VENDOR_KERNEL_RAMDISK_OUT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_KERNEL_RAMDISK))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_KERNEL_RAMDISK))
INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS := --vendor_ramdisk $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_kernel_boot.img
$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET)
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(INSTALLED_DTBIMAGE_TARGET)
endif
ifdef BOARD_KERNEL_PAGESIZE
INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
ifeq ($(BOARD_AVB_ENABLE),true)
$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_KERNEL_BOOTIMAGE_KEY_PATH)
$(call pretty,"Target vendor_kernel_boot image: $@")
$(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
$(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
$(AVBTOOL) add_hash_footer \
--image $@ \
$(call get-partition-size-argument,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)) \
--partition_name vendor_kernel_boot $(INTERNAL_AVB_VENDOR_KERNEL_BOOT_SIGNING_ARGS) \
$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)
else
$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):
$(call pretty,"Target vendor_kernel_boot image: $@")
$(MKBOOTIMG) $(INTERNAL_VENDOR_KERNEL_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_boot $@
$(call assert-max-image-size,$@,$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE))
endif
$(call declare-1p-container,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),\
$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET) $(INSTALLED_DTBIMAGE_TARGET),\
$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
else
$(call declare-container-license-deps,$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_KERNEL_RAMDISK_TARGET),$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET):)
endif
endif # BUILDING_VENDOR_KERNEL_BOOT_IMAGE
# -----------------------------------------------------------------
# NOTICE files
#
# We are required to publish the licenses for all code under BSD, GPL and
# Apache licenses (and possibly other more exotic ones as well). We err on the
# side of caution, so the licenses for other third-party code are included here
# too.
#
# This needs to be before the systemimage rules, because it adds to
# ALL_DEFAULT_INSTALLED_MODULES, which those use to pick which files
# go into the systemimage.
.PHONY: notice_files
# Convert license metadata into xml notice file.
# $(1) - Output target notice filename
# $(2) - Product name
# $(3) - File title
# $(4) - License metadata file roots
# $(5) - Prefixes to strip
#
define xml-notice-rule
$(1): PRIVATE_PRODUCT := $(2)
$(1): PRIVATE_MESSAGE := $(3)
$(1): PRIVATE_DEPS := $(call corresponding-license-metadata,$(4))
$(1): $(call corresponding-license-metadata,$(4)) $(XMLNOTICE) $(BUILD_SYSTEM)/Makefile
OUT_DIR=$(OUT_DIR) $(XMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $$(PRIVATE_DEPS)
notice_files: $(1)
endef
# Convert license metadata into text notice file.
# $(1) - Output target notice filename
# $(2) - Product name
# $(3) - File title
# $(4) - License metadata file roots
# $(5) - Prefixes to strip
#
define text-notice-rule
$(1): PRIVATE_PRODUCT := $(2)
$(1): PRIVATE_MESSAGE := $(3)
$(1): $(call corresponding-license-metadata,$(4)) $(TEXTNOTICE) $(BUILD_SYSTEM)/Makefile
OUT_DIR=$(OUT_DIR) $(TEXTNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
notice_files: $(1)
endef
# Conversion license metadata into html notice file.
# $(1) - Output target notice filename
# $(2) - Product name
# $(3) - File title
# $(4) - License metadata file roots
# $(5) - Prefixes to strip
#
define html-notice-rule
$(1): PRIVATE_PRODUCT := $(2)
$(1): PRIVATE_MESSAGE := $(3)
$(1): $(call corresponding-license-metadata,$(4)) $(HTMLNOTICE) $(BUILD_SYSTEM)/Makefile
OUT_DIR=$(OUT_DIR) $(HTMLNOTICE) -o $$@ -product=$$(PRIVATE_PRODUCT) -title=$$(PRIVATE_MESSAGE) $(foreach prefix, $(5), -strip_prefix=$(prefix)) $(call corresponding-license-metadata,$(4))
notice_files: $(1)
endef
$(KATI_obsolete_var combine-notice-files, To create notice files use xml-notice-rule, html-notice-rule, or text-notice-rule.)
# Notice file logic isn't relevant for TARGET_BUILD_APPS
ifndef TARGET_BUILD_APPS
# TODO These intermediate NOTICE.txt/NOTICE.html files should go into
# TARGET_OUT_NOTICE_FILES now that the notice files are gathered from
# the src subdirectory.
kernel_notice_file := $(TARGET_OUT_NOTICE_FILES)/src/kernel.txt
# Some targets get included under $(PRODUCT_OUT) for debug symbols or other
# reasons--not to be flashed onto any device. Targets under these directories
# need no associated notice file on the device UI.
exclude_target_dirs := apex
# target_notice_file_xml := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml
target_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE.xml.gz
installed_notice_html_or_xml_gz := $(TARGET_OUT)/etc/NOTICE.xml.gz
target_vendor_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.txt
target_vendor_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR.xml.gz
installed_vendor_notice_xml_gz := $(TARGET_OUT_VENDOR)/etc/NOTICE.xml.gz
target_product_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.txt
target_product_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_PRODUCT.xml.gz
installed_product_notice_xml_gz := $(TARGET_OUT_PRODUCT)/etc/NOTICE.xml.gz
target_system_ext_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.txt
target_system_ext_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_EXT.xml.gz
installed_system_ext_notice_xml_gz := $(TARGET_OUT_SYSTEM_EXT)/etc/NOTICE.xml.gz
target_odm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.txt
target_odm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM.xml.gz
installed_odm_notice_xml_gz := $(TARGET_OUT_ODM)/etc/NOTICE.xml.gz
target_vendor_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.txt
target_vendor_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_VENDOR_DLKM.xml.gz
installed_vendor_dlkm_notice_xml_gz := $(TARGET_OUT_VENDOR_DLKM)/etc/NOTICE.xml.gz
target_odm_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.txt
target_odm_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_ODM_DLKM.xml.gz
installed_odm_dlkm_notice_xml_gz := $(TARGET_OUT_ODM_DLKM)/etc/NOTICE.xml.gz
target_system_dlkm_notice_file_txt := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.txt
target_system_dlkm_notice_file_xml_gz := $(TARGET_OUT_INTERMEDIATES)/NOTICE_SYSTEM_DLKM.xml.gz
installed_system_dlkm_notice_xml_gz := $(TARGET_OUT_SYSTEM_DLKM)/etc/NOTICE.xml.gz
ALL_INSTALLED_NOTICE_FILES := \
$(installed_notice_html_or_xml_gz) \
$(installed_vendor_notice_xml_gz) \
$(installed_product_notice_xml_gz) \
$(installed_system_ext_notice_xml_gz) \
$(installed_odm_notice_xml_gz) \
$(installed_vendor_dlkm_notice_xml_gz) \
$(installed_odm_dlkm_notice_xml_gz) \
$(installed_system_dlkm_notice_xml_gz) \
# $1 installed file path, e.g. out/target/product/vsoc_x86_64/system_ext/etc/NOTICE.xml.gz
define is-notice-file
$(if $(filter true,$(PRODUCT_USE_SOONG_NOTICE_XML)),, \
$(if $(findstring $1,$(ALL_INSTALLED_NOTICE_FILES)),Y))
endef
# Notice files are copied to TARGET_OUT_NOTICE_FILES as a side-effect of their module
# being built. A notice xml file must depend on all modules that could potentially
# install a license file relevant to it.
license_modules := $(ALL_DEFAULT_INSTALLED_MODULES) $(kernel_notice_file)
# Only files copied to a system image need system image notices.
license_modules := $(filter $(PRODUCT_OUT)/%,$(license_modules))
# Phonys/fakes don't have notice files (though their deps might)
license_modules := $(filter-out $(TARGET_OUT_FAKE)/%,$(license_modules))
# testcases are not relevant to the system image.
license_modules := $(filter-out $(TARGET_OUT_TESTCASES)/%,$(license_modules))
# filesystem images: system, vendor, product, system_ext, odm, vendor_dlkm, and odm_dlkm
license_modules_system := $(filter $(TARGET_OUT)/%,$(license_modules))
# system_other is relevant to system partition.
license_modules_system += $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(license_modules))
license_modules_vendor := $(filter $(TARGET_OUT_VENDOR)/%,$(license_modules))
license_modules_product := $(filter $(TARGET_OUT_PRODUCT)/%,$(license_modules))
license_modules_system_ext := $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(license_modules))
license_modules_odm := $(filter $(TARGET_OUT_ODM)/%,$(license_modules))
license_modules_vendor_dlkm := $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(license_modules))
license_modules_odm_dlkm := $(filter $(TARGET_OUT_ODM_DLKM)/%,$(license_modules))
license_modules_odm_dlkm := $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(license_modules))
license_modules_agg := $(license_modules_system) \
$(license_modules_vendor) \
$(license_modules_product) \
$(license_modules_system_ext) \
$(license_modules_odm) \
$(license_modules_vendor_dlkm) \
$(license_modules_odm_dlkm) \
$(license_modules_system_dlkm)
# targets used for debug symbols only and do not get copied to the device
license_modules_symbols_only := $(filter $(PRODUCT_OUT)/apex/%,$(license_modules))
license_modules_rest := $(filter-out $(license_modules_agg),$(license_modules))
license_modules_rest := $(filter-out $(license_modules_symbols_only),$(license_modules_rest))
# Identify the other targets we expect to have notices for:
# targets copied to the device but are not readable by the UI (e.g. must boot
# into a different partition to read or don't have an associated /etc
# directory) must have their notices built somewhere readable.
license_modules_rehomed := $(filter-out $(PRODUCT_OUT)/%/%,$(license_modules_rest)) # files in root have no /etc
license_modules_rehomed += $(filter $(PRODUCT_OUT)/recovery/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/root/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/data/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/ramdisk/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/debug_ramdisk/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/vendor_ramdisk/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/persist.img,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/system_other/%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/kernel%,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.img,$(license_modules_rest))
license_modules_rehomed += $(filter $(PRODUCT_OUT)/%.bin,$(license_modules_rest))
# after removing targets in system images, targets reported in system images, and
# targets used for debug symbols that do not need notices, nothing must remain.
license_modules_rest := $(filter-out $(license_modules_rehomed),$(license_modules_rest))
$(call maybe-print-list-and-error, $(license_modules_rest), \
"Targets added under $(PRODUCT_OUT)/ unaccounted for notice handling.")
# If we are building in a configuration that includes a prebuilt vendor.img, we can't
# update its notice file, so include those notices in the system partition instead
ifdef BOARD_PREBUILT_VENDORIMAGE
license_modules_system += $(license_modules_rehomed)
system_xml_directories := xml_excluded_vendor_product_odm_vendor_dlkm_odm_dlkm
system_notice_file_message := "Notices for files contained in all filesystem images except vendor/system_ext/product/odm/vendor_dlkm/odm_dlkm in this directory:"
else
license_modules_vendor += $(license_modules_rehomed)
system_xml_directories := xml_system
system_notice_file_message := "Notices for files contained in the system filesystem image in this directory:"
endif
ALL_DEFAULT_INSTALLED_MODULES += $(installed_notice_html_or_xml_gz)
need_vendor_notice:=false
ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
need_vendor_notice:=true
endif
ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
need_vendor_notice:=true
endif
ifdef BUILDING_VENDOR_IMAGE
need_vendor_notice:=true
endif
ifeq (true,$(need_vendor_notice))
ifneq (,$(installed_vendor_notice_xml_gz))
ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_notice_xml_gz)
endif
endif
need_vendor_notice:=
ifdef BUILDING_ODM_IMAGE
ifneq (,$(installed_odm_notice_xml_gz))
ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_notice_xml_gz)
endif
endif
ifdef BUILDING_PRODUCT_IMAGE
ifneq (,$(installed_product_notice_xml_gz))
ALL_DEFAULT_INSTALLED_MODULES += $(installed_product_notice_xml_gz)
endif
endif
ifdef BUILDING_SYSTEM_EXT_IMAGE
ifneq (,$(installed_system_ext_notice_xml_gz))
ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_ext_notice_xml_gz)
endif
endif
ifdef BUILDING_VENDOR_DLKM_IMAGE
ifneq (,$(installed_vendor_dlkm_notice_xml_gz)
ALL_DEFAULT_INSTALLED_MODULES += $(installed_vendor_dlkm_notice_xml_gz)
endif
endif
ifdef BUILDING_ODM_DLKM_IMAGE
ifneq (,$(installed_odm_dlkm_notice_xml_gz))
ALL_DEFAULT_INSTALLED_MODULES += $(installed_odm_dlkm_notice_xml_gz)
endif
endif
ifdef BUILDING_SYSTEM_DLKM_IMAGE
ifneq (,$(installed_system_dlkm_notice_xml_gz))
ALL_DEFAULT_INSTALLED_MODULES += $(installed_system_dlkm_notice_xml_gz)
endif
endif
endif # TARGET_BUILD_APPS
# Presently none of the prebuilts etc. comply with policy to have a license text. Fake one here.
$(eval $(call copy-one-file,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,$(kernel_notice_file)))
ifneq (,$(strip $(INSTALLED_KERNEL_TARGET)))
$(call declare-license-metadata,$(INSTALLED_KERNEL_TARGET),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
endif
# No matter where it gets copied from, a copied linux kernel is licensed under "GPL 2.0 only"
$(eval $(call declare-copy-files-license-metadata,,:kernel,SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,kernel))
# #################################################################
# Targets for user images
# #################################################################
# These options tell the recovery updater/installer how to mount the partitions writebale.
# =[|]...
# fstype_opts := [,]...
# opt := [=]
# The following worked on Nexus devices with Kernel 3.1, 3.4, 3.10
DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS := ext4=max_batch_time=0,commit=1,data=ordered,barrier=1,errors=panic,nodelalloc
INTERNAL_USERIMAGES_DEPS := \
$(BUILD_IMAGE) \
$(MKE2FS_CONF) \
$(MKEXTUSERIMG)
$(call declare-1p-target,$(MKE2FS_CONF),system/extras)
ifeq ($(TARGET_USERIMAGES_USE_F2FS),true)
INTERNAL_USERIMAGES_DEPS += $(MKF2FSUSERIMG)
endif
ifneq ($(filter \
$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
,erofs),)
INTERNAL_USERIMAGES_DEPS += $(MKEROFS)
ifeq ($(BOARD_EROFS_USE_LEGACY_COMPRESSION),true)
BOARD_EROFS_COMPRESSOR ?= "lz4"
else
BOARD_EROFS_COMPRESSOR ?= "lz4hc,9"
endif
endif
ifneq ($(filter \
$(BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
$(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE) \
,squashfs),)
INTERNAL_USERIMAGES_DEPS += $(MKSQUASHFSUSERIMG)
endif
ifeq ($(BOARD_AVB_ENABLE),true)
INTERNAL_USERIMAGES_DEPS += $(AVBTOOL)
endif
# Get a colon-separated list of search paths.
INTERNAL_USERIMAGES_BINARY_PATHS := $(subst $(space),:,$(sort $(dir $(INTERNAL_USERIMAGES_DEPS))))
SELINUX_FC := $(call intermediates-dir-for,ETC,file_contexts.bin)/file_contexts.bin
INTERNAL_USERIMAGES_DEPS += $(SELINUX_FC)
# $(1) the partition name (eg system)
# $(2) the image prop file
define add-common-flags-to-image-props
$(eval _var := $(call to-upper,$(1)))
$(hide) echo "$(1)_selinux_fc=$(SELINUX_FC)" >> $(2)
$(hide) echo "building_$(1)_image=$(BUILDING_$(_var)_IMAGE)" >> $(2)
endef
# $(1) the partition name (eg system)
# $(2) the image prop file
define add-common-ro-flags-to-image-props
$(eval _var := $(call to-upper,$(1)))
$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR),$(hide) echo "$(1)_erofs_compressor=$(BOARD_$(_var)IMAGE_EROFS_COMPRESSOR)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_EROFS_COMPRESS_HINTS),$(hide) echo "$(1)_erofs_compress_hints=$(BOARD_$(_var)IMAGE_EROFS_COMPRESS_HINTS)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_EROFS_PCLUSTER_SIZE),$(hide) echo "$(1)_erofs_pcluster_size=$(BOARD_$(_var)IMAGE_EROFS_PCLUSTER_SIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_EROFS_BLOCKSIZE),$(hide) echo "$(1)_erofs_blocksize=$(BOARD_$(_var)IMAGE_EROFS_BLOCKSIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT),$(hide) echo "$(1)_extfs_inode_count=$(BOARD_$(_var)IMAGE_EXTFS_INODE_COUNT)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT),$(hide) echo "$(1)_extfs_rsv_pct=$(BOARD_$(_var)IMAGE_EXTFS_RSV_PCT)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS),$(hide) echo "$(1)_f2fs_sldc_flags=$(BOARD_$(_var)IMAGE_F2FS_SLOAD_COMPRESS_FLAGS)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_F2FS_BLOCKSIZE),$(hide) echo "$(1)_f2fs_blocksize=$(BOARD_$(_var)IMAGE_F2FS_BLOCKSIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS),$(hide) echo "$(1)_f2fs_compress=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_COMPRESS)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE),$(hide) echo "$(1)_fs_type=$(BOARD_$(_var)IMAGE_FILE_SYSTEM_TYPE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_JOURNAL_SIZE),$(hide) echo "$(1)_journal_size=$(BOARD_$(_var)IMAGE_JOURNAL_SIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE),$(hide) echo "$(1)_reserved_size=$(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_PARTITION_SIZE),$(hide) echo "$(1)_size=$(BOARD_$(_var)IMAGE_PARTITION_SIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE),$(hide) echo "$(1)_squashfs_block_size=$(BOARD_$(_var)IMAGE_SQUASHFS_BLOCK_SIZE)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR),$(hide) echo "$(1)_squashfs_compressor=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT),$(hide) echo "$(1)_squashfs_compressor_opt=$(BOARD_$(_var)IMAGE_SQUASHFS_COMPRESSOR_OPT)" >> $(2))
$(if $(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN),$(hide) echo "$(1)_squashfs_disable_4k_align=$(BOARD_$(_var)IMAGE_SQUASHFS_DISABLE_4K_ALIGN)" >> $(2))
$(if $(PRODUCT_$(_var)_BASE_FS_PATH),$(hide) echo "$(1)_base_fs_file=$(PRODUCT_$(_var)_BASE_FS_PATH)" >> $(2))
$(eval _size := $(BOARD_$(_var)IMAGE_PARTITION_SIZE))
$(eval _reserved := $(BOARD_$(_var)IMAGE_PARTITION_RESERVED_SIZE))
$(eval _headroom := $(PRODUCT_$(_var)_HEADROOM))
$(if $(or $(_size), $(_reserved), $(_headroom)),,
$(hide) echo "$(1)_disable_sparse=true" >> $(2))
$(call add-common-flags-to-image-props,$(1),$(2))
endef
# $(1): the path of the output dictionary file
# $(2): a subset of "system vendor cache userdata product system_ext oem odm vendor_dlkm odm_dlkm system_dlkm"
# $(3): additional "key=value" pairs to append to the dictionary file.
define generate-image-prop-dictionary
$(if $(filter $(2),system),\
$(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),$(hide) echo "system_other_size=$(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE)" >> $(1))
$(if $(PRODUCT_SYSTEM_HEADROOM),$(hide) echo "system_headroom=$(PRODUCT_SYSTEM_HEADROOM)" >> $(1))
$(call add-common-ro-flags-to-image-props,system,$(1))
)
$(if $(filter $(2),system_other),\
$(hide) echo "building_system_other_image=$(BUILDING_SYSTEM_OTHER_IMAGE)" >> $(1)
$(if $(INTERNAL_SYSTEM_OTHER_PARTITION_SIZE),,
$(hide) echo "system_other_disable_sparse=true" >> $(1))
)
$(if $(filter $(2),userdata),\
$(if $(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "userdata_fs_type=$(BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_USERDATAIMAGE_PARTITION_SIZE),$(hide) echo "userdata_size=$(BOARD_USERDATAIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(PRODUCT_FS_CASEFOLD),$(hide) echo "needs_casefold=$(PRODUCT_FS_CASEFOLD)" >> $(1))
$(if $(PRODUCT_QUOTA_PROJID),$(hide) echo "needs_projid=$(PRODUCT_QUOTA_PROJID)" >> $(1))
$(if $(PRODUCT_FS_COMPRESSION),$(hide) echo "needs_compress=$(PRODUCT_FS_COMPRESSION)" >> $(1))
$(call add-common-flags-to-image-props,userdata,$(1))
)
$(if $(filter $(2),cache),\
$(if $(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE),$(hide) echo "cache_fs_type=$(BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE)" >> $(1))
$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),$(hide) echo "cache_size=$(BOARD_CACHEIMAGE_PARTITION_SIZE)" >> $(1))
$(call add-common-flags-to-image-props,cache,$(1))
)
$(if $(filter $(2),vendor),\
$(call add-common-ro-flags-to-image-props,vendor,$(1))
)
$(if $(filter $(2),product),\
$(call add-common-ro-flags-to-image-props,product,$(1))
)
$(if $(filter $(2),system_ext),\
$(call add-common-ro-flags-to-image-props,system_ext,$(1))
)
$(if $(filter $(2),odm),\
$(call add-common-ro-flags-to-image-props,odm,$(1))
)
$(if $(filter $(2),vendor_dlkm),\
$(call add-common-ro-flags-to-image-props,vendor_dlkm,$(1))
)
$(if $(filter $(2),odm_dlkm),\
$(call add-common-ro-flags-to-image-props,odm_dlkm,$(1))
)
$(if $(filter $(2),system_dlkm),\
$(call add-common-ro-flags-to-image-props,system_dlkm,$(1))
)
$(if $(filter $(2),oem),\
$(if $(BOARD_OEMIMAGE_PARTITION_SIZE),$(hide) echo "oem_size=$(BOARD_OEMIMAGE_PARTITION_SIZE)" >> $(1))
$(if $(BOARD_OEMIMAGE_JOURNAL_SIZE),$(hide) echo "oem_journal_size=$(BOARD_OEMIMAGE_JOURNAL_SIZE)" >> $(1))
$(if $(BOARD_OEMIMAGE_EXTFS_INODE_COUNT),$(hide) echo "oem_extfs_inode_count=$(BOARD_OEMIMAGE_EXTFS_INODE_COUNT)" >> $(1))
$(if $(BOARD_OEMIMAGE_EXTFS_RSV_PCT),$(hide) echo "oem_extfs_rsv_pct=$(BOARD_OEMIMAGE_EXTFS_RSV_PCT)" >> $(1))
$(call add-common-flags-to-image-props,oem,$(1))
)
$(hide) echo "ext_mkuserimg=$(notdir $(MKEXTUSERIMG))" >> $(1)
$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT2)),$(hide) echo "fs_type=ext2" >> $(1),
$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT3)),$(hide) echo "fs_type=ext3" >> $(1),
$(if $(filter true,$(TARGET_USERIMAGES_USE_EXT4)),$(hide) echo "fs_type=ext4" >> $(1))))
$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)),,$(hide) echo "extfs_sparse_flag=-s" >> $(1))
$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EROFS_DISABLED)),,$(hide) echo "erofs_sparse_flag=-s" >> $(1))
$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_SQUASHFS_DISABLED)),,$(hide) echo "squashfs_sparse_flag=-s" >> $(1))
$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)),,$(hide) echo "f2fs_sparse_flag=-S" >> $(1))
$(if $(BOARD_EROFS_COMPRESSOR),$(hide) echo "erofs_default_compressor=$(BOARD_EROFS_COMPRESSOR)" >> $(1))
$(if $(BOARD_EROFS_COMPRESS_HINTS),$(hide) echo "erofs_default_compress_hints=$(BOARD_EROFS_COMPRESS_HINTS)" >> $(1))
$(if $(BOARD_EROFS_PCLUSTER_SIZE),$(hide) echo "erofs_pcluster_size=$(BOARD_EROFS_PCLUSTER_SIZE)" >> $(1))
$(if $(BOARD_EROFS_BLOCKSIZE),$(hide) echo "erofs_blocksize=$(BOARD_EROFS_BLOCKSIZE)" >> $(1))
$(if $(BOARD_EROFS_SHARE_DUP_BLOCKS),$(hide) echo "erofs_share_dup_blocks=$(BOARD_EROFS_SHARE_DUP_BLOCKS)" >> $(1))
$(if $(BOARD_EROFS_USE_LEGACY_COMPRESSION),$(hide) echo "erofs_use_legacy_compression=$(BOARD_EROFS_USE_LEGACY_COMPRESSION)" >> $(1))
$(if $(BOARD_EXT4_SHARE_DUP_BLOCKS),$(hide) echo "ext4_share_dup_blocks=$(BOARD_EXT4_SHARE_DUP_BLOCKS)" >> $(1))
$(if $(BOARD_F2FS_BLOCKSIZE),$(hide) echo "f2fs_blocksize=$(BOARD_F2FS_BLOCKSIZE)" >> $(1))
$(if $(BOARD_FLASH_LOGICAL_BLOCK_SIZE), $(hide) echo "flash_logical_block_size=$(BOARD_FLASH_LOGICAL_BLOCK_SIZE)" >> $(1))
$(if $(BOARD_FLASH_ERASE_BLOCK_SIZE), $(hide) echo "flash_erase_block_size=$(BOARD_FLASH_ERASE_BLOCK_SIZE)" >> $(1))
$(if $(filter eng, $(TARGET_BUILD_VARIANT)),$(hide) echo "verity_disable=true" >> $(1))
$(if $(PRODUCT_SYSTEM_VERITY_PARTITION),$(hide) echo "system_verity_block_device=$(PRODUCT_SYSTEM_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_VENDOR_VERITY_PARTITION),$(hide) echo "vendor_verity_block_device=$(PRODUCT_VENDOR_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_PRODUCT_VERITY_PARTITION),$(hide) echo "product_verity_block_device=$(PRODUCT_PRODUCT_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_SYSTEM_EXT_VERITY_PARTITION),$(hide) echo "system_ext_verity_block_device=$(PRODUCT_SYSTEM_EXT_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_VENDOR_DLKM_VERITY_PARTITION),$(hide) echo "vendor_dlkm_verity_block_device=$(PRODUCT_VENDOR_DLKM_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_ODM_DLKM_VERITY_PARTITION),$(hide) echo "odm_dlkm_verity_block_device=$(PRODUCT_ODM_DLKM_VERITY_PARTITION)" >> $(1))
$(if $(PRODUCT_SYSTEM_DLKM_VERITY_PARTITION),$(hide) echo "system_dlkm_verity_block_device=$(PRODUCT_SYSTEM_DLKM_VERITY_PARTITION)" >> $(1))
$(if $(BOARD_AVB_ENABLE), \
$(hide) echo "avb_avbtool=$(notdir $(AVBTOOL))" >> $(1)$(newline) \
$(if $(filter $(2),system), \
$(hide) echo "avb_system_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_system_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_SYSTEM_KEY_PATH), \
$(hide) echo "avb_system_key_path=$(BOARD_AVB_SYSTEM_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_system_algorithm=$(BOARD_AVB_SYSTEM_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_system_rollback_index_location=$(BOARD_AVB_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),system_other), \
$(hide) echo "avb_system_other_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_system_other_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH),\
$(hide) echo "avb_system_other_key_path=$(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_system_other_algorithm=$(BOARD_AVB_SYSTEM_OTHER_ALGORITHM)" >> $(1)$(newline))) \
$(if $(filter $(2),vendor), \
$(hide) echo "avb_vendor_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_vendor_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_VENDOR_KEY_PATH),\
$(hide) echo "avb_vendor_key_path=$(BOARD_AVB_VENDOR_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_vendor_algorithm=$(BOARD_AVB_VENDOR_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_vendor_rollback_index_location=$(BOARD_AVB_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),product), \
$(hide) echo "avb_product_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_product_add_hashtree_footer_args=$(BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
$(hide) echo "avb_product_key_path=$(BOARD_AVB_PRODUCT_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_product_algorithm=$(BOARD_AVB_PRODUCT_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_product_rollback_index_location=$(BOARD_AVB_PRODUCT_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),system_ext), \
$(hide) echo "avb_system_ext_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_system_ext_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
$(hide) echo "avb_system_ext_key_path=$(BOARD_AVB_SYSTEM_EXT_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_system_ext_algorithm=$(BOARD_AVB_SYSTEM_EXT_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_system_ext_rollback_index_location=$(BOARD_AVB_SYSTEM_EXT_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),odm), \
$(hide) echo "avb_odm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_odm_add_hashtree_footer_args=$(BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_ODM_KEY_PATH),\
$(hide) echo "avb_odm_key_path=$(BOARD_AVB_ODM_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_odm_algorithm=$(BOARD_AVB_ODM_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_odm_rollback_index_location=$(BOARD_AVB_ODM_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),vendor_dlkm), \
$(hide) echo "avb_vendor_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_vendor_dlkm_add_hashtree_footer_args=$(BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
$(hide) echo "avb_vendor_dlkm_key_path=$(BOARD_AVB_VENDOR_DLKM_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_vendor_dlkm_algorithm=$(BOARD_AVB_VENDOR_DLKM_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_vendor_dlkm_rollback_index_location=$(BOARD_AVB_VENDOR_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),odm_dlkm), \
$(hide) echo "avb_odm_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_odm_dlkm_add_hashtree_footer_args=$(BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
$(hide) echo "avb_odm_dlkm_key_path=$(BOARD_AVB_ODM_DLKM_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_odm_dlkm_algorithm=$(BOARD_AVB_ODM_DLKM_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_odm_dlkm_rollback_index_location=$(BOARD_AVB_ODM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
$(if $(filter $(2),system_dlkm), \
$(hide) echo "avb_system_dlkm_hashtree_enable=$(BOARD_AVB_ENABLE)" >> $(1)$(newline) \
$(hide) echo "avb_system_dlkm_add_hashtree_footer_args=$(BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS)" >> $(1)$(newline) \
$(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
$(hide) echo "avb_system_dlkm_key_path=$(BOARD_AVB_SYSTEM_DLKM_KEY_PATH)" >> $(1)$(newline) \
$(hide) echo "avb_system_dlkm_algorithm=$(BOARD_AVB_SYSTEM_DLKM_ALGORITHM)" >> $(1)$(newline) \
$(hide) echo "avb_system_dlkm_rollback_index_location=$(BOARD_SYSTEM_SYSTEM_DLKM_ROLLBACK_INDEX_LOCATION)" >> $(1)$(newline))) \
)
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)),\
$(hide) echo "recovery_as_boot=true" >> $(1))
$(hide) echo "root_dir=$(TARGET_ROOT_OUT)" >> $(1)
$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITION_SIZE)),\
$(hide) echo "use_dynamic_partition_size=true" >> $(1))
$(if $(USE_FIXED_TIMESTAMP_IMG_FILES)$(COPY_IMAGES_FOR_TARGET_FILES_ZIP),\
$(hide) echo "use_fixed_timestamp=true" >> $(1))
$(if $(3),$(hide) $(foreach kv,$(3),echo "$(kv)" >> $(1);))
$(hide) sort -o $(1) $(1)
endef
# $(1): the path of the output dictionary file
# $(2): additional "key=value" pairs to append to the dictionary file.
PROP_DICTIONARY_IMAGES := oem
ifdef BUILDING_CACHE_IMAGE
PROP_DICTIONARY_IMAGES += cache
endif
ifdef BUILDING_SYSTEM_IMAGE
PROP_DICTIONARY_IMAGES += system
endif
ifdef BUILDING_SYSTEM_OTHER_IMAGE
PROP_DICTIONARY_IMAGES += system_other
endif
ifdef BUILDING_USERDATA_IMAGE
PROP_DICTIONARY_IMAGES += userdata
endif
ifdef BUILDING_VENDOR_IMAGE
PROP_DICTIONARY_IMAGES += vendor
endif
ifdef BUILDING_PRODUCT_IMAGE
PROP_DICTIONARY_IMAGES += product
endif
ifdef BUILDING_SYSTEM_EXT_IMAGE
PROP_DICTIONARY_IMAGES += system_ext
endif
ifdef BUILDING_ODM_IMAGE
PROP_DICTIONARY_IMAGES += odm
endif
ifdef BUILDING_VENDOR_DLKM_IMAGE
PROP_DICTIONARY_IMAGES += vendor_dlkm
endif
ifdef BUILDING_ODM_DLKM_IMAGE
PROP_DICTIONARY_IMAGES += odm_dlkm
endif
ifdef BUILDING_SYSTEM_DLKM_IMAGE
PROP_DICTIONARY_IMAGES += system_dlkm
endif
define generate-userimage-prop-dictionary
$(call generate-image-prop-dictionary,$(1),$(PROP_DICTIONARY_IMAGES),$(2))
endef
# $(1): the path of the input dictionary file, where each line has the format key=value
# $(2): the key to look up
define read-image-prop-dictionary
$$(grep '$(2)=' $(1) | cut -f2- -d'=')
endef
# -----------------------------------------------------------------
# Recovery image
# Recovery image exists if we are building recovery, or building recovery as boot.
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_RECOVERY_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_RECOVERY_IMAGE
INTERNAL_RECOVERYIMAGE_FILES := $(filter $(TARGET_RECOVERY_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_RECOVERY := $(PRODUCT_OUT)/installed-files-recovery.txt
INSTALLED_FILES_JSON_RECOVERY := $(INSTALLED_FILES_FILE_RECOVERY:.txt=.json)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
INSTALLED_BOOTIMAGE_TARGET := $(BUILT_BOOTIMAGE_TARGET)
endif
# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
# INSTALLED_FILES_FILE_* rules. Because currently there're cp/rsync/rm commands in
# build-recoveryimage-target, which would touch the files under TARGET_RECOVERY_OUT and race with
# the call to FILELIST.
$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
$(INSTALLED_FILES_FILE_RECOVERY): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_RECOVERY)
$(INSTALLED_FILES_FILE_RECOVERY): $(INTERNAL_RECOVERYIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_RECOVERY_ROOT_OUT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_RECOVERY)))
$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_RECOVERY)))
recovery_sepolicy := \
$(TARGET_RECOVERY_ROOT_OUT)/sepolicy \
$(TARGET_RECOVERY_ROOT_OUT)/plat_file_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/plat_service_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/plat_property_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/system_ext_file_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/system_ext_service_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/system_ext_property_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/vendor_file_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/vendor_service_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/vendor_property_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/odm_file_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/odm_property_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/product_file_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/product_service_contexts \
$(TARGET_RECOVERY_ROOT_OUT)/product_property_contexts
# Passed into rsync from non-recovery root to recovery root, to avoid overwriting recovery-specific
# SELinux files
IGNORE_RECOVERY_SEPOLICY := $(patsubst $(TARGET_RECOVERY_OUT)/%,--exclude=/%,$(recovery_sepolicy))
# if building multiple boot images from multiple kernels, use the first kernel listed
# for the recovery image
recovery_kernel := $(firstword $(INSTALLED_KERNEL_TARGET))
recovery_ramdisk := $(PRODUCT_OUT)/ramdisk-recovery.img
recovery_resources_common := bootable/recovery/res
# Set recovery_density to a density bucket based on TARGET_SCREEN_DENSITY, PRODUCT_AAPT_PREF_CONFIG,
# or mdpi, in order of preference. We support both specific buckets (e.g. xdpi) and numbers,
# which get remapped to a bucket.
recovery_density := $(or $(TARGET_SCREEN_DENSITY),$(PRODUCT_AAPT_PREF_CONFIG),mdpi)
ifeq (,$(filter xxxhdpi xxhdpi xhdpi hdpi mdpi,$(recovery_density)))
recovery_density_value := $(patsubst %dpi,%,$(recovery_density))
# We roughly use the medium point between the primary densities to split buckets.
# ------160------240------320----------480------------640------
# mdpi hdpi xhdpi xxhdpi xxxhdpi
recovery_density := $(strip \
$(or $(if $(filter $(shell echo $$(($(recovery_density_value) >= 560))),1),xxxhdpi),\
$(if $(filter $(shell echo $$(($(recovery_density_value) >= 400))),1),xxhdpi),\
$(if $(filter $(shell echo $$(($(recovery_density_value) >= 280))),1),xhdpi),\
$(if $(filter $(shell echo $$(($(recovery_density_value) >= 200))),1),hdpi,mdpi)))
endif
ifneq (,$(wildcard $(recovery_resources_common)-$(recovery_density)))
recovery_resources_common := $(recovery_resources_common)-$(recovery_density)
else
recovery_resources_common := $(recovery_resources_common)-xhdpi
endif
# Select the 18x32 font on high-density devices (xhdpi and up); and the 12x22 font on other devices.
# Note that the font selected here can be overridden for a particular device by putting a font.png
# in its private recovery resources.
ifneq (,$(filter xxxhdpi xxhdpi xhdpi,$(recovery_density)))
recovery_font := bootable/recovery/fonts/18x32.png
else
recovery_font := bootable/recovery/fonts/12x22.png
endif
# We will only generate the recovery background text images if the variable
# TARGET_RECOVERY_UI_SCREEN_WIDTH is defined. For devices with xxxhdpi and xxhdpi, we set the
# variable to the commonly used values here, if it hasn't been intialized elsewhere. While for
# devices with lower density, they must have TARGET_RECOVERY_UI_SCREEN_WIDTH defined in their
# BoardConfig in order to use this feature.
ifeq ($(recovery_density),xxxhdpi)
TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1440
else ifeq ($(recovery_density),xxhdpi)
TARGET_RECOVERY_UI_SCREEN_WIDTH ?= 1080
endif
ifneq ($(TARGET_RECOVERY_UI_SCREEN_WIDTH),)
# Subtracts the margin width and menu indent from the screen width; it's safe to be conservative.
ifeq ($(TARGET_RECOVERY_UI_MARGIN_WIDTH),)
recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - 10))
else
recovery_image_width := $$(($(TARGET_RECOVERY_UI_SCREEN_WIDTH) - $(TARGET_RECOVERY_UI_MARGIN_WIDTH) - 10))
endif
RECOVERY_INSTALLING_TEXT_FILE := $(call intermediates-dir-for,ETC,recovery_text_res)/installing_text.png
RECOVERY_INSTALLING_SECURITY_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/installing_security_text.png
RECOVERY_ERASING_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/erasing_text.png
RECOVERY_ERROR_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/error_text.png
RECOVERY_NO_COMMAND_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/no_command_text.png
RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/cancel_wipe_data_text.png
RECOVERY_FACTORY_DATA_RESET_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/factory_data_reset_text.png
RECOVERY_TRY_AGAIN_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/try_again_text.png
RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_confirmation_text.png
RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE := $(dir $(RECOVERY_INSTALLING_TEXT_FILE))/wipe_data_menu_header_text.png
generated_recovery_text_files := \
$(RECOVERY_INSTALLING_TEXT_FILE) \
$(RECOVERY_INSTALLING_SECURITY_TEXT_FILE) \
$(RECOVERY_ERASING_TEXT_FILE) \
$(RECOVERY_ERROR_TEXT_FILE) \
$(RECOVERY_NO_COMMAND_TEXT_FILE) \
$(RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE) \
$(RECOVERY_FACTORY_DATA_RESET_TEXT_FILE) \
$(RECOVERY_TRY_AGAIN_TEXT_FILE) \
$(RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE) \
$(RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE)
resource_dir := bootable/recovery/tools/recovery_l10n/res/
resource_dir_deps := $(sort $(shell find $(resource_dir) -name *.xml -not -name .*))
image_generator_jar := $(HOST_OUT_JAVA_LIBRARIES)/RecoveryImageGenerator.jar
zopflipng := $(HOST_OUT_EXECUTABLES)/zopflipng
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_SOURCE_FONTS := $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep)
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_FONT_FILES_DIR := $(call intermediates-dir-for,ETC,recovery_font_files)
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RESOURCE_DIR := $(resource_dir)
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_IMAGE_GENERATOR_JAR := $(image_generator_jar)
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_ZOPFLIPNG := $(zopflipng)
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_IMAGE_WIDTH := $(recovery_image_width)
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST := \
recovery_installing \
recovery_installing_security \
recovery_erasing \
recovery_error \
recovery_no_command
$(RECOVERY_INSTALLING_TEXT_FILE): PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST := \
recovery_cancel_wipe_data \
recovery_factory_data_reset \
recovery_try_again \
recovery_wipe_data_menu_header \
recovery_wipe_data_confirmation
$(RECOVERY_INSTALLING_TEXT_FILE): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(RECOVERY_INSTALLING_TEXT_FILE),$(generated_recovery_text_files))
$(RECOVERY_INSTALLING_TEXT_FILE): $(image_generator_jar) $(resource_dir_deps) $(recovery_noto-fonts_dep) $(recovery_roboto-fonts_dep) $(zopflipng)
# Prepares the font directory.
@rm -rf $(PRIVATE_RECOVERY_FONT_FILES_DIR)
@mkdir -p $(PRIVATE_RECOVERY_FONT_FILES_DIR)
$(foreach filename,$(PRIVATE_SOURCE_FONTS), cp $(filename) $(PRIVATE_RECOVERY_FONT_FILES_DIR) &&) true
@rm -rf $(dir $@)
@mkdir -p $(dir $@)
$(foreach text_name,$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST) $(PRIVATE_RECOVERY_WIPE_DATA_TEXT_LIST), \
$(eval output_file := $(dir $@)/$(patsubst recovery_%,%_text.png,$(text_name))) \
$(eval center_alignment := $(if $(filter $(text_name),$(PRIVATE_RECOVERY_BACKGROUND_TEXT_LIST)), --center_alignment)) \
java -jar $(PRIVATE_IMAGE_GENERATOR_JAR) \
--image_width $(PRIVATE_RECOVERY_IMAGE_WIDTH) \
--text_name $(text_name) \
--font_dir $(PRIVATE_RECOVERY_FONT_FILES_DIR) \
--resource_dir $(PRIVATE_RESOURCE_DIR) \
--output_file $(output_file) $(center_alignment) && \
$(PRIVATE_ZOPFLIPNG) -y --iterations=1 --filters=0 $(output_file) $(output_file) > /dev/null &&) true
else
RECOVERY_INSTALLING_TEXT_FILE :=
RECOVERY_INSTALLING_SECURITY_TEXT_FILE :=
RECOVERY_ERASING_TEXT_FILE :=
RECOVERY_ERROR_TEXT_FILE :=
RECOVERY_NO_COMMAND_TEXT_FILE :=
RECOVERY_CANCEL_WIPE_DATA_TEXT_FILE :=
RECOVERY_FACTORY_DATA_RESET_TEXT_FILE :=
RECOVERY_TRY_AGAIN_TEXT_FILE :=
RECOVERY_WIPE_DATA_CONFIRMATION_TEXT_FILE :=
RECOVERY_WIPE_DATA_MENU_HEADER_TEXT_FILE :=
endif # TARGET_RECOVERY_UI_SCREEN_WIDTH
ifndef TARGET_PRIVATE_RES_DIRS
TARGET_PRIVATE_RES_DIRS := $(wildcard $(TARGET_DEVICE_DIR)/recovery/res)
endif
recovery_resource_deps := $(shell find $(recovery_resources_common) \
$(TARGET_PRIVATE_RES_DIRS) -type f -not -name "*.bp")
recovery_resource_deps += $(generated_recovery_text_files)
ifdef TARGET_RECOVERY_FSTAB
recovery_fstab := $(TARGET_RECOVERY_FSTAB)
else ifdef TARGET_RECOVERY_FSTAB_GENRULE
# Specifies a soong genrule module that generates an fstab.
recovery_fstab := $(call intermediates-dir-for,ETC,$(TARGET_RECOVERY_FSTAB_GENRULE))/$(TARGET_RECOVERY_FSTAB_GENRULE)
else
recovery_fstab := $(strip $(wildcard $(TARGET_DEVICE_DIR)/recovery.fstab))
endif
ifdef TARGET_RECOVERY_WIPE
recovery_wipe := $(TARGET_RECOVERY_WIPE)
else
recovery_wipe :=
endif
# Traditionally with non-A/B OTA we have:
# boot.img + recovery-from-boot.p + recovery-resource.dat = recovery.img.
# recovery-resource.dat is needed only if we carry an imgdiff patch of the boot and recovery images
# and invoke install-recovery.sh on the first boot post an OTA update.
#
# We no longer need that if one of the following conditions holds:
# a) We carry a full copy of the recovery image - no patching needed
# (BOARD_USES_FULL_RECOVERY_IMAGE = true);
# b) We build a single image that contains boot and recovery both - no recovery image to install
# (BOARD_USES_RECOVERY_AS_BOOT = true);
# c) We include the recovery DTBO image within recovery - not needing the resource file as we
# do bsdiff because boot and recovery will contain different number of entries
# (BOARD_INCLUDE_RECOVERY_DTBO = true).
# d) We include the recovery ACPIO image within recovery - not needing the resource file as we
# do bsdiff because boot and recovery will contain different number of entries
# (BOARD_INCLUDE_RECOVERY_ACPIO = true).
# e) We build a single image that contains vendor_boot and recovery both - no recovery image to
# install
# (BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT = true).
ifeq (,$(filter true, $(BOARD_USES_FULL_RECOVERY_IMAGE) $(BOARD_USES_RECOVERY_AS_BOOT) \
$(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO) \
$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
# Named '.dat' so we don't attempt to use imgdiff for patching it.
RECOVERY_RESOURCE_ZIP := $(TARGET_OUT_VENDOR)/etc/recovery-resource.dat
ALL_DEFAULT_INSTALLED_MODULES += $(RECOVERY_RESOURCE_ZIP)
else
RECOVERY_RESOURCE_ZIP :=
endif
INSTALLED_RECOVERY_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/prop.default
$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): PRIVATE_RECOVERY_UI_PROPERTIES := \
TARGET_RECOVERY_UI_ANIMATION_FPS:animation_fps \
TARGET_RECOVERY_UI_MARGIN_HEIGHT:margin_height \
TARGET_RECOVERY_UI_MARGIN_WIDTH:margin_width \
TARGET_RECOVERY_UI_MENU_UNUSABLE_ROWS:menu_unusable_rows \
TARGET_RECOVERY_UI_PROGRESS_BAR_BASELINE:progress_bar_baseline \
TARGET_RECOVERY_UI_TOUCH_LOW_THRESHOLD:touch_low_threshold \
TARGET_RECOVERY_UI_TOUCH_HIGH_THRESHOLD:touch_high_threshold \
TARGET_RECOVERY_UI_VR_STEREO_OFFSET:vr_stereo_offset \
TARGET_RECOVERY_UI_BRIGHTNESS_FILE:brightness_file \
TARGET_RECOVERY_UI_MAX_BRIGHTNESS_FILE:max_brightness_file \
TARGET_RECOVERY_UI_BRIGHTNESS_NORMAL:brightness_normal_percent \
TARGET_RECOVERY_UI_BRIGHTNESS_DIMMED:brightness_dimmed_percent
# Parses the given list of build variables and writes their values as build properties if defined.
# For example, if a target defines `TARGET_RECOVERY_UI_MARGIN_HEIGHT := 100`,
# `ro.recovery.ui.margin_height=100` will be appended to the given output file.
# $(1): Map from the build variable names to property names
# $(2): Output file
define append-recovery-ui-properties
echo "#" >> $(2)
echo "# RECOVERY UI BUILD PROPERTIES" >> $(2)
echo "#" >> $(2)
$(foreach prop,$(1), \
$(eval _varname := $(call word-colon,1,$(prop))) \
$(eval _propname := $(call word-colon,2,$(prop))) \
$(eval _value := $($(_varname))) \
$(if $(_value), \
echo ro.recovery.ui.$(_propname)=$(_value) >> $(2) &&)) true
endef
$(INSTALLED_RECOVERY_BUILD_PROP_TARGET): \
$(INSTALLED_BUILD_PROP_TARGET) \
$(INSTALLED_VENDOR_BUILD_PROP_TARGET) \
$(INSTALLED_ODM_BUILD_PROP_TARGET) \
$(INSTALLED_PRODUCT_BUILD_PROP_TARGET) \
$(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET)
@echo "Target recovery buildinfo: $@"
$(hide) mkdir -p $(dir $@)
$(hide) rm -f $@
$(hide) cat $(INSTALLED_BUILD_PROP_TARGET) >> $@
$(hide) cat $(INSTALLED_VENDOR_BUILD_PROP_TARGET) >> $@
$(hide) cat $(INSTALLED_ODM_BUILD_PROP_TARGET) >> $@
$(hide) cat $(INSTALLED_PRODUCT_BUILD_PROP_TARGET) >> $@
$(hide) cat $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET) >> $@
$(call append-recovery-ui-properties,$(PRIVATE_RECOVERY_UI_PROPERTIES),$@)
$(call declare-1p-target,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),build)
$(call declare-license-deps,$(INSTALLED_RECOVERY_BUILD_PROP_TARGET),\
$(INSTALLED_BUILD_PROP_TARGET) $(INSTALLED_VENDOR_BUILD_PROP_TARGET) $(INSTALLED_ODM_BUILD_PROP_TARGET) \
$(INSTALLED_PRODUCT_BUILD_PROP_TARGET) $(INSTALLED_SYSTEM_EXT_BUILD_PROP_TARGET))
# Only install boot/etc/build.prop to recovery image on recovery_as_boot.
# On device with dedicated recovery partition, the file should come from the boot
# ramdisk.
ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET := $(TARGET_RECOVERY_ROOT_OUT)/$(RAMDISK_BUILD_PROP_REL_PATH)
$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET): $(INSTALLED_RAMDISK_BUILD_PROP_TARGET)
$(copy-file-to-target)
$(call declare-1p-target,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),build)
$(call declare-license-deps,$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET),$(INSTALLED_RAMDISK_BUILD_PROP_TARGET))
endif
INTERNAL_RECOVERYIMAGE_ARGS := --ramdisk $(recovery_ramdisk)
ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
INTERNAL_RECOVERYIMAGE_ARGS += $(addprefix --second ,$(INSTALLED_2NDBOOTLOADER_TARGET))
# Assumes this has already been stripped
ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
ifdef INTERNAL_KERNEL_CMDLINE
INTERNAL_RECOVERYIMAGE_ARGS += --cmdline "$(INTERNAL_KERNEL_CMDLINE)"
endif # INTERNAL_KERNEL_CMDLINE != ""
endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
ifdef BOARD_KERNEL_BASE
INTERNAL_RECOVERYIMAGE_ARGS += --base $(BOARD_KERNEL_BASE)
endif
ifdef BOARD_KERNEL_PAGESIZE
INTERNAL_RECOVERYIMAGE_ARGS += --pagesize $(BOARD_KERNEL_PAGESIZE)
endif
ifdef BOARD_INCLUDE_RECOVERY_DTBO
ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
else
INTERNAL_RECOVERYIMAGE_ARGS += --recovery_dtbo $(BOARD_PREBUILT_DTBOIMAGE)
endif
endif # BOARD_INCLUDE_RECOVERY_DTBO
ifdef BOARD_INCLUDE_RECOVERY_ACPIO
INTERNAL_RECOVERYIMAGE_ARGS += --recovery_acpio $(BOARD_RECOVERY_ACPIO)
endif
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
INTERNAL_RECOVERYIMAGE_ARGS += --dtb $(INSTALLED_DTBIMAGE_TARGET)
endif
endif # (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
ifndef BOARD_RECOVERY_MKBOOTIMG_ARGS
BOARD_RECOVERY_MKBOOTIMG_ARGS := $(BOARD_MKBOOTIMG_ARGS)
endif
$(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP): $(MKBOOTFS) $(COMPRESSION_COMMAND_DEPS) \
$(INTERNAL_ROOT_FILES) \
$(INSTALLED_RAMDISK_TARGET) \
$(INTERNAL_RECOVERYIMAGE_FILES) \
$(recovery_sepolicy) \
$(INSTALLED_2NDBOOTLOADER_TARGET) \
$(INSTALLED_RECOVERY_BUILD_PROP_TARGET) \
$(INSTALLED_RECOVERY_RAMDISK_BUILD_PROP_TARGET) \
$(recovery_resource_deps) \
$(recovery_fstab)
# Making recovery image
mkdir -p $(TARGET_RECOVERY_OUT)
mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/sdcard $(TARGET_RECOVERY_ROOT_OUT)/tmp
# Copying baseline ramdisk...
# Use rsync because "cp -Rf" fails to overwrite broken symlinks on Mac.
rsync -a --exclude=sdcard $(IGNORE_RECOVERY_SEPOLICY) $(IGNORE_CACHE_LINK) $(TARGET_ROOT_OUT) $(TARGET_RECOVERY_OUT)
# Modifying ramdisk contents...
ln -sf /system/bin/init $(TARGET_RECOVERY_ROOT_OUT)/init
# Removes $(TARGET_RECOVERY_ROOT_OUT)/init*.rc EXCEPT init.recovery*.rc.
find $(TARGET_RECOVERY_ROOT_OUT) -maxdepth 1 -name 'init*.rc' -type f -not -name "init.recovery.*.rc" | xargs rm -f
cp $(TARGET_ROOT_OUT)/init.recovery.*.rc $(TARGET_RECOVERY_ROOT_OUT)/ 2> /dev/null || true # Ignore error when the src file doesn't exist.
mkdir -p $(TARGET_RECOVERY_ROOT_OUT)/res
rm -rf $(TARGET_RECOVERY_ROOT_OUT)/res/*
cp -rf $(recovery_resources_common)/* $(TARGET_RECOVERY_ROOT_OUT)/res
$(foreach recovery_text_file,$(generated_recovery_text_files), \
cp -rf $(recovery_text_file) $(TARGET_RECOVERY_ROOT_OUT)/res/images/ &&) true
cp -f $(recovery_font) $(TARGET_RECOVERY_ROOT_OUT)/res/images/font.png
$(foreach item,$(TARGET_PRIVATE_RES_DIRS), \
cp -rf $(item) $(TARGET_RECOVERY_ROOT_OUT)/$(newline))
$(foreach item,$(recovery_fstab), \
cp -f $(item) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab)
$(if $(strip $(recovery_wipe)), \
cp -f $(recovery_wipe) $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.wipe)
ln -sf prop.default $(TARGET_RECOVERY_ROOT_OUT)/default.prop
# Silence warnings in first_stage_console.
touch $(TARGET_RECOVERY_ROOT_OUT)/linkerconfig/ld.config.txt
$(BOARD_RECOVERY_IMAGE_PREPARE)
$(hide) touch $@
$(recovery_ramdisk): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
$(MKBOOTFS) -d $(TARGET_OUT) $(TARGET_RECOVERY_ROOT_OUT) | $(COMPRESSION_COMMAND) > $(recovery_ramdisk)
# $(1): output file
# $(2): optional kernel file
define build-recoveryimage-target
$(MKBOOTIMG) $(if $(strip $(2)),--kernel $(strip $(2))) $(INTERNAL_RECOVERYIMAGE_ARGS) \
$(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
$(BOARD_RECOVERY_MKBOOTIMG_ARGS) --output $(1)
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),boot))), \
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE))))
$(if $(filter true,$(BOARD_AVB_ENABLE)), \
$(if $(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)), \
$(AVBTOOL) add_hash_footer --image $(1) $(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),boot)) --partition_name boot $(INTERNAL_AVB_BOOT_SIGNING_ARGS) $(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS),\
$(AVBTOOL) add_hash_footer --image $(1) $(call get-partition-size-argument,$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)) --partition_name recovery $(INTERNAL_AVB_RECOVERY_SIGNING_ARGS) $(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)))
endef
recoveryimage-deps := $(MKBOOTIMG) $(recovery_ramdisk) $(recovery_kernel)
ifeq (true,$(BOARD_AVB_ENABLE))
recoveryimage-deps += $(AVBTOOL) $(BOARD_AVB_BOOT_KEY_PATH)
endif
ifdef BOARD_INCLUDE_RECOVERY_DTBO
ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
recoveryimage-deps += $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE)
else
recoveryimage-deps += $(BOARD_PREBUILT_DTBOIMAGE)
endif
endif
ifdef BOARD_INCLUDE_RECOVERY_ACPIO
recoveryimage-deps += $(BOARD_RECOVERY_ACPIO)
endif
ifdef BOARD_INCLUDE_DTB_IN_BOOTIMG
recoveryimage-deps += $(INSTALLED_DTBIMAGE_TARGET)
endif
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET), $(eval $(call add-dependency,$(b),$(call bootimage-to-kernel,$(b)))))
$(INSTALLED_BOOTIMAGE_TARGET): $(recoveryimage-deps)
$(call pretty,"Target boot image from recovery: $@")
$(call build-recoveryimage-target, $@, $(PRODUCT_OUT)/$(subst .img,,$(subst boot,kernel,$(notdir $@))))
$(call declare-container-license-metadata,$(INSTALLED_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",bool)
$(call declare-container-license-deps,$(INSTALLED_BOOTIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_BOOTIMAGE_TARGET)
endif # BOARD_USES_RECOVERY_AS_BOOT
$(INSTALLED_RECOVERYIMAGE_TARGET): $(recoveryimage-deps)
$(call build-recoveryimage-target, $@, \
$(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
ifdef RECOVERY_RESOURCE_ZIP
$(RECOVERY_RESOURCE_ZIP): $(INSTALLED_RECOVERYIMAGE_TARGET) | $(ZIPTIME)
$(hide) mkdir -p $(dir $@)
$(hide) find $(TARGET_RECOVERY_ROOT_OUT)/res -type f | sort | zip -0qrjX $@ -@
$(remove-timestamps-from-package)
endif
$(call declare-1p-container,$(INSTALLED_RECOVERYIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_RECOVERYIMAGE_TARGET),$(recoveryimage-deps),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_RECOVERYIMAGE_TARGET)
.PHONY: recoveryimage-nodeps
recoveryimage-nodeps:
@echo "make $@: ignoring dependencies"
$(call build-recoveryimage-target, $(INSTALLED_RECOVERYIMAGE_TARGET), \
$(if $(filter true, $(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE)),, $(recovery_kernel)))
else # BUILDING_RECOVERY_IMAGE
RECOVERY_RESOURCE_ZIP :=
endif # BUILDING_RECOVERY_IMAGE
.PHONY: recoveryimage
recoveryimage: $(INSTALLED_RECOVERYIMAGE_TARGET) $(RECOVERY_RESOURCE_ZIP)
ifneq ($(BOARD_NAND_PAGE_SIZE),)
$(error MTD device is no longer supported and thus BOARD_NAND_PAGE_SIZE is deprecated.)
endif
ifneq ($(BOARD_NAND_SPARE_SIZE),)
$(error MTD device is no longer supported and thus BOARD_NAND_SPARE_SIZE is deprecated.)
endif
recovery_intermediates := $(call intermediates-dir-for,PACKAGING,recovery)
$(eval $(call write-partition-file-list,$(recovery_intermediates)/file_list.txt,$(TARGET_RECOVERY_OUT),$(INTERNAL_RECOVERYIMAGE_FILES)))
# -----------------------------------------------------------------
# Build debug ramdisk and debug boot image.
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifneq ($(BUILDING_DEBUG_BOOT_IMAGE)$(BUILDING_DEBUG_VENDOR_BOOT_IMAGE),)
INTERNAL_DEBUG_RAMDISK_FILES := $(filter $(TARGET_DEBUG_RAMDISK_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
# Directories to be picked into the debug ramdisk.
# As these directories are all merged into one single cpio archive, the order
# matters. If there are multiple files with the same pathname, then the last one
# wins.
#
# ramdisk-debug.img will merge the content from either ramdisk.img or
# ramdisk-recovery.img, depending on whether BOARD_USES_RECOVERY_AS_BOOT
# is set or not.
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RECOVERY_ROOT_OUT)
INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(recovery_ramdisk)
else # BOARD_USES_RECOVERY_AS_BOOT == true
INTERNAL_DEBUG_RAMDISK_SRC_DIRS := $(TARGET_RAMDISK_OUT)
INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET := $(INSTALLED_RAMDISK_TARGET)
endif # BOARD_USES_RECOVERY_AS_BOOT != true
INTERNAL_DEBUG_RAMDISK_SRC_DIRS += $(TARGET_DEBUG_RAMDISK_OUT)
INTERNAL_DEBUG_RAMDISK_SRC_DEPS := $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET) $(INTERNAL_DEBUG_RAMDISK_FILES)
# INSTALLED_FILES_FILE_DEBUG_RAMDISK would ensure TARGET_DEBUG_RAMDISK_OUT is created.
INSTALLED_FILES_FILE_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-ramdisk-debug.txt
INSTALLED_FILES_JSON_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK:.txt=.json)
$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_DEBUG_RAMDISK)
$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(INTERNAL_DEBUG_RAMDISK_SRC_DEPS)
$(INSTALLED_FILES_FILE_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
@echo "Installed file list: $@"
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@) $(TARGET_DEBUG_RAMDISK_OUT)
touch $(TARGET_DEBUG_RAMDISK_OUT)/force_debuggable
$(FILESLIST) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_DEBUG_RAMDISK)))
$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_DEBUG_RAMDISK)))
ifdef BUILDING_DEBUG_BOOT_IMAGE
# -----------------------------------------------------------------
# the debug ramdisk, which is the original ramdisk plus additional
# files: force_debuggable, adb_debug.prop and userdebug sepolicy.
# When /force_debuggable is present, /init will load userdebug sepolicy
# and property files to allow adb root, if the device is unlocked.
INSTALLED_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-debug.img
$(INSTALLED_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
$(INSTALLED_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
@echo "Target debug ramdisk: $@"
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@)
$(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
$(call declare-1p-container,$(INSTALLED_DEBUG_RAMDISK_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_RAMDISK_TARGET)
.PHONY: ramdisk_debug-nodeps
ramdisk_debug-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
@echo "make $@: ignoring dependencies"
$(hide) rm -f $(INSTALLED_DEBUG_RAMDISK_TARGET)
$(hide) mkdir -p $(dir $(INSTALLED_DEBUG_RAMDISK_TARGET)) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS)
$(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_DEBUG_RAMDISK_TARGET)
# -----------------------------------------------------------------
# the boot-debug.img, which is the kernel plus ramdisk-debug.img
#
# Note: it's intentional to skip signing for boot-debug.img, because it
# can only be used if the device is unlocked with verification error.
ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-debug,$(BOARD_KERNEL_BINARIES)), \
$(PRODUCT_OUT)/$(k).img)
else
INSTALLED_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-debug.img
endif
# Replace ramdisk.img in $(MKBOOTIMG) ARGS with ramdisk-debug.img to build boot-debug.img
$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(INSTALLED_DEBUG_RAMDISK_TARGET)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_RECOVERYIMAGE_ARGS))
else
INTERNAL_DEBUG_BOOTIMAGE_ARGS := $(subst $(INTERNAL_DEBUG_RAMDISK_SRC_RAMDISK_TARGET),$(INSTALLED_DEBUG_RAMDISK_TARGET),$(INTERNAL_BOOTIMAGE_ARGS))
endif
# If boot.img is chained but boot-debug.img is not signed, libavb in bootloader
# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
# Using a test key to sign boot-debug.img to continue booting with the mismatched
# public key, if the device is unlocked.
ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
endif
BOARD_AVB_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_BOOT_TEST_KEY_PATH)
# $(1): the bootimage to sign
# $(2): boot image variant (boot, boot-debug, boot-test-harness)
define test-key-sign-bootimage
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(call get-bootimage-partition-size,$(1),$(2))))
$(AVBTOOL) add_hash_footer \
--image $(1) \
$(call get-partition-size-argument,$(call get-bootimage-partition-size,$(1),$(2)))\
--partition_name boot $(INTERNAL_AVB_BOOT_TEST_SIGNING_ARGS) \
$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)
$(call assert-max-image-size,$(1),$(call get-bootimage-partition-size,$(1),$(2)))
endef
# $(1): output file
define build-debug-bootimage-target
$(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-debug,kernel,$(notdir $(1)))) \
$(INTERNAL_DEBUG_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
$(BOARD_MKBOOTIMG_ARGS) --output $1
$(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$1,boot-debug))
endef
# Depends on original boot.img and ramdisk-debug.img, to build the new boot-debug.img
$(INSTALLED_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_BOOTIMAGE_TARGET) $(AVBTOOL)
$(call pretty,"Target boot debug image: $@")
$(call build-debug-bootimage-target, $@)
$(call declare-container-license-metadata,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),SPDX-license-identifier-GPL-2.0-only SPDX-license-identifier-Apache-2.0,restricted notice,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING build/soong/licenses/LICENSE,"Boot Image",boot)
$(call declare-container-license-deps,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(INSTALLED_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_DEBUG_BOOTIMAGE_TARGET)
.PHONY: bootimage_debug-nodeps
bootimage_debug-nodeps: $(MKBOOTIMG) $(AVBTOOL)
echo "make $@: ignoring dependencies"
$(foreach b,$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(call build-debug-bootimage-target,$b))
endif # BUILDING_DEBUG_BOOT_IMAGE
# -----------------------------------------------------------------
# vendor debug ramdisk
# Combines vendor ramdisk files and debug ramdisk files to build the vendor debug ramdisk.
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
INTERNAL_VENDOR_DEBUG_RAMDISK_FILES := $(filter $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES))
# The debug vendor ramdisk combines vendor ramdisk and debug ramdisk.
INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS := $(TARGET_VENDOR_RAMDISK_OUT)
INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS := $(INTERNAL_VENDOR_RAMDISK_TARGET)
# Exclude recovery files in the default vendor ramdisk if including a standalone
# recovery ramdisk in vendor_boot.
ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_RECOVERY_ROOT_OUT)
INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
endif # BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT != true
endif # BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT == true
INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS += $(TARGET_VENDOR_DEBUG_RAMDISK_OUT) $(TARGET_DEBUG_RAMDISK_OUT)
INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS += $(INTERNAL_VENDOR_DEBUG_RAMDISK_FILES) $(INSTALLED_FILES_FILE_DEBUG_RAMDISK)
# INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK would ensure TARGET_VENDOR_DEBUG_RAMDISK_OUT is created.
INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK := $(PRODUCT_OUT)/installed-files-vendor-ramdisk-debug.txt
INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK:.txt=.json)
$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK)
$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DEPS)
$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK): $(FILESLIST) $(FILESLIST_UTIL)
@echo "Installed file list: $@"
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@) $(TARGET_VENDOR_DEBUG_RAMDISK_OUT)
$(FILESLIST) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DEBUG_RAMDISK))
INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-debug)/vendor_ramdisk-debug.cpio$(RAMDISK_EXT)
$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK)
$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@)
$(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-debug.img
$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET): $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
@echo "Target debug vendor ramdisk: $@"
$(copy-file-to-target)
$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_RAMDISK_TARGET)
# -----------------------------------------------------------------
# vendor_boot-debug.img.
INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-debug.img
# The util to sign vendor_boot-debug.img with a test key.
BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH := external/avb/test/data/testkey_rsa2048.pem
INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS := --algorithm SHA256_RSA2048 --key $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
# $(1): the vendor bootimage to sign
define test-key-sign-vendor-bootimage
$(call assert-max-image-size,$(1),$(call get-hash-image-max-size,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)))
$(AVBTOOL) add_hash_footer \
--image $(1) \
$(call get-partition-size-argument,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)) \
--partition_name vendor_boot $(INTERNAL_AVB_VENDOR_BOOT_TEST_SIGNING_ARGS) \
$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)
$(call assert-max-image-size,$(1),$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
endef
ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
endif
# Depends on vendor_boot.img and vendor-ramdisk-debug.cpio.gz to build the new vendor_boot-debug.img
$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET)
$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
$(call pretty,"Target vendor_boot debug image: $@")
$(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
$(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
$(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
$(call declare-1p-container,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_DEBUG_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_DEBUG_BOOTIMAGE_TARGET)
endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
# Appends a few test harness specific properties into the adb_debug.prop.
ADDITIONAL_TEST_HARNESS_PROPERTIES := ro.audio.silent=1
ADDITIONAL_TEST_HARNESS_PROPERTIES += ro.test_harness=1
INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET := $(strip $(filter $(TARGET_DEBUG_RAMDISK_OUT)/adb_debug.prop,$(INTERNAL_DEBUG_RAMDISK_FILES)))
INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET := $(TARGET_TEST_HARNESS_RAMDISK_OUT)/adb_debug.prop
$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET): $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET)
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@)
ifdef INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET
$(hide) cp $(INTERNAL_DEBUG_RAMDISK_ADB_DEBUG_PROP_TARGET) $@
endif
$(hide) echo "" >> $@
$(hide) echo "#" >> $@
$(hide) echo "# ADDITIONAL TEST HARNESS PROPERTIES" >> $@
$(hide) echo "#" >> $@
$(hide) $(foreach line,$(ADDITIONAL_TEST_HARNESS_PROPERTIES), \
echo "$(line)" >> $@;)
$(call declare-1p-target,$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET))
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
INTERNAL_TEST_HARNESS_RAMDISK_FILES := $(filter $(TARGET_TEST_HARNESS_RAMDISK_OUT)/%, \
$(INTERNAL_TEST_HARNESS_RAMDISK_ADB_DEBUG_PROP_TARGET) \
$(ALL_DEFAULT_INSTALLED_MODULES))
# The order is important here. The test harness ramdisk staging directory has to
# come last so that it can override the adb_debug.prop in the debug ramdisk
# staging directory.
INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
ifdef BUILDING_DEBUG_BOOT_IMAGE
# -----------------------------------------------------------------
# The test harness ramdisk, which is based off debug_ramdisk, plus a
# few additional test-harness-specific properties in adb_debug.prop.
INSTALLED_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/ramdisk-test-harness.img
$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS)
$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
@echo "Target test harness ramdisk: $@"
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@)
$(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DEPS),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
.PHONY: ramdisk_test_harness-nodeps
ramdisk_test_harness-nodeps: $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
@echo "make $@: ignoring dependencies"
$(hide) rm -f $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
$(hide) mkdir -p $(dir $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS)
$(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
# -----------------------------------------------------------------
# the boot-test-harness.img, which is the kernel plus ramdisk-test-harness.img
#
# Note: it's intentional to skip signing for boot-test-harness.img, because it
# can only be used if the device is unlocked with verification error.
ifneq ($(strip $(BOARD_KERNEL_BINARIES)),)
INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(foreach k,$(subst kernel,boot-test-harness,$(BOARD_KERNEL_BINARIES)), \
$(PRODUCT_OUT)/$(k).img)
else
INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/boot-test-harness.img
endif
# Replace ramdisk-debug.img in $(MKBOOTIMG) ARGS with ramdisk-test-harness.img to build boot-test-harness.img
$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(INSTALLED_TEST_HARNESS_RAMDISK_TARGET)
INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS := $(subst $(INSTALLED_DEBUG_RAMDISK_TARGET),$(INSTALLED_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_DEBUG_BOOTIMAGE_ARGS))
# If boot.img is chained but boot-test-harness.img is not signed, libavb in bootloader
# will fail to find valid AVB metadata from the end of /boot, thus stop booting.
# Using a test key to sign boot-test-harness.img to continue booting with the mismatched
# public key, if the device is unlocked.
ifneq ($(BOARD_AVB_BOOT_KEY_PATH),)
$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_BOOT_TEST_KEY_PATH)
endif
# $(1): output file
define build-boot-test-harness-target
$(MKBOOTIMG) --kernel $(PRODUCT_OUT)/$(subst .img,,$(subst boot-test-harness,kernel,$(notdir $(1)))) \
$(INTERNAL_TEST_HARNESS_BOOTIMAGE_ARGS) $(INTERNAL_MKBOOTIMG_VERSION_ARGS) \
$(BOARD_MKBOOTIMG_ARGS) --output $@
$(if $(BOARD_AVB_BOOT_KEY_PATH),$(call test-key-sign-bootimage,$@,boot-test-harness))
endef
# Build the new boot-test-harness.img, based on boot-debug.img and ramdisk-test-harness.img.
$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_DEBUG_BOOTIMAGE_TARGET) $(AVBTOOL)
$(call pretty,"Target boot test harness image: $@")
$(call build-boot-test-harness-target,$@)
$(call declare-1p-container,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(INSTALLED_DEBUG_BOOTIMAGE_TARGET),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET)
.PHONY: bootimage_test_harness-nodeps
bootimage_test_harness-nodeps: $(MKBOOTIMG) $(AVBTOOL)
echo "make $@: ignoring dependencies"
$(foreach b,$(INSTALLED_TEST_HARNESS_BOOTIMAGE_TARGET),$(call build-boot-test-harness-target,$b))
endif # BUILDING_DEBUG_BOOT_IMAGE
# -----------------------------------------------------------------
# vendor test harness ramdisk, which is a vendor ramdisk combined with
# a test harness ramdisk.
ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(call intermediates-dir-for,PACKAGING,vendor_boot-test-harness)/vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT)
# The order is important here. The test harness ramdisk staging directory has to
# come last so that it can override the adb_debug.prop in the debug ramdisk
# staging directory.
INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS := $(INTERNAL_DEBUG_VENDOR_RAMDISK_SRC_DIRS) $(TARGET_TEST_HARNESS_RAMDISK_OUT)
INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS := $(INSTALLED_FILES_FILE_VENDOR_DEBUG_RAMDISK) $(INTERNAL_TEST_HARNESS_RAMDISK_FILES)
$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DEPS)
$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(MKBOOTFS) | $(COMPRESSION_COMMAND_DEPS)
$(hide) rm -f $@
$(hide) mkdir -p $(dir $@)
$(MKBOOTFS) -d $(TARGET_OUT) $(INTERNAL_TEST_HARNESS_VENDOR_RAMDISK_SRC_DIRS) | $(COMPRESSION_COMMAND) > $@
INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET := $(PRODUCT_OUT)/vendor_ramdisk-test-harness.img
$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
@echo "Target test harness vendor ramdisk: $@"
$(copy-file-to-target)
$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
# -----------------------------------------------------------------
# vendor_boot-test-harness.img.
INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET := $(PRODUCT_OUT)/vendor_boot-test-harness.img
ifneq ($(BOARD_AVB_VENDOR_BOOT_KEY_PATH),)
$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(AVBTOOL) $(BOARD_AVB_VENDOR_BOOT_TEST_KEY_PATH)
endif
# Depends on vendor_boot.img and vendor_ramdisk-test-harness.cpio$(RAMDISK_EXT) to build the new vendor_boot-test-harness.img
$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(MKBOOTIMG) $(INSTALLED_VENDOR_BOOTIMAGE_TARGET)
$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET)
$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
$(call pretty,"Target vendor_boot test harness image: $@")
$(MKBOOTIMG) $(INTERNAL_VENDOR_BOOTIMAGE_ARGS) $(BOARD_MKBOOTIMG_ARGS) --vendor_ramdisk $(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_ARGS) --vendor_boot $@
$(call assert-max-image-size,$@,$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE))
$(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),$(call test-key-sign-vendor-bootimage,$@))
$(call declare-1p-container,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET),$(INTERNAL_VENDOR_TEST_HARNESS_RAMDISK_TARGET),$(PRODUCT_OUT)/:/)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDOR_TEST_HARNESS_BOOTIMAGE_TARGET)
endif # BUILDING_DEBUG_VENDOR_BOOT_IMAGE
endif # BUILDING_DEBUG_BOOT_IMAGE || BUILDING_DEBUG_VENDOR_BOOT_IMAGE
PARTITION_COMPAT_SYMLINKS :=
# Creates a compatibility symlink between two partitions, e.g. /system/vendor to /vendor
# $1: from location (e.g $(TARGET_OUT)/vendor)
# $2: destination location (e.g. /vendor)
# $3: partition image name (e.g. vendor.img)
define create-partition-compat-symlink
$(eval \
$1:
@echo Symlink $(patsubst $(PRODUCT_OUT)/%,%,$1) to $2
mkdir -p $(dir $1)
if [ -d $1 ] && [ ! -h $1 ]; then \
echo 'Non-symlink $1 detected!' 1>&2; \
echo 'You cannot install files to $1 while building a separate $3!' 1>&2; \
exit 1; \
fi
ln -sfn $2 $1
)
$(eval PARTITION_COMPAT_SYMLINKS += $1)
$1
endef
# FSVerity metadata generation
# Generate fsverity metadata files (.fsv_meta) and build manifest
# (/etc/security/fsverity/BuildManifest.apk) BEFORE filtering systemimage,
# vendorimage, odmimage, productimage files below.
ifeq ($(PRODUCT_FSVERITY_GENERATE_METADATA),true)
fsverity-metadata-targets-patterns := \
$(TARGET_OUT)/framework/% \
$(TARGET_OUT)/etc/boot-image.prof \
$(TARGET_OUT)/etc/dirty-image-objects \
$(TARGET_OUT)/etc/preloaded-classes \
$(TARGET_OUT)/etc/classpaths/%.pb \
ifdef BUILDING_SYSTEM_EXT_IMAGE
fsverity-metadata-targets-patterns += $(TARGET_OUT_SYSTEM_EXT)/framework/%
endif
# Generate fsv_meta
fsverity-metadata-targets := $(sort $(filter \
$(fsverity-metadata-targets-patterns), \
$(ALL_DEFAULT_INSTALLED_MODULES)))
define fsverity-generate-metadata
$(call declare-0p-target,$(1).fsv_meta)
$(1).fsv_meta: PRIVATE_SRC := $(1)
$(1).fsv_meta: PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
$(1).fsv_meta: $(HOST_OUT_EXECUTABLES)/fsverity_metadata_generator $(HOST_OUT_EXECUTABLES)/fsverity $(1)
$$< --fsverity-path $$(PRIVATE_FSVERITY) --signature none \
--hash-alg sha256 --output $$@ $$(PRIVATE_SRC)
endef
$(foreach f,$(fsverity-metadata-targets),$(eval $(call fsverity-generate-metadata,$(f))))
ALL_DEFAULT_INSTALLED_MODULES += $(addsuffix .fsv_meta,$(fsverity-metadata-targets))
FSVERITY_APK_KEY_PATH := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
FSVERITY_APK_MANIFEST_TEMPLATE_PATH := system/security/fsverity/AndroidManifest.xml
# Generate and install BuildManifest.apk for the given partition
# $(1): path of the output APK
# $(2): partition name
define fsverity-generate-and-install-manifest-apk
fsverity-metadata-targets-$(2) := $(filter $(PRODUCT_OUT)/$(2)/%,\
$(fsverity-metadata-targets))
$(1): PRIVATE_FSVERITY := $(HOST_OUT_EXECUTABLES)/fsverity
$(1): PRIVATE_AAPT2 := $(HOST_OUT_EXECUTABLES)/aapt2
$(1): PRIVATE_MIN_SDK_VERSION := $(DEFAULT_APP_TARGET_SDK)
$(1): PRIVATE_VERSION_CODE := $(PLATFORM_SDK_VERSION)
$(1): PRIVATE_VERSION_NAME := $(APPS_DEFAULT_VERSION_NAME)
$(1): PRIVATE_APKSIGNER := $(HOST_OUT_EXECUTABLES)/apksigner
$(1): PRIVATE_MANIFEST := $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH)
$(1): PRIVATE_FRAMEWORK_RES := $(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk
$(1): PRIVATE_KEY := $(FSVERITY_APK_KEY_PATH)
$(1): PRIVATE_INPUTS := $$(fsverity-metadata-targets-$(2))
$(1): PRIVATE_ASSETS := $(call intermediates-dir-for,ETC,build_manifest-$(2))/assets
$(1): $(HOST_OUT_EXECUTABLES)/fsverity_manifest_generator \
$(HOST_OUT_EXECUTABLES)/fsverity $(HOST_OUT_EXECUTABLES)/aapt2 \
$(HOST_OUT_EXECUTABLES)/apksigner $(FSVERITY_APK_MANIFEST_TEMPLATE_PATH) \
$(FSVERITY_APK_KEY_PATH).x509.pem $(FSVERITY_APK_KEY_PATH).pk8 \
$(call intermediates-dir-for,APPS,framework-res,,COMMON)/package-export.apk \
$$(fsverity-metadata-targets-$(2))
rm -rf $$(PRIVATE_ASSETS)
mkdir -p $$(PRIVATE_ASSETS)
$$< --fsverity-path $$(PRIVATE_FSVERITY) \
--base-dir $$(PRODUCT_OUT) \
--output $$(PRIVATE_ASSETS)/build_manifest.pb \
$$(PRIVATE_INPUTS)
$$(PRIVATE_AAPT2) link -o $$@ \
-A $$(PRIVATE_ASSETS) \
-I $$(PRIVATE_FRAMEWORK_RES) \
--min-sdk-version $$(PRIVATE_MIN_SDK_VERSION) \
--version-code $$(PRIVATE_VERSION_CODE) \
--version-name $$(PRIVATE_VERSION_NAME) \
--manifest $$(PRIVATE_MANIFEST) \
--rename-manifest-package com.android.security.fsverity_metadata.$(2)
$$(PRIVATE_APKSIGNER) sign --in $$@ \
--cert $$(PRIVATE_KEY).x509.pem \
--key $$(PRIVATE_KEY).pk8
$(1).idsig: $(1)
ALL_DEFAULT_INSTALLED_MODULES += $(1) $(1).idsig
endef # fsverity-generate-and-install-manifest-apk
$(eval $(call fsverity-generate-and-install-manifest-apk, \
$(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk,system))
ALL_FSVERITY_BUILD_MANIFEST_APK += $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk $(TARGET_OUT)/etc/security/fsverity/BuildManifest.apk.idsig
ifdef BUILDING_SYSTEM_EXT_IMAGE
$(eval $(call fsverity-generate-and-install-manifest-apk, \
$(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk,system_ext))
ALL_FSVERITY_BUILD_MANIFEST_APK += $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk $(TARGET_OUT_SYSTEM_EXT)/etc/security/fsverity/BuildManifestSystemExt.apk.idsig
endif
endif # PRODUCT_FSVERITY_GENERATE_METADATA
# -----------------------------------------------------------------
# system image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_SYSTEM_IMAGE
INTERNAL_SYSTEMIMAGE_FILES := $(sort $(filter $(TARGET_OUT)/%, \
$(ALL_DEFAULT_INSTALLED_MODULES)))
endif
# Create symlink /system/vendor to /vendor if necessary.
ifdef BOARD_USES_VENDORIMAGE
_vendor_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/vendor,/vendor,vendor.img)
INTERNAL_SYSTEMIMAGE_FILES += $(_vendor_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_vendor_symlink)
endif
# Create symlink /system/product to /product if necessary.
ifdef BOARD_USES_PRODUCTIMAGE
_product_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/product,/product,product.img)
INTERNAL_SYSTEMIMAGE_FILES += $(_product_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_product_symlink)
endif
# Create symlink /system/system_ext to /system_ext if necessary.
ifdef BOARD_USES_SYSTEM_EXTIMAGE
_systemext_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/system_ext,/system_ext,system_ext.img)
INTERNAL_SYSTEMIMAGE_FILES += $(_systemext_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_systemext_symlink)
endif
# -----------------------------------------------------------------
# system_dlkm partition image
# Create symlinks for system_dlkm on devices with a system_dlkm partition:
# /system/lib/modules -> /system_dlkm/lib/modules
#
# On devices with a system_dlkm partition,
# - /system/lib/modules is a symlink to a directory that stores system DLKMs.
# - The system_dlkm partition is mounted at /system_dlkm at runtime.
ifdef BOARD_USES_SYSTEM_DLKMIMAGE
_system_dlkm_lib_modules_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT)/lib/modules,/system_dlkm/lib/modules,system_dlkm.img)
INTERNAL_SYSTEMIMAGE_FILES += $(_system_dlkm_lib_modules_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_system_dlkm_lib_modules_symlink)
endif
FULL_SYSTEMIMAGE_DEPS := $(INTERNAL_SYSTEMIMAGE_FILES) $(INTERNAL_USERIMAGES_DEPS)
# ASAN libraries in the system image - add dependency.
ASAN_IN_SYSTEM_INSTALLED := $(TARGET_OUT)/asan.tar.bz2
ifneq (,$(filter address, $(SANITIZE_TARGET)))
ifeq (true,$(SANITIZE_TARGET_SYSTEM))
FULL_SYSTEMIMAGE_DEPS += $(ASAN_IN_SYSTEM_INSTALLED)
endif
endif
FULL_SYSTEMIMAGE_DEPS += $(INTERNAL_ROOT_FILES) $(INSTALLED_FILES_FILE_ROOT)
# -----------------------------------------------------------------
ifdef BUILDING_SYSTEM_IMAGE
# Install system linker configuration
# Collect all available stub libraries installed in system and install with predefined linker configuration
# Also append LLNDK libraries in the APEX as required libs
SYSTEM_LINKER_CONFIG := $(TARGET_OUT)/etc/linker.config.pb
SYSTEM_LINKER_CONFIG_SOURCE := system/core/rootdir/etc/linker.config.json
$(SYSTEM_LINKER_CONFIG): PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE := $(SYSTEM_LINKER_CONFIG_SOURCE)
$(SYSTEM_LINKER_CONFIG): $(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE) | conv_linker_config
@echo Creating linker config: $@
@mkdir -p $(dir $@)
@rm -f $@ $@.step1
$(HOST_OUT_EXECUTABLES)/conv_linker_config proto --force -s $(PRIVATE_SYSTEM_LINKER_CONFIG_SOURCE) -o $@.step1
$(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $@.step1 \
--output $@ --value "$(STUB_LIBRARIES)" --system "$(TARGET_OUT)"
$(HOST_OUT_EXECUTABLES)/conv_linker_config append --source $@ --output $@ --key requireLibs \
--value "$(foreach lib,$(LLNDK_MOVED_TO_APEX_LIBRARIES), $(lib).so)"
$(HOST_OUT_EXECUTABLES)/conv_linker_config append --source $@ --output $@ --key provideLibs \
--value "$(foreach lib,$(PRODUCT_EXTRA_STUB_LIBRARIES), $(lib).so)"
rm -f $@.step1
$(call declare-1p-target,$(SYSTEM_LINKER_CONFIG),)
$(call declare-license-deps,$(SYSTEM_LINKER_CONFIG),$(INTERNAL_SYSTEMIMAGE_FILES) $(SYSTEM_LINKER_CONFIG_SOURCE))
FULL_SYSTEMIMAGE_DEPS += $(SYSTEM_LINKER_CONFIG)
ALL_DEFAULT_INSTALLED_MODULES += $(SYSTEM_LINKER_CONFIG)
# installed file list
# Depending on anything that $(BUILT_SYSTEMIMAGE) depends on.
# We put installed-files.txt ahead of image itself in the dependency graph
# so that we can get the size stat even if the build fails due to too large
# system image.
INSTALLED_FILES_FILE := $(PRODUCT_OUT)/installed-files.txt
INSTALLED_FILES_JSON := $(INSTALLED_FILES_FILE:.txt=.json)
$(INSTALLED_FILES_FILE): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON)
$(INSTALLED_FILES_FILE): $(FULL_SYSTEMIMAGE_DEPS) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE)))
$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON)))
.PHONY: installed-file-list
installed-file-list: $(INSTALLED_FILES_FILE)
systemimage_intermediates :=$= $(call intermediates-dir-for,PACKAGING,system)
BUILT_SYSTEMIMAGE :=$= $(systemimage_intermediates)/system.img
# $(1): output file
define build-systemimage-target
@echo "Target system fs image: $(1)"
@mkdir -p $(dir $(1)) $(systemimage_intermediates) && rm -rf $(systemimage_intermediates)/system_image_info.txt
$(call generate-image-prop-dictionary, $(systemimage_intermediates)/system_image_info.txt,system, \
skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(systemimage_intermediates)/file_list.txt) \
$(TARGET_OUT) $(systemimage_intermediates)/system_image_info.txt $(1) $(TARGET_OUT) \
|| ( mkdir -p $${DIST_DIR}; \
cp $(INSTALLED_FILES_FILE) $${DIST_DIR}/installed-files-rescued.txt; \
exit 1 )
endef
$(eval $(call write-partition-file-list,$(systemimage_intermediates)/file_list.txt,$(TARGET_OUT),$(FULL_SYSTEMIMAGE_DEPS)))
ifneq ($(PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE),)
file_list_diff := $(HOST_OUT_EXECUTABLES)/file_list_diff$(HOST_EXECUTABLE_SUFFIX)
system_file_diff_timestamp := $(systemimage_intermediates)/file_diff.timestamp
# The build configuration to build the REL version may have more files to allow.
# Use allowlist_next in addition to the allowlist in this case.
system_file_diff_allowlist_next :=
ifeq (REL,$(PLATFORM_VERSION_CODENAME))
system_file_diff_allowlist_next := $(ALL_MODULES.system_image_diff_allowlist_next.INSTALLED)
$(system_file_diff_timestamp): PRIVATE_ALLOWLIST_NEXT := $(system_file_diff_allowlist_next)
endif
$(system_file_diff_timestamp): \
$(systemimage_intermediates)/file_list.txt \
$(ALL_MODULES.$(PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE).FILESYSTEM_FILELIST) \
$(ALL_MODULES.system_image_diff_allowlist.INSTALLED) \
$(system_file_diff_allowlist_next) \
$(file_list_diff)
$(file_list_diff) $(systemimage_intermediates)/file_list.txt \
$(ALL_MODULES.$(PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE).FILESYSTEM_FILELIST) \
$(PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE) \
--allowlists $(ALL_MODULES.system_image_diff_allowlist.INSTALLED) \
$(PRIVATE_ALLOWLIST_NEXT)
touch $@
$(BUILT_SYSTEMIMAGE): $(system_file_diff_timestamp)
endif
# Used by soong sandwich to request the staging dir be built
$(systemimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT)/%,$(FULL_SYSTEMIMAGE_DEPS))
touch $@
ifeq ($(BOARD_AVB_ENABLE),true)
$(BUILT_SYSTEMIMAGE): $(BOARD_AVB_SYSTEM_KEY_PATH)
endif
ifeq ($(USE_SOONG_DEFINED_SYSTEM_IMAGE),true)
ifeq ($(PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE),)
$(error PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE must be set if USE_SOONG_DEFINED_SYSTEM_IMAGE is true)
endif
SOONG_DEFINED_SYSTEM_IMAGE_BASE := $(dir $(ALL_MODULES.$(PRODUCT_SOONG_DEFINED_SYSTEM_IMAGE).FILESYSTEM_FILELIST))
$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(systemimage_intermediates)/file_list.txt $(SOONG_DEFINED_SYSTEM_IMAGE_PATH)
$(eval $(call copy-one-file, $(SOONG_DEFINED_SYSTEM_IMAGE_PATH), $(BUILT_SYSTEMIMAGE)))
else
$(BUILT_SYSTEMIMAGE): $(FULL_SYSTEMIMAGE_DEPS) $(INSTALLED_FILES_FILE) $(systemimage_intermediates)/file_list.txt
$(call build-systemimage-target,$@)
endif
$(call declare-1p-container,$(BUILT_SYSTEMIMAGE),system/extras)
$(call declare-container-license-deps,$(BUILT_SYSTEMIMAGE),$(FULL_SYSTEMIMAGE_DEPS),$(PRODUCT_OUT)/:/)
INSTALLED_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/system.img
SYSTEMIMAGE_SOURCE_DIR := $(TARGET_OUT)
# INSTALLED_SYSTEMIMAGE_TARGET used to be named INSTALLED_SYSTEMIMAGE. Create an alias for backward
# compatibility, in case device-specific Makefiles still refer to the old name.
INSTALLED_SYSTEMIMAGE := $(INSTALLED_SYSTEMIMAGE_TARGET)
# The system partition needs room for the recovery image as well. We
# now store the recovery image as a binary patch using the boot image
# as the source (since they are very similar). Generate the patch so
# we can see how big it's going to be, and include that in the system
# image size check calculation.
ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
ifneq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
ifneq (,$(filter true,$(BOARD_INCLUDE_RECOVERY_DTBO) $(BOARD_INCLUDE_RECOVERY_ACPIO)))
diff_tool := $(HOST_OUT_EXECUTABLES)/bsdiff
else
diff_tool := $(HOST_OUT_EXECUTABLES)/imgdiff
endif
intermediates := $(call intermediates-dir-for,PACKAGING,recovery_patch)
RECOVERY_FROM_BOOT_PATCH := $(intermediates)/recovery_from_boot.p
$(RECOVERY_FROM_BOOT_PATCH): PRIVATE_DIFF_TOOL := $(diff_tool)
$(RECOVERY_FROM_BOOT_PATCH): \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(firstword $(INSTALLED_BOOTIMAGE_TARGET)) \
$(diff_tool)
@echo "Construct recovery from boot"
mkdir -p $(dir $@)
$(PRIVATE_DIFF_TOOL) $(firstword $(INSTALLED_BOOTIMAGE_TARGET)) $(INSTALLED_RECOVERYIMAGE_TARGET) $@
else # $(BOARD_USES_FULL_RECOVERY_IMAGE) == true
RECOVERY_FROM_BOOT_PATCH := $(INSTALLED_RECOVERYIMAGE_TARGET)
endif # BOARD_USES_FULL_RECOVERY_IMAGE
endif # INSTALLED_RECOVERYIMAGE_TARGET
endif # INSTALLED_BOOTIMAGE_TARGET
$(INSTALLED_SYSTEMIMAGE_TARGET): $(BUILT_SYSTEMIMAGE)
@echo "Install system fs image: $@"
$(copy-file-to-target)
$(hide) $(call assert-max-image-size,$@,$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
$(call declare-1p-container,$(INSTALLED_SYSTEMIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BUILT_SYSTEMIMAGE),$(BUILT_SYSTEMIMAGE):/)
systemimage: $(INSTALLED_SYSTEMIMAGE_TARGET)
SYSTEM_NOTICE_DEPS += $(INSTALLED_SYSTEMIMAGE_TARGET)
.PHONY: systemimage-nodeps snod
systemimage-nodeps snod: $(filter-out systemimage-nodeps snod,$(MAKECMDGOALS)) \
| $(INTERNAL_USERIMAGES_DEPS) $(systemimage_intermediates)/file_list.txt
@echo "make $@: ignoring dependencies"
$(call build-systemimage-target,$(INSTALLED_SYSTEMIMAGE_TARGET))
$(hide) $(call assert-max-image-size,$(INSTALLED_SYSTEMIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
ifeq (true,$(WITH_DEXPREOPT))
$(warning Warning: with dexpreopt enabled, you may need a full rebuild.)
endif
endif # BUILDING_SYSTEM_IMAGE
.PHONY: sync syncsys sync_system
sync syncsys sync_system: $(INTERNAL_SYSTEMIMAGE_FILES)
# -----------------------------------------------------------------
# Old PDK fusion targets
.PHONY: platform
platform:
echo "Warning: 'platform' is obsolete"
.PHONY: platform-java
platform-java:
echo "Warning: 'platform-java' is obsolete"
# -----------------------------------------------------------------
# data partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_DATA)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_USERDATA_IMAGE
INTERNAL_USERDATAIMAGE_FILES := \
$(filter $(TARGET_OUT_DATA)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
userdataimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,userdata)
BUILT_USERDATAIMAGE_TARGET := $(PRODUCT_OUT)/userdata.img
define build-userdataimage-target
$(call pretty,"Target userdata fs image: $(INSTALLED_USERDATAIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_DATA)
@mkdir -p $(userdataimage_intermediates) && rm -rf $(userdataimage_intermediates)/userdata_image_info.txt
$(call generate-image-prop-dictionary, $(userdataimage_intermediates)/userdata_image_info.txt,userdata,skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(userdataimage_intermediates)/file_list.txt) \
$(TARGET_OUT_DATA) $(userdataimage_intermediates)/userdata_image_info.txt \
$(INSTALLED_USERDATAIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_USERDATAIMAGE_TARGET),$(BOARD_USERDATAIMAGE_PARTITION_SIZE))
endef
# We just build this directly to the install location.
INSTALLED_USERDATAIMAGE_TARGET := $(BUILT_USERDATAIMAGE_TARGET)
INSTALLED_USERDATAIMAGE_TARGET_DEPS := \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_USERDATAIMAGE_FILES)
$(eval $(call write-partition-file-list,$(userdataimage_intermediates)/file_list.txt,$(TARGET_OUT_DATA),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS)))
# Used by soong sandwich to request the staging dir be built
$(userdataimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_DATA)/%,$(INSTALLED_USERDATAIMAGE_TARGET_DEPS))
touch $@
$(INSTALLED_USERDATAIMAGE_TARGET): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS) $(userdataimage_intermediates)/file_list.txt
$(build-userdataimage-target)
$(call declare-1p-container,$(INSTALLED_USERDATAIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_USERDATAIMAGE_TARGET),$(INSTALLED_USERDATAIMAGE_TARGET_DEPS),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_USERDATAIMAGE_TARGET)
.PHONY: userdataimage-nodeps
userdataimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) $(userdataimage_intermediates)/file_list.txt
$(build-userdataimage-target)
endif # BUILDING_USERDATA_IMAGE
# ASAN libraries in the system image - build rule.
ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL := $(sort $(patsubst $(PRODUCT_OUT)/%,%,\
$(TARGET_OUT_SHARED_LIBRARIES) \
$(2ND_TARGET_OUT_SHARED_LIBRARIES) \
$(TARGET_OUT_VENDOR_SHARED_LIBRARIES) \
$(2ND_TARGET_OUT_VENDOR_SHARED_LIBRARIES)))
# Extra options: Enforce the system user for the files to avoid having to change ownership.
ASAN_SYSTEM_INSTALL_OPTIONS := --owner=1000 --group=1000
# Note: experimentally, it seems not worth it to try to get "best" compression. We don't save
# enough space.
$(ASAN_IN_SYSTEM_INSTALLED): $(INSTALLED_USERDATAIMAGE_TARGET_DEPS)
tar cfj $(ASAN_IN_SYSTEM_INSTALLED) $(ASAN_SYSTEM_INSTALL_OPTIONS) -C $(TARGET_OUT_DATA)/.. $(ASAN_OUT_DIRS_FOR_SYSTEM_INSTALL) >/dev/null
# -----------------------------------------------------------------
# cache partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_CACHE)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_CACHE_IMAGE
INTERNAL_CACHEIMAGE_FILES := \
$(filter $(TARGET_OUT_CACHE)/%,$(ALL_DEFAULT_INSTALLED_MODULES))
cacheimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,cache)
BUILT_CACHEIMAGE_TARGET := $(PRODUCT_OUT)/cache.img
define build-cacheimage-target
$(call pretty,"Target cache fs image: $(INSTALLED_CACHEIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_CACHE)
@mkdir -p $(cacheimage_intermediates) && rm -rf $(cacheimage_intermediates)/cache_image_info.txt
$(call generate-image-prop-dictionary, $(cacheimage_intermediates)/cache_image_info.txt,cache,skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(cacheimage_intermediates)/file_list.txt) \
$(TARGET_OUT_CACHE) $(cacheimage_intermediates)/cache_image_info.txt \
$(INSTALLED_CACHEIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_CACHEIMAGE_TARGET),$(BOARD_CACHEIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(cacheimage_intermediates)/file_list.txt,$(TARGET_OUT_CACHE),$(INTERNAL_CACHEIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(cacheimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_CACHE)/%,$(INTERNAL_CACHEIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_CACHEIMAGE_TARGET := $(BUILT_CACHEIMAGE_TARGET)
$(INSTALLED_CACHEIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES) $(cacheimage_intermediates)/file_list.txt
$(build-cacheimage-target)
$(call declare-1p-container,$(INSTALLED_CACHEIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_CACHEIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_CACHEIMAGE_FILES),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS+= $(INSTALLED_CACHEIMAGE_TARGET)
.PHONY: cacheimage-nodeps
cacheimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) $(cacheimage_intermediates)/file_list.txt
$(build-cacheimage-target)
else # BUILDING_CACHE_IMAGE
# we need to ignore the broken cache link when doing the rsync
IGNORE_CACHE_LINK := --exclude=cache
endif # BUILDING_CACHE_IMAGE
# -----------------------------------------------------------------
# system_other partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_OTHER)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_SYSTEM_OTHER_IMAGE
ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
# Marker file to identify that odex files are installed
INSTALLED_SYSTEM_OTHER_ODEX_MARKER := $(TARGET_OUT_SYSTEM_OTHER)/system-other-odex-marker
ALL_DEFAULT_INSTALLED_MODULES += $(INSTALLED_SYSTEM_OTHER_ODEX_MARKER)
$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER):
$(hide) touch $@
$(call declare-0p-target,$(INSTALLED_SYSTEM_OTHER_ODEX_MARKER))
endif
INTERNAL_SYSTEMOTHERIMAGE_FILES := \
$(filter $(TARGET_OUT_SYSTEM_OTHER)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
# system_other dex files are installed as a side-effect of installing system image files
INTERNAL_SYSTEMOTHERIMAGE_FILES += $(INTERNAL_SYSTEMIMAGE_FILES)
INSTALLED_FILES_FILE_SYSTEMOTHER := $(PRODUCT_OUT)/installed-files-system-other.txt
INSTALLED_FILES_JSON_SYSTEMOTHER := $(INSTALLED_FILES_FILE_SYSTEMOTHER:.txt=.json)
$(INSTALLED_FILES_FILE_SYSTEMOTHER): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEMOTHER)
$(INSTALLED_FILES_FILE_SYSTEMOTHER) : $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_SYSTEM_OTHER) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(eval $(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEMOTHER)))
$(eval $(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEMOTHER)))
# Determines partition size for system_other.img.
ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
ifneq ($(filter system,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
INTERNAL_SYSTEM_OTHER_PARTITION_SIZE := $(BOARD_SUPER_PARTITION_SYSTEM_DEVICE_SIZE)
endif
endif
ifndef INTERNAL_SYSTEM_OTHER_PARTITION_SIZE
INTERNAL_SYSTEM_OTHER_PARTITION_SIZE:= $(BOARD_SYSTEMIMAGE_PARTITION_SIZE)
endif
systemotherimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,system_other)
BUILT_SYSTEMOTHERIMAGE_TARGET := $(PRODUCT_OUT)/system_other.img
# Note that we assert the size is SYSTEMIMAGE_PARTITION_SIZE since this is the 'b' system image.
define build-systemotherimage-target
$(call pretty,"Target system_other fs image: $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_SYSTEM_OTHER)
@mkdir -p $(systemotherimage_intermediates) && rm -rf $(systemotherimage_intermediates)/system_other_image_info.txt
$(call generate-image-prop-dictionary, $(systemotherimage_intermediates)/system_other_image_info.txt,system,skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(systemotherimage_intermediates)/file_list.txt) \
$(TARGET_OUT_SYSTEM_OTHER) $(systemotherimage_intermediates)/system_other_image_info.txt \
$(INSTALLED_SYSTEMOTHERIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(BOARD_SYSTEMIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(systemotherimage_intermediates)/file_list.txt,$(TARGET_OUT_SYSTEM_OTHER),$(INTERNAL_SYSTEMOTHERIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(systemotherimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_SYSTEM_OTHER)/%,$(INTERNAL_SYSTEMOTHERIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_SYSTEMOTHERIMAGE_TARGET := $(BUILT_SYSTEMOTHERIMAGE_TARGET)
ifneq (true,$(SANITIZE_LITE))
# Only create system_other when not building the second stage of a SANITIZE_LITE build.
$(INSTALLED_SYSTEMOTHERIMAGE_TARGET): $(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEMOTHER) $(systemotherimage_intermediates)/file_list.txt
$(build-systemotherimage-target)
$(call declare-1p-container,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEMOTHERIMAGE_FILES),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_DEPS += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
endif
.PHONY: systemotherimage-nodeps
systemotherimage-nodeps: | $(INTERNAL_USERIMAGES_DEPS) $(systemotherimage_intermediates)/file_list.txt
$(build-systemotherimage-target)
endif # BUILDING_SYSTEM_OTHER_IMAGE
# -----------------------------------------------------------------
# vendor partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_VENDOR_IMAGE
INTERNAL_VENDORIMAGE_FILES := \
$(filter $(TARGET_OUT_VENDOR)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
# Create symlink /vendor/odm to /odm if necessary.
ifdef BOARD_USES_ODMIMAGE
_odm_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/odm,/odm,odm.img)
INTERNAL_VENDORIMAGE_FILES += $(_odm_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_odm_symlink)
endif
# Create symlinks for vendor_dlkm on devices with a vendor_dlkm partition:
# /vendor/lib/modules -> /vendor_dlkm/lib/modules
#
# On devices with a vendor_dlkm partition,
# - /vendor/lib/modules is a symlink to a directory that stores vendor DLKMs.
# - /vendor_dlkm/{etc,...} store other vendor_dlkm files directly. The vendor_dlkm partition is
# mounted at /vendor_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
# are hidden.
# On devices without a vendor_dlkm partition,
# - /vendor/lib/modules stores vendor DLKMs directly.
# - /vendor_dlkm/{etc,...} are symlinks to directories that store other vendor_dlkm files.
# See system/core/rootdir/Android.mk for a list of created symlinks.
# The vendor DLKMs and other vendor_dlkm files must not be accessed using other paths because they
# are not guaranteed to exist on all devices.
ifdef BOARD_USES_VENDOR_DLKMIMAGE
_vendor_dlkm_lib_modules_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT_VENDOR)/lib/modules,/vendor_dlkm/lib/modules,vendor_dlkm.img)
INTERNAL_VENDORIMAGE_FILES += $(_vendor_dlkm_lib_modules_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_vendor_dlkm_lib_modules_symlink)
endif
# Install vendor/etc/linker.config.pb with PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS and SOONG_STUB_VENDOR_LIBRARIES
vendor_linker_config_file := $(TARGET_OUT_VENDOR)/etc/linker.config.pb
$(vendor_linker_config_file): private_linker_config_fragments := $(PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS)
$(vendor_linker_config_file): $(INTERNAL_VENDORIMAGE_FILES) $(PRODUCT_VENDOR_LINKER_CONFIG_FRAGMENTS) | $(HOST_OUT_EXECUTABLES)/conv_linker_config
@echo Creating linker config: $@
@mkdir -p $(dir $@)
@rm -f $@
$(HOST_OUT_EXECUTABLES)/conv_linker_config proto \
--source $(call normalize-path-list,$(private_linker_config_fragments)) \
--output $@
$(HOST_OUT_EXECUTABLES)/conv_linker_config systemprovide --source $@ \
--output $@ --value "$(SOONG_STUB_VENDOR_LIBRARIES)" --system "$(TARGET_OUT_VENDOR)"
$(call define declare-0p-target,$(vendor_linker_config_file),)
INTERNAL_VENDORIMAGE_FILES += $(vendor_linker_config_file)
ALL_DEFAULT_INSTALLED_MODULES += $(vendor_linker_config_file)
INSTALLED_FILES_FILE_VENDOR := $(PRODUCT_OUT)/installed-files-vendor.txt
INSTALLED_FILES_JSON_VENDOR := $(INSTALLED_FILES_FILE_VENDOR:.txt=.json)
$(INSTALLED_FILES_FILE_VENDOR): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR)
$(INSTALLED_FILES_FILE_VENDOR) : $(INTERNAL_VENDORIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_VENDOR) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR))
vendorimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,vendor)
BUILT_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
define build-vendorimage-target
$(call pretty,"Target vendor fs image: $(INSTALLED_VENDORIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_VENDOR)
@mkdir -p $(vendorimage_intermediates) && rm -rf $(vendorimage_intermediates)/vendor_image_info.txt
$(call generate-image-prop-dictionary, $(vendorimage_intermediates)/vendor_image_info.txt,vendor,skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(vendorimage_intermediates)/file_list.txt) \
$(TARGET_OUT_VENDOR) $(vendorimage_intermediates)/vendor_image_info.txt \
$(INSTALLED_VENDORIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_VENDORIMAGE_TARGET) $(RECOVERY_FROM_BOOT_PATCH),$(BOARD_VENDORIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(vendorimage_intermediates)/file_list.txt,$(TARGET_OUT_VENDOR),$(INTERNAL_VENDORIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(vendorimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_VENDOR)/%,$(INTERNAL_VENDORIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_VENDORIMAGE_TARGET := $(BUILT_VENDORIMAGE_TARGET)
$(INSTALLED_VENDORIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_VENDORIMAGE_FILES) \
$(INSTALLED_FILES_FILE_VENDOR) \
$(RECOVERY_FROM_BOOT_PATCH) \
$(vendorimage_intermediates)/file_list.txt
$(build-vendorimage-target)
VENDOR_NOTICE_DEPS += $(INSTALLED_VENDORIMAGE_TARGET)
$(call declare-container-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)
$(call declare-container-license-deps,$(INSTALLED_VENDORIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDORIMAGE_FILES) $(RECOVERY_FROM_BOOT_PATH),$(PRODUCT_OUT)/:/)
.PHONY: vendorimage-nodeps vnod
vendorimage-nodeps vnod: | $(INTERNAL_USERIMAGES_DEPS) $(vendorimage_intermediates)/file_list.txt
$(build-vendorimage-target)
.PHONY: sync_vendor
sync sync_vendor: $(INTERNAL_VENDORIMAGE_FILES)
else ifdef BOARD_PREBUILT_VENDORIMAGE
INSTALLED_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vendor.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDORIMAGE),$(INSTALLED_VENDORIMAGE_TARGET)))
$(if $(strip $(ALL_TARGETS.$(INSTALLED_VENDORIMAGE_TARGET).META_LIC)),,\
$(if $(strip $(ALL_TARGETS.$(BOARD_PREBUILT_VENDORIMAGE).META_LIC)),\
$(call declare-copy-target-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),$(BOARD_PREBUILT_VENDORIMAGE)),\
$(call declare-license-metadata,$(INSTALLED_VENDORIMAGE_TARGET),legacy_proprietary,proprietary,,"Vendor Image",vendor)))
endif
# -----------------------------------------------------------------
# product partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_PRODUCT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_PRODUCT_IMAGE
INTERNAL_PRODUCTIMAGE_FILES := \
$(filter $(TARGET_OUT_PRODUCT)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
# Install product/etc/linker.config.pb with PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS
product_linker_config_file := $(TARGET_OUT_PRODUCT)/etc/linker.config.pb
$(product_linker_config_file): private_linker_config_fragments := $(PRODUCT_PRODUCT_LINKER_CONFIG_FRAGMENTS)
$(product_linker_config_file): $(INTERNAL_PRODUCTIMAGE_FILES) | $(HOST_OUT_EXECUTABLES)/conv_linker_config
@echo Creating linker config: $@
@mkdir -p $(dir $@)
@rm -f $@
$(HOST_OUT_EXECUTABLES)/conv_linker_config proto \
--source $(call normalize-path-list,$(private_linker_config_fragments)) \
--output $@
$(call define declare-1p-target,$(product_linker_config_file),)
INTERNAL_PRODUCTIMAGE_FILES += $(product_linker_config_file)
ALL_DEFAULT_INSTALLED_MODULES += $(product_linker_config_file)
INSTALLED_FILES_FILE_PRODUCT := $(PRODUCT_OUT)/installed-files-product.txt
INSTALLED_FILES_JSON_PRODUCT := $(INSTALLED_FILES_FILE_PRODUCT:.txt=.json)
$(INSTALLED_FILES_FILE_PRODUCT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_PRODUCT)
$(INSTALLED_FILES_FILE_PRODUCT) : $(INTERNAL_PRODUCTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_PRODUCT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_PRODUCT))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_PRODUCT))
productimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,product)
BUILT_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
define build-productimage-target
$(call pretty,"Target product fs image: $(INSTALLED_PRODUCTIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_PRODUCT)
@mkdir -p $(productimage_intermediates) && rm -rf $(productimage_intermediates)/product_image_info.txt
$(call generate-image-prop-dictionary, $(productimage_intermediates)/product_image_info.txt,product,skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(productimage_intermediates)/file_list.txt) \
$(TARGET_OUT_PRODUCT) $(productimage_intermediates)/product_image_info.txt \
$(INSTALLED_PRODUCTIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_PRODUCTIMAGE_TARGET),$(BOARD_PRODUCTIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(productimage_intermediates)/file_list.txt,$(TARGET_OUT_PRODUCT),$(INTERNAL_PRODUCTIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(productimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_PRODUCT)/%,$(INTERNAL_PRODUCTIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_PRODUCTIMAGE_TARGET := $(BUILT_PRODUCTIMAGE_TARGET)
$(INSTALLED_PRODUCTIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_PRODUCTIMAGE_FILES) \
$(INSTALLED_FILES_FILE_PRODUCT) \
$(productimage_intermediates)/file_list.txt
$(build-productimage-target)
PRODUCT_NOTICE_DEPS += $(INSTALLED_PRODUCTIMAGE_TARGET)
$(call declare-1p-container,$(INSTALLED_PRODUCTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_PRODUCTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_PRODUCTIMAGE_FILES) $(INSTALLED_FILES_FILE_PRODUCT),$(PRODUCT_OUT)/:/)
.PHONY: productimage-nodeps pnod
productimage-nodeps pnod: | $(INTERNAL_USERIMAGES_DEPS) $(productimage_intermediates)/file_list.txt
$(build-productimage-target)
.PHONY: sync_product
sync sync_product: $(INTERNAL_PRODUCTIMAGE_FILES)
else ifdef BOARD_PREBUILT_PRODUCTIMAGE
INSTALLED_PRODUCTIMAGE_TARGET := $(PRODUCT_OUT)/product.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_PRODUCTIMAGE),$(INSTALLED_PRODUCTIMAGE_TARGET)))
endif
# -----------------------------------------------------------------
# system_ext partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_EXT)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_SYSTEM_EXT_IMAGE
INTERNAL_SYSTEM_EXTIMAGE_FILES := \
$(filter $(TARGET_OUT_SYSTEM_EXT)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_SYSTEM_EXT := $(PRODUCT_OUT)/installed-files-system_ext.txt
INSTALLED_FILES_JSON_SYSTEM_EXT := $(INSTALLED_FILES_FILE_SYSTEM_EXT:.txt=.json)
$(INSTALLED_FILES_FILE_SYSTEM_EXT): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_EXT)
$(INSTALLED_FILES_FILE_SYSTEM_EXT) : $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_SYSTEM_EXT) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_EXT))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_EXT))
system_extimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,system_ext)
BUILT_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
define build-system_extimage-target
$(call pretty,"Target system_ext fs image: $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_SYSTEM_EXT)
@mkdir -p $(system_extimage_intermediates) && rm -rf $(system_extimage_intermediates)/system_ext_image_info.txt
$(call generate-image-prop-dictionary, $(system_extimage_intermediates)/system_ext_image_info.txt,system_ext, skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(system_extimage_intermediates)/file_list.txt) \
$(TARGET_OUT_SYSTEM_EXT) \
$(system_extimage_intermediates)/system_ext_image_info.txt \
$(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
$(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_PRODUCT_SERVICESIMAGE_TARGET),$(BOARD_PRODUCT_SERVICESIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(system_extimage_intermediates)/file_list.txt,$(TARGET_OUT_SYSTEM_EXT),$(INTERNAL_SYSTEM_EXTIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(system_extimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(INTERNAL_SYSTEM_EXTIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(BUILT_SYSTEM_EXTIMAGE_TARGET)
$(INSTALLED_SYSTEM_EXTIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
$(INSTALLED_FILES_FILE_SYSTEM_EXT) \
$(system_extimage_intermediates)/file_list.txt
$(build-system_extimage-target)
SYSTEM_EXT_NOTICE_DEPS += $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
$(call declare-1p-container,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_SYSTEM_EXTIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_EXTIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_EXT),$(PRODUCT_OUT)/:/)
.PHONY: systemextimage-nodeps senod
systemextimage-nodeps senod: | $(INTERNAL_USERIMAGES_DEPS) $(system_extimage_intermediates)/file_list.txt
$(build-system_extimage-target)
.PHONY: sync_system_ext
sync sync_system_ext: $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
INSTALLED_SYSTEM_EXTIMAGE_TARGET := $(PRODUCT_OUT)/system_ext.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_EXTIMAGE),$(INSTALLED_SYSTEM_EXTIMAGE_TARGET)))
endif
# -----------------------------------------------------------------
# odm partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_ODM_IMAGE
INTERNAL_ODMIMAGE_FILES := \
$(filter $(TARGET_OUT_ODM)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
# Create symlinks for odm_dlkm on devices with a odm_dlkm partition:
# /odm/lib/modules -> /odm_dlkm/lib/modules
#
# On devices with a odm_dlkm partition,
# - /odm/lib/modules is a symlink to a directory that stores odm DLKMs.
# - /odm_dlkm/{etc,...} store other odm_dlkm files directly. The odm_dlkm partition is
# mounted at /odm_dlkm at runtime and the symlinks created in system/core/rootdir/Android.mk
# are hidden.
# On devices without a odm_dlkm partition,
# - /odm/lib/modules stores odm DLKMs directly.
# - /odm_dlkm/{etc,...} are symlinks to directories that store other odm_dlkm files.
# See system/core/rootdir/Android.mk for a list of created symlinks.
# The odm DLKMs and other odm_dlkm files must not be accessed using other paths because they
# are not guaranteed to exist on all devices.
ifdef BOARD_USES_ODM_DLKMIMAGE
_odm_dlkm_lib_modules_symlink := $(call create-partition-compat-symlink,$(TARGET_OUT_ODM)/lib/modules,/odm_dlkm/lib/modules,odm_dlkm.img)
INTERNAL_ODMIMAGE_FILES += $(_odm_dlkm_lib_modules_symlink)
ALL_DEFAULT_INSTALLED_MODULES += $(_odm_dlkm_lib_modules_symlink)
endif
INSTALLED_FILES_FILE_ODM := $(PRODUCT_OUT)/installed-files-odm.txt
INSTALLED_FILES_JSON_ODM := $(INSTALLED_FILES_FILE_ODM:.txt=.json)
$(INSTALLED_FILES_FILE_ODM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM)
$(INSTALLED_FILES_FILE_ODM) : $(INTERNAL_ODMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_ODM) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM))
odmimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,odm)
BUILT_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
define build-odmimage-target
$(call pretty,"Target odm fs image: $(INSTALLED_ODMIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_ODM)
@mkdir -p $(odmimage_intermediates) && rm -rf $(odmimage_intermediates)/odm_image_info.txt
$(call generate-image-prop-dictionary, $(odmimage_intermediates)/odm_image_info.txt, odm, \
skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(odmimage_intermediates)/file_list.txt) \
$(TARGET_OUT_ODM) $(odmimage_intermediates)/odm_image_info.txt \
$(INSTALLED_ODMIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_ODMIMAGE_TARGET),$(BOARD_ODMIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(odmimage_intermediates)/file_list.txt,$(TARGET_OUT_ODM),$(INTERNAL_ODMIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(odmimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_ODM)/%,$(INTERNAL_ODMIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_ODMIMAGE_TARGET := $(BUILT_ODMIMAGE_TARGET)
$(INSTALLED_ODMIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_ODMIMAGE_FILES) \
$(INSTALLED_FILES_FILE_ODM) \
$(odmimage_intermediates)/file_list.txt
$(build-odmimage-target)
ODM_NOTICE_DEPS += $(INSTALLED_ODMIMAGE_TARGET)
$(call declare-1p-container,$(INSTALLED_ODMIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_ODMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM),$(PRODUCT_OUT)/:/)
.PHONY: odmimage-nodeps onod
odmimage-nodeps onod: | $(INTERNAL_USERIMAGES_DEPS) $(odmimage_intermediates)/file_list.txt
$(build-odmimage-target)
.PHONY: sync_odm
sync sync_odm: $(INTERNAL_ODMIMAGE_FILES)
else ifdef BOARD_PREBUILT_ODMIMAGE
INSTALLED_ODMIMAGE_TARGET := $(PRODUCT_OUT)/odm.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODMIMAGE),$(INSTALLED_ODMIMAGE_TARGET)))
endif
# -----------------------------------------------------------------
# vendor_dlkm partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_VENDOR_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_VENDOR_DLKM_IMAGE
INTERNAL_VENDOR_DLKMIMAGE_FILES := \
$(filter $(TARGET_OUT_VENDOR_DLKM)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_VENDOR_DLKM := $(PRODUCT_OUT)/installed-files-vendor_dlkm.txt
INSTALLED_FILES_JSON_VENDOR_DLKM := $(INSTALLED_FILES_FILE_VENDOR_DLKM:.txt=.json)
$(INSTALLED_FILES_FILE_VENDOR_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_VENDOR_DLKM)
$(INSTALLED_FILES_FILE_VENDOR_DLKM) : $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_VENDOR_DLKM) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_VENDOR_DLKM))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_VENDOR_DLKM))
vendor_dlkmimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,vendor_dlkm)
BUILT_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
define build-vendor_dlkmimage-target
$(call pretty,"Target vendor_dlkm fs image: $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_VENDOR_DLKM)
@mkdir -p $(vendor_dlkmimage_intermediates) && rm -rf $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt
$(call generate-image-prop-dictionary, $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt, \
vendor_dlkm, skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(vendor_dlkmimage_intermediates)/file_list.txt) \
$(TARGET_OUT_VENDOR_DLKM) $(vendor_dlkmimage_intermediates)/vendor_dlkm_image_info.txt \
$(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(vendor_dlkmimage_intermediates)/file_list.txt,$(TARGET_OUT_VENDOR_DLKM),$(INTERNAL_VENDOR_DLKMIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(vendor_dlkmimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_VENDOR_DLKM)/%,$(INTERNAL_VENDOR_DLKMIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(BUILT_VENDOR_DLKMIMAGE_TARGET)
$(INSTALLED_VENDOR_DLKMIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
$(INSTALLED_FILES_FILE_VENDOR_DLKM) \
$(vendor_dlkmimage_intermediates)/file_list.txt
$(build-vendor_dlkmimage-target)
VENDOR_DLKM_NOTICE_DEPS += $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
$(call declare-1p-container,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_VENDOR_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_VENDOR_DLKM),$(PRODUCT_OUT)/:/)
.PHONY: vendor_dlkmimage-nodeps vdnod
vendor_dlkmimage-nodeps vdnod: | $(INTERNAL_USERIMAGES_DEPS) $(vendor_dlkmimage_intermediates)/file_list.txt
$(build-vendor_dlkmimage-target)
.PHONY: sync_vendor_dlkm
sync sync_vendor_dlkm: $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
INSTALLED_VENDOR_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/vendor_dlkm.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_VENDOR_DLKMIMAGE),$(INSTALLED_VENDOR_DLKMIMAGE_TARGET)))
endif
# -----------------------------------------------------------------
# odm_dlkm partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_ODM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_ODM_DLKM_IMAGE
INTERNAL_ODM_DLKMIMAGE_FILES := \
$(filter $(TARGET_OUT_ODM_DLKM)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_ODM_DLKM := $(PRODUCT_OUT)/installed-files-odm_dlkm.txt
INSTALLED_FILES_JSON_ODM_DLKM := $(INSTALLED_FILES_FILE_ODM_DLKM:.txt=.json)
$(INSTALLED_FILES_FILE_ODM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_ODM_DLKM)
$(INSTALLED_FILES_FILE_ODM_DLKM) : $(INTERNAL_ODM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_ODM_DLKM) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_ODM_DLKM))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_ODM_DLKM))
odm_dlkmimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,odm_dlkm)
BUILT_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
define build-odm_dlkmimage-target
$(call pretty,"Target odm_dlkm fs image: $(INSTALLED_ODM_DLKMIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_ODM_DLKM)
@mkdir -p $(odm_dlkmimage_intermediates) && rm -rf $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt
$(call generate-image-prop-dictionary, $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt, \
odm_dlkm, skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(odm_dlkmimage_intermediates)/file_list.txt) \
$(TARGET_OUT_ODM_DLKM) $(odm_dlkmimage_intermediates)/odm_dlkm_image_info.txt \
$(INSTALLED_ODM_DLKMIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(odm_dlkmimage_intermediates)/file_list.txt,$(TARGET_OUT_ODM_DLKM),$(INTERNAL_ODM_DLKMIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(odm_dlkmimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_ODM_DLKM)/%,$(INTERNAL_ODM_DLKMIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_ODM_DLKMIMAGE_TARGET := $(BUILT_ODM_DLKMIMAGE_TARGET)
$(INSTALLED_ODM_DLKMIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_ODM_DLKMIMAGE_FILES) \
$(INSTALLED_FILES_FILE_ODM_DLKM) \
$(odm_dlkmimage_intermediates)/file_list.txt
$(build-odm_dlkmimage-target)
ODM_DLKM_NOTICE_DEPS += $(INSTALLED_ODM_DLKMIMAGE_TARGET)
$(call declare-1p-container,$(INSTALLED_ODM_DLKMIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_ODM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_ODM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_ODM_DLKM),$(PRODUCT_OUT)/:/)
.PHONY: odm_dlkmimage-nodeps odnod
odm_dlkmimage-nodeps odnod: | $(INTERNAL_USERIMAGES_DEPS) $(odm_dlkmimage_intermediates)/file_list.txt
$(build-odm_dlkmimage-target)
.PHONY: sync_odm_dlkm
sync sync_odm_dlkm: $(INTERNAL_ODM_DLKMIMAGE_FILES)
else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
INSTALLED_ODM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/odm_dlkm.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_ODM_DLKMIMAGE),$(INSTALLED_ODM_DLKMIMAGE_TARGET)))
endif
# -----------------------------------------------------------------
# system_dlkm partition image
INSTALLED_FILES_OUTSIDE_IMAGES := $(filter-out $(TARGET_OUT_SYSTEM_DLKM)/%, $(INSTALLED_FILES_OUTSIDE_IMAGES))
ifdef BUILDING_SYSTEM_DLKM_IMAGE
INTERNAL_SYSTEM_DLKMIMAGE_FILES := \
$(filter $(TARGET_OUT_SYSTEM_DLKM)/%,\
$(ALL_DEFAULT_INSTALLED_MODULES))
INSTALLED_FILES_FILE_SYSTEM_DLKM := $(PRODUCT_OUT)/installed-files-system_dlkm.txt
INSTALLED_FILES_JSON_SYSTEM_DLKM := $(INSTALLED_FILES_FILE_SYSTEM_DLKM:.txt=.json)
$(INSTALLED_FILES_FILE_SYSTEM_DLKM): .KATI_IMPLICIT_OUTPUTS := $(INSTALLED_FILES_JSON_SYSTEM_DLKM)
$(INSTALLED_FILES_FILE_SYSTEM_DLKM): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(FILESLIST) $(FILESLIST_UTIL)
@echo Installed file list: $@
mkdir -p $(dir $@)
rm -f $@
$(FILESLIST) $(TARGET_OUT_SYSTEM_DLKM) > $(@:.txt=.json)
$(FILESLIST_UTIL) -c $(@:.txt=.json) > $@
$(call declare-0p-target,$(INSTALLED_FILES_FILE_SYSTEM_DLKM))
$(call declare-0p-target,$(INSTALLED_FILES_JSON_SYSTEM_DLKM))
system_dlkmimage_intermediates := \
$(call intermediates-dir-for,PACKAGING,system_dlkm)
BUILT_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
define build-system_dlkmimage-target
$(call pretty,"Target system_dlkm fs image: $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)")
@mkdir -p $(TARGET_OUT_SYSTEM_DLKM)
@mkdir -p $(system_dlkmimage_intermediates) && rm -rf $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt
$(call generate-image-prop-dictionary, $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt, \
system_dlkm, skip_fsck=true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH \
$(BUILD_IMAGE) \
$(if $(BUILD_BROKEN_INCORRECT_PARTITION_IMAGES),,--input-directory-filter-file $(system_dlkmimage_intermediates)/file_list.txt) \
$(TARGET_OUT_SYSTEM_DLKM) $(system_dlkmimage_intermediates)/system_dlkm_image_info.txt \
$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(TARGET_OUT)
$(call assert-max-image-size,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE))
endef
$(eval $(call write-partition-file-list,$(system_dlkmimage_intermediates)/file_list.txt,$(TARGET_OUT_SYSTEM_DLKM),$(INTERNAL_SYSTEM_DLKMIMAGE_FILES)))
# Used by soong sandwich to request the staging dir be built
$(system_dlkmimage_intermediates)/staging_dir.stamp: $(filter $(TARGET_OUT_SYSTEM_DLKM)/%,$(INTERNAL_SYSTEM_DLKMIMAGE_FILES))
touch $@
# We just build this directly to the install location.
INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET): \
$(INTERNAL_USERIMAGES_DEPS) \
$(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
$(INSTALLED_FILES_FILE_SYSTEM_DLKM) \
$(system_dlkmimage_intermediates)/file_list.txt
$(build-system_dlkmimage-target)
SYSTEM_DLKM_NOTICE_DEPS += $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
$(call declare-1p-container,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(INTERNAL_USERIMAGES_DEPS) $(INTERNAL_SYSTEM_DLKMIMAGE_FILES) $(INSTALLED_FILES_FILE_SYSTEM_DLKM),$(PRODUCT_OUT)/:/)
.PHONY: system_dlkmimage-nodeps sdnod
system_dlkmimage-nodeps sdnod: | $(INTERNAL_USERIMAGES_DEPS) $(system_dlkmimage_intermediates)/file_list.txt
$(build-system_dlkmimage-target)
.PHONY: sync_system_dlkm
sync sync_system_dlkm: $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
INSTALLED_SYSTEM_DLKMIMAGE_TARGET := $(PRODUCT_OUT)/system_dlkm.img
$(eval $(call copy-one-file,$(BOARD_PREBUILT_SYSTEM_DLKMIMAGE),$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)))
endif
# Protected VM firmware image
ifeq ($(BOARD_USES_PVMFWIMAGE),true)
.PHONY: pvmfwimage
pvmfwimage: $(INSTALLED_PVMFWIMAGE_TARGET)
INSTALLED_PVMFWIMAGE_TARGET := $(PRODUCT_OUT)/pvmfw.img
INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET := $(PRODUCT_OUT)/pvmfw_embedded.avbpubkey
INSTALLED_PVMFW_BINARY_TARGET := $(call module-target-built-files,pvmfw_bin)
INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,pvmfw_img)
INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,pvmfw_embedded_key_pub_bin)
INTERNAL_PVMFW_SYMBOL := $(TARGET_OUT_EXECUTABLES_UNSTRIPPED)/pvmfw
# If pvmfw target is not available and there is a prebuilt available use prebuilt
# NOTE: This is only a temporary feature for x86_64 and is not meant to be supported for long.
# TODO(b/391333413): Don't allow use of pvmfw prebuilts as soon as it is possible
ifeq ($(INTERNAL_PVMFWIMAGE_FILES),)
ifneq ($(PRODUCT_PVMFW_IMAGE_PREBUILT),)
INTERNAL_PVMFWIMAGE_FILES := $(call module-target-built-files,$(PRODUCT_PVMFW_IMAGE_PREBUILT))
INTERNAL_PVMFW_SYMBOL :=
ifneq ($(PRODUCT_PVMFW_BIN_PREBUILT),)
INSTALLED_PVMFW_BINARY_TARGET := $(call module-target-built-files,$(PRODUCT_PVMFW_BIN_PREBUILT))
endif # PRODUCT_PVMFW_BIN_PREBUILT
ifneq ($(PRODUCT_PVMFW_EMBEDDED_AVBKEY_PREBUILT),)
INTERNAL_PVMFW_EMBEDDED_AVBKEY := $(call module-target-built-files,$(PRODUCT_PVMFW_EMBEDDED_AVBKEY_PREBUILT))
endif # PRODUCT_PVMFW_EMBEDDED_AVBKEY_PREBUILT
endif # PRODUCT_PVMFW_IMAGE_PREBUILT
endif # INTERNAL_PVMFWIMAGE_FILES
$(call declare-1p-container,$(INSTALLED_PVMFWIMAGE_TARGET),)
$(call declare-container-license-deps,$(INSTALLED_PVMFWIMAGE_TARGET),$(INTERNAL_PVMFWIMAGE_FILES),$(PRODUCT_OUT)/:/)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_PVMFWIMAGE_TARGET)
# Place the unstripped pvmfw image to the symbols directory
$(INTERNAL_PVMFWIMAGE_FILES): |$(INTERNAL_PVMFW_SYMBOL)
$(eval $(call copy-one-file,$(INTERNAL_PVMFWIMAGE_FILES),$(INSTALLED_PVMFWIMAGE_TARGET)))
$(INSTALLED_PVMFWIMAGE_TARGET): $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)
$(eval $(call copy-one-file,$(INTERNAL_PVMFW_EMBEDDED_AVBKEY),$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET)))
endif # BOARD_USES_PVMFWIMAGE
# Returns a list of image targets corresponding to the given list of partitions. For example, it
# returns "$(INSTALLED_PRODUCTIMAGE_TARGET)" for "product", or "$(INSTALLED_SYSTEMIMAGE_TARGET)
# $(INSTALLED_VENDORIMAGE_TARGET)" for "system vendor".
# (1): list of partitions like "system", "vendor" or "system product system_ext".
define images-for-partitions
$(strip $(foreach item,$(1),\
$(if $(filter $(item),system_other),$(INSTALLED_SYSTEMOTHERIMAGE_TARGET),\
$(if $(filter $(item),init_boot),$(INSTALLED_INIT_BOOT_IMAGE_TARGET),\
$(INSTALLED_$(call to-upper,$(item))IMAGE_TARGET)))))
endef
# -----------------------------------------------------------------
# custom images
INSTALLED_CUSTOMIMAGES_TARGET :=
ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS :=
BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST :=
# If BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH is set, the image will be included in
# BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST, otherwise the image won't be AVB signed.
$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
$(if $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH), \
$(eval BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST += $(partition)) \
$(eval BOARD_$(call to-upper,$(partition))_IMAGE_LIST := $(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST))))
# Sign custom image.
# $(1): the prebuilt custom image.
# $(2): the mount point of the prebuilt custom image.
# $(3): the signed custom image target.
define sign_custom_image
$(3): $(1) $(INTERNAL_USERIMAGES_DEPS)
@echo Target custom image: $(3)
mkdir -p $(dir $(3))
cp $(1) $(3)
ifeq ($(BOARD_AVB_ENABLE),true)
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$$$PATH \
$(AVBTOOL) add_hashtree_footer \
--image $(3) \
--key $(BOARD_AVB_$(call to-upper,$(2))_KEY_PATH) \
--algorithm $(BOARD_AVB_$(call to-upper,$(2))_ALGORITHM) \
$(call get-partition-size-argument,$(BOARD_AVB_$(call to-upper,$(2))_PARTITION_SIZE)) \
--partition_name $(2) \
$(INTERNAL_AVB_CUSTOMIMAGES_SIGNING_ARGS) \
$(BOARD_AVB_$(call to-upper,$(2))_ADD_HASHTREE_FOOTER_ARGS)
endif
INSTALLED_CUSTOMIMAGES_TARGET += $(3)
endef
# Copy unsigned custom image.
# $(1): the prebuilt custom image.
# $(2): the signed custom image target.
define copy_custom_image
$(2): $(1) $(INTERNAL_USERIMAGES_DEPS)
@echo Target custom image: $(2)
mkdir -p $(dir $(2))
cp $(1) $(2)
INSTALLED_CUSTOMIMAGES_TARGET += $(2)
endef
# Add AVB custom image to droid target
$(foreach partition,$(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), \
$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST), \
$(eval $(call sign_custom_image,$(image),$(partition),$(PRODUCT_OUT)/$(notdir $(image))))))
# Add unsigned custom image to droid target
$(foreach partition,$(filter-out $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), $(BOARD_CUSTOMIMAGES_PARTITION_LIST)), \
$(foreach image,$(BOARD_$(call to-upper,$(partition))_IMAGE_LIST), \
$(eval $(call copy_custom_image,$(image),$(PRODUCT_OUT)/$(notdir $(image))))))
endif
# -----------------------------------------------------------------
# vbmeta image
ifeq ($(BOARD_AVB_ENABLE),true)
BUILT_VBMETAIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta.img
AVB_CHAIN_KEY_DIR := $(TARGET_OUT_INTERMEDIATES)/avb_chain_keys
ifdef BOARD_AVB_KEY_PATH
$(if $(BOARD_AVB_ALGORITHM),,$(error BOARD_AVB_ALGORITHM is not defined))
else
# If key path isn't specified, use the 4096-bit test key.
BOARD_AVB_ALGORITHM := SHA256_RSA4096
BOARD_AVB_KEY_PATH := external/avb/test/data/testkey_rsa4096.pem
endif
# AVB signing for system_other.img.
ifdef BUILDING_SYSTEM_OTHER_IMAGE
ifdef BOARD_AVB_SYSTEM_OTHER_KEY_PATH
$(if $(BOARD_AVB_SYSTEM_OTHER_ALGORITHM),,$(error BOARD_AVB_SYSTEM_OTHER_ALGORITHM is not defined))
else
# If key path isn't specified, use the same key as BOARD_AVB_KEY_PATH.
BOARD_AVB_SYSTEM_OTHER_KEY_PATH := $(BOARD_AVB_KEY_PATH)
BOARD_AVB_SYSTEM_OTHER_ALGORITHM := $(BOARD_AVB_ALGORITHM)
endif
$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET): $(AVBTOOL) $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH)
@echo Extracting system_other avb key: $@
@rm -f $@
@mkdir -p $(dir $@)
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_OTHER_KEY_PATH) --output $@
$(eval $(call declare-0p-target,$(INSTALLED_PRODUCT_SYSTEM_OTHER_AVBKEY_TARGET),))
ifndef BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX
BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX := $(PLATFORM_SECURITY_PATCH_TIMESTAMP)
endif
BOARD_AVB_SYSTEM_OTHER_ADD_HASHTREE_FOOTER_ARGS += --rollback_index $(BOARD_AVB_SYSTEM_OTHER_ROLLBACK_INDEX)
endif # end of AVB for BUILDING_SYSTEM_OTHER_IMAGE
INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES := \
$(BOARD_AVB_VBMETA_SYSTEM) \
$(BOARD_AVB_VBMETA_VENDOR) \
$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))))
# Not allowing the same partition to appear in multiple groups.
ifneq ($(words $(sort $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES))),$(words $(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
$(error BOARD_AVB_VBMETA_SYSTEM and BOARD_AVB_VBMETA_VENDOR cannot have duplicates)
endif
# When building a standalone recovery image for non-A/B devices, recovery image must be self-signed
# to be verified independently, and cannot be chained into vbmeta.img. See the link below for
# details.
ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(if $(BOARD_AVB_RECOVERY_KEY_PATH),,\
$(error BOARD_AVB_RECOVERY_KEY_PATH must be defined for if non-A/B is supported. \
See https://android.googlesource.com/platform/external/avb/+/master/README.md#booting-into-recovery))
endif
endif
# Appends os version as a AVB property descriptor.
SYSTEM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system.os_version:$(SYSTEM_OS_VERSION)
PRODUCT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.product.os_version:$(PRODUCT_OS_VERSION)
SYSTEM_EXT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system_ext.os_version:$(SYSTEM_EXT_OS_VERSION)
INIT_BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.init_boot.os_version:$(INIT_BOOT_OS_VERSION)
BOOT_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.boot.os_version:$(BOOT_OS_VERSION)
VENDOR_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.vendor.os_version:$(VENDOR_OS_VERSION)
ODM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.odm.os_version:$(ODM_OS_VERSION)
VENDOR_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.vendor_dlkm.os_version:$(VENDOR_DLKM_OS_VERSION)
ODM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.odm_dlkm.os_version:$(ODM_DLKM_OS_VERSION)
SYSTEM_DLKM_OS_VERSION ?= $(PLATFORM_VERSION_LAST_STABLE)
BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system_dlkm.os_version:$(SYSTEM_DLKM_OS_VERSION)
# Appends fingerprint and security patch level as a AVB property descriptor.
BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
--prop com.android.build.system.security_patch:$(PLATFORM_SECURITY_PATCH)
BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.product.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
--prop com.android.build.product.security_patch:$(PLATFORM_SECURITY_PATCH)
BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system_ext.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
--prop com.android.build.system_ext.security_patch:$(PLATFORM_SECURITY_PATCH)
BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.init_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.vendor_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.vendor_kernel_boot.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE) \
BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.recovery.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.vendor.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.odm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.vendor_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.odm_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system_dlkm.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.dtbo.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.pvmfw.fingerprint:$(BUILD_FINGERPRINT_FROM_FILE)
# The following vendor- and odm-specific images needs explicit SPL set per board.
# TODO(b/210875415) Is this security_patch property used? Should it be removed from
# boot.img when there is no platform ramdisk included in it?
ifdef BOOT_SECURITY_PATCH
BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.boot.security_patch:$(BOOT_SECURITY_PATCH)
endif
ifdef INIT_BOOT_SECURITY_PATCH
BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.init_boot.security_patch:$(INIT_BOOT_SECURITY_PATCH)
else ifdef BOOT_SECURITY_PATCH
BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.init_boot.security_patch:$(BOOT_SECURITY_PATCH)
endif
ifdef VENDOR_SECURITY_PATCH
BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.vendor.security_patch:$(VENDOR_SECURITY_PATCH)
endif
ifdef ODM_SECURITY_PATCH
BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.odm.security_patch:$(ODM_SECURITY_PATCH)
endif
ifdef VENDOR_DLKM_SECURITY_PATCH
BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.vendor_dlkm.security_patch:$(VENDOR_DLKM_SECURITY_PATCH)
endif
ifdef ODM_DLKM_SECURITY_PATCH
BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.odm_dlkm.security_patch:$(ODM_DLKM_SECURITY_PATCH)
endif
ifdef SYSTEM_DLKM_SECURITY_PATCH
BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS += \
--prop com.android.build.system_dlkm.security_patch:$(SYSTEM_DLKM_SECURITY_PATCH)
endif
ifdef PVMFW_SECURITY_PATCH
BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS += \
--prop com.android.build.pvmfw.security_patch:$(PVMFW_SECURITY_PATCH)
endif
# Append root digest of microdroid-vendor partition's hashtree descriptor into vendor partition.
ifdef MICRODROID_VENDOR_IMAGE_MODULE
MICRODROID_VENDOR_IMAGE := \
$(call intermediates-dir-for,ETC,$(MICRODROID_VENDOR_IMAGE_MODULE))/$(MICRODROID_VENDOR_IMAGE_MODULE)
MICRODROID_VENDOR_ROOT_DIGEST := $(PRODUCT_OUT)/microdroid_vendor_root_digest
BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS += \
--prop_from_file com.android.build.microdroid-vendor.root_digest:$(MICRODROID_VENDOR_ROOT_DIGEST)
$(MICRODROID_VENDOR_ROOT_DIGEST): $(AVBTOOL) $(MICRODROID_VENDOR_IMAGE)
$(AVBTOOL) print_partition_digests \
--image $(MICRODROID_VENDOR_IMAGE) \
| tr -d '\n' | sed -E 's/.*: //g' > $@
$(INSTALLED_VENDORIMAGE_TARGET): $(MICRODROID_VENDOR_ROOT_DIGEST)
endif
BOOT_FOOTER_ARGS := BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS
INIT_BOOT_FOOTER_ARGS := BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS
VENDOR_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS
VENDOR_KERNEL_BOOT_FOOTER_ARGS := BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS
DTBO_FOOTER_ARGS := BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS
PVMFW_FOOTER_ARGS := BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS
SYSTEM_FOOTER_ARGS := BOARD_AVB_SYSTEM_ADD_HASHTREE_FOOTER_ARGS
VENDOR_FOOTER_ARGS := BOARD_AVB_VENDOR_ADD_HASHTREE_FOOTER_ARGS
RECOVERY_FOOTER_ARGS := BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS
PRODUCT_FOOTER_ARGS := BOARD_AVB_PRODUCT_ADD_HASHTREE_FOOTER_ARGS
SYSTEM_EXT_FOOTER_ARGS := BOARD_AVB_SYSTEM_EXT_ADD_HASHTREE_FOOTER_ARGS
ODM_FOOTER_ARGS := BOARD_AVB_ODM_ADD_HASHTREE_FOOTER_ARGS
VENDOR_DLKM_FOOTER_ARGS := BOARD_AVB_VENDOR_DLKM_ADD_HASHTREE_FOOTER_ARGS
ODM_DLKM_FOOTER_ARGS := BOARD_AVB_ODM_DLKM_ADD_HASHTREE_FOOTER_ARGS
SYSTEM_DLKM_FOOTER_ARGS := BOARD_AVB_SYSTEM_DLKM_ADD_HASHTREE_FOOTER_ARGS
# Helper function that checks and sets required build variables for an AVB chained partition.
# $(1): the partition to enable AVB chain, e.g., boot or system or vbmeta_system.
define _check-and-set-avb-chain-args
$(eval part := $(1))
$(eval PART=$(call to-upper,$(part)))
$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
$(eval _signing_algorithm := BOARD_AVB_$(PART)_ALGORITHM)
$(eval _rollback_index := BOARD_AVB_$(PART)_ROLLBACK_INDEX)
$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
$(if $($(_key_path)),,$(error $(_key_path) is not defined))
$(if $($(_signing_algorithm)),,$(error $(_signing_algorithm) is not defined))
$(if $($(_rollback_index)),,$(error $(_rollback_index) is not defined))
$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
# Set INTERNAL_AVB_(PART)_SIGNING_ARGS
$(eval _signing_args := INTERNAL_AVB_$(PART)_SIGNING_ARGS)
$(eval $(_signing_args) := \
--algorithm $($(_signing_algorithm)) --key $($(_key_path)))
# The recovery partition in non-A/B devices should be verified separately. Skip adding the chain
# partition descriptor for recovery partition into vbmeta.img.
$(if $(or $(filter-out true,$(TARGET_OTA_ALLOW_NON_AB)),$(filter-out recovery,$(part))),\
$(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
--chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey))
# Set rollback_index via footer args for non-chained vbmeta image. Chained vbmeta image will pick up
# the index via a separate flag (e.g. BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX).
$(if $(filter $(part),$(part:vbmeta_%=%)),\
$(eval _footer_args := $(PART)_FOOTER_ARGS) \
$(eval $($(_footer_args)) += --rollback_index $($(_rollback_index))))
endef
# Checks and sets the required build variables for an AVB partition. The partition will be
# configured as a chained partition, if BOARD_AVB__KEY_PATH is defined. Otherwise the
# image descriptor will be included into vbmeta.img, unless it has been already added to any chained
# VBMeta image.
# Multiple boot images can be generated based on BOARD_KERNEL_BINARIES
# but vbmeta would capture the image descriptor of only the first boot
# image specified in BUILT_BOOTIMAGE_TARGET.
# $(1): Partition name, e.g. boot or system.
define check-and-set-avb-args
$(eval _in_chained_vbmeta := $(filter $(1),$(INTERNAL_AVB_PARTITIONS_IN_CHAINED_VBMETA_IMAGES)))
$(if $(BOARD_AVB_$(call to-upper,$(1))_KEY_PATH),\
$(if $(_in_chained_vbmeta),\
$(error Chaining partition "$(1)" in chained VBMeta image is not supported)) \
$(call _check-and-set-avb-chain-args,$(1)),\
$(if $(_in_chained_vbmeta),,\
$(if $(filter boot,$(1)),\
$(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
--include_descriptors_from_image $(firstword $(call images-for-partitions,$(1)))),\
$(eval INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
--include_descriptors_from_image $(call images-for-partitions,$(1))))))
endef
# Checks and sets build variables for a custom chained partition to include it into vbmeta.img.
# $(1): the custom partition to enable AVB chain.
define check-and-set-custom-avb-chain-args
$(eval part := $(1))
$(eval PART=$(call to-upper,$(part)))
$(eval _rollback_index_location := BOARD_AVB_$(PART)_ROLLBACK_INDEX_LOCATION)
$(eval _key_path := BOARD_AVB_$(PART)_KEY_PATH)
$(if $($(_rollback_index_location)),,$(error $(_rollback_index_location) is not defined))
$(if $($(_key_path)),,$(error $(_key_path) is not defined))
INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS += \
--chain_partition $(part):$($(_rollback_index_location)):$(AVB_CHAIN_KEY_DIR)/$(part).avbpubkey
endef
ifdef INSTALLED_BOOTIMAGE_TARGET
$(eval $(call check-and-set-avb-args,boot))
endif
ifdef INSTALLED_INIT_BOOT_IMAGE_TARGET
$(eval $(call check-and-set-avb-args,init_boot))
endif
ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
$(eval $(call check-and-set-avb-args,vendor_boot))
endif
ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
$(eval $(call check-and-set-avb-args,vendor_kernel_boot))
endif
ifdef INSTALLED_SYSTEMIMAGE_TARGET
$(eval $(call check-and-set-avb-args,system))
endif
ifdef INSTALLED_VENDORIMAGE_TARGET
$(eval $(call check-and-set-avb-args,vendor))
endif
ifdef INSTALLED_PRODUCTIMAGE_TARGET
$(eval $(call check-and-set-avb-args,product))
endif
ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
$(eval $(call check-and-set-avb-args,system_ext))
endif
ifdef INSTALLED_ODMIMAGE_TARGET
$(eval $(call check-and-set-avb-args,odm))
endif
ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
$(eval $(call check-and-set-avb-args,vendor_dlkm))
endif
ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
$(eval $(call check-and-set-avb-args,odm_dlkm))
endif
ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
$(eval $(call check-and-set-avb-args,system_dlkm))
endif
ifdef INSTALLED_DTBOIMAGE_TARGET
$(eval $(call check-and-set-avb-args,dtbo))
endif
ifdef INSTALLED_PVMFWIMAGE_TARGET
$(eval $(call check-and-set-avb-args,pvmfw))
endif
ifdef INSTALLED_RECOVERYIMAGE_TARGET
$(eval $(call check-and-set-avb-args,recovery))
endif
# Not using INSTALLED_VBMETA_SYSTEMIMAGE_TARGET as it won't be set yet.
ifdef BOARD_AVB_VBMETA_SYSTEM
$(eval $(call check-and-set-avb-args,vbmeta_system))
endif
ifdef BOARD_AVB_VBMETA_VENDOR
$(eval $(call check-and-set-avb-args,vbmeta_vendor))
endif
ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(eval $(call check-and-set-avb-args,vbmeta_$(partition))))
$(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),$(eval BOARD_AVB_MAKE_VBMETA_$(call to-upper,$(partition))_IMAGE_ARGS += --padding_size 4096))
endif
ifneq ($(strip $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST)),)
$(foreach partition,$(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), \
$(eval $(call check-and-set-custom-avb-chain-args,$(partition))))
endif
BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --padding_size 4096
BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += --padding_size 4096
BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += --padding_size 4096
ifeq (eng,$(filter eng, $(TARGET_BUILD_VARIANT)))
# We only need the flag in top-level vbmeta.img.
BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --set_hashtree_disabled_flag
endif
ifdef BOARD_AVB_ROLLBACK_INDEX
BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS += --rollback_index $(BOARD_AVB_ROLLBACK_INDEX)
endif
ifdef BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX
BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS += \
--rollback_index $(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX)
endif
ifdef BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX
BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS += \
--rollback_index $(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX)
endif
ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
$(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)), \
$(if $(BOARD_AVB_VBMETA_$(partition)_ROLLBACK_INDEX),$(eval \
BOARD_AVB_MAKE_VBMETA_$(partition)_IMAGE_ARGS += \
--rollback_index $(BOARD_AVB_VBMETA_$(partition)_ROLLBACK_INDEX))))
endif
# $(1): the directory to extract public keys to
define extract-avb-chain-public-keys
$(if $(BOARD_AVB_BOOT_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_BOOT_KEY_PATH) \
--output $(1)/boot.avbpubkey)
$(if $(BOARD_AVB_INIT_BOOT_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_INIT_BOOT_KEY_PATH) \
--output $(1)/init_boot.avbpubkey)
$(if $(BOARD_AVB_VENDOR_BOOT_KEY_PATH),\
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_BOOT_KEY_PATH) \
--output $(1)/vendor_boot.avbpubkey)
$(if $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH),\
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH) \
--output $(1)/vendor_kernel_boot.avbpubkey)
$(if $(BOARD_AVB_SYSTEM_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_KEY_PATH) \
--output $(1)/system.avbpubkey)
$(if $(BOARD_AVB_VENDOR_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_KEY_PATH) \
--output $(1)/vendor.avbpubkey)
$(if $(BOARD_AVB_PRODUCT_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PRODUCT_KEY_PATH) \
--output $(1)/product.avbpubkey)
$(if $(BOARD_AVB_SYSTEM_EXT_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_EXT_KEY_PATH) \
--output $(1)/system_ext.avbpubkey)
$(if $(BOARD_AVB_ODM_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_KEY_PATH) \
--output $(1)/odm.avbpubkey)
$(if $(BOARD_AVB_VENDOR_DLKM_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VENDOR_DLKM_KEY_PATH) \
--output $(1)/vendor_dlkm.avbpubkey)
$(if $(BOARD_AVB_ODM_DLKM_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_ODM_DLKM_KEY_PATH) \
--output $(1)/odm_dlkm.avbpubkey)
$(if $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_SYSTEM_DLKM_KEY_PATH) \
--output $(1)/system_dlkm.avbpubkey)
$(if $(BOARD_AVB_DTBO_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_DTBO_KEY_PATH) \
--output $(1)/dtbo.avbpubkey)
$(if $(BOARD_AVB_PVMFW_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_PVMFW_KEY_PATH) \
--output $(1)/pvmfw.avbpubkey)
$(if $(BOARD_AVB_RECOVERY_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_RECOVERY_KEY_PATH) \
--output $(1)/recovery.avbpubkey)
$(if $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
--output $(1)/vbmeta_system.avbpubkey)
$(if $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH),\
$(hide) $(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
--output $(1)/vbmeta_vendor.avbpubkey)
$(if $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST),\
$(hide) $(foreach partition,$(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), \
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH) \
--output $(1)/$(partition).avbpubkey;))
$(if $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
$(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS), \
$(AVBTOOL) extract_public_key --key $(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH) \
--output $(1)/vbmeta_$(partition).avbpubkey;))
endef
# Builds a chained VBMeta image. This VBMeta image will contain the descriptors for the partitions
# specified in BOARD_AVB_VBMETA_. The built VBMeta image will be included into the top-level
# vbmeta image as a chained partition. For example, if a target defines `BOARD_AVB_VBMETA_SYSTEM
# := system system_ext`, `vbmeta_system.img` will be created that includes the descriptors for
# `system.img` and `system_ext.img`. `vbmeta_system.img` itself will be included into
# `vbmeta.img` as a chained partition.
# $(1): VBMeta image name, such as "vbmeta_system", "vbmeta_vendor" etc.
# $(2): Output filename.
define build-chained-vbmeta-image
$(call pretty,"Target chained vbmeta image: $@")
$(hide) $(AVBTOOL) make_vbmeta_image \
$(INTERNAL_AVB_$(call to-upper,$(1))_SIGNING_ARGS) \
$(BOARD_AVB_MAKE_$(call to-upper,$(1))_IMAGE_ARGS) \
$(foreach image,$(BOARD_AVB_$(call to-upper,$(1))), \
--include_descriptors_from_image $(call images-for-partitions,$(image))) \
--output $@
# libavb expects to be able to read the maximum vbmeta size, so we must provide a partition
# which matches this or the read will fail.
# See external/avb/libavb/avb_slot_verify.c#VBMETA_MAX_SIZE
truncate -s 65536 $@
endef
ifdef BUILDING_SYSTEM_IMAGE
ifdef BOARD_AVB_VBMETA_SYSTEM
INSTALLED_VBMETA_SYSTEMIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_system.img
$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET): \
$(AVBTOOL) \
$(call images-for-partitions,$(BOARD_AVB_VBMETA_SYSTEM)) \
$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)
$(call build-chained-vbmeta-image,vbmeta_system)
$(call declare-1p-container,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET),)
SYSTEM_NOTICE_DEPS += $(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET)
endif
endif # BUILDING_SYSTEM_IMAGE
ifdef BOARD_AVB_VBMETA_VENDOR
INSTALLED_VBMETA_VENDORIMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_vendor.img
$(INSTALLED_VBMETA_VENDORIMAGE_TARGET): \
$(AVBTOOL) \
$(call images-for-partitions,$(BOARD_AVB_VBMETA_VENDOR)) \
$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)
$(call build-chained-vbmeta-image,vbmeta_vendor)
$(call declare-1p-container,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET),)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_VBMETA_VENDORIMAGE_TARGET)
endif
ifdef BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
define declare-custom-vbmeta-target
INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET := $(PRODUCT_OUT)/vbmeta_$(call to-lower,$(1)).img
$$(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET): \
$(AVBTOOL) \
$(call images-for-partitions,$(BOARD_AVB_VBMETA_$(call to-upper,$(1)))) \
$(BOARD_AVB_VBMETA_$(call to-upper,$(1))_KEY_PATH)
$$(call build-chained-vbmeta-image,vbmeta_$(call to-lower,$(1)))
$(call declare-1p-container,$(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET),)
UNMOUNTED_NOTICE_VENDOR_DEPS += $(INSTALLED_VBMETA_$(call to-upper,$(1))IMAGE_TARGET)
endef
$(foreach partition,\
$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),\
$(eval $(call declare-custom-vbmeta-target,$(partition))))
endif
define build-vbmetaimage-target
$(call pretty,"Target vbmeta image: $(INSTALLED_VBMETAIMAGE_TARGET)")
$(hide) mkdir -p $(AVB_CHAIN_KEY_DIR)
$(call extract-avb-chain-public-keys, $(AVB_CHAIN_KEY_DIR))
$(hide) $(AVBTOOL) make_vbmeta_image \
$(INTERNAL_AVB_MAKE_VBMETA_IMAGE_ARGS) \
$(PRIVATE_AVB_VBMETA_SIGNING_ARGS) \
$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS) \
--output $@
# libavb expects to be able to read the maximum vbmeta size, so we must provide a partition
# which matches this or the read will fail.
# See external/avb/libavb/avb_slot_verify.c#VBMETA_MAX_SIZE
truncate -s 65536 $@
$(hide) rm -rf $(AVB_CHAIN_KEY_DIR)
endef
ifdef BUILDING_VBMETA_IMAGE
INSTALLED_VBMETAIMAGE_TARGET := $(BUILT_VBMETAIMAGE_TARGET)
$(INSTALLED_VBMETAIMAGE_TARGET): PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
--algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
$(INSTALLED_VBMETAIMAGE_TARGET): \
$(AVBTOOL) \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
$(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET) \
$(INSTALLED_SYSTEMIMAGE_TARGET) \
$(INSTALLED_VENDORIMAGE_TARGET) \
$(INSTALLED_PRODUCTIMAGE_TARGET) \
$(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
$(INSTALLED_ODMIMAGE_TARGET) \
$(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
$(INSTALLED_ODM_DLKMIMAGE_TARGET) \
$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
$(INSTALLED_DTBOIMAGE_TARGET) \
$(INSTALLED_PVMFWIMAGE_TARGET) \
$(INSTALLED_CUSTOMIMAGES_TARGET) \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET) \
$(INSTALLED_VBMETA_VENDORIMAGE_TARGET) \
$(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(INSTALLED_VBMETA_$(partition)IMAGE_TARGET)) \
$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH) \
$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH) \
$(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)),$(BOARD_AVB_VBMETA_$(partition)_KEY_PATH)) \
$(BOARD_AVB_KEY_PATH)
$(build-vbmetaimage-target)
$(call declare-1p-container,$(INSTALLED_VBMETAIMAGE_TARGET),)
UNMOUNTED_NOTICE_DEPS += $(INSTALLED_VBMETAIMAGE_TARGET)
.PHONY: vbmetaimage-nodeps
vbmetaimage-nodeps: PRIVATE_AVB_VBMETA_SIGNING_ARGS := \
--algorithm $(BOARD_AVB_ALGORITHM) --key $(BOARD_AVB_KEY_PATH)
vbmetaimage-nodeps:
$(build-vbmetaimage-target)
endif # BUILDING_VBMETA_IMAGE
endif # BOARD_AVB_ENABLE
# List of files from all images
INTERNAL_ALLIMAGES_FILES := \
$(FULL_SYSTEMIMAGE_DEPS) \
$(INTERNAL_RAMDISK_FILES) \
$(INTERNAL_USERDATAIMAGE_FILES) \
$(INTERNAL_VENDORIMAGE_FILES) \
$(INTERNAL_PRODUCTIMAGE_FILES) \
$(INTERNAL_SYSTEM_EXTIMAGE_FILES) \
$(INTERNAL_ODMIMAGE_FILES) \
$(INTERNAL_VENDOR_DLKMIMAGE_FILES) \
$(INTERNAL_ODM_DLKMIMAGE_FILES) \
$(INTERNAL_SYSTEM_DLKMIMAGE_FILES) \
$(INTERNAL_PVMFWIMAGE_FILES) \
# -----------------------------------------------------------------
# Run apex_sepolicy_tests for all installed APEXes
ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifneq (,$(filter ext4 erofs,$(PRODUCT_DEFAULT_APEX_PAYLOAD_TYPE)))
intermediate := $(call intermediates-dir-for,PACKAGING,apex_sepolicy_tests)
apex_dirs := \
$(TARGET_OUT)/apex/% \
$(TARGET_OUT_SYSTEM_EXT)/apex/% \
$(TARGET_OUT_VENDOR)/apex/% \
$(TARGET_OUT_ODM)/apex/% \
$(TARGET_OUT_PRODUCT)/apex/% \
apex_files := $(sort $(filter $(apex_dirs), $(INTERNAL_ALLIMAGES_FILES)))
apex_dirs :=
# $1: apex file
# $2: output file
define _run_apex_sepolicy_tests
$2: $1 \
$(HOST_OUT_EXECUTABLES)/apex_sepolicy_tests \
$(HOST_OUT_EXECUTABLES)/apex-ls
@rm -rf $$@
@mkdir -p $(dir $$@)
$(HOST_OUT_EXECUTABLES)/apex_sepolicy_tests --all -f <($(HOST_OUT_EXECUTABLES)/apex-ls -Z $$<)
@touch $$@
endef
# $1: apex file list
define run_apex_sepolicy_tests
$(foreach apex_file,$1, \
$(eval passfile := $(patsubst $(PRODUCT_OUT)/%,$(intermediate)/%.pass,$(apex_file))) \
$(eval $(call _run_apex_sepolicy_tests,$(apex_file),$(passfile))) \
$(passfile))
endef
.PHONY: run_apex_sepolicy_tests
run_apex_sepolicy_tests: $(call run_apex_sepolicy_tests,$(apex_files))
droid_targets: run_apex_sepolicy_tests
apex_files :=
intermediate :=
endif # PRODUCT_DEFAULT_APEX_PAYLOAD_TYPE
endif # TARGET_BUILD_UNBUNDLED
# -----------------------------------------------------------------
# Check VINTF of build
# Note: vendor_dlkm, odm_dlkm, and system_dlkm does not have VINTF files.
ifeq (,$(TARGET_BUILD_UNBUNDLED))
intermediates := $(call intermediates-dir-for,PACKAGING,check_vintf_all)
check_vintf_all_deps :=
# -----------------------------------------------------------------
# Activate APEXes for checkvintf
apex_dirs := \
$(TARGET_OUT)/apex/% \
$(TARGET_OUT_PRODUCT)/apex/% \
$(TARGET_OUT_SYSTEM_EXT)/apex/% \
$(TARGET_OUT_VENDOR)/apex/% \
$(TARGET_OUT_ODM)/apex/% \
apex_files := $(sort $(filter $(apex_dirs), $(INTERNAL_ALLIMAGES_FILES)))
APEX_OUT := $(intermediates)/apex
APEX_INFO_FILE := $(APEX_OUT)/apex-info-list.xml
# apexd_host scans/activates APEX files and writes /apex/apex-info-list.xml
# Note that `@echo $(PRIVATE_APEX_FILES)` line is added to trigger the rule when the APEX list is changed.
$(APEX_INFO_FILE): PRIVATE_APEX_FILES := $(apex_files)
$(APEX_INFO_FILE): $(HOST_OUT_EXECUTABLES)/apexd_host \
$(HOST_OUT_EXECUTABLES)/deapexer $(HOST_OUT_EXECUTABLES)/debugfs $(HOST_OUT_EXECUTABLES)/fsck.erofs \
$(apex_files)
@echo "Extracting apexes..."
@echo $(PRIVATE_APEX_FILES) > /dev/null
@rm -rf $(APEX_OUT)
@mkdir -p $(APEX_OUT)
$< --system_path $(TARGET_OUT) \
--system_ext_path $(TARGET_OUT_SYSTEM_EXT) \
--product_path $(TARGET_OUT_PRODUCT) \
--vendor_path $(TARGET_OUT_VENDOR) \
--odm_path $(TARGET_OUT_ODM) \
--apex_path $(APEX_OUT)
apex_files :=
apex_dirs :=
# The build system only writes VINTF metadata to */etc/vintf paths. Legacy paths aren't needed here
# because they are only used for prebuilt images.
# APEX files in /$partition/apex can have VINTF fragments as well.
check_vintf_common_srcs_patterns := \
$(TARGET_OUT)/etc/vintf/% \
$(TARGET_OUT_VENDOR)/etc/vintf/% \
$(TARGET_OUT_ODM)/etc/vintf/% \
$(TARGET_OUT_PRODUCT)/etc/vintf/% \
$(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
$(apex_dirs)
check_vintf_common_srcs := $(sort $(filter $(check_vintf_common_srcs_patterns),$(INTERNAL_ALLIMAGES_FILES)))
check_vintf_common_srcs_patterns :=
check_vintf_has_system :=
check_vintf_has_vendor :=
ifneq (,$(filter EMPTY_ODM_SKU_PLACEHOLDER,$(ODM_MANIFEST_SKUS)))
$(error EMPTY_ODM_SKU_PLACEHOLDER is an internal variable and cannot be used for ODM_MANIFEST_SKUS)
endif
ifneq (,$(filter EMPTY_VENDOR_SKU_PLACEHOLDER,$(DEVICE_MANIFEST_SKUS)))
$(error EMPTY_VENDOR_SKU_PLACEHOLDER is an internal variable and cannot be used for DEIVCE_MANIFEST_SKUS)
endif
# -- Check system and system_ext manifests / matrices including fragments (excluding other framework manifests / matrices, e.g. product);
ifdef BUILDING_SYSTEM_IMAGE
check_vintf_system_deps := $(filter $(TARGET_OUT)/etc/vintf/% \
$(TARGET_OUT_SYSTEM_EXT)/etc/vintf/% \
$(TARGET_OUT)/apex/% \
$(TARGET_OUT_SYSTEM_EXT)/apex/%, \
$(check_vintf_common_srcs))
ifneq ($(check_vintf_system_deps),)
check_vintf_has_system := true
check_vintf_system_log := $(intermediates)/check_vintf_system.log
check_vintf_all_deps += $(check_vintf_system_log)
$(check_vintf_system_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_system_deps) $(APEX_INFO_FILE)
@( $< --check-one --dirmap /system:$(TARGET_OUT) --dirmap /apex:$(APEX_OUT) > $@ 2>&1 ) || ( cat $@ && exit 1 )
$(call declare-1p-target,$(check_vintf_system_log))
check_vintf_system_log :=
# -- Check framework manifest against frozen manifests for GSI targets. They need to be compatible.
ifneq (true, $(BUILDING_VENDOR_IMAGE))
vintffm_log := $(intermediates)/vintffm.log
endif
check_vintf_all_deps += $(vintffm_log)
$(vintffm_log): $(HOST_OUT_EXECUTABLES)/vintffm $(check_vintf_system_deps) $(APEX_INFO_FILE)
@( $< --check --dirmap /system:$(TARGET_OUT) \
--dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
--dirmap /product:$(TARGET_OUT_PRODUCT) \
--dirmap /apex:$(APEX_OUT) \
system/libhidl/vintfdata/frozen > $@ 2>&1 ) || ( cat $@ && exit 1 )
$(call declare-1p-target,$(vintffm_log))
endif # check_vintf_system_deps
check_vintf_system_deps :=
endif # BUILDING_SYSTEM_IMAGE
# -- Check vendor manifest / matrix including fragments (excluding other device manifests / matrices)
check_vintf_vendor_deps := $(filter $(TARGET_OUT_VENDOR)/etc/vintf/% \
$(TARGET_OUT_VENDOR)/apex/%, \
$(check_vintf_common_srcs))
ifneq ($(strip $(check_vintf_vendor_deps)),)
check_vintf_has_vendor := true
check_vintf_vendor_log := $(intermediates)/check_vintf_vendor.log
check_vintf_all_deps += $(check_vintf_vendor_log)
# Check vendor SKU=(empty) case when:
# - DEVICE_MANIFEST_FILE is not empty; OR
# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
$(check_vintf_vendor_log): PRIVATE_VENDOR_SKUS := \
$(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
$(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
$(DEVICE_MANIFEST_SKUS)
$(check_vintf_vendor_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_vendor_deps) $(APEX_INFO_FILE)
$(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
( $< --check-one --dirmap /vendor:$(TARGET_OUT_VENDOR) --dirmap /apex:$(APEX_OUT) \
--property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
> $@ 2>&1 ) || ( cat $@ && exit 1 ); )
$(call declare-1p-target,$(check_vintf_vendor_log))
check_vintf_vendor_log :=
endif # check_vintf_vendor_deps
check_vintf_vendor_deps :=
# -- Kernel version and configurations.
ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
BUILT_KERNEL_CONFIGS_FILE := $(intermediates)/kernel_configs.txt
BUILT_KERNEL_VERSION_FILE := $(intermediates)/kernel_version.txt
my_board_extracted_kernel :=
# Tools for decompression that is not in PATH.
# Check $(EXTRACT_KERNEL) for decompression algorithms supported by the script.
# Algorithms that are in the script but not in this list will be found in PATH.
my_decompress_tools := \
lz4:$(HOST_OUT_EXECUTABLES)/lz4 \
# BOARD_KERNEL_VERSION can be used to override the values extracted
# from INSTALLED_KERNEL_TARGET.
ifdef BOARD_KERNEL_VERSION
$(BUILT_KERNEL_VERSION_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
$(BUILT_KERNEL_VERSION_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
$(BUILT_KERNEL_VERSION_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
KERNEL_RELEASE=`$(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
--output-release` ;\
if [ "$$KERNEL_RELEASE" != '$(BOARD_KERNEL_VERSION)' ]; then \
echo "Specified kernel version '$(BOARD_KERNEL_VERSION)' does not match actual kernel version '$$KERNEL_RELEASE' " ; exit 1; fi;
echo '$(BOARD_KERNEL_VERSION)' > $@
$(call declare-license-metadata,$(BUILT_KERNEL_VERSION_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
endif # BOARD_KERNEL_VERSION
ifneq ($(my_board_extracted_kernel),true)
ifdef INSTALLED_KERNEL_TARGET
ifndef BOARD_KERNEL_VERSION
$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
endif
$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
$(BUILT_KERNEL_CONFIGS_FILE): $(EXTRACT_KERNEL) $(firstword $(INSTALLED_KERNEL_TARGET))
$< --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(firstword $(INSTALLED_KERNEL_TARGET)) \
--output-configs $@ \
$(if $(BOARD_KERNEL_VERSION),,--output-release $(BUILT_KERNEL_VERSION_FILE))
$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
my_board_extracted_kernel := true
endif # INSTALLED_KERNEL_TARGET
endif # my_board_extracted_kernel
ifneq ($(my_board_extracted_kernel),true)
ifdef INSTALLED_BOOTIMAGE_TARGET
$(BUILT_KERNEL_CONFIGS_FILE): .KATI_IMPLICIT_OUTPUTS := $(BUILT_KERNEL_VERSION_FILE)
$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_DECOMPRESS_TOOLS := $(my_decompress_tools)
$(BUILT_KERNEL_CONFIGS_FILE): $(foreach pair,$(my_decompress_tools),$(call word-colon,2,$(pair)))
$(BUILT_KERNEL_CONFIGS_FILE): PRIVATE_UNPACKED_BOOTIMG := $(intermediates)/unpacked_bootimage
$(BUILT_KERNEL_CONFIGS_FILE): \
$(HOST_OUT_EXECUTABLES)/unpack_bootimg \
$(EXTRACT_KERNEL) \
$(INSTALLED_BOOTIMAGE_TARGET)
$(HOST_OUT_EXECUTABLES)/unpack_bootimg --boot_img $(INSTALLED_BOOTIMAGE_TARGET) --out $(PRIVATE_UNPACKED_BOOTIMG)
$(EXTRACT_KERNEL) --tools $(PRIVATE_DECOMPRESS_TOOLS) --input $(PRIVATE_UNPACKED_BOOTIMG)/kernel \
--output-configs $@ \
--output-release $(BUILT_KERNEL_VERSION_FILE)
$(call declare-license-metadata,$(BUILT_KERNEL_CONFIGS_FILE),SPDX-license-identifier-GPL-2.0-only,restricted,$(BUILD_SYSTEM)/LINUX_KERNEL_COPYING,"Kernel",kernel)
my_board_extracted_kernel := true
endif # INSTALLED_BOOTIMAGE_TARGET
endif # my_board_extracted_kernel
ifeq ($(my_board_extracted_kernel),true)
$(call dist-for-goals, droid_targets, $(BUILT_KERNEL_VERSION_FILE))
else
$(warning Neither INSTALLED_KERNEL_TARGET nor INSTALLED_BOOTIMAGE_TARGET is defined when \
PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS is true. Information about the updated kernel \
cannot be built into OTA update package. You can fix this by: \
(1) setting TARGET_NO_KERNEL to false and installing the built kernel to $(PRODUCT_OUT)/kernel,\
so that kernel information will be extracted from the built kernel; or \
(2) Add a prebuilt boot image and specify it in BOARD_PREBUILT_BOOTIMAGE; or \
(3) extracting kernel configuration and defining BOARD_KERNEL_CONFIG_FILE and \
BOARD_KERNEL_VERSION manually; or \
(4) unsetting PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS manually.)
# Clear their values to indicate that these two files does not exist.
BUILT_KERNEL_CONFIGS_FILE :=
BUILT_KERNEL_VERSION_FILE :=
endif
my_decompress_tools :=
my_board_extracted_kernel :=
endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
ifeq (default,$(ENABLE_UFFD_GC))
ifneq (,$(BUILT_KERNEL_VERSION_FILE))
$(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC): $(BUILT_KERNEL_VERSION_FILE)
$(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC):
if ! cmp -s $(BUILT_KERNEL_VERSION_FILE) $@ ; then cp $(BUILT_KERNEL_VERSION_FILE) $@; fi
.KATI_RESTAT: $(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC)
else
# We make this a warning rather than an error to avoid breaking too many builds. When it happens,
# we use a placeholder as the kernel version, which is consumed by uffd_gc_utils.py.
$(BUILT_KERNEL_VERSION_FILE_FOR_UFFD_GC):
echo $$'\
Unable to determine UFFD GC flag because the kernel version is not available and\n\
PRODUCT_ENABLE_UFFD_GC is "default".\n\
You can fix this by:\n\
1. [Recommended] Making the kernel version available.\n\
(1). Set PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS to "true".\n\
(2). If you are still getting this message after doing so, see the warning about\n\
PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS in the build logs.\n\
or\n\
2. Explicitly setting PRODUCT_ENABLE_UFFD_GC to "true" or "false" based on the kernel version.\n\
(1). Set PRODUCT_ENABLE_UFFD_GC to "true" if the kernel is a GKI kernel and is android12-5.4\n\
or above, or a non-GKI kernel that supports userfaultfd(2) and MREMAP_DONTUNMAP.\n\
(2). Set PRODUCT_ENABLE_UFFD_GC to "false" otherwise.'\
&& echo '' > $@
endif # BUILT_KERNEL_VERSION_FILE
endif # ENABLE_UFFD_GC == "default"
# -- Check VINTF compatibility of build.
# Skip partial builds; only check full builds. Only check if:
# - PRODUCT_ENFORCE_VINTF_MANIFEST is true
# - system / vendor VINTF metadata exists
# - Building product / system_ext / odm images if board has product / system_ext / odm images
ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
ifeq ($(check_vintf_has_system),true)
ifeq ($(check_vintf_has_vendor),true)
ifeq ($(filter true,$(BUILDING_ODM_IMAGE)),$(filter true,$(BOARD_USES_ODMIMAGE)))
ifeq ($(filter true,$(BUILDING_PRODUCT_IMAGE)),$(filter true,$(BOARD_USES_PRODUCTIMAGE)))
ifeq ($(filter true,$(BUILDING_SYSTEM_EXT_IMAGE)),$(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)))
check_vintf_compatible_log := $(intermediates)/check_vintf_compatible.log
check_vintf_all_deps += $(check_vintf_compatible_log)
check_vintf_compatible_args :=
check_vintf_compatible_deps := $(check_vintf_common_srcs) $(APEX_INFO_FILE)
ifeq ($(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS),true)
ifneq (,$(BUILT_KERNEL_VERSION_FILE)$(BUILT_KERNEL_CONFIGS_FILE))
check_vintf_compatible_args += --kernel $(BUILT_KERNEL_VERSION_FILE):$(BUILT_KERNEL_CONFIGS_FILE)
check_vintf_compatible_deps += $(BUILT_KERNEL_CONFIGS_FILE) $(BUILT_KERNEL_VERSION_FILE)
endif # BUILT_KERNEL_VERSION_FILE != "" || BUILT_KERNEL_CONFIGS_FILE != ""
endif # PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS
check_vintf_compatible_args += \
--dirmap /system:$(TARGET_OUT) \
--dirmap /vendor:$(TARGET_OUT_VENDOR) \
--dirmap /odm:$(TARGET_OUT_ODM) \
--dirmap /product:$(TARGET_OUT_PRODUCT) \
--dirmap /system_ext:$(TARGET_OUT_SYSTEM_EXT) \
--dirmap /apex:$(APEX_OUT) \
ifdef PRODUCT_SHIPPING_API_LEVEL
check_vintf_compatible_args += --property ro.product.first_api_level=$(PRODUCT_SHIPPING_API_LEVEL)
endif # PRODUCT_SHIPPING_API_LEVEL
$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_ARGS := $(check_vintf_compatible_args)
$(check_vintf_compatible_log): PRIVATE_CHECK_VINTF_DEPS := $(check_vintf_compatible_deps)
# Check ODM SKU=(empty) case when:
# - ODM_MANIFEST_FILES is not empty; OR
# - ODM_MANIFEST_FILES is empty AND ODM_MANIFEST_SKUS is empty (only ODM manifest fragments are used)
$(check_vintf_compatible_log): PRIVATE_ODM_SKUS := \
$(if $(ODM_MANIFEST_FILES),EMPTY_ODM_SKU_PLACEHOLDER,\
$(if $(ODM_MANIFEST_SKUS),,EMPTY_ODM_SKU_PLACEHOLDER)) \
$(ODM_MANIFEST_SKUS)
# Check vendor SKU=(empty) case when:
# - DEVICE_MANIFEST_FILE is not empty; OR
# - DEVICE_MANIFEST_FILE is empty AND DEVICE_MANIFEST_SKUS is empty (only vendor manifest fragments are used)
$(check_vintf_compatible_log): PRIVATE_VENDOR_SKUS := \
$(if $(DEVICE_MANIFEST_FILE),EMPTY_VENDOR_SKU_PLACEHOLDER,\
$(if $(DEVICE_MANIFEST_SKUS),,EMPTY_VENDOR_SKU_PLACEHOLDER)) \
$(DEVICE_MANIFEST_SKUS)
$(check_vintf_compatible_log): $(HOST_OUT_EXECUTABLES)/checkvintf $(check_vintf_compatible_deps)
@echo "PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS=$(PRODUCT_OTA_ENFORCE_VINTF_KERNEL_REQUIREMENTS)" > $@
@echo -n -e 'Deps: \n ' >> $@
@sed 's/ /\n /g' <<< "$(PRIVATE_CHECK_VINTF_DEPS)" >> $@
@echo -n -e 'Args: \n ' >> $@
@cat <<< "$(PRIVATE_CHECK_VINTF_ARGS)" >> $@
$(foreach odm_sku,$(PRIVATE_ODM_SKUS), $(foreach vendor_sku,$(PRIVATE_VENDOR_SKUS), \
echo "For ODM SKU = $(odm_sku), vendor SKU = $(vendor_sku)" >> $@; \
( $< --check-compat $(PRIVATE_CHECK_VINTF_ARGS) \
--property ro.boot.product.hardware.sku=$(filter-out EMPTY_ODM_SKU_PLACEHOLDER,$(odm_sku)) \
--property ro.boot.product.vendor.sku=$(filter-out EMPTY_VENDOR_SKU_PLACEHOLDER,$(vendor_sku)) \
>> $@ 2>&1 ) || (cat $@ && exit 1); ))
$(call declare-1p-target,$(check_vintf_compatible_log))
check_vintf_compatible_log :=
check_vintf_compatible_args :=
check_vintf_compatible_deps :=
endif # BUILDING_SYSTEM_EXT_IMAGE equals BOARD_USES_SYSTEM_EXTIMAGE
endif # BUILDING_PRODUCT_IMAGE equals BOARD_USES_PRODUCTIMAGE
endif # BUILDING_ODM_IMAGE equals BOARD_USES_ODMIMAGE
endif # check_vintf_has_vendor
endif # check_vintf_has_system
endif # PRODUCT_ENFORCE_VINTF_MANIFEST
# Add all logs of VINTF checks to dist builds
droid_targets: $(check_vintf_all_deps)
$(call dist-for-goals, droid_targets, $(check_vintf_all_deps))
# Helper alias to check all VINTF of current build.
.PHONY: check-vintf-all
check-vintf-all: $(check_vintf_all_deps)
$(foreach file,$^,echo "$(file)"; cat "$(file)"; echo;)
check_vintf_has_vendor :=
check_vintf_has_system :=
check_vintf_common_srcs :=
check_vintf_all_deps :=
intermediates :=
endif # !TARGET_BUILD_UNBUNDLED
# -----------------------------------------------------------------
# Check image sizes <= size of super partition
ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
PARTITIONS_AND_OTHER_IN_SUPER := $(BOARD_SUPER_PARTITION_PARTITION_LIST)
# Add the system other image to the misc_info. Because factory ota may install system_other to the super partition.
ifdef BUILDING_SYSTEM_OTHER_IMAGE
PARTITIONS_AND_OTHER_IN_SUPER += system_other
endif # BUILDING_SYSTEM_OTHER_IMAGE
# $(1): misc_info.txt
# #(2): optional log file
define check-all-partition-sizes-target
mkdir -p $(dir $(1))
rm -f $(1)
$(call dump-super-image-info, $(1))
$(foreach partition,$(PARTITIONS_AND_OTHER_IN_SUPER), \
echo "$(partition)_image="$(call images-for-partitions,$(partition)) >> $(1);)
$(CHECK_PARTITION_SIZES) $(if $(2),--logfile $(2),-v) $(1)
endef
check_all_partition_sizes_log := $(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/check_all_partition_sizes.log
droid_targets: $(check_all_partition_sizes_log)
$(call dist-for-goals, droid_targets, $(check_all_partition_sizes_log))
$(check_all_partition_sizes_log): \
$(CHECK_PARTITION_SIZES) \
$(call images-for-partitions,$(PARTITIONS_AND_OTHER_IN_SUPER))
$(call check-all-partition-sizes-target, \
$(call intermediates-dir-for,PACKAGING,check-all-partition-sizes)/misc_info.txt, \
$@)
$(call declare-1p-target,$(check_all_partition_sizes_log))
.PHONY: check-all-partition-sizes
check-all-partition-sizes: $(check_all_partition_sizes_log)
.PHONY: check-all-partition-sizes-nodeps
check-all-partition-sizes-nodeps:
$(call check-all-partition-sizes-target, \
$(call intermediates-dir-for,PACKAGING,check-all-partition-sizes-nodeps)/misc_info.txt)
endif # PRODUCT_BUILD_SUPER_PARTITION
endif # !TARGET_BUILD_UNBUNDLED
# -----------------------------------------------------------------
# bring in the installer image generation defines if necessary
ifeq ($(TARGET_USE_DISKINSTALLER),true)
include bootable/diskinstaller/config.mk
endif
# -----------------------------------------------------------------
# host tools needed to build dist and OTA packages
ifeq ($(BUILD_OS),darwin)
build_ota_package := false
build_otatools_package := false
else
# Set build_ota_package, and allow opt-out below.
build_ota_package := true
ifeq ($(TARGET_SKIP_OTA_PACKAGE),true)
build_ota_package := false
endif
ifneq (,$(filter address, $(SANITIZE_TARGET)))
build_ota_package := false
endif
ifeq ($(TARGET_PRODUCT),sdk)
build_ota_package := false
endif
# A target without a kernel may be one of the following:
# - A generic target. In this case, the OTA package usually isn't built.
# PRODUCT_BUILD_GENERIC_OTA_PACKAGE may be set to true to force OTA package
# generation.
# - A real device target, with TARGET_NO_KERNEL set to true and
# BOARD_PREBUILT_BOOTIMAGE set. In this case, it is valid to generate
# an OTA package.
ifneq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
ifneq ($(filter generic%,$(TARGET_DEVICE)),)
build_ota_package := false
endif
ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
ifeq ($(TARGET_NO_KERNEL),true)
build_ota_package := false
endif
endif # INSTALLED_BOOTIMAGE_TARGET == ""
ifeq ($(recovery_fstab),)
ifeq ($(filter $(TARGET_RECOVERY_ROOT_OUT)/system/etc/recovery.fstab,$(INTERNAL_RECOVERYIMAGE_FILES)),)
build_ota_package := false
endif
endif
endif # PRODUCT_BUILD_GENERIC_OTA_PACKAGE
# Set build_otatools_package, and allow opt-out below.
build_otatools_package := true
ifeq ($(TARGET_SKIP_OTATOOLS_PACKAGE),true)
build_otatools_package := false
endif
endif
ifeq ($(build_otatools_package),true)
INTERNAL_OTATOOLS_MODULES := \
aapt2 \
add_img_to_target_files \
apksigner \
append2simg \
avbtool \
blk_alloc_to_base_fs \
boot_signer \
brillo_update_payload \
brotli \
bsdiff \
build_image \
build_mixed_kernels_ramdisk_host \
build_super_image \
build_verity_metadata \
build_verity_tree \
care_map_generator \
check_ota_package_signature \
check_target_files_signatures \
check_target_files_vintf \
checkvintf \
create_brick_ota \
delta_generator \
e2fsck \
e2fsdroid \
fc_sort \
fec \
fsck.erofs \
fsck.f2fs \
fs_config \
generate_verity_key \
host_init_verifier \
img2simg \
img_from_target_files \
imgdiff \
initrd_bootconfig \
libconscrypt_openjdk_jni \
lpmake \
lpunpack \
lz4 \
make_f2fs \
make_f2fs_casefold \
merge_ota \
merge_target_files \
mk_combined_img \
mkbootfs \
mkbootimg \
mke2fs \
mke2fs.conf \
mkfs.erofs \
mkf2fsuserimg \
mksquashfs \
mksquashfsimage \
mkuserimg_mke2fs \
ota_extractor \
ota_from_target_files \
repack_bootimg \
secilc \
sefcontext_compile \
sgdisk \
shflags \
sign_apex \
sign_target_files_apks \
sign_virt_apex \
signapk \
simg2img \
sload_f2fs \
toybox \
tune2fs \
unpack_bootimg \
update_device \
update_host_simulator \
validate_target_files \
verity_signer \
verity_verifier \
zipalign \
zucchini \
zip2zip \
# Additional tools to unpack and repack the apex file.
INTERNAL_OTATOOLS_MODULES += \
apexd_host \
apexer \
apex_compression_tool \
deapexer \
debugfs_static \
fsck.erofs \
make_erofs \
merge_zips \
resize2fs \
soong_zip \
INTERNAL_OTATOOLS_FILES := \
$(filter $(HOST_OUT)/%,$(call module-installed-files,$(INTERNAL_OTATOOLS_MODULES)))
.PHONY: otatools
otatools: $(INTERNAL_OTATOOLS_FILES)
endif # build_otatools_package
# -----------------------------------------------------------------
# fastboot-info.txt
FASTBOOT_INFO_VERSION = 1
INSTALLED_FASTBOOT_INFO_TARGET := $(PRODUCT_OUT)/fastboot-info.txt
ifdef TARGET_BOARD_FASTBOOT_INFO_FILE
$(INSTALLED_FASTBOOT_INFO_TARGET): $(TARGET_BOARD_FASTBOOT_INFO_FILE)
rm -f $@
$(call pretty,"Target fastboot-info.txt: $@")
$(hide) cp $< $@
else
$(INSTALLED_FASTBOOT_INFO_TARGET):
rm -f $@
$(call pretty,"Target fastboot-info.txt: $@")
$(hide) echo "# fastboot-info for $(TARGET_PRODUCT)" >> $@
$(hide) echo "version $(FASTBOOT_INFO_VERSION)" >> $@
ifneq ($(INSTALLED_BOOTIMAGE_TARGET),)
$(hide) echo "flash boot" >> $@
endif
ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
$(hide) echo "flash init_boot" >> $@
endif
ifdef BOARD_PREBUILT_DTBOIMAGE
$(hide) echo "flash dtbo" >> $@
endif
ifneq ($(INSTALLED_DTIMAGE_TARGET),)
$(hide) echo "flash dts dt.img" >> $@
endif
ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
$(hide) echo "flash vendor_kernel_boot" >> $@
endif
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) echo "flash recovery" >> $@
endif
ifeq ($(BOARD_USES_PVMFWIMAGE),true)
$(hide) echo "flash pvmfw" >> $@
endif
ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
$(hide) echo "flash vendor_boot" >> $@
endif
ifeq ($(BOARD_AVB_ENABLE),true)
ifeq ($(BUILDING_VBMETA_IMAGE),true)
$(hide) echo "flash --apply-vbmeta vbmeta" >> $@
endif
ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
$(hide) echo "flash vbmeta_system" >> $@
endif
ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
$(hide) echo "flash vbmeta_vendor" >> $@
endif
ifneq (,$(strip $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)))
$(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS), \
echo "flash vbmeta_$(partition)" >> $@;)
endif
endif # BOARD_AVB_ENABLE
ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
$(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
$(if $(BOARD_$(call to-upper,$(partition))_IMAGE_NO_FLASHALL),, \
echo "flash $(partition)" >> $@; \
) \
)
endif
$(hide) echo "reboot fastboot" >> $@
$(hide) echo "update-super" >> $@
$(hide) $(foreach partition,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
echo "flash $(partition)" >> $@;)
ifdef BUILDING_SYSTEM_OTHER_IMAGE
$(hide) echo "flash --slot-other system system_other.img" >> $@
endif
ifdef BUILDING_CACHE_IMAGE
$(hide) echo "if-wipe erase cache" >> $@
endif
$(hide) echo "if-wipe erase userdata" >> $@
ifeq ($(BOARD_USES_METADATA_PARTITION),true)
$(hide) echo "if-wipe erase metadata" >> $@
endif
endif
# -----------------------------------------------------------------
# misc_info.txt
INSTALLED_MISC_INFO_TARGET := $(PRODUCT_OUT)/misc_info.txt
ifeq ($(TARGET_RELEASETOOLS_EXTENSIONS),)
# default to common dir for device vendor
tool_extensions := $(TARGET_DEVICE_DIR)/../common
else
tool_extensions := $(TARGET_RELEASETOOLS_EXTENSIONS)
endif
.KATI_READONLY := tool_extensions
# $1: boot image file name
define misc_boot_size
$(subst .img,_size,$(1))=$(BOARD_KERNEL$(call to-upper,$(subst boot,,$(subst .img,,$(1))))_BOOTIMAGE_PARTITION_SIZE)
endef
$(INSTALLED_MISC_INFO_TARGET):
rm -f $@
$(call pretty,"Target misc_info.txt: $@")
$(hide) echo "recovery_api_version=$(RECOVERY_API_VERSION)" >> $@
$(hide) echo "fstab_version=$(RECOVERY_FSTAB_VERSION)" >> $@
ifdef BOARD_FLASH_BLOCK_SIZE
$(hide) echo "blocksize=$(BOARD_FLASH_BLOCK_SIZE)" >> $@
endif
ifneq ($(strip $(BOARD_BOOTIMAGE_PARTITION_SIZE))$(strip $(BOARD_KERNEL_BINARIES)),)
$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),\
echo "$(call misc_boot_size,$(notdir $(b)))" >> $@;)
endif
ifeq ($(INSTALLED_BOOTIMAGE_TARGET),)
$(hide) echo "no_boot=true" >> $@
else
echo "boot_images=$(foreach b,$(INSTALLED_BOOTIMAGE_TARGET),$(notdir $(b)))" >> $@
endif
ifneq ($(INSTALLED_INIT_BOOT_IMAGE_TARGET),)
$(hide) echo "init_boot=true" >> $@
$(hide) echo "init_boot_size=$(BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE)" >> $@
endif
ifeq ($(BOARD_RAMDISK_USE_LZ4),true)
echo "lz4_ramdisks=true" >> $@
endif
ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
echo "vendor_boot=true" >> $@
echo "vendor_boot_size=$(BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE)" >> $@
endif
ifneq ($(INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET),)
echo "vendor_kernel_boot=true" >> $@
echo "vendor_kernel_boot_size=$(BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE)" >> $@
endif
ifeq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) echo "no_recovery=true" >> $@
endif
ifdef BOARD_INCLUDE_RECOVERY_DTBO
$(hide) echo "include_recovery_dtbo=true" >> $@
endif
ifdef BOARD_INCLUDE_RECOVERY_ACPIO
$(hide) echo "include_recovery_acpio=true" >> $@
endif
ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
$(hide) echo "recovery_size=$(BOARD_RECOVERYIMAGE_PARTITION_SIZE)" >> $@
endif
ifdef TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS
@# TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS can be empty to indicate that nothing but defaults should be used.
$(hide) echo "recovery_mount_options=$(TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
else
$(hide) echo "recovery_mount_options=$(DEFAULT_TARGET_RECOVERY_FSTYPE_MOUNT_OPTIONS)" >> $@
endif
$(hide) echo "tool_extensions=$(tool_extensions)" >> $@
$(hide) echo "default_system_dev_certificate=$(DEFAULT_SYSTEM_DEV_CERTIFICATE)" >> $@
ifdef PRODUCT_EXTRA_OTA_KEYS
$(hide) echo "extra_ota_keys=$(PRODUCT_EXTRA_OTA_KEYS)" >> $@
endif
ifdef PRODUCT_EXTRA_RECOVERY_KEYS
$(hide) echo "extra_recovery_keys=$(PRODUCT_EXTRA_RECOVERY_KEYS)" >> $@
endif
$(hide) echo 'mkbootimg_args=$(BOARD_MKBOOTIMG_ARGS)' >> $@
$(hide) echo 'recovery_mkbootimg_args=$(BOARD_RECOVERY_MKBOOTIMG_ARGS)' >> $@
$(hide) echo 'mkbootimg_version_args=$(INTERNAL_MKBOOTIMG_VERSION_ARGS)' >> $@
$(hide) echo 'mkbootimg_init_args=$(BOARD_MKBOOTIMG_INIT_ARGS)' >> $@
$(hide) echo "multistage_support=1" >> $@
$(hide) echo "blockimgdiff_versions=3,4" >> $@
ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
$(hide) echo "build_generic_ota_package=true" >> $@
endif
ifneq ($(OEM_THUMBPRINT_PROPERTIES),)
# OTA scripts are only interested in fingerprint related properties
$(hide) echo "oem_fingerprint_properties=$(OEM_THUMBPRINT_PROPERTIES)" >> $@
endif
ifneq (,$(filter address, $(SANITIZE_TARGET)))
# We need to create userdata.img with real data because the instrumented libraries are in userdata.img.
$(hide) echo "userdata_img_with_data=true" >> $@
endif
ifeq ($(BOARD_USES_FULL_RECOVERY_IMAGE),true)
$(hide) echo "full_recovery_image=true" >> $@
endif
ifdef BOARD_USES_VENDORIMAGE
$(hide) echo "board_uses_vendorimage=true" >> $@
endif
ifeq ($(BOARD_AVB_ENABLE),true)
ifeq ($(BUILDING_VBMETA_IMAGE),true)
$(hide) echo "avb_building_vbmeta_image=true" >> $@
endif # BUILDING_VBMETA_IMAGE
$(hide) echo "avb_enable=true" >> $@
$(hide) echo "avb_vbmeta_key_path=$(BOARD_AVB_KEY_PATH)" >> $@
$(hide) echo "avb_vbmeta_algorithm=$(BOARD_AVB_ALGORITHM)" >> $@
$(hide) echo "avb_vbmeta_args=$(BOARD_AVB_MAKE_VBMETA_IMAGE_ARGS)" >> $@
$(hide) echo "avb_boot_add_hash_footer_args=$(BOARD_AVB_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_BOOT_KEY_PATH
$(hide) echo "avb_boot_key_path=$(BOARD_AVB_BOOT_KEY_PATH)" >> $@
$(hide) echo "avb_boot_algorithm=$(BOARD_AVB_BOOT_ALGORITHM)" >> $@
$(hide) echo "avb_boot_rollback_index_location=$(BOARD_AVB_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_BOOT_KEY_PATH
$(hide) echo "avb_init_boot_add_hash_footer_args=$(BOARD_AVB_INIT_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_INIT_BOOT_KEY_PATH
$(hide) echo "avb_init_boot_key_path=$(BOARD_AVB_INIT_BOOT_KEY_PATH)" >> $@
$(hide) echo "avb_init_boot_algorithm=$(BOARD_AVB_INIT_BOOT_ALGORITHM)" >> $@
$(hide) echo "avb_init_boot_rollback_index_location=$(BOARD_AVB_INIT_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_INIT_BOOT_KEY_PATH
echo "avb_vendor_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_VENDOR_BOOT_KEY_PATH
echo "avb_vendor_boot_key_path=$(BOARD_AVB_VENDOR_BOOT_KEY_PATH)" >> $@
echo "avb_vendor_boot_algorithm=$(BOARD_AVB_VENDOR_BOOT_ALGORITHM)" >> $@
echo "avb_vendor_boot_rollback_index_location=$(BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_VENDOR_BOOT_KEY_PATH
echo "avb_vendor_kernel_boot_add_hash_footer_args=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
echo "avb_vendor_kernel_boot_key_path=$(BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH)" >> $@
echo "avb_vendor_kernel_boot_algorithm=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM)" >> $@
echo "avb_vendor_kernel_boot_rollback_index_location=$(BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
$(hide) echo "avb_recovery_add_hash_footer_args=$(BOARD_AVB_RECOVERY_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_RECOVERY_KEY_PATH
$(hide) echo "avb_recovery_key_path=$(BOARD_AVB_RECOVERY_KEY_PATH)" >> $@
$(hide) echo "avb_recovery_algorithm=$(BOARD_AVB_RECOVERY_ALGORITHM)" >> $@
$(hide) echo "avb_recovery_rollback_index_location=$(BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_RECOVERY_KEY_PATH
ifneq (,$(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)))
$(hide) echo "custom_images_partition_list=$(filter-out $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), $(BOARD_CUSTOMIMAGES_PARTITION_LIST))" >> $@
$(hide) $(foreach partition,$(filter-out $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), $(BOARD_CUSTOMIMAGES_PARTITION_LIST)), \
echo "$(partition)_image_list=$(foreach image,$(BOARD_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
ifneq (,$(strip $(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST)))
$(hide) echo "avb_custom_images_partition_list=$(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST)" >> $@
$(hide) $(foreach partition,$(BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST), \
echo "avb_$(partition)_key_path=$(BOARD_AVB_$(call to-upper,$(partition))_KEY_PATH)" >> $@; \
echo "avb_$(partition)_algorithm=$(BOARD_AVB_$(call to-upper,$(partition))_ALGORITHM)" >> $@; \
echo "avb_$(partition)_add_hashtree_footer_args=$(BOARD_AVB_$(call to-upper,$(partition))_ADD_HASHTREE_FOOTER_ARGS)" >> $@; \
echo "avb_$(partition)_rollback_index_location=$(BOARD_AVB_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@; \
echo "avb_$(partition)_partition_size=$(BOARD_AVB_$(call to-upper,$(partition))_PARTITION_SIZE)" >> $@; \
echo "avb_$(partition)_image_list=$(foreach image,$(BOARD_AVB_$(call to-upper,$(partition))_IMAGE_LIST),$(notdir $(image)))" >> $@;)
endif # BOARD_AVB_CUSTOMIMAGES_PARTITION_LIST
ifneq (,$(strip $(BOARD_AVB_VBMETA_SYSTEM)))
$(hide) echo "avb_vbmeta_system=$(BOARD_AVB_VBMETA_SYSTEM)" >> $@
$(hide) echo "avb_vbmeta_system_args=$(BOARD_AVB_MAKE_VBMETA_SYSTEM_IMAGE_ARGS)" >> $@
$(hide) echo "avb_vbmeta_system_key_path=$(BOARD_AVB_VBMETA_SYSTEM_KEY_PATH)" >> $@
$(hide) echo "avb_vbmeta_system_algorithm=$(BOARD_AVB_VBMETA_SYSTEM_ALGORITHM)" >> $@
$(hide) echo "avb_vbmeta_system_rollback_index_location=$(BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_VBMETA_SYSTEM
ifneq (,$(strip $(BOARD_AVB_VBMETA_VENDOR)))
$(hide) echo "avb_vbmeta_vendor=$(BOARD_AVB_VBMETA_VENDOR)" >> $@
$(hide) echo "avb_vbmeta_vendor_args=$(BOARD_AVB_MAKE_VBMETA_VENDOR_IMAGE_ARGS)" >> $@
$(hide) echo "avb_vbmeta_vendor_key_path=$(BOARD_AVB_VBMETA_VENDOR_KEY_PATH)" >> $@
$(hide) echo "avb_vbmeta_vendor_algorithm=$(BOARD_AVB_VBMETA_VENDOR_ALGORITHM)" >> $@
$(hide) echo "avb_vbmeta_vendor_rollback_index_location=$(BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_VBMETA_VENDOR_KEY_PATH
ifneq (,$(strip $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)))
$(hide) echo "avb_custom_vbmeta_images_partition_list=$(sort $(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS))" >> $@
$(hide) $(foreach partition,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS),\
echo "avb_vbmeta_$(partition)=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition)))" >> $@ ;\
echo "avb_vbmeta_$(partition)_args=$(BOARD_AVB_MAKE_VBMETA_$(call to-upper,$(partition))_IMAGE_ARGS)" >> $@ ;\
echo "avb_vbmeta_$(partition)_key_path=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_KEY_PATH)" >> $@ ;\
echo "avb_vbmeta_$(partition)_algorithm=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_ALGORITHM)" >> $@ ;\
echo "avb_vbmeta_$(partition)_rollback_index_location=$(BOARD_AVB_VBMETA_$(call to-upper,$(partition))_ROLLBACK_INDEX_LOCATION)" >> $@ ;)
endif # BOARD_AVB_VBMETA_CUSTOM_PARTITIONS
endif # BOARD_AVB_ENABLE
$(call generate-userimage-prop-dictionary, $@)
ifeq ($(AB_OTA_UPDATER),true)
@# Include the build type in META/misc_info.txt so the server can easily differentiate production builds.
$(hide) echo "build_type=$(TARGET_BUILD_VARIANT)" >> $@
$(hide) echo "ab_update=true" >> $@
endif
ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
$(hide) echo "allow_non_ab=true" >> $@
endif
ifeq ($(BOARD_NON_AB_OTA_DISABLE_COMPRESSION),true)
$(hide) echo "board_non_ab_ota_disable_compression=true" >> $@
endif
ifdef BOARD_PREBUILT_DTBOIMAGE
$(hide) echo "has_dtbo=true" >> $@
ifeq ($(BOARD_AVB_ENABLE),true)
$(hide) echo "dtbo_size=$(BOARD_DTBOIMG_PARTITION_SIZE)" >> $@
$(hide) echo "avb_dtbo_add_hash_footer_args=$(BOARD_AVB_DTBO_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_DTBO_KEY_PATH
$(hide) echo "avb_dtbo_key_path=$(BOARD_AVB_DTBO_KEY_PATH)" >> $@
$(hide) echo "avb_dtbo_algorithm=$(BOARD_AVB_DTBO_ALGORITHM)" >> $@
$(hide) echo "avb_dtbo_rollback_index_location=$(BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_DTBO_KEY_PATH
endif # BOARD_AVB_ENABLE
endif # BOARD_PREBUILT_DTBOIMAGE
ifeq ($(BOARD_USES_PVMFWIMAGE),true)
$(hide) echo "has_pvmfw=true" >> $@
ifeq ($(BOARD_AVB_ENABLE),true)
$(hide) echo "pvmfw_size=$(BOARD_PVMFWIMAGE_PARTITION_SIZE)" >> $@
$(hide) echo "avb_pvmfw_add_hash_footer_args=$(BOARD_AVB_PVMFW_ADD_HASH_FOOTER_ARGS)" >> $@
ifdef BOARD_AVB_PVMFW_KEY_PATH
$(hide) echo "avb_pvmfw_key_path=$(BOARD_AVB_PVMFW_KEY_PATH)" >> $@
$(hide) echo "avb_pvmfw_algorithm=$(BOARD_AVB_PVMFW_ALGORITHM)" >> $@
$(hide) echo "avb_pvmfw_rollback_index_location=$(BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION)" >> $@
endif # BOARD_AVB_PVMFW_KEY_PATH
endif # BOARD_AVB_ENABLE
endif # BOARD_USES_PVMFWIMAGE
$(call dump-dynamic-partitions-info,$@)
@# VINTF checks
ifeq ($(PRODUCT_ENFORCE_VINTF_MANIFEST),true)
$(hide) echo "vintf_enforce=true" >> $@
endif
ifdef ODM_MANIFEST_SKUS
$(hide) echo "vintf_odm_manifest_skus=$(ODM_MANIFEST_SKUS)" >> $@
endif
ifdef ODM_MANIFEST_FILES
$(hide) echo "vintf_include_empty_odm_sku=true" >> $@
endif
ifdef DEVICE_MANIFEST_SKUS
$(hide) echo "vintf_vendor_manifest_skus=$(DEVICE_MANIFEST_SKUS)" >> $@
endif
ifdef DEVICE_MANIFEST_FILE
$(hide) echo "vintf_include_empty_vendor_sku=true" >> $@
endif
ifeq ($(BOARD_BOOTLOADER_IN_UPDATE_PACKAGE),true)
$(hide) echo "bootloader_in_update_package=true" >> $@
endif
ifeq ($(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE),true)
$(hide) echo "exclude_kernel_from_recovery_image=true" >> $@
endif
ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
$(hide) echo "partial_ota_update_partitions_list=$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)" >> $@
endif
$(hide) sort -o $@ $@
$(call declare-0p-target,$(INSTALLED_FASTBOOT_INFO_TARGET))
.PHONY: fastboot_info
fastboot_info: $(INSTALLED_FASTBOOT_INFO_TARGET)
droidcore-unbundled: $(INSTALLED_FASTBOOT_INFO_TARGET)
$(call declare-0p-target,$(INSTALLED_MISC_INFO_TARGET))
.PHONY: misc_info
misc_info: $(INSTALLED_MISC_INFO_TARGET)
droidcore-unbundled: $(INSTALLED_MISC_INFO_TARGET)
# -----------------------------------------------------------------
# A zip of the directories that map to the target filesystem.
# This zip can be used to create an OTA package or filesystem image
# as a post-build step.
#
name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
name := $(name)-target_files
intermediates := $(call intermediates-dir-for,PACKAGING,target_files)
BUILT_TARGET_FILES_DIR := $(intermediates)/$(name).zip.list
BUILT_TARGET_FILES_PACKAGE := $(intermediates)/$(name).zip
$(BUILT_TARGET_FILES_PACKAGE): zip_root := $(intermediates)/$(name)
$(BUILT_TARGET_FILES_DIR): zip_root := $(intermediates)/$(name)
$(BUILT_TARGET_FILES_DIR): intermediates := $(intermediates)
ifneq ($(SOONG_DEFINED_SYSTEM_IMAGE_PATH),)
$(BUILT_TARGET_FILES_DIR): $(SOONG_DEFINED_SYSTEM_IMAGE_PATH)
endif
# $(1): Directory to copy
# $(2): Location to copy it to
# The "ls -A" is to skip if $(1) is empty.
define package_files-copy-root
if [ -d "$(strip $(1))" -a "$$(ls -A $(1))" ]; then \
mkdir -p $(2) && \
$(ACP) -rd $(strip $(1))/. $(strip $(2))/; \
fi
endef
built_ota_tools :=
# We can't build static executables when SANITIZE_TARGET=address
ifeq (,$(filter address, $(SANITIZE_TARGET)))
ifeq (false,$(AB_OTA_UPDATER))
built_ota_tools += \
$(call intermediates-dir-for,EXECUTABLES,updater)/updater
endif
endif
$(BUILT_TARGET_FILES_DIR): PRIVATE_OTA_TOOLS := $(built_ota_tools)
tool_extension := $(wildcard $(tool_extensions)/releasetools.py)
$(BUILT_TARGET_FILES_DIR): PRIVATE_TOOL_EXTENSION := $(tool_extension)
updater_dep :=
ifeq ($(AB_OTA_UPDATER),true)
updater_dep += system/update_engine/update_engine.conf
$(call declare-1p-target,system/update_engine/update_engine.conf,system/update_engine)
updater_dep += external/zucchini/version_info.h
$(call declare-license-metadata,external/zucchini/version_info.h,legacy_notice,notice,external/zucchini/LICENSE,external/zucchini)
updater_dep += $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so
endif
# Build OTA tools if non-A/B is allowed
ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
updater_dep += $(built_ota_tools)
endif
$(BUILT_TARGET_FILES_DIR): $(updater_dep)
# If we are using recovery as boot, output recovery files to BOOT/.
# If we are moving recovery resources to vendor_boot, output recovery files to VENDOR_BOOT/.
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
$(BUILT_TARGET_FILES_DIR): PRIVATE_RECOVERY_OUT := BOOT
else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
$(BUILT_TARGET_FILES_DIR): PRIVATE_RECOVERY_OUT := VENDOR_BOOT
else
$(BUILT_TARGET_FILES_DIR): PRIVATE_RECOVERY_OUT := RECOVERY
endif
ifeq ($(AB_OTA_UPDATER),true)
ifdef OSRELEASED_DIRECTORY
$(BUILT_TARGET_FILES_DIR): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id
$(BUILT_TARGET_FILES_DIR): $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version
$(BUILT_TARGET_FILES_DIR): $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version
endif
endif
ifneq ($(AB_OTA_PARTITIONS),)
ifneq ($(AB_OTA_UPDATER),true)
$(error AB_OTA_UPDATER must be true when defining AB_OTA_PARTITIONS)
endif
endif
# Run fs_config while creating the target files package
# $1: root directory
# $2: add prefix
define fs_config
(cd $(1); find . -type d | sed 's,$$,/,'; find . \! -type d) | cut -c 3- | sort | sed 's,^,$(2),' | $(HOST_OUT_EXECUTABLES)/fs_config -C -D $(TARGET_OUT) -R "$(2)"
endef
define filter-out-missing-vendor
$(if $(INSTALLED_VENDORIMAGE_TARGET),$(1),$(filter-out vendor,$(1)))
endef
define filter-out-missing-vendor_dlkm
$(if $(INSTALLED_VENDOR_DLKMIMAGE_TARGET),$(1),$(filter-out vendor_dlkm,$(1)))
endef
define filter-out-missing-odm
$(if $(INSTALLED_ODMIMAGE_TARGET),$(1),$(filter-out odm,$(1)))
endef
define filter-out-missing-odm_dlkm
$(if $(INSTALLED_ODM_DLKMIMAGE_TARGET),$(1),$(filter-out odm_dlkm,$(1)))
endef
define filter-out-missing-system_dlkm
$(if $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET),$(1),$(filter-out system_dlkm,$(1)))
endef
# Filter out vendor,vendor_dlkm,odm,odm_dlkm,system_dlkm from the list for AOSP targets.
# $(1): list
define filter-out-missing-partitions
$(call filter-out-missing-vendor,\
$(call filter-out-missing-vendor_dlkm,\
$(call filter-out-missing-odm,\
$(call filter-out-missing-odm_dlkm,\
$(call filter-out-missing-system_dlkm,$(1))))))
endef
# Information related to dynamic partitions and virtual A/B. This information
# is needed for building the super image (see dump-super-image-info) and
# building OTA packages.
# $(1): file
define dump-dynamic-partitions-info
$(if $(filter true,$(PRODUCT_USE_DYNAMIC_PARTITIONS)), \
echo "use_dynamic_partitions=true" >> $(1))
$(if $(filter true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)), \
echo "dynamic_partition_retrofit=true" >> $(1))
echo "lpmake=$(notdir $(LPMAKE))" >> $(1)
$(if $(filter true,$(PRODUCT_BUILD_SUPER_PARTITION)), $(if $(BOARD_SUPER_PARTITION_SIZE), \
echo "build_super_partition=true" >> $(1)))
$(if $(BUILDING_SUPER_EMPTY_IMAGE), \
echo "build_super_empty_partition=true" >> $(1))
$(if $(filter true,$(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE)), \
echo "build_retrofit_dynamic_partitions_ota_package=true" >> $(1))
echo "super_metadata_device=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)" >> $(1)
$(if $(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
echo "super_block_devices=$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)" >> $(1))
$(foreach device,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES), \
echo "super_$(device)_device_size=$(BOARD_SUPER_PARTITION_$(call to-upper,$(device))_DEVICE_SIZE)" >> $(1);)
$(if $(BOARD_SUPER_PARTITION_PARTITION_LIST), \
echo "dynamic_partition_list=$(sort $(call filter-out-missing-partitions,$(BOARD_SUPER_PARTITION_PARTITION_LIST)))" >> $(1))
$(if $(BOARD_SUPER_PARTITION_GROUPS),
echo "super_partition_groups=$(BOARD_SUPER_PARTITION_GROUPS)" >> $(1))
$(foreach group,$(BOARD_SUPER_PARTITION_GROUPS), \
echo "super_$(group)_group_size=$(BOARD_$(call to-upper,$(group))_SIZE)" >> $(1); \
$(if $(BOARD_$(call to-upper,$(group))_PARTITION_LIST), \
echo "super_$(group)_partition_list=$(strip $(call filter-out-missing-partitions,$(BOARD_$(call to-upper,$(group))_PARTITION_LIST)))" >> $(1);))
$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_EXT_DISABLED)), \
echo "build_non_sparse_super_partition=true" >> $(1))
$(if $(filter true,$(TARGET_USERIMAGES_SPARSE_F2FS_DISABLED)), \
echo "build_non_sparse_super_partition=true" >> $(1))
$(if $(filter true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE)), \
echo "super_image_in_update_package=true" >> $(1))
$(if $(BOARD_SUPER_PARTITION_SIZE), \
echo "super_partition_size=$(BOARD_SUPER_PARTITION_SIZE)" >> $(1))
$(if $(BOARD_SUPER_PARTITION_ALIGNMENT), \
echo "super_partition_alignment=$(BOARD_SUPER_PARTITION_ALIGNMENT)" >> $(1))
$(if $(BOARD_SUPER_PARTITION_WARN_LIMIT), \
echo "super_partition_warn_limit=$(BOARD_SUPER_PARTITION_WARN_LIMIT)" >> $(1))
$(if $(BOARD_SUPER_PARTITION_ERROR_LIMIT), \
echo "super_partition_error_limit=$(BOARD_SUPER_PARTITION_ERROR_LIMIT)" >> $(1))
$(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA)), \
echo "virtual_ab=true" >> $(1))
$(if $(filter true,$(PRODUCT_VIRTUAL_AB_COMPRESSION)), \
echo "virtual_ab_compression=true" >> $(1))
# This value controls the compression algorithm used for VABC
# valid options are defined in system/core/fs_mgr/libsnapshot/cow_writer.cpp
# e.g. "none", "gz", "brotli"
$(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD), \
echo "virtual_ab_compression_method=$(PRODUCT_VIRTUAL_AB_COMPRESSION_METHOD)" >> $(1))
$(if $(filter true,$(PRODUCT_VIRTUAL_AB_OTA_RETROFIT)), \
echo "virtual_ab_retrofit=true" >> $(1))
$(if $(PRODUCT_VIRTUAL_AB_COW_VERSION), \
echo "virtual_ab_cow_version=$(PRODUCT_VIRTUAL_AB_COW_VERSION)" >> $(1))
$(if $(PRODUCT_VIRTUAL_AB_COMPRESSION_FACTOR), \
echo "virtual_ab_compression_factor=$(PRODUCT_VIRTUAL_AB_COMPRESSION_FACTOR)" >> $(1))
endef
# Copy an image file to a directory and generate a block list map file from the image,
# only if the map_file_generator supports the file system.
# Otherwise, skip generating map files as well as copying images. The image will be
# generated from the $(ADD_IMG_TO_TARGET_FILES) to generate the map file with it.
# $(1): path of the image file
# $(2): target out directory
# $(3): image name to generate a map file. skip generating map file if empty
define copy-image-and-generate-map
$(if $(COPY_IMAGES_FOR_TARGET_FILES_ZIP), \
$(eval _supported_fs_for_map_file_generator := erofs ext%) \
$(eval _img := $(call to-upper,$(3))) \
$(if $(3),$(eval _map_fs_type := $(BOARD_$(_img)IMAGE_FILE_SYSTEM_TYPE)),\
$(eval _no_map_file := "true")) \
$(if $(filter $(_supported_fs_for_map_file_generator),$(_map_fs_type))$(_no_map_file),\
mkdir -p $(2); \
cp $(1) $(2); \
$(if $(3),$(HOST_OUT_EXECUTABLES)/map_file_generator $(1) $(2)/$(3).map)) \
$(eval _img :=) \
$(eval _map_fs_type :=) \
$(eval _no_map_file :=) \
)
endef
# By conditionally including the dependency of the target files package on the
# full system image deps, we speed up builds that do not build the system
# image.
ifdef BUILDING_SYSTEM_IMAGE
$(BUILT_TARGET_FILES_DIR): $(FULL_SYSTEMIMAGE_DEPS)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_SYSTEMIMAGE)
endif
else
# releasetools may need the system build.prop even when building a
# system-image-less product.
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_BUILD_PROP_TARGET)
endif
ifdef BUILDING_USERDATA_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_USERDATAIMAGE_FILES)
endif
ifdef BUILDING_SYSTEM_OTHER_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_SYSTEMOTHERIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_SYSTEMOTHERIMAGE_TARGET)
endif
endif
ifdef BUILDING_VENDOR_BOOT_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_RAMDISK_FILES)
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_RAMDISK_FRAGMENT_TARGETS)
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_BOOTCONFIG_TARGET)
# The vendor ramdisk may be built from the recovery ramdisk.
ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_RECOVERY_RAMDISK_FILES_TIMESTAMP)
endif
endif
ifdef BUILDING_VENDOR_KERNEL_BOOT_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_KERNEL_RAMDISK_FILES)
endif
ifdef BUILDING_RECOVERY_IMAGE
# TODO(b/30414428): Can't depend on INTERNAL_RECOVERYIMAGE_FILES alone like other
# BUILT_TARGET_FILES_PACKAGE dependencies because currently there're cp/rsync/rm
# commands in build-recoveryimage-target, which would touch the files under
# TARGET_RECOVERY_OUT and race with packaging target-files.zip.
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_BOOTIMAGE_TARGET)
else
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_RECOVERYIMAGE_TARGET)
endif
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_RECOVERYIMAGE_FILES)
endif
# Conditionally depend on the image files if the image is being built so the
# target-files.zip rule doesn't wait on the image creation rule, or the image
# if it is coming from a prebuilt.
ifdef BUILDING_VENDOR_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDORIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_VENDORIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_VENDORIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_VENDORIMAGE_TARGET)
endif
ifdef BUILDING_PRODUCT_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_PRODUCTIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_PRODUCTIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_PRODUCTIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_PRODUCTIMAGE_TARGET)
endif
ifdef BUILDING_SYSTEM_EXT_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_SYSTEM_EXTIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_SYSTEM_EXTIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET)
endif
ifneq (,$(BUILDING_BOOT_IMAGE)$(BUILDING_INIT_BOOT_IMAGE))
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_RAMDISK_FILES)
endif # BUILDING_BOOT_IMAGE != "" || BUILDING_INIT_BOOT_IMAGE != ""
ifneq (,$(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES)))
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_BOOTIMAGE_TARGET)
endif
ifdef BUILDING_ODM_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_ODMIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_ODMIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_ODMIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_ODMIMAGE_TARGET)
endif
ifdef BUILDING_VENDOR_DLKM_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_VENDOR_DLKMIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_VENDOR_DLKMIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET)
endif
ifdef BUILDING_ODM_DLKM_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_ODM_DLKMIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_ODM_DLKMIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_ODM_DLKMIMAGE_TARGET)
endif
ifdef BUILDING_SYSTEM_DLKM_IMAGE
$(BUILT_TARGET_FILES_DIR): $(INTERNAL_SYSTEM_DLKMIMAGE_FILES)
ifdef COPY_IMAGES_FOR_TARGET_FILES_ZIP
$(BUILT_TARGET_FILES_DIR): $(BUILT_SYSTEM_DLKMIMAGE_TARGET)
endif
else ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET)
endif
ifeq ($(BUILD_QEMU_IMAGES),true)
MK_VBMETA_BOOT_KERNEL_CMDLINE_SH := device/generic/goldfish/tools/mk_vbmeta_boot_params.sh
$(BUILT_TARGET_FILES_DIR): $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH)
endif
ifdef BOARD_PREBUILT_BOOTLOADER
$(BUILT_TARGET_FILES_DIR): $(INSTALLED_BOOTLOADER_MODULE)
droidcore-unbundled: $(INSTALLED_BOOTLOADER_MODULE)
endif
# Depending on the various images guarantees that the underlying
# directories are up-to-date.
$(BUILT_TARGET_FILES_DIR): \
$(INSTALLED_RADIOIMAGE_TARGET) \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_CACHEIMAGE_TARGET) \
$(INSTALLED_DTBOIMAGE_TARGET) \
$(INSTALLED_PVMFWIMAGE_TARGET) \
$(INSTALLED_PVMFW_BINARY_TARGET) \
$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
$(INSTALLED_CUSTOMIMAGES_TARGET) \
$(INSTALLED_ANDROID_INFO_TXT_TARGET) \
$(INSTALLED_KERNEL_TARGET) \
$(INSTALLED_RAMDISK_TARGET) \
$(INSTALLED_DTBIMAGE_TARGET) \
$(INSTALLED_2NDBOOTLOADER_TARGET) \
$(INSTALLED_VENDOR_KERNEL_RAMDISK_TARGET) \
$(BUILT_RAMDISK_16K_TARGET) \
$(BUILT_KERNEL_16K_TARGET) \
$(BUILT_BOOTIMAGE_16K_TARGET) \
$(INSTALLED_DTBOIMAGE_16KB_TARGET) \
$(BOARD_PREBUILT_DTBOIMAGE) \
$(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
$(BOARD_RECOVERY_ACPIO) \
$(PRODUCT_SYSTEM_BASE_FS_PATH) \
$(PRODUCT_VENDOR_BASE_FS_PATH) \
$(PRODUCT_PRODUCT_BASE_FS_PATH) \
$(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
$(PRODUCT_ODM_BASE_FS_PATH) \
$(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
$(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
$(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
$(LPMAKE) \
$(SELINUX_FC) \
$(INSTALLED_MISC_INFO_TARGET) \
$(INSTALLED_FASTBOOT_INFO_TARGET) \
$(APKCERTS_FILE) \
$(APEX_KEYS_FILE) \
$(SOONG_ZIP) \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/map_file_generator \
$(ADD_IMG_TO_TARGET_FILES) \
$(MAKE_RECOVERY_PATCH) \
$(BUILT_KERNEL_CONFIGS_FILE) \
$(BUILT_KERNEL_VERSION_FILE) \
| $(ACP)
@echo "Building target files: $@"
$(hide) rm -rf $@ $@.list $(zip_root)
$(hide) mkdir -p $(dir $@) $(zip_root)
ifneq (,$(INSTALLED_RECOVERYIMAGE_TARGET)$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT))$(filter true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT)))
@# Components of the recovery image
$(hide) mkdir -p $(zip_root)/$(PRIVATE_RECOVERY_OUT)
# Exclude recovery files in the default vendor ramdisk if including a standalone
# recovery ramdisk in vendor_boot.
ifneq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
$(hide) $(call package_files-copy-root, \
$(TARGET_RECOVERY_ROOT_OUT),$(zip_root)/$(PRIVATE_RECOVERY_OUT)/RAMDISK)
endif
ifdef INSTALLED_KERNEL_TARGET
ifneq (,$(filter true,$(BOARD_USES_RECOVERY_AS_BOOT)))
cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/
else ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
cp $(firstword $(INSTALLED_KERNEL_TARGET)) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/kernel
endif
endif
ifneq (truetrue,$(strip $(BUILDING_VENDOR_BOOT_IMAGE))$(strip $(BOARD_USES_RECOVERY_AS_BOOT)))
ifdef INSTALLED_2NDBOOTLOADER_TARGET
cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/second
endif
ifdef BOARD_INCLUDE_RECOVERY_DTBO
ifdef BOARD_PREBUILT_RECOVERY_DTBOIMAGE
cp $(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
else
cp $(BOARD_PREBUILT_DTBOIMAGE) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_dtbo
endif
endif # BOARD_INCLUDE_RECOVERY_DTBO
ifdef BOARD_INCLUDE_RECOVERY_ACPIO
cp $(BOARD_RECOVERY_ACPIO) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/recovery_acpio
endif
ifdef INSTALLED_DTBIMAGE_TARGET
cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/$(PRIVATE_RECOVERY_OUT)/dtb
endif
ifneq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
ifdef INTERNAL_KERNEL_CMDLINE
echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/cmdline
endif # INTERNAL_KERNEL_CMDLINE != ""
endif # BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE != true
ifdef BOARD_KERNEL_BASE
echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/base
endif
ifdef BOARD_KERNEL_PAGESIZE
echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/$(PRIVATE_RECOVERY_OUT)/pagesize
endif
endif # not (BUILDING_VENDOR_BOOT_IMAGE and BOARD_USES_RECOVERY_AS_BOOT)
endif # INSTALLED_RECOVERYIMAGE_TARGET defined or BOARD_USES_RECOVERY_AS_BOOT is true
@# Components of the boot image
$(hide) mkdir -p $(zip_root)/BOOT
$(hide) mkdir -p $(zip_root)/ROOT
$(hide) $(call package_files-copy-root, \
$(TARGET_ROOT_OUT),$(zip_root)/ROOT)
@# If we are using recovery as boot, this is already done when processing recovery.
ifneq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
$(hide) $(call package_files-copy-root, \
$(TARGET_RAMDISK_OUT),$(zip_root)/BOOT/RAMDISK)
ifdef INSTALLED_KERNEL_TARGET
$(hide) cp $(INSTALLED_KERNEL_TARGET) $(zip_root)/BOOT/
endif
ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
echo "$(GENERIC_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
else ifndef INSTALLED_VENDOR_BOOTIMAGE_TARGET # && BOARD_USES_GENERIC_KERNEL_IMAGE != true
echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/BOOT/cmdline
ifdef INSTALLED_2NDBOOTLOADER_TARGET
cp $(INSTALLED_2NDBOOTLOADER_TARGET) $(zip_root)/BOOT/second
endif
ifdef INSTALLED_DTBIMAGE_TARGET
cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/BOOT/dtb
endif
ifdef BOARD_KERNEL_BASE
echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/BOOT/base
endif
ifdef BOARD_KERNEL_PAGESIZE
echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/BOOT/pagesize
endif
endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET == "" && BOARD_USES_GENERIC_KERNEL_IMAGE != true
endif # BOARD_USES_RECOVERY_AS_BOOT not true
$(hide) $(foreach t,$(INSTALLED_RADIOIMAGE_TARGET),\
mkdir -p $(zip_root)/RADIO; \
cp $(t) $(zip_root)/RADIO/$(notdir $(t));)
ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
mkdir -p $(zip_root)/VENDOR_BOOT
$(call package_files-copy-root, \
$(TARGET_VENDOR_RAMDISK_OUT),$(zip_root)/VENDOR_BOOT/RAMDISK)
ifdef INSTALLED_DTBIMAGE_TARGET
ifneq ($(BUILDING_VENDOR_KERNEL_BOOT_IMAGE),true)
cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_BOOT/dtb
endif
endif # end of INSTALLED_DTBIMAGE_TARGET
ifdef INTERNAL_VENDOR_BOOTCONFIG_TARGET
cp $(INTERNAL_VENDOR_BOOTCONFIG_TARGET) $(zip_root)/VENDOR_BOOT/vendor_bootconfig
endif
ifdef BOARD_KERNEL_BASE
echo "$(BOARD_KERNEL_BASE)" > $(zip_root)/VENDOR_BOOT/base
endif
ifdef BOARD_KERNEL_PAGESIZE
echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_BOOT/pagesize
endif
echo "$(INTERNAL_KERNEL_CMDLINE)" > $(zip_root)/VENDOR_BOOT/vendor_cmdline
ifdef INTERNAL_VENDOR_RAMDISK_FRAGMENTS
echo "$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS)" > "$(zip_root)/VENDOR_BOOT/vendor_ramdisk_fragments"
$(foreach vendor_ramdisk_fragment,$(INTERNAL_VENDOR_RAMDISK_FRAGMENTS), \
mkdir -p $(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment); \
echo "$(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).MKBOOTIMG_ARGS)" > "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/mkbootimg_args"; \
$(eval prebuilt_ramdisk := $(BOARD_VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).PREBUILT)) \
$(if $(prebuilt_ramdisk), \
cp "$(prebuilt_ramdisk)" "$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/prebuilt_ramdisk";, \
$(call package_files-copy-root, \
$(VENDOR_RAMDISK_FRAGMENT.$(vendor_ramdisk_fragment).STAGING_DIR), \
$(zip_root)/VENDOR_BOOT/RAMDISK_FRAGMENTS/$(vendor_ramdisk_fragment)/RAMDISK); \
))
endif # INTERNAL_VENDOR_RAMDISK_FRAGMENTS != ""
endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
ifdef INSTALLED_VENDOR_KERNEL_BOOTIMAGE_TARGET
mkdir -p $(zip_root)/VENDOR_KERNEL_BOOT
$(call package_files-copy-root, \
$(TARGET_VENDOR_KERNEL_RAMDISK_OUT),$(zip_root)/VENDOR_KERNEL_BOOT/RAMDISK)
ifdef INSTALLED_DTBIMAGE_TARGET
cp $(INSTALLED_DTBIMAGE_TARGET) $(zip_root)/VENDOR_KERNEL_BOOT/dtb
endif
ifdef BOARD_KERNEL_PAGESIZE
echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/VENDOR_KERNEL_BOOT/pagesize
endif
endif # INSTALLED_VENDOR_BOOTIMAGE_TARGET
ifdef BUILDING_SYSTEM_IMAGE
@# Contents of the system image
ifneq ($(SOONG_DEFINED_SYSTEM_IMAGE_PATH),)
$(hide) $(call package_files-copy-root, \
$(SOONG_DEFINED_SYSTEM_IMAGE_BASE)/system/system,$(zip_root)/SYSTEM)
else
$(hide) $(call package_files-copy-root, \
$(SYSTEMIMAGE_SOURCE_DIR),$(zip_root)/SYSTEM)
endif
else ifdef INSTALLED_BUILD_PROP_TARGET
@# Copy the system build.prop even if not building a system image
@# because add_img_to_target_files may need it to build other partition
@# images.
$(hide) mkdir -p "$(zip_root)/SYSTEM"
$(hide) cp "$(INSTALLED_BUILD_PROP_TARGET)" "$(patsubst $(TARGET_OUT)/%,$(zip_root)/SYSTEM/%,$(INSTALLED_BUILD_PROP_TARGET))"
endif
ifdef BUILDING_USERDATA_IMAGE
@# Contents of the data image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_DATA),$(zip_root)/DATA)
endif
ifdef BUILDING_VENDOR_IMAGE
@# Contents of the vendor image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_VENDOR),$(zip_root)/VENDOR)
endif
ifdef BUILDING_PRODUCT_IMAGE
@# Contents of the product image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_PRODUCT),$(zip_root)/PRODUCT)
endif
ifdef BUILDING_SYSTEM_EXT_IMAGE
@# Contents of the system_ext image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_SYSTEM_EXT),$(zip_root)/SYSTEM_EXT)
endif
ifdef BUILDING_ODM_IMAGE
@# Contents of the odm image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_ODM),$(zip_root)/ODM)
endif
ifdef BUILDING_VENDOR_DLKM_IMAGE
@# Contents of the vendor_dlkm image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_VENDOR_DLKM),$(zip_root)/VENDOR_DLKM)
endif
ifdef BUILDING_ODM_DLKM_IMAGE
@# Contents of the odm_dlkm image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_ODM_DLKM),$(zip_root)/ODM_DLKM)
endif
ifdef BUILDING_SYSTEM_DLKM_IMAGE
@# Contents of the system_dlkm image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_SYSTEM_DLKM),$(zip_root)/SYSTEM_DLKM)
endif
ifdef BUILDING_SYSTEM_OTHER_IMAGE
@# Contents of the system_other image
$(hide) $(call package_files-copy-root, \
$(TARGET_OUT_SYSTEM_OTHER),$(zip_root)/SYSTEM_OTHER)
endif
@# Extra contents of the OTA package
$(hide) mkdir -p $(zip_root)/OTA
$(hide) cp $(INSTALLED_ANDROID_INFO_TXT_TARGET) $(zip_root)/OTA/
ifdef BUILDING_RAMDISK_IMAGE
ifeq (true,$(BOARD_IMG_USE_RAMDISK))
@# Contents of the ramdisk image
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_RAMDISK_TARGET) $(zip_root)/IMAGES/
endif
endif
ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
ifneq ($(built_ota_tools),)
$(hide) mkdir -p $(zip_root)/OTA/bin
$(hide) cp $(PRIVATE_OTA_TOOLS) $(zip_root)/OTA/bin/
endif
endif
@# Files that do not end up in any images, but are necessary to
@# build them.
$(hide) mkdir -p $(zip_root)/META
$(hide) cp $(APKCERTS_FILE) $(zip_root)/META/apkcerts.txt
$(hide) cp $(APEX_KEYS_FILE) $(zip_root)/META/apexkeys.txt
ifneq ($(tool_extension),)
$(hide) cp $(PRIVATE_TOOL_EXTENSION) $(zip_root)/META/
endif
$(hide) echo "$(PRODUCT_OTA_PUBLIC_KEYS)" > $(zip_root)/META/otakeys.txt
$(hide) cp $(SELINUX_FC) $(zip_root)/META/file_contexts.bin
$(hide) cp $(INSTALLED_MISC_INFO_TARGET) $(zip_root)/META/misc_info.txt
ifneq ($(INSTALLED_FASTBOOT_INFO_TARGET),)
$(hide) cp $(INSTALLED_FASTBOOT_INFO_TARGET) $(zip_root)/META/fastboot-info.txt
endif
ifneq ($(PRODUCT_SYSTEM_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_SYSTEM_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_VENDOR_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_VENDOR_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_VENDOR_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_PRODUCT_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_PRODUCT_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_PRODUCT_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_SYSTEM_EXT_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_EXT_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_ODM_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_ODM_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_ODM_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_VENDOR_DLKM_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_VENDOR_DLKM_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_ODM_DLKM_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_ODM_DLKM_BASE_FS_PATH))
endif
ifneq ($(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH),)
$(hide) cp $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
$(zip_root)/META/$(notdir $(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH))
endif
ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
$(MAKE_RECOVERY_PATCH) $(zip_root) $(zip_root)
endif
endif
ifeq ($(AB_OTA_UPDATER),true)
@# When using the A/B updater, include the updater config files in the zip.
$(hide) cp $(TOPDIR)system/update_engine/update_engine.conf $(zip_root)/META/update_engine_config.txt
$(hide) cp $(TOPDIR)external/zucchini/version_info.h $(zip_root)/META/zucchini_config.txt
$(hide) cp $(HOST_OUT_SHARED_LIBRARIES)/liblz4.so $(zip_root)/META/liblz4.so
$(hide) for part in $(sort $(AB_OTA_PARTITIONS)); do \
echo "$${part}" >> $(zip_root)/META/ab_partitions.txt; \
done
$(hide) for conf in $(strip $(AB_OTA_POSTINSTALL_CONFIG)); do \
echo "$${conf}" >> $(zip_root)/META/postinstall_config.txt; \
done
ifdef OSRELEASED_DIRECTORY
$(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_id $(zip_root)/META/product_id.txt
$(hide) cp $(TARGET_OUT_OEM)/$(OSRELEASED_DIRECTORY)/product_version $(zip_root)/META/product_version.txt
$(hide) cp $(TARGET_OUT_ETC)/$(OSRELEASED_DIRECTORY)/system_version $(zip_root)/META/system_version.txt
endif
endif
ifeq ($(BREAKPAD_GENERATE_SYMBOLS),true)
@# If breakpad symbols have been generated, add them to the zip.
$(hide) cp -R $(TARGET_OUT_BREAKPAD) $(zip_root)/BREAKPAD
endif
ifdef BOARD_PREBUILT_VENDOR_BOOTIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_VENDOR_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_VENDORIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_VENDORIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_PRODUCTIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_PRODUCTIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) cp $(INSTALLED_INIT_BOOT_IMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
endif
ifndef BOARD_PREBUILT_BOOTIMAGE
ifneq (,$(strip $(INTERNAL_PREBUILT_BOOTIMAGE) $(filter true,$(BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES))))
ifdef INSTALLED_BOOTIMAGE_TARGET
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/IMAGES/
endif # INSTALLED_BOOTIMAGE_TARGET
endif # INTERNAL_PREBUILT_BOOTIMAGE != "" || BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES == true
else # BOARD_PREBUILT_BOOTIMAGE is defined
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) cp $(INSTALLED_BOOTIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
endif # BOARD_PREBUILT_BOOTIMAGE
ifdef BOARD_PREBUILT_ODMIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_ODMIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(zip_root)/IMAGES/
endif
ifdef BOARD_PREBUILT_DTBOIMAGE
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) cp $(INSTALLED_DTBOIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
endif # BOARD_PREBUILT_DTBOIMAGE
ifdef BOARD_KERNEL_PATH_16K
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) cp $(BUILT_KERNEL_16K_TARGET) $(zip_root)/PREBUILT_IMAGES/
endif # BOARD_KERNEL_PATH_16K
ifdef BOARD_KERNEL_MODULES_16K
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) cp $(BUILT_RAMDISK_16K_TARGET) $(zip_root)/PREBUILT_IMAGES/
endif # BOARD_KERNEL_MODULES_16K
ifdef BUILT_BOOTIMAGE_16K_TARGET
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(BUILT_BOOTIMAGE_16K_TARGET) $(zip_root)/IMAGES/
endif # BUILT_BOOTIMAGE_16K_TARGET
ifdef INSTALLED_DTBOIMAGE_16KB_TARGET
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_DTBOIMAGE_16KB_TARGET) $(zip_root)/IMAGES/
endif # INSTALLED_DTBOIMAGE_16KB_TARGET
ifeq ($(BOARD_USES_PVMFWIMAGE),true)
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) cp $(INSTALLED_PVMFWIMAGE_TARGET) $(zip_root)/PREBUILT_IMAGES/
$(hide) cp $(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) $(zip_root)/PREBUILT_IMAGES/
$(hide) mkdir -p $(zip_root)/PVMFW
$(hide) cp $(INSTALLED_PVMFW_BINARY_TARGET) $(zip_root)/PVMFW/
endif
ifdef BOARD_PREBUILT_BOOTLOADER
$(hide) mkdir -p $(zip_root)/IMAGES
$(hide) cp $(INSTALLED_BOOTLOADER_MODULE) $(zip_root)/IMAGES/
endif
ifneq ($(strip $(BOARD_CUSTOMIMAGES_PARTITION_LIST)),)
$(hide) mkdir -p $(zip_root)/PREBUILT_IMAGES
$(hide) $(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
$(foreach image,$(BOARD_$(call to-upper,$(partition))_IMAGE_LIST),cp $(image) $(zip_root)/PREBUILT_IMAGES/;))
endif # BOARD_CUSTOMIMAGES_PARTITION_LIST
@# The radio images in BOARD_PACK_RADIOIMAGES will be additionally copied from RADIO/ into
@# IMAGES/, which then will be added into -img.zip. Such images must be listed in
@# INSTALLED_RADIOIMAGE_TARGET.
$(hide) $(foreach part,$(BOARD_PACK_RADIOIMAGES), \
echo $(part) >> $(zip_root)/META/pack_radioimages.txt;)
@# Run fs_config on all the system, vendor, boot ramdisk,
@# and recovery ramdisk files in the zip, and save the output
ifdef BUILDING_SYSTEM_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_SYSTEMIMAGE),$(zip_root)/IMAGES,system)
$(hide) $(call fs_config,$(zip_root)/SYSTEM,system/) > $(zip_root)/META/filesystem_config.txt
endif
ifdef BUILDING_VENDOR_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_VENDORIMAGE_TARGET),$(zip_root)/IMAGES,vendor)
$(hide) $(call fs_config,$(zip_root)/VENDOR,vendor/) > $(zip_root)/META/vendor_filesystem_config.txt
endif
ifdef BUILDING_PRODUCT_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_PRODUCTIMAGE_TARGET),$(zip_root)/IMAGES,product)
$(hide) $(call fs_config,$(zip_root)/PRODUCT,product/) > $(zip_root)/META/product_filesystem_config.txt
endif
ifdef BUILDING_SYSTEM_EXT_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_SYSTEM_EXTIMAGE_TARGET),$(zip_root)/IMAGES,system_ext)
$(hide) $(call fs_config,$(zip_root)/SYSTEM_EXT,system_ext/) > $(zip_root)/META/system_ext_filesystem_config.txt
endif
ifdef BUILDING_ODM_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_ODMIMAGE_TARGET),$(zip_root)/IMAGES,odm)
$(hide) $(call fs_config,$(zip_root)/ODM,odm/) > $(zip_root)/META/odm_filesystem_config.txt
endif
ifdef BUILDING_VENDOR_DLKM_IMAGE
$(hide)$(call copy-image-and-generate-map,$(BUILT_VENDOR_DLKMIMAGE_TARGET),$(zip_root)/IMAGES,vendor_dlkm)
$(hide) $(call fs_config,$(zip_root)/VENDOR_DLKM,vendor_dlkm/) > $(zip_root)/META/vendor_dlkm_filesystem_config.txt
endif
ifdef BUILDING_ODM_DLKM_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_ODM_DLKMIMAGE_TARGET),$(zip_root)/IMAGES,odm_dlkm)
$(hide) $(call fs_config,$(zip_root)/ODM_DLKM,odm_dlkm/) > $(zip_root)/META/odm_dlkm_filesystem_config.txt
endif
ifdef BUILDING_SYSTEM_DLKM_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_SYSTEM_DLKMIMAGE_TARGET),$(zip_root)/IMAGES,system_dlkm)
$(hide) $(call fs_config,$(zip_root)/SYSTEM_DLKM,system_dlkm/) > $(zip_root)/META/system_dlkm_filesystem_config.txt
endif
@# ROOT always contains the files for the root under normal boot.
$(hide) $(call fs_config,$(zip_root)/ROOT,) > $(zip_root)/META/root_filesystem_config.txt
@# BOOT/RAMDISK contains the first stage and recovery ramdisk.
$(hide) $(call fs_config,$(zip_root)/BOOT/RAMDISK,) > $(zip_root)/META/boot_filesystem_config.txt
ifdef BUILDING_INIT_BOOT_IMAGE
$(hide) $(call package_files-copy-root, $(TARGET_RAMDISK_OUT),$(zip_root)/INIT_BOOT/RAMDISK)
$(hide) $(call fs_config,$(zip_root)/INIT_BOOT/RAMDISK,) > $(zip_root)/META/init_boot_filesystem_config.txt
$(hide) cp $(RAMDISK_NODE_LIST) $(zip_root)/META/ramdisk_node_list
ifdef BOARD_KERNEL_PAGESIZE
$(hide) echo "$(BOARD_KERNEL_PAGESIZE)" > $(zip_root)/INIT_BOOT/pagesize
endif # BOARD_KERNEL_PAGESIZE
endif # BUILDING_INIT_BOOT_IMAGE
ifdef BOARD_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_EROFS_COMPRESS_HINTS) $(zip_root)/META/erofs_default_compress_hints.txt
endif
ifdef BOARD_SYSTEMIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_SYSTEMIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/system_erofs_compress_hints.txt
endif
ifdef BOARD_SYSTEM_EXTIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_SYSTEM_EXTIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/system_ext_erofs_compress_hints.txt
endif
ifdef BOARD_PRODUCTIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_PRODUCTIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/product_erofs_compress_hints.txt
endif
ifdef BOARD_VENDORIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_VENDORIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/vendor_erofs_compress_hints.txt
endif
ifdef BOARD_ODMIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_ODMIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/odm_erofs_compress_hints.txt
endif
ifdef BOARD_VENDOR_DLKMIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_VENDOR_DLKMIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/vendor_dlkm_erofs_compress_hints.txt
endif
ifdef BOARD_ODM_DLKMIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_ODM_DLKMIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/odm_dlkm_erofs_compress_hints.txt
endif
ifdef BOARD_SYSTEM_DLKMIMAGE_EROFS_COMPRESS_HINTS
$(hide) cp $(BOARD_SYSTEM_DLKMIMAGE_EROFS_COMPRESS_HINTS) $(zip_root)/META/system_dlkm_erofs_compress_hints.txt
endif
ifneq ($(INSTALLED_VENDOR_BOOTIMAGE_TARGET),)
$(call fs_config,$(zip_root)/VENDOR_BOOT/RAMDISK,) > $(zip_root)/META/vendor_boot_filesystem_config.txt
endif
ifneq ($(INSTALLED_RECOVERYIMAGE_TARGET),)
$(hide) $(call fs_config,$(zip_root)/RECOVERY/RAMDISK,) > $(zip_root)/META/recovery_filesystem_config.txt
endif
ifdef BUILDING_SYSTEM_OTHER_IMAGE
$(hide) $(call copy-image-and-generate-map,$(BUILT_SYSTEMOTHERIMAGE_TARGET),$(zip_root)/IMAGES)
$(hide) $(call fs_config,$(zip_root)/SYSTEM_OTHER,system/) > $(zip_root)/META/system_other_filesystem_config.txt
endif
@# Metadata for compatibility verification.
ifdef BUILT_KERNEL_CONFIGS_FILE
$(hide) cp $(BUILT_KERNEL_CONFIGS_FILE) $(zip_root)/META/kernel_configs.txt
endif
ifdef BUILT_KERNEL_VERSION_FILE
$(hide) cp $(BUILT_KERNEL_VERSION_FILE) $(zip_root)/META/kernel_version.txt
endif
rm -rf $(zip_root)/META/dynamic_partitions_info.txt
ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
$(call dump-dynamic-partitions-info, $(zip_root)/META/dynamic_partitions_info.txt)
endif
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$$PATH MKBOOTIMG=$(MKBOOTIMG) \
$(ADD_IMG_TO_TARGET_FILES) -a -v -p $(HOST_OUT) $(zip_root)
ifeq ($(BUILD_QEMU_IMAGES),true)
$(hide) AVBTOOL=$(AVBTOOL) $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(zip_root)/IMAGES/vbmeta.img \
$(zip_root)/IMAGES/system.img $(zip_root)/IMAGES/VerifiedBootParams.textproto
endif
@# Zip everything up, preserving symlinks and placing META/ files first to
@# help early validation of the .zip file while uploading it.
$(hide) find $(zip_root)/META | sort >$@
$(hide) find $(zip_root) -path $(zip_root)/META -prune -o -print | sort >>$@
$(BUILT_TARGET_FILES_PACKAGE): $(BUILT_TARGET_FILES_DIR)
@echo "Packaging target files: $@"
$(hide) $(SOONG_ZIP) -d -o $@ -C $(zip_root) -r $@.list -sha256
.PHONY: target-files-package
target-files-package: $(BUILT_TARGET_FILES_PACKAGE)
.PHONY: target-files-dir
target-files-dir: $(BUILT_TARGET_FILES_DIR)
$(call declare-1p-container,$(BUILT_TARGET_FILES_PACKAGE),)
$(call declare-container-license-deps,$(BUILT_TARGET_FILES_PACKAGE), $(INSTALLED_RADIOIMAGE_TARGET) \
$(INSTALLED_RECOVERYIMAGE_TARGET) \
$(INSTALLED_CACHEIMAGE_TARGET) \
$(INSTALLED_DTBOIMAGE_TARGET) \
$(INSTALLED_PVMFWIMAGE_TARGET) \
$(INSTALLED_PVMFW_EMBEDDED_AVBKEY_TARGET) \
$(INSTALLED_CUSTOMIMAGES_TARGET) \
$(INSTALLED_ANDROID_INFO_TXT_TARGET) \
$(INSTALLED_KERNEL_TARGET) \
$(INSTALLED_RAMDISK_TARGET) \
$(INSTALLED_DTBIMAGE_TARGET) \
$(INSTALLED_2NDBOOTLOADER_TARGET) \
$(BOARD_PREBUILT_DTBOIMAGE) \
$(BOARD_PREBUILT_RECOVERY_DTBOIMAGE) \
$(BOARD_RECOVERY_ACPIO) \
$(PRODUCT_SYSTEM_BASE_FS_PATH) \
$(PRODUCT_VENDOR_BASE_FS_PATH) \
$(PRODUCT_PRODUCT_BASE_FS_PATH) \
$(PRODUCT_SYSTEM_EXT_BASE_FS_PATH) \
$(PRODUCT_ODM_BASE_FS_PATH) \
$(PRODUCT_VENDOR_DLKM_BASE_FS_PATH) \
$(PRODUCT_ODM_DLKM_BASE_FS_PATH) \
$(PRODUCT_SYSTEM_DLKM_BASE_FS_PATH) \
$(LPMAKE) \
$(SELINUX_FC) \
$(INSTALLED_MISC_INFO_TARGET) \
$(INSTALLED_FASTBOOT_INFO_TARGET) \
$(APKCERTS_FILE) \
$(APEX_KEYS_FILE) \
$(HOST_OUT_EXECUTABLES)/fs_config \
$(HOST_OUT_EXECUTABLES)/map_file_generator \
$(ADD_IMG_TO_TARGET_FILES) \
$(MAKE_RECOVERY_PATCH) \
$(BUILT_KERNEL_CONFIGS_FILE) \
$(BUILT_KERNEL_VERSION_FILE),$(BUILT_TARGET_FILES_PACKAGE):)
$(call dist-for-goals-with-filenametag, target-files-package, $(BUILT_TARGET_FILES_PACKAGE))
# -----------------------------------------------------------------
# NDK Sysroot Package
NDK_SYSROOT_TARGET := $(PRODUCT_OUT)/ndk_sysroot.tar.bz2
.PHONY: ndk_sysroot
ndk_sysroot: $(NDK_SYSROOT_TARGET)
$(NDK_SYSROOT_TARGET): $(SOONG_OUT_DIR)/ndk.timestamp
@echo Package NDK sysroot...
$(hide) tar cjf $@ -C $(SOONG_OUT_DIR) ndk
ifeq ($(HOST_OS),linux)
$(call dist-for-goals,sdk ndk_sysroot,$(NDK_SYSROOT_TARGET))
endif
ifeq ($(build_ota_package),true)
# -----------------------------------------------------------------
# OTA update package
# $(1): output file
# $(2): additional args
define build-ota-package-target
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
$(OTA_FROM_TARGET_FILES) \
--verbose \
--path $(HOST_OUT) \
$(if $(OEM_OTA_CONFIG), --oem_settings $(OEM_OTA_CONFIG)) \
$(if $(BOOT_VAR_OTA_CONFIG), --boot_variable_file $(BOOT_VAR_OTA_CONFIG)) \
$(2) \
$(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE)) $(1)
endef
product_name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
product_name := $(product_name)_debug
endif
name := $(product_name)-ota
INTERNAL_OTA_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
INTERNAL_OTA_METADATA := $(PRODUCT_OUT)/ota_metadata
$(call declare-0p-target,$(INTERNAL_OTA_METADATA))
$(INTERNAL_OTA_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
$(INTERNAL_OTA_PACKAGE_TARGET): .KATI_IMPLICIT_OUTPUTS := $(INTERNAL_OTA_METADATA)
$(INTERNAL_OTA_PACKAGE_TARGET): $(BUILT_TARGET_FILES_DIR) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
@echo "Package OTA: $@"
$(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --output_metadata_path $(INTERNAL_OTA_METADATA))
$(call declare-1p-container,$(INTERNAL_OTA_PACKAGE_TARGET),)
$(call declare-container-license-deps,$(INTERNAL_OTA_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
.PHONY: otapackage
otapackage: $(INTERNAL_OTA_PACKAGE_TARGET)
ifeq ($(BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE),true)
name := $(product_name)-ota-retrofit
INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET): \
$(BUILT_TARGET_FILES_PACKAGE) \
$(OTA_FROM_TARGET_FILES) \
$(INTERNAL_OTATOOLS_FILES)
@echo "Package OTA (retrofit dynamic partitions): $@"
$(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --retrofit_dynamic_partitions)
$(call declare-1p-container,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),)
$(call declare-container-license-deps,$(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
.PHONY: otardppackage
otapackage otardppackage: $(INTERNAL_OTA_RETROFIT_DYNAMIC_PARTITIONS_PACKAGE_TARGET)
endif # BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
ifneq ($(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST),)
name := $(product_name)-partial-ota
INTERNAL_OTA_PARTIAL_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): KEY_CERT_PAIR := $(DEFAULT_KEY_CERT_PAIR)
$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET): $(BUILT_TARGET_FILES_DIR) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES)
@echo "Package partial OTA: $@"
$(call build-ota-package-target,$@,-k $(KEY_CERT_PAIR) --partial "$(BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST)")
$(call declare-1p-container,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),)
$(call declare-container-license-deps,$(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(OTA_FROM_TARGET_FILES) $(INTERNAL_OTATOOLS_FILES),$(PRODUCT_OUT)/:/)
.PHONY: partialotapackage
partialotapackage: $(INTERNAL_OTA_PARTIAL_PACKAGE_TARGET)
endif # BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
endif # build_ota_package
# -----------------------------------------------------------------
# A zip of the appcompat directory containing logs
APPCOMPAT_ZIP := $(PRODUCT_OUT)/appcompat.zip
# For apps_only build we'll establish the dependency later in build/make/core/main.mk.
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(APPCOMPAT_ZIP): $(FULL_SYSTEMIMAGE_DEPS) \
$(INTERNAL_RAMDISK_FILES) \
$(INTERNAL_USERDATAIMAGE_FILES) \
$(INTERNAL_VENDORIMAGE_FILES) \
$(INTERNAL_PRODUCTIMAGE_FILES) \
$(INTERNAL_SYSTEM_EXTIMAGE_FILES)
endif
$(APPCOMPAT_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,appcompat)/filelist
$(APPCOMPAT_ZIP): $(SOONG_ZIP)
@echo "appcompat logs: $@"
$(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
$(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/appcompat $(dir $(PRIVATE_LIST_FILE))
$(hide) find $(PRODUCT_OUT)/appcompat | sort >$(PRIVATE_LIST_FILE)
$(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/appcompat -l $(PRIVATE_LIST_FILE)
DEXPREOPT_CONFIG_ZIP := $(PRODUCT_OUT)/dexpreopt_config.zip
$(DEXPREOPT_CONFIG_ZIP): $(INSTALLED_SYSTEMIMAGE_TARGET) \
$(INSTALLED_VENDORIMAGE_TARGET) \
$(INSTALLED_ODMIMAGE_TARGET) \
$(INSTALLED_PRODUCTIMAGE_TARGET) \
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(DEXPREOPT_CONFIG_ZIP): $(DEX_PREOPT_CONFIG_FOR_MAKE) \
$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE) \
endif
$(DEXPREOPT_CONFIG_ZIP): PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS :=
ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifneq (,$(DEX_PREOPT_CONFIG_FOR_MAKE))
$(DEXPREOPT_CONFIG_ZIP): PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS += -e $(notdir $(DEX_PREOPT_CONFIG_FOR_MAKE)) -f $(DEX_PREOPT_CONFIG_FOR_MAKE)
endif
ifneq (,$(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE))
$(DEXPREOPT_CONFIG_ZIP): PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS += -e $(notdir $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)) -f $(DEX_PREOPT_SOONG_CONFIG_FOR_MAKE)
endif
endif #!TARGET_BUILD_UNBUNDLED
$(DEXPREOPT_CONFIG_ZIP): $(SOONG_ZIP)
$(hide) mkdir -p $(dir $@) $(PRODUCT_OUT)/dexpreopt_config
$(hide) $(SOONG_ZIP) -d -o $@ -C $(PRODUCT_OUT)/dexpreopt_config -D $(PRODUCT_OUT)/dexpreopt_config $(PRIVATE_DEXPREOPT_CONFIG_ZIP_PARAMS)
.PHONY: dexpreopt_config_zip
dexpreopt_config_zip: $(DEXPREOPT_CONFIG_ZIP)
$(call declare-1p-target,$(DEXPREOPT_CONFIG_ZIP),)
# -----------------------------------------------------------------
# Zips of the symbols directory per test suites
#
$(foreach suite,$(ALL_COMPATIBILITY_SUITES),$(eval $(call create-suite-symbols-map,$(suite))))
# -----------------------------------------------------------------
# A zip of the symbols directory. Keep the full paths to make it
# more obvious where these files came from.
# Also produces a textproto containing mappings from elf IDs to symbols
# filename, which will allow finding the appropriate symbols to deobfuscate
# a stack trace frame.
#
name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
# The path to the zip file containing binaries with symbols.
SYMBOLS_ZIP := $(PRODUCT_OUT)/$(name)-symbols.zip
# The path to a file containing mappings from elf IDs to filenames.
SYMBOLS_MAPPING := $(PRODUCT_OUT)/$(name)-symbols-mapping.textproto
.KATI_READONLY := SYMBOLS_ZIP SYMBOLS_MAPPING
ifeq (,$(TARGET_BUILD_UNBUNDLED))
_symbols_zip_modules := $(call product-installed-modules,$(INTERNAL_PRODUCT))
$(SYMBOLS_ZIP): $(updater_dep)
else
_symbols_zip_modules := $(unbundled_build_modules)
endif
_symbols_zip_modules_symbols_files := $(foreach m,$(_symbols_zip_modules),$(ALL_MODULES.$(m).SYMBOLIC_OUTPUT_PATH))
_symbols_zip_modules_mapping_files := $(foreach m,$(_symbols_zip_modules),$(ALL_MODULES.$(m).ELF_SYMBOL_MAPPING_PATH))
$(SYMBOLS_ZIP): PRIVATE_SYMBOLS_MODULES_FILES := $(_symbols_zip_modules_symbols_files)
$(SYMBOLS_ZIP): PRIVATE_SYMBOLS_MODULES_MAPPING_FILES := $(_symbols_zip_modules_mapping_files)
$(SYMBOLS_ZIP): $(SOONG_ZIP) $(SYMBOLS_MAP) $(_symbols_zip_modules_symbols_files) $(_symbols_zip_modules_mapping_files)
@echo "Package symbols: $@"
$(hide) rm -rf $@ $@.symbols_list $@.mapping_list
# Find all installed files in the symbols directory and zip them into the symbols zip.
echo "$(PRIVATE_SYMBOLS_MODULES_FILES)" | tr " " "\n" | sort > $@.symbols_list
$(hide) $(SOONG_ZIP) -d -o $@ -l $@.symbols_list
# Find all installed files in the symbols mapping directory and merge them into the symbols mapping textproto.
echo "$(PRIVATE_SYMBOLS_MODULES_MAPPING_FILES)" | tr " " "\n" | sort > $@.mapping_list
$(hide) $(SYMBOLS_MAP) -merge $(SYMBOLS_MAPPING) @$@.mapping_list
$(SYMBOLS_ZIP): .KATI_IMPLICIT_OUTPUTS := $(SYMBOLS_MAPPING)
$(call declare-1p-container,$(SYMBOLS_ZIP),)
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(call declare-container-license-deps,$(SYMBOLS_ZIP),$(PRIVATE_SYMBOLS_MODULES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
endif
_symbols_zip_modules_symbols_files :=
_symbols_zip_modules_mapping_files :=
# -----------------------------------------------------------------
# A zip of the coverage directory.
#
name := gcov-report-files-all
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
COVERAGE_ZIP := $(PRODUCT_OUT)/$(name).zip
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(COVERAGE_ZIP): $(INTERNAL_ALLIMAGES_FILES)
endif
$(COVERAGE_ZIP): PRIVATE_LIST_FILE := $(call intermediates-dir-for,PACKAGING,coverage)/filelist
$(COVERAGE_ZIP): $(SOONG_ZIP)
@echo "Package coverage: $@"
$(hide) rm -rf $@ $(PRIVATE_LIST_FILE)
$(hide) mkdir -p $(dir $@) $(TARGET_OUT_COVERAGE) $(dir $(PRIVATE_LIST_FILE))
$(hide) find $(TARGET_OUT_COVERAGE) | sort >$(PRIVATE_LIST_FILE)
$(hide) $(SOONG_ZIP) -d -o $@ -C $(TARGET_OUT_COVERAGE) -l $(PRIVATE_LIST_FILE)
$(call declare-1p-container,$(COVERAGE_ZIP),)
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(call declare-container-license-deps,$(COVERAGE_ZIP),$(INTERNAL_ALLIMAGE_FILES),$(PRODUCT_OUT)/:/)
endif
SYSTEM_NOTICE_DEPS += $(COVERAGE_ZIP)
#------------------------------------------------------------------
# Export the LLVM profile data tool and dependencies for Clang coverage processing
#
ifeq (true,$(CLANG_COVERAGE))
LLVM_PROFDATA := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-profdata
LLVM_COV := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-cov
LIBCXX := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib/x86_64-unknown-linux-gnu/libc++.so
# Use llvm-profdata.zip for backwards compatibility with tradefed code.
LLVM_COVERAGE_TOOLS_ZIP := $(PRODUCT_OUT)/llvm-profdata.zip
$(LLVM_COVERAGE_TOOLS_ZIP): $(SOONG_ZIP)
$(hide) $(SOONG_ZIP) -d -o $@ -C $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION) -f $(LLVM_PROFDATA) -f $(LIBCXX) -f $(LLVM_COV)
$(call dist-for-goals,droidcore-unbundled apps_only,$(LLVM_COVERAGE_TOOLS_ZIP))
endif
ifeq (true,$(EMMA_INSTRUMENT))
#------------------------------------------------------------------
# An archive of classes for use in generating code-coverage reports
# These are the uninstrumented versions of any classes that were
# to be instrumented.
# Any dependencies are set up later in build/make/core/main.mk.
JACOCO_REPORT_CLASSES_ALL := $(PRODUCT_OUT)/jacoco-report-classes-all.jar
$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco)
$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_JACOCO_DIR := $(call intermediates-dir-for,PACKAGING,jacoco,HOST)
$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_TARGET_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage)
$(JACOCO_REPORT_CLASSES_ALL): PRIVATE_HOST_PROGUARD_USAGE_DIR := $(call intermediates-dir-for,PACKAGING,proguard_usage,HOST)
$(JACOCO_REPORT_CLASSES_ALL) :
@echo "Collecting uninstrumented classes"
mkdir -p $(PRIVATE_TARGET_JACOCO_DIR) $(PRIVATE_HOST_JACOCO_DIR) $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
$(SOONG_ZIP) -o $@ -L 0 \
-C $(PRIVATE_TARGET_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_JACOCO_DIR) \
-C $(PRIVATE_HOST_JACOCO_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_JACOCO_DIR) \
-C $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_TARGET_PROGUARD_USAGE_DIR) \
-C $(PRIVATE_HOST_PROGUARD_USAGE_DIR) -P out/target/common/obj -D $(PRIVATE_HOST_PROGUARD_USAGE_DIR)
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(JACOCO_REPORT_CLASSES_ALL): $(INTERNAL_ALLIMAGES_FILES)
endif
# This is not ideal, but it is difficult to correctly figure out the actual jacoco report
# jars we need to add here as dependencies, so we add the device-tests as a dependency when
# the env variable is set and this should guarantee thaat all the jacoco report jars are ready
# when we package the final report jar here.
ifeq ($(JACOCO_PACKAGING_INCLUDE_DEVICE_TESTS),true)
$(JACOCO_REPORT_CLASSES_ALL): $(COMPATIBILITY.device-tests.FILES)
endif
endif # EMMA_INSTRUMENT=true
#------------------------------------------------------------------
# A zip of Proguard obfuscation dictionary files.
# Also produces a textproto containing mappings from the hashes of the
# dictionary contents (which are also stored in the dex files on the
# devices) to the filename of the proguard dictionary, which will allow
# finding the appropriate dictionary to deobfuscate a stack trace frame.
#
ifeq (,$(TARGET_BUILD_UNBUNDLED))
_proguard_dict_zip_modules := $(call product-installed-modules,$(INTERNAL_PRODUCT))
else
_proguard_dict_zip_modules := $(unbundled_build_modules)
endif
# Filter out list to avoid uncessary proguard related file generation
ifeq (,$(TARGET_BUILD_UNBUNDLED))
filter_out_proguard_dict_zip_modules :=
# product.img
ifndef BUILDING_PRODUCT_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/product/%
endif
# system.img
ifndef BUILDING_SYSTEM_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/system/%
endif
# system_dlkm.img
ifndef BUILDING_SYSTEM_DLKM_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/system_dlkm/%
endif
# system_ext.img
ifndef BUILDING_SYSTEM_EXT_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/system_ext/%
endif
# system_other.img
ifndef BUILDING_SYSTEM_OTHER_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/system_other/%
endif
# odm.img
ifndef BUILDING_ODM_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/odm/%
endif
# odm_dlkm.img
ifndef BUILDING_ODM_DLKM_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/odm_dlkm/%
endif
# vendor.img
ifndef BUILDING_VENDOR_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/vendor/%
endif
# vendor_dlkm.img
ifndef BUILDING_VENDOR_DLKM_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/vendor_dlkm/%
endif
# cache.img
ifndef BUILDING_CACHE_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/cache/%
endif
# ramdisk.img
ifndef BUILDING_RAMDISK_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/ramdisk/%
endif
# recovery.img
ifndef INSTALLED_RECOVERYIMAGE_TARGET
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/recovery/%
endif
# userdata.img
ifndef BUILDING_USERDATA_IMAGE
filter_out_proguard_dict_zip_modules += $(PRODUCT_OUT)/data/%
endif
# Check the installed files of each module and return the module name
# or return empty if none of the files remain to be installed
define filter-out-proguard-modules
$(if $(filter-out $(filter_out_proguard_dict_zip_modules),$(call module-installed-files,$(1))),$(1))
endef
# Filter out proguard dict zip modules those are not installed at the built image
_proguard_dict_zip_modules := $(foreach m,$(_proguard_dict_zip_modules),$(strip $(call filter-out-proguard-modules,$(m))))
endif
# The path to the zip file containing proguard dictionaries.
PROGUARD_DICT_ZIP :=$= $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict.zip
$(PROGUARD_DICT_ZIP): PRIVATE_SOONG_ZIP_ARGUMENTS := $(foreach m,$(_proguard_dict_zip_modules),$(ALL_MODULES.$(m).PROGUARD_DICTIONARY_SOONG_ZIP_ARGUMENTS))
$(PROGUARD_DICT_ZIP): $(SOONG_ZIP) $(foreach m,$(_proguard_dict_zip_modules),$(ALL_MODULES.$(m).PROGUARD_DICTIONARY_FILES))
@echo "Packaging Proguard obfuscation dictionary files."
# Zip all of the files in PROGUARD_DICTIONARY_FILES.
echo -n > $@.tmparglist
$(foreach arg,$(PRIVATE_SOONG_ZIP_ARGUMENTS),printf "%s\n" "$(arg)" >> $@.tmparglist$(newline))
$(SOONG_ZIP) -d -o $@ @$@.tmparglist
rm -f $@.tmparglist
# The path to the zip file containing mappings from dictionary hashes to filenames.
PROGUARD_DICT_MAPPING :=$= $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-dict-mapping.textproto
_proguard_dict_mapping_files := $(foreach m,$(_proguard_dict_zip_modules),$(ALL_MODULES.$(m).PROGUARD_DICTIONARY_MAPPING))
$(PROGUARD_DICT_MAPPING): PRIVATE_MAPPING_FILES := $(_proguard_dict_mapping_files)
$(PROGUARD_DICT_MAPPING): $(SYMBOLS_MAP) $(_proguard_dict_mapping_files)
@echo "Packaging Proguard obfuscation dictionary mapping files."
# Merge all the mapping files together
echo -n > $@.tmparglist
$(foreach mf,$(PRIVATE_MAPPING_FILES),echo "$(mf)" >> $@.tmparglist$(newline))
$(SYMBOLS_MAP) -merge $(PROGUARD_DICT_MAPPING) @$@.tmparglist
rm -f $@.tmparglist
$(call declare-1p-container,$(PROGUARD_DICT_ZIP),)
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(call declare-container-license-deps,$(PROGUARD_DICT_ZIP),$(INTERNAL_ALLIMAGES_FILES) $(updater_dep),$(PRODUCT_OUT)/:/)
endif
#------------------------------------------------------------------
# A zip of Proguard usage files.
#
PROGUARD_USAGE_ZIP :=$= $(PRODUCT_OUT)/$(TARGET_PRODUCT)-proguard-usage.zip
_proguard_usage_zips := $(foreach m,$(_proguard_dict_zip_modules),$(ALL_MODULES.$(m).PROGUARD_USAGE_ZIP))
$(PROGUARD_USAGE_ZIP): PRIVATE_ZIPS := $(_proguard_usage_zips)
$(PROGUARD_USAGE_ZIP): $(MERGE_ZIPS) $(_proguard_usage_zips)
@echo "Packaging Proguard usage files."
echo -n > $@.tmparglist
$(foreach z,$(PRIVATE_ZIPS),echo "$(z)" >> $@.tmparglist$(newline))
$(MERGE_ZIPS) $@ @$@.tmparglist
rm -rf $@.tmparglist
_proguard_dict_mapping_files :=
_proguard_usage_zips :=
_proguard_dict_zip_modules :=
$(call declare-1p-container,$(PROGUARD_USAGE_ZIP),)
ifeq (,$(TARGET_BUILD_UNBUNDLED))
$(call declare-container-license-deps,$(PROGUARD_USAGE_ZIP),$(INSTALLED_SYSTEMIMAGE_TARGET) \
$(INSTALLED_RAMDISK_TARGET) \
$(INSTALLED_BOOTIMAGE_TARGET) \
$(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
$(INSTALLED_USERDATAIMAGE_TARGET) \
$(INSTALLED_VENDORIMAGE_TARGET) \
$(INSTALLED_PRODUCTIMAGE_TARGET) \
$(INSTALLED_SYSTEM_EXTIMAGE_TARGET) \
$(INSTALLED_ODMIMAGE_TARGET) \
$(INSTALLED_VENDOR_DLKMIMAGE_TARGET) \
$(INSTALLED_ODM_DLKMIMAGE_TARGET) \
$(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) \
$(updater_dep),$(PROGUARD_USAGE_ZIP):/)
endif
ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
# Dump variables used by build_super_image.py (for building super.img and super_empty.img).
# $(1): output file
define dump-super-image-info
$(call dump-dynamic-partitions-info,$(1))
$(if $(filter true,$(AB_OTA_UPDATER)), \
echo "ab_update=true" >> $(1))
endef
endif # PRODUCT_USE_DYNAMIC_PARTITIONS
# -----------------------------------------------------------------
# super partition image (dist)
ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
# BOARD_SUPER_PARTITION_SIZE must be defined to build super image.
ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
# For real devices and for dist builds, build super image from target files to an intermediate directory.
INTERNAL_SUPERIMAGE_DIST_TARGET := $(call intermediates-dir-for,PACKAGING,super.img)/super.img
$(INTERNAL_SUPERIMAGE_DIST_TARGET): extracted_input_target_files := $(patsubst %.zip,%,$(BUILT_TARGET_FILES_PACKAGE))
$(INTERNAL_SUPERIMAGE_DIST_TARGET): $(LPMAKE) $(BUILT_TARGET_FILES_DIR) $(BUILD_SUPER_IMAGE)
$(call pretty,"Target super fs image from target files: $@")
PATH=$(dir $(LPMAKE)):$$PATH \
$(BUILD_SUPER_IMAGE) -v $(extracted_input_target_files) $@
# Skip packing it in dist package because it is in update package.
ifneq (true,$(BOARD_SUPER_IMAGE_IN_UPDATE_PACKAGE))
$(call dist-for-goals,dist_files,$(INTERNAL_SUPERIMAGE_DIST_TARGET))
endif
.PHONY: superimage_dist
superimage_dist: $(INTERNAL_SUPERIMAGE_DIST_TARGET)
endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
endif # BOARD_SUPER_PARTITION_SIZE != ""
endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
# -----------------------------------------------------------------
# super partition image for development
ifeq (true,$(PRODUCT_BUILD_SUPER_PARTITION))
ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
ifneq (true,$(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS))
# Build super.img by using $(INSTALLED_*IMAGE_TARGET) to $(1)
# $(1): built image path
# $(2): misc_info.txt path; its contents should match expectation of build_super_image.py
define build-superimage-target
mkdir -p $(dir $(2))
rm -rf $(2)
$(call dump-super-image-info,$(2))
$(foreach p,$(BOARD_SUPER_PARTITION_PARTITION_LIST), \
echo "$(p)_image=$(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET)" >> $(2);)
$(if $(BUILDING_SYSTEM_OTHER_IMAGE), $(if $(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)), \
echo "system_other_image=$(INSTALLED_SYSTEMOTHERIMAGE_TARGET)" >> $(2);))
mkdir -p $(dir $(1))
PATH=$(dir $(LPMAKE)):$$PATH \
$(BUILD_SUPER_IMAGE) -v $(2) $(1)
endef
INSTALLED_SUPERIMAGE_TARGET := $(PRODUCT_OUT)/super.img
INSTALLED_SUPERIMAGE_DEPENDENCIES := $(LPMAKE) $(BUILD_SUPER_IMAGE) \
$(foreach p, $(BOARD_SUPER_PARTITION_PARTITION_LIST), $(INSTALLED_$(call to-upper,$(p))IMAGE_TARGET))
ifdef BUILDING_SYSTEM_OTHER_IMAGE
ifneq ($(filter system,$(BOARD_SUPER_PARTITION_PARTITION_LIST)),)
INSTALLED_SUPERIMAGE_DEPENDENCIES += $(INSTALLED_SYSTEMOTHERIMAGE_TARGET)
endif
endif
$(INSTALLED_SUPERIMAGE_TARGET): $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
$(call pretty,"Target super fs image for debug: $@")
$(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
$(call intermediates-dir-for,PACKAGING,superimage_debug)/misc_info.txt)
# For devices that uses super image directly, the superimage target points to the file in $(PRODUCT_OUT).
.PHONY: superimage
superimage: $(INSTALLED_SUPERIMAGE_TARGET)
# If BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT is set, super.img is built from images in the
# $(PRODUCT_OUT) directory, and is built to $(PRODUCT_OUT)/super.img. Also, it will
# be built for non-dist builds. This is useful for devices that uses super.img directly, e.g.
# virtual devices.
ifeq (true,$(BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT))
droidcore-unbundled: $(INSTALLED_SUPERIMAGE_TARGET)
$(call dist-for-goals,dist_files,$(INSTALLED_MISC_INFO_TARGET):super_misc_info.txt)
endif # BOARD_BUILD_SUPER_IMAGE_BY_DEFAULT
# Build $(PRODUCT_OUT)/super.img without dependencies.
.PHONY: superimage-nodeps supernod
superimage-nodeps supernod: intermediates :=
superimage-nodeps supernod: | $(INSTALLED_SUPERIMAGE_DEPENDENCIES)
$(call pretty,"make $(INSTALLED_SUPERIMAGE_TARGET): ignoring dependencies")
$(call build-superimage-target,$(INSTALLED_SUPERIMAGE_TARGET),\
$(call intermediates-dir-for,PACKAGING,superimage-nodeps)/misc_info.txt)
endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS != "true"
endif # BOARD_SUPER_PARTITION_SIZE != ""
endif # PRODUCT_BUILD_SUPER_PARTITION == "true"
# -----------------------------------------------------------------
# super empty image
ifdef BUILDING_SUPER_EMPTY_IMAGE
INSTALLED_SUPERIMAGE_EMPTY_TARGET := $(PRODUCT_OUT)/super_empty.img
$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): intermediates := $(call intermediates-dir-for,PACKAGING,super_empty)
$(INSTALLED_SUPERIMAGE_EMPTY_TARGET): $(LPMAKE) $(BUILD_SUPER_IMAGE)
$(call pretty,"Target empty super fs image: $@")
mkdir -p $(intermediates)
rm -rf $(intermediates)/misc_info.txt
$(call dump-super-image-info,$(intermediates)/misc_info.txt)
PATH=$(dir $(LPMAKE)):$$PATH \
$(BUILD_SUPER_IMAGE) -v $(intermediates)/misc_info.txt $@
$(call dist-for-goals,dist_files,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
$(call declare-0p-target,$(INSTALLED_SUPERIMAGE_EMPTY_TARGET))
endif # BUILDING_SUPER_EMPTY_IMAGE
# -----------------------------------------------------------------
# The update package
name := $(TARGET_PRODUCT)
ifeq ($(TARGET_BUILD_TYPE),debug)
name := $(name)_debug
endif
name := $(name)-img
INTERNAL_UPDATE_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
$(INTERNAL_UPDATE_PACKAGE_TARGET): $(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES)
$(call pretty,"Package: $@")
PATH=$(INTERNAL_USERIMAGES_BINARY_PATHS):$(dir $(ZIP2ZIP)):$$PATH \
$(IMG_FROM_TARGET_FILES) \
--additional IMAGES/VerifiedBootParams.textproto:VerifiedBootParams.textproto \
$(foreach partition,$(BOARD_CUSTOMIMAGES_PARTITION_LIST), \
$(if $(BOARD_$(call to-upper,$(partition))_IMAGE_NO_FLASHALL), \
--exclude IMAGES/$(partition).img \
--exclude IMAGES/$(partition).map \
) \
) \
--build_super_image $(BUILD_SUPER_IMAGE) \
$(BUILT_TARGET_FILES_PACKAGE) $@
$(call declare-1p-container,$(INTERNAL_UPDATE_PACKAGE_TARGET),)
$(call declare-container-license-deps,$(INTERNAL_UPDATE_PACKAGE_TARGET),$(BUILT_TARGET_FILES_PACKAGE) $(IMG_FROM_TARGET_FILES),$(PRODUCT_OUT)/:/)
.PHONY: updatepackage
updatepackage: $(INTERNAL_UPDATE_PACKAGE_TARGET)
$(call dist-for-goals-with-filenametag,updatepackage,$(INTERNAL_UPDATE_PACKAGE_TARGET))
# -----------------------------------------------------------------
# dalvik something
.PHONY: dalvikfiles
dalvikfiles: $(INTERNAL_DALVIK_MODULES)
ifeq ($(BUILD_QEMU_IMAGES),true)
MK_QEMU_IMAGE_SH := device/generic/goldfish/tools/mk_qemu_image.sh
MK_COMBINE_QEMU_IMAGE := $(HOST_OUT_EXECUTABLES)/mk_combined_img
SGDISK_HOST := $(HOST_OUT_EXECUTABLES)/sgdisk
ifdef INSTALLED_SYSTEMIMAGE_TARGET
INSTALLED_QEMU_SYSTEMIMAGE := $(PRODUCT_OUT)/system-qemu.img
INSTALLED_SYSTEM_QEMU_CONFIG := $(PRODUCT_OUT)/system-qemu-config.txt
$(INSTALLED_SYSTEM_QEMU_CONFIG): $(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_VBMETAIMAGE_TARGET)
@echo "$(PRODUCT_OUT)/vbmeta.img vbmeta 1" > $@
@echo "$(INSTALLED_SUPERIMAGE_TARGET) super 2" >> $@
$(INSTALLED_QEMU_SYSTEMIMAGE): $(INSTALLED_VBMETAIMAGE_TARGET) $(MK_COMBINE_QEMU_IMAGE) $(SGDISK_HOST) $(SIMG2IMG) \
$(INSTALLED_SUPERIMAGE_TARGET) $(INSTALLED_SYSTEM_QEMU_CONFIG)
@echo Create system-qemu.img now
(export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); \
$(MK_COMBINE_QEMU_IMAGE) -i $(INSTALLED_SYSTEM_QEMU_CONFIG) -o $@)
systemimage: $(INSTALLED_QEMU_SYSTEMIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_SYSTEMIMAGE)
endif
ifdef INSTALLED_VENDORIMAGE_TARGET
INSTALLED_QEMU_VENDORIMAGE := $(PRODUCT_OUT)/vendor-qemu.img
$(INSTALLED_QEMU_VENDORIMAGE): $(INSTALLED_VENDORIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
@echo Create vendor-qemu.img
(export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDORIMAGE_TARGET))
vendorimage: $(INSTALLED_QEMU_VENDORIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_VENDORIMAGE)
endif
ifdef INSTALLED_RAMDISK_TARGET
ifdef INSTALLED_VENDOR_BOOTIMAGE_TARGET
ifdef INTERNAL_VENDOR_RAMDISK_TARGET
INSTALLED_QEMU_RAMDISKIMAGE := $(PRODUCT_OUT)/ramdisk-qemu.img
$(INSTALLED_QEMU_RAMDISKIMAGE): $(INTERNAL_VENDOR_RAMDISK_TARGET) $(INSTALLED_RAMDISK_TARGET)
@echo Create ramdisk-qemu.img
(cat $(INSTALLED_RAMDISK_TARGET) $(INTERNAL_VENDOR_RAMDISK_TARGET) > $(INSTALLED_QEMU_RAMDISKIMAGE))
droidcore-unbundled: $(INSTALLED_QEMU_RAMDISKIMAGE)
endif
endif
endif
ifdef INSTALLED_PRODUCTIMAGE_TARGET
INSTALLED_QEMU_PRODUCTIMAGE := $(PRODUCT_OUT)/product-qemu.img
$(INSTALLED_QEMU_PRODUCTIMAGE): $(INSTALLED_PRODUCTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
@echo Create product-qemu.img
(export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_PRODUCTIMAGE_TARGET))
productimage: $(INSTALLED_QEMU_PRODUCTIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_PRODUCTIMAGE)
endif
ifdef INSTALLED_SYSTEM_EXTIMAGE_TARGET
INSTALLED_QEMU_SYSTEM_EXTIMAGE := $(PRODUCT_OUT)/system_ext-qemu.img
$(INSTALLED_QEMU_SYSTEM_EXTIMAGE): $(INSTALLED_SYSTEM_EXTIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST) $(SIMG2IMG)
@echo Create system_ext-qemu.img
(export SGDISK=$(SGDISK_HOST) SIMG2IMG=$(SIMG2IMG); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_EXTIMAGE_TARGET))
systemextimage: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_EXTIMAGE)
endif
ifdef INSTALLED_ODMIMAGE_TARGET
INSTALLED_QEMU_ODMIMAGE := $(PRODUCT_OUT)/odm-qemu.img
$(INSTALLED_QEMU_ODMIMAGE): $(INSTALLED_ODMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
@echo Create odm-qemu.img
(export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODMIMAGE_TARGET))
odmimage: $(INSTALLED_QEMU_ODMIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_ODMIMAGE)
endif
ifdef INSTALLED_VENDOR_DLKMIMAGE_TARGET
INSTALLED_QEMU_VENDOR_DLKMIMAGE := $(PRODUCT_OUT)/vendor_dlkm-qemu.img
$(INSTALLED_QEMU_VENDOR_DLKMIMAGE): $(INSTALLED_VENDOR_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
@echo Create vendor_dlkm-qemu.img
(export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_VENDOR_DLKMIMAGE_TARGET))
vendor_dlkmimage: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_VENDOR_DLKMIMAGE)
endif
ifdef INSTALLED_ODM_DLKMIMAGE_TARGET
INSTALLED_QEMU_ODM_DLKMIMAGE := $(PRODUCT_OUT)/odm_dlkm-qemu.img
$(INSTALLED_QEMU_ODM_DLKMIMAGE): $(INSTALLED_ODM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
@echo Create odm_dlkm-qemu.img
(export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_ODM_DLKMIMAGE_TARGET))
odm_dlkmimage: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_ODM_DLKMIMAGE)
endif
ifdef INSTALLED_SYSTEM_DLKMIMAGE_TARGET
INSTALLED_QEMU_SYSTEM_DLKMIMAGE := $(PRODUCT_OUT)/system_dlkm-qemu.img
$(INSTALLED_QEMU_SYSTEM_DLKMIMAGE): $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET) $(MK_QEMU_IMAGE_SH) $(SGDISK_HOST)
@echo Create system_dlkm-qemu.img
(export SGDISK=$(SGDISK_HOST); $(MK_QEMU_IMAGE_SH) $(INSTALLED_SYSTEM_DLKMIMAGE_TARGET))
system_dlkmimage: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
droidcore-unbundled: $(INSTALLED_QEMU_SYSTEM_DLKMIMAGE)
endif
QEMU_VERIFIED_BOOT_PARAMS := $(PRODUCT_OUT)/VerifiedBootParams.textproto
$(QEMU_VERIFIED_BOOT_PARAMS): $(INSTALLED_VBMETAIMAGE_TARGET) $(INSTALLED_SYSTEMIMAGE_TARGET) \
$(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(AVBTOOL)
@echo Creating $@
(export AVBTOOL=$(AVBTOOL); $(MK_VBMETA_BOOT_KERNEL_CMDLINE_SH) $(INSTALLED_VBMETAIMAGE_TARGET) \
$(INSTALLED_SYSTEMIMAGE_TARGET) $(QEMU_VERIFIED_BOOT_PARAMS))
systemimage: $(QEMU_VERIFIED_BOOT_PARAMS)
droidcore-unbundled: $(QEMU_VERIFIED_BOOT_PARAMS)
endif
# Preprocess files for emulator and sdk.
-include development/build/tools/sdk-preprocess-files.mk
# -----------------------------------------------------------------
# The emulator package
ifeq ($(BUILD_EMULATOR),true)
INTERNAL_EMULATOR_PACKAGE_FILES += \
$(HOST_OUT_EXECUTABLES)/emulator$(HOST_EXECUTABLE_SUFFIX) \
$(INSTALLED_RAMDISK_TARGET) \
$(INSTALLED_SYSTEMIMAGE_TARGET) \
$(INSTALLED_USERDATAIMAGE_TARGET)
name := $(TARGET_PRODUCT)-emulator
INTERNAL_EMULATOR_PACKAGE_TARGET := $(PRODUCT_OUT)/$(name).zip
$(INTERNAL_EMULATOR_PACKAGE_TARGET): $(INTERNAL_EMULATOR_PACKAGE_FILES)
@echo "Package: $@"
$(hide) zip -qjX $@ $(INTERNAL_EMULATOR_PACKAGE_FILES)
endif
# -----------------------------------------------------------------
# The SDK
ifneq ($(filter sdk,$(MAKECMDGOALS)),)
# The SDK includes host-specific components, so it belongs under HOST_OUT.
sdk_dir := $(HOST_OUT)/sdk/$(TARGET_PRODUCT)
# Build a name that looks like:
#
# linux-x86 --> android-sdk_12345_linux-x86
# darwin-x86 --> android-sdk_12345_mac-x86
# windows-x86 --> android-sdk_12345_windows
#
ifneq ($(HOST_OS),linux)
$(error Building the monolithic SDK is only supported on Linux)
endif
sdk_name := android-sdk
INTERNAL_SDK_HOST_OS_NAME := linux-$(SDK_HOST_ARCH)
sdk_name := $(sdk_name)_$(INTERNAL_SDK_HOST_OS_NAME)
sdk_dep_file := $(sdk_dir)/sdk_deps.mk
ATREE_FILES :=
-include $(sdk_dep_file)
# if we don't have a real list, then use "everything"
ifeq ($(strip $(ATREE_FILES)),)
ATREE_FILES := \
$(ALL_DOCS) \
$(ALL_SDK_FILES)
endif
atree_dir := development/build
sdk_atree_files := $(atree_dir)/sdk.exclude.atree
# development/build/sdk-android-.atree is used to differentiate
# between architecture models (e.g. ARMv5TE versus ARMv7) when copying
# files like the kernel image. We use TARGET_CPU_ABI because we don't
# have a better way to distinguish between CPU models.
ifneq (,$(strip $(wildcard $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree)))
sdk_atree_files += $(atree_dir)/sdk-android-$(TARGET_CPU_ABI).atree
endif
ifneq ($(PRODUCT_SDK_ATREE_FILES),)
sdk_atree_files += $(PRODUCT_SDK_ATREE_FILES)
else
sdk_atree_files += $(atree_dir)/sdk.atree
endif
SDK_METADATA_DIR :=$= $(call intermediates-dir-for,PACKAGING,framework-doc-stubs-metadata,,COMMON)
SDK_METADATA_FILES :=$= $(addprefix $(SDK_METADATA_DIR)/,\
activity_actions.txt \
broadcast_actions.txt \
categories.txt \
features.txt \
service_actions.txt \
widgets.txt)
SDK_METADATA :=$= $(firstword $(SDK_METADATA_FILES))
$(SDK_METADATA): .KATI_IMPLICIT_OUTPUTS := $(filter-out $(SDK_METADATA),$(SDK_METADATA_FILES))
$(SDK_METADATA): $(TARGET_OUT_COMMON_INTERMEDIATES)/PACKAGING/framework-doc-stubs-metadata.zip
rm -rf $(SDK_METADATA_DIR)
mkdir -p $(SDK_METADATA_DIR)
unzip -DDqo $< -d $(SDK_METADATA_DIR)
.PHONY: framework-doc-stubs
framework-doc-stubs: $(SDK_METADATA)
deps := \
$(OUT_DOCS)/offline-sdk-timestamp \
$(SDK_METADATA_FILES) \
$(INSTALLED_SDK_BUILD_PROP_TARGET) \
$(ATREE_FILES) \
$(sdk_atree_files) \
$(HOST_OUT_EXECUTABLES)/atree \
$(HOST_OUT_EXECUTABLES)/line_endings
# The name of the subdir within the platforms dir of the sdk. One of:
# - android- (stable base dessert SDKs)
# - android- (stable extension SDKs)
# - android--ext (codename SDKs)
sdk_platform_dir_name := $(strip \
$(if $(filter REL,$(PLATFORM_VERSION_CODENAME)), \
$(if $(filter $(PLATFORM_SDK_EXTENSION_VERSION),$(PLATFORM_BASE_SDK_EXTENSION_VERSION)), \
android-$(PLATFORM_SDK_VERSION), \
android-$(PLATFORM_SDK_VERSION)-ext$(PLATFORM_SDK_EXTENSION_VERSION) \
), \
android-$(PLATFORM_VERSION_CODENAME) \
) \
)
INTERNAL_SDK_TARGET := $(sdk_dir)/$(sdk_name).zip
$(INTERNAL_SDK_TARGET): PRIVATE_NAME := $(sdk_name)
$(INTERNAL_SDK_TARGET): PRIVATE_DIR := $(sdk_dir)/$(sdk_name)
$(INTERNAL_SDK_TARGET): PRIVATE_DEP_FILE := $(sdk_dep_file)
$(INTERNAL_SDK_TARGET): PRIVATE_INPUT_FILES := $(sdk_atree_files)
$(INTERNAL_SDK_TARGET): PRIVATE_PLATFORM_NAME := $(sdk_platform_dir_name)
# Set SDK_GNU_ERROR to non-empty to fail when a GNU target is built.
#
#SDK_GNU_ERROR := true
$(INTERNAL_SDK_TARGET): $(deps)
@echo "Package SDK: $@"
$(hide) rm -rf $(PRIVATE_DIR) $@
$(hide) for f in $(strip $(target_gnu_MODULES)); do \
if [ -f $$f ]; then \
echo SDK: $(if $(SDK_GNU_ERROR),ERROR:,warning:) \
including GNU target $$f >&2; \
FAIL=$(SDK_GNU_ERROR); \
fi; \
done; \
if [ $$FAIL ]; then exit 1; fi
$(hide) ( \
ATREE_STRIP="$(HOST_STRIP) -x" \
$(HOST_OUT_EXECUTABLES)/atree \
$(addprefix -f ,$(PRIVATE_INPUT_FILES)) \
-m $(PRIVATE_DEP_FILE) \
-I . \
-I $(PRODUCT_OUT) \
-I $(HOST_OUT) \
-I $(TARGET_COMMON_OUT_ROOT) \
-v "PLATFORM_NAME=$(PRIVATE_PLATFORM_NAME)" \
-v "OUT_DIR=$(OUT_DIR)" \
-v "HOST_OUT=$(HOST_OUT)" \
-v "TARGET_ARCH=$(TARGET_ARCH)" \
-v "TARGET_CPU_ABI=$(TARGET_CPU_ABI)" \
-v "DLL_EXTENSION=$(HOST_SHLIB_SUFFIX)" \
-o $(PRIVATE_DIR) && \
HOST_OUT_EXECUTABLES=$(HOST_OUT_EXECUTABLES) HOST_OS=$(HOST_OS) \
development/build/tools/sdk_clean.sh $(PRIVATE_DIR) && \
chmod -R ug+rwX $(PRIVATE_DIR) && \
cd $(dir $@) && zip -rqX $(notdir $@) $(PRIVATE_NAME) \
) || ( rm -rf $(PRIVATE_DIR) $@ && exit 44 )
MAIN_SDK_DIR := $(sdk_dir)
MAIN_SDK_ZIP := $(INTERNAL_SDK_TARGET)
endif # sdk in MAKECMDGOALS
# -----------------------------------------------------------------
# Findbugs
INTERNAL_FINDBUGS_XML_TARGET := $(PRODUCT_OUT)/findbugs.xml
INTERNAL_FINDBUGS_HTML_TARGET := $(PRODUCT_OUT)/findbugs.html
$(INTERNAL_FINDBUGS_XML_TARGET): $(ALL_FINDBUGS_FILES)
@echo UnionBugs: $@
$(hide) $(FINDBUGS_DIR)/unionBugs $(ALL_FINDBUGS_FILES) \
> $@
$(INTERNAL_FINDBUGS_HTML_TARGET): $(INTERNAL_FINDBUGS_XML_TARGET)
@echo ConvertXmlToText: $@
$(hide) $(FINDBUGS_DIR)/convertXmlToText -html:fancy.xsl \
$(INTERNAL_FINDBUGS_XML_TARGET) > $@
# -----------------------------------------------------------------
# Findbugs
# -----------------------------------------------------------------
# These are some additional build tasks that need to be run.
ifneq ($(dont_bother),true)
include $(sort $(wildcard $(BUILD_SYSTEM)/tasks/*.mk))
-include $(sort $(wildcard vendor/*/build/tasks/*.mk))
-include $(sort $(wildcard device/*/build/tasks/*.mk))
-include $(sort $(wildcard product/*/build/tasks/*.mk))
# Also the project-specific tasks
-include $(sort $(wildcard vendor/*/*/build/tasks/*.mk))
-include $(sort $(wildcard device/*/*/build/tasks/*.mk))
-include $(sort $(wildcard product/*/*/build/tasks/*.mk))
# Also add test specifc tasks
include $(sort $(wildcard platform_testing/build/tasks/*.mk))
include $(sort $(wildcard test/vts/tools/build/tasks/*.mk))
endif
include $(BUILD_SYSTEM)/product-graph.mk
# -----------------------------------------------------------------
# Create SDK repository packages. Must be done after tasks/* since
# we need the addon rules defined.
ifneq ($(sdk_repo_goal),)
include $(TOPDIR)development/build/tools/sdk_repo.mk
endif
# -----------------------------------------------------------------
# Soong generates the list of all shared libraries that are depended on by fuzz
# targets. It saves this list as a source:destination pair to
# FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS, where the source is the path to the
# build of the unstripped shared library, and the destination is the
# /data/fuzz/$ARCH/lib (for device) or /fuzz/$ARCH/lib (for host) directory
# where fuzz target shared libraries are to be "reinstalled". The
# copy-many-files below generates the rules to copy the unstripped shared
# libraries to the device or host "reinstallation" directory. These rules are
# depended on by each module in soong_cc_prebuilt.mk, where the module will have
# a dependency on each shared library that it needs to be "reinstalled".
FUZZ_SHARED_DEPS := $(call copy-many-files,$(strip $(FUZZ_TARGET_SHARED_DEPS_INSTALL_PAIRS)))
# -----------------------------------------------------------------
# The rule to build all fuzz targets for C++ and Rust, and package them.
# Note: The packages are created in Soong, and in a perfect world,
# we'd be able to create the phony rule there. But, if we want to
# have dist goals for the fuzz target, we need to have the PHONY
# target defined in make. MakeVarsContext.DistForGoal doesn't take
# into account that a PHONY rule create by Soong won't be available
# during make, and such will fail with `writing to readonly
# directory`, because kati will see 'haiku' as being a file, not a
# phony target.
.PHONY: haiku
haiku: $(SOONG_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_FUZZ_TARGETS)
$(call dist-for-goals,haiku,$(SOONG_FUZZ_PACKAGING_ARCH_MODULES))
$(call dist-for-goals,haiku,$(PRODUCT_OUT)/module-info.json)
.PHONY: haiku-java
haiku-java: $(SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_JAVA_FUZZ_TARGETS)
$(call dist-for-goals,haiku-java,$(SOONG_JAVA_FUZZ_PACKAGING_ARCH_MODULES))
.PHONY: haiku-rust
haiku-rust: $(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_RUST_FUZZ_TARGETS)
$(call dist-for-goals,haiku-rust,$(SOONG_RUST_FUZZ_PACKAGING_ARCH_MODULES))
$(call dist-for-goals,haiku-rust,$(PRODUCT_OUT)/module-info.json)
.PHONY: haiku-presubmit
haiku-presubmit: $(SOONG_PRESUBMIT_FUZZ_PACKAGING_ARCH_MODULES) $(ALL_PRESUBMIT_FUZZ_TARGETS)
$(call dist-for-goals,haiku-presubmit,$(SOONG_PRESUBMIT_FUZZ_PACKAGING_ARCH_MODULES))
# -----------------------------------------------------------------
# Extract additional data files used in Layoutlib
include $(BUILD_SYSTEM)/layoutlib_data.mk
# -----------------------------------------------------------------
# Desktop pack common variables.
PACK_IMAGE_SCRIPT := $(HOST_OUT_EXECUTABLES)/pack_image
UPDATE_PARTITION_SCRIPT := $(HOST_OUT_EXECUTABLES)/update-partition
IMAGES := $(INSTALLED_BOOTIMAGE_TARGET) \
$(INSTALLED_SUPERIMAGE_TARGET) \
$(INSTALLED_INIT_BOOT_IMAGE_TARGET) \
$(INSTALLED_VENDOR_BOOTIMAGE_TARGET) \
$(INSTALLED_VBMETAIMAGE_TARGET) \
$(INSTALLED_USERDATAIMAGE_TARGET)
# -----------------------------------------------------------------
# Desktop generated firmware filesystem.
TARGET_PRODUCT_FW_IMAGE_PACKAGE := prebuilt-$(TARGET_PRODUCT)-firmware-image
GENERATED_FW_IMAGE := $(PRODUCT_OUT)/product/etc/$(TARGET_PRODUCT)-firmware.img
generated_fw_image_found := $(strip $(foreach pp,$(PRODUCT_PACKAGES),\
$(if $(findstring $(TARGET_PRODUCT_FW_IMAGE_PACKAGE),$(pp)),$(pp))))
ifneq (,$(generated_fw_image_found))
$(call dist-for-goals,dist_files,$(GENERATED_FW_IMAGE))
endif
# -----------------------------------------------------------------
# Desktop pack image hook.
ifneq (,$(strip $(PACK_DESKTOP_FILESYSTEM_IMAGES)))
PACK_IMAGE_TARGET := $(PRODUCT_OUT)/android-desktop_image.bin
$(PACK_IMAGE_TARGET): $(IMAGES) $(PACK_IMAGE_SCRIPT)
$(PACK_IMAGE_SCRIPT) --out_dir $(PRODUCT_OUT) --noarchive
PACKED_IMAGE_ARCHIVE_TARGET := $(PACK_IMAGE_TARGET).gz
$(PACKED_IMAGE_ARCHIVE_TARGET): $(PACK_IMAGE_TARGET) | $(GZIP)
$(GZIP) -fk $(PACK_IMAGE_TARGET)
$(call dist-for-goals,dist_files,$(PACKED_IMAGE_ARCHIVE_TARGET))
.PHONY: pack-image
pack-image: $(PACK_IMAGE_TARGET)
endif # PACK_DESKTOP_FILESYSTEM_IMAGES
# -----------------------------------------------------------------
# Desktop pack recovery image hook.
ifeq ($(BOARD_USES_DESKTOP_RECOVERY_IMAGE),true)
PACK_RECOVERY_IMAGE_TARGET := $(PRODUCT_OUT)/android-desktop_recovery_image.bin
PACK_RECOVERY_IMAGE_ARGS := --noarchive --recovery
ifneq (,$(strip $(PACK_RECOVERY_IMAGE_EXPERIMENTAL)))
PACK_RECOVERY_IMAGE_ARGS += --experimental
endif # PACK_RECOVERY_IMAGE_EXPERIMENTAL
$(PACK_RECOVERY_IMAGE_TARGET): $(IMAGES) $(PACK_IMAGE_SCRIPT)
$(PACK_IMAGE_SCRIPT) --out_dir $(PRODUCT_OUT) $(PACK_RECOVERY_IMAGE_ARGS)
PACKED_RECOVERY_IMAGE_ARCHIVE_TARGET := $(PACK_RECOVERY_IMAGE_TARGET).gz
$(PACKED_RECOVERY_IMAGE_ARCHIVE_TARGET): $(PACK_RECOVERY_IMAGE_TARGET) | $(GZIP)
$(GZIP) -fk $(PACK_RECOVERY_IMAGE_TARGET)
$(call dist-for-goals,dist_files,$(PACKED_RECOVERY_IMAGE_ARCHIVE_TARGET))
.PHONY: pack-recovery-image
pack-recovery-image: $(PACK_RECOVERY_IMAGE_TARGET)
RECOVERY_SWAP_KERNEL_TARGET := $(PRODUCT_OUT)/recovery-kernel-swap
# Has swap kernel for insecure recovery image.
ifeq ($(BOARD_USES_DESKTOP_RECOVERY_SWAP_KERNEL),true)
$(call dist-for-goals,dist_files,$(RECOVERY_SWAP_KERNEL_TARGET))
PACK_INSECURE_RECOVERY_IMAGE_TARGET := $(PRODUCT_OUT)/android-desktop_insecure_recovery_image.bin
$(PACK_INSECURE_RECOVERY_IMAGE_TARGET): PRIVATE_SGDISK := $(HOST_OUT_EXECUTABLES)/sgdisk
$(PACK_INSECURE_RECOVERY_IMAGE_TARGET): $(PACK_RECOVERY_IMAGE_TARGET) $(UPDATE_PARTITION_SCRIPT) $(RECOVERY_SWAP_KERNEL_TARGET)
@cp -f $< $@
(export SGDISK=$(PRIVATE_SGDISK); $(UPDATE_PARTITION_SCRIPT) KERN-A $@ $(RECOVERY_SWAP_KERNEL_TARGET))
PACKED_INSECURE_RECOVERY_IMAGE_ARCHIVE_TARGET := $(PACK_INSECURE_RECOVERY_IMAGE_TARGET).gz
$(PACKED_INSECURE_RECOVERY_IMAGE_ARCHIVE_TARGET): $(PACK_INSECURE_RECOVERY_IMAGE_TARGET) | $(GZIP)
$(GZIP) -fk $(PACK_INSECURE_RECOVERY_IMAGE_TARGET)
$(call dist-for-goals,dist_files,$(PACKED_INSECURE_RECOVERY_IMAGE_ARCHIVE_TARGET))
.PHONY: pack-insecure-recovery-image
pack-insecure-recovery-image: $(PACK_INSECURE_RECOVERY_IMAGE_TARGET)
endif # BOARD_USES_DESKTOP_RECOVERY_SWAP_KERNEL
endif # BOARD_USES_DESKTOP_RECOVERY_IMAGE
# -----------------------------------------------------------------
# Desktop pack update image hook.
ifeq ($(BOARD_USES_DESKTOP_UPDATE_IMAGE),true)
PACK_UPDATE_IMAGE_TARGET := $(PRODUCT_OUT)/android-desktop_update_image.bin
PACK_UPDATE_IMAGE_ARGS := --noarchive --update
ifneq (,$(strip $(PACK_UPDATE_IMAGE_EXPERIMENTAL)))
PACK_UPDATE_IMAGE_ARGS += --experimental
endif # PACK_UPDATE_IMAGE_EXPERIMENTAL
$(PACK_UPDATE_IMAGE_TARGET): $(IMAGES) $(PACK_IMAGE_SCRIPT)
$(PACK_IMAGE_SCRIPT) --out_dir $(PRODUCT_OUT) $(PACK_UPDATE_IMAGE_ARGS)
PACKED_UPDATE_IMAGE_ARCHIVE_TARGET := $(PACK_UPDATE_IMAGE_TARGET).gz
$(PACKED_UPDATE_IMAGE_ARCHIVE_TARGET): $(PACK_UPDATE_IMAGE_TARGET) | $(GZIP)
$(GZIP) -fk $(PACK_UPDATE_IMAGE_TARGET)
$(call dist-for-goals,dist_files,$(PACKED_UPDATE_IMAGE_ARCHIVE_TARGET))
.PHONY: pack-update-image
pack-update-image: $(PACK_UPDATE_IMAGE_TARGET)
endif # BOARD_USES_DESKTOP_UPDATE_IMAGE
PACK_MIGRATION_IMAGE_SCRIPT := $(HOST_OUT_EXECUTABLES)/pack_migration_image
# -----------------------------------------------------------------
# Desktop pack migration image hook.
ifeq ($(ANDROID_DESKTOP_MIGRATION_IMAGE),true)
PACK_MIGRATION_IMAGE_TARGET := $(PRODUCT_OUT)/android-desktop_migration_image.bin
$(PACK_MIGRATION_IMAGE_TARGET): $(IMAGES) $(PACK_MIGRATION_IMAGE_SCRIPT)
$(PACK_MIGRATION_IMAGE_SCRIPT) --out_dir $(PRODUCT_OUT) --noarchive
PACKED_MIGRATION_IMAGE_ARCHIVE_TARGET := $(PACK_MIGRATION_IMAGE_TARGET).gz
$(PACKED_MIGRATION_IMAGE_ARCHIVE_TARGET): $(PACK_MIGRATION_IMAGE_TARGET) | $(GZIP)
$(GZIP) -fk $(PACK_MIGRATION_IMAGE_TARGET)
$(call dist-for-goals,dist_files,$(PACKED_MIGRATION_IMAGE_ARCHIVE_TARGET))
.PHONY: pack-migration-image
pack-migration-image: $(PACK_MIGRATION_IMAGE_TARGET)
endif # ANDROID_DESKTOP_MIGRATION_IMAGE
ifdef SOONG_ONLY_ALL_IMAGES_ZIP
allimages_soong_zip_args :=
allimages_deps :=
define include_image
$(if $(1), \
$(eval allimages_soong_zip_args += -e $(notdir $(1)) -f $(1)) \
$(eval allimages_deps += $(1)))
endef
$(call include_image,$(INSTALLED_SUPERIMAGE_TARGET))
$(call include_image,$(INSTALLED_BOOTIMAGE_TARGET))
$(call include_image,$(INSTALLED_INIT_BOOT_IMAGE_TARGET))
$(call include_image,$(INSTALLED_VENDOR_BOOTIMAGE_TARGET))
$(call include_image,$(INSTALLED_USERDATAIMAGE_TARGET))
$(call include_image,$(INSTALLED_RECOVERYIMAGE_TARGET))
$(call include_image,$(INSTALLED_VBMETAIMAGE_TARGET))
$(call include_image,$(INSTALLED_VBMETA_SYSTEMIMAGE_TARGET))
$(call include_image,$(INSTALLED_VBMETA_VENDORIMAGE_TARGET))
$(foreach partition,$(call to-upper,$(BOARD_AVB_VBMETA_CUSTOM_PARTITIONS)), \
$(call include_image,$(INSTALLED_VBMETA_$(partition)IMAGE_TARGET)))
allimages_zip := $(PRODUCT_OUT)/all_images.zip
$(allimages_zip): PRIVATE_SOONG_ZIP_ARGUMENTS := $(allimages_soong_zip_args)
$(allimages_zip): $(SOONG_ZIP) $(allimages_deps)
$(SOONG_ZIP) -o $@ $(PRIVATE_SOONG_ZIP_ARGUMENTS)
.PHONY: soong_only_diff_test
soong_only_diff_test: PRIVATE_ALLIMAGES_ZIP := $(allimages_zip)
soong_only_diff_test: $(allimages_zip) $(SOONG_ONLY_ALL_IMAGES_ZIP)
diff $(PRIVATE_ALLIMAGES_ZIP) $(SOONG_ONLY_ALL_IMAGES_ZIP)
allimages_soong_zip_args :=
allimages_deps :=
allimages_zip :=
include_image :=
endif # ifdef SOONG_ONLY_ALL_IMAGES_ZIP
# -----------------------------------------------------------------
# OS Licensing
include $(BUILD_SYSTEM)/os_licensing.mk
# When appending new code to this file, please insert above OS Licensing
================================================
FILE: core/OWNERS
================================================
# For global Proguard rules
per-file proguard*.flags = jdduke@google.com
# For version updates
per-file version_defaults.mk = ankurbakshi@google.com,bkhalife@google.com,jainne@google.com,lokeshgoel@google.com,lubomir@google.com,pscovanner@google.com
# For sdk extensions version updates
per-file version_defaults.mk = amhk@google.com,gurpreetgs@google.com,mkhokhlova@google.com,robertogil@google.com
# For Ravenwood test configs
per-file ravenwood_test_config_template.xml =omakoto@google.com
================================================
FILE: core/WINPTHREADS_COPYING
================================================
Copyright (c) 2011 mingw-w64 project
Permission is hereby granted, free of charge, to any person obtaining a
copy of this software and associated documentation files (the "Software"),
to deal in the Software without restriction, including without limitation
the rights to use, copy, modify, merge, publish, distribute, sublicense,
and/or sell copies of the Software, and to permit persons to whom the
Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.
/*
* Parts of this library are derived by:
*
* Posix Threads library for Microsoft Windows
*
* Use at own risk, there is no implied warranty to this code.
* It uses undocumented features of Microsoft Windows that can change
* at any time in the future.
*
* (C) 2010 Lockless Inc.
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
*
*
* * Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* * Neither the name of Lockless Inc. nor the names of its contributors may be
* used to endorse or promote products derived from this software without
* specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AN
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
* DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
* OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
* OF THE POSSIBILITY OF SUCH DAMAGE.
*/
================================================
FILE: core/aapt2.mk
================================================
######################################
# Compile resource with AAPT2
# Input variables:
# - full_android_manifest
# - my_res_resources
# - my_overlay_resources
# - my_compiled_res_base_dir
# - my_asset_dirs
# - my_full_asset_paths
# - my_res_package
# - R_file_stamp
# - proguard_options_file
# - my_generated_res_dirs: Resources generated during the build process and we have to compile them in a single run of aapt2.
# - my_generated_res_dirs_deps: the dependency to use for my_generated_res_dirs.
# - my_generated_res_zips: Zip files containing resources
# - my_apk_split_configs: The configurations for which to generate splits.
# - built_apk_splits: The paths where AAPT should generate the splits.
#
# Output variables:
# - my_res_resources_flat
# - my_overlay_resources_flat
# - my_generated_resources_flata
#
######################################
# Compile all the resource files.
my_res_resources_flat := \
$(foreach r, $(my_res_resources),\
$(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\
$(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\
$(o))
my_overlay_resources_flat := \
$(foreach r, $(my_overlay_resources),\
$(eval o := $(call aapt2-compiled-resource-out-file,$(r),$(my_compiled_res_base_dir)))\
$(eval $(call aapt2-compile-one-resource-file-rule,$(r),$(o)))\
$(o))
my_resources_flata :=
# Compile generated resources
ifneq ($(my_generated_res_dirs),)
my_generated_resources_flata := $(my_compiled_res_base_dir)/gen_res.flata
$(my_generated_resources_flata): PRIVATE_SOURCE_RES_DIRS := $(my_generated_res_dirs)
$(my_generated_resources_flata) : $(my_generated_res_dirs_deps) $(AAPT2)
@echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_DIRS)"
$(call aapt2-compile-resource-dirs)
my_resources_flata += $(my_generated_resources_flata)
endif
# Compile zipped resources
ifneq ($(my_generated_res_zips),)
my_zipped_resources_flata := $(my_compiled_res_base_dir)/zip_res.flata
$(my_zipped_resources_flata): PRIVATE_SOURCE_RES_ZIPS := $(my_generated_res_zips)
$(my_zipped_resources_flata) : $(my_generated_res_zips) $(AAPT2) $(ZIPSYNC)
@echo "AAPT2 compile $@ <- $(PRIVATE_SOURCE_RES_ZIPS)"
$(call aapt2-compile-resource-zips)
my_resources_flata += $(my_zipped_resources_flata)
endif
# Always set --pseudo-localize, it will be stripped out later for release
# builds that don't want it.
$(my_res_resources_flat) $(my_overlay_resources_flat) $(my_resources_flata) $(my_generated_resources_flata) $(my_zippped_resources_flata): \
PRIVATE_AAPT2_CFLAGS := --pseudo-localize $(filter --legacy,$(LOCAL_AAPT_FLAGS))
# TODO(b/78447299): Forbid LOCAL_STATIC_JAVA_AAR_LIBRARIES in aapt2 and remove
# support for it.
my_static_library_resources := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
my_static_library_transitive_resource_packages_lists := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/transitive-res-packages)
my_static_library_extra_packages := $(foreach l, $(call reverse-list,$(LOCAL_STATIC_ANDROID_LIBRARIES) $(LOCAL_STATIC_JAVA_AAR_LIBRARIES)),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/extra_packages)
my_shared_library_resources := $(foreach l, $(LOCAL_SHARED_ANDROID_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(l),,COMMON)/package-res.apk)
ifneq ($(my_static_library_resources),)
$(my_res_package): PRIVATE_AAPT_FLAGS += --auto-add-overlay
endif
ifneq ($(my_apk_split_configs),)
# Join the Split APK paths with their configuration, separated by a ':'.
$(my_res_package): PRIVATE_AAPT_FLAGS += $(addprefix --split ,$(join $(built_apk_splits),$(addprefix :,$(my_apk_split_configs))))
endif
my_srcjar := $(intermediates.COMMON)/aapt2.srcjar
LOCAL_SRCJARS += $(my_srcjar)
aapt_extra_packages := $(intermediates.COMMON)/extra_packages
$(my_res_package): PRIVATE_RES_FLAT := $(my_res_resources_flat)
$(my_res_package): PRIVATE_OVERLAY_FLAT := $(my_static_library_resources) $(my_resources_flata) $(my_overlay_resources_flat)
$(my_res_package): PRIVATE_SHARED_ANDROID_LIBRARIES := $(my_shared_library_resources)
$(my_res_package): PRIVATE_PROGUARD_OPTIONS_FILE := $(proguard_options_file)
$(my_res_package): PRIVATE_ASSET_DIRS := $(my_asset_dirs)
$(my_res_package): PRIVATE_JAVA_GEN_DIR := $(intermediates.COMMON)/aapt2
$(my_res_package): PRIVATE_SRCJAR := $(my_srcjar)
$(my_res_package): PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES := $(my_static_library_extra_packages)
$(my_res_package): PRIVATE_STATIC_LIBRARY_TRANSITIVE_RES_PACKAGES_LISTS := $(my_static_library_transitive_resource_packages_lists)
$(my_res_package): PRIVATE_AAPT_EXTRA_PACKAGES := $(aapt_extra_packages)
$(my_res_package): .KATI_IMPLICIT_OUTPUTS := $(my_srcjar) $(aapt_extra_packages)
ifdef R_file_stamp
$(my_res_package): PRIVATE_R_FILE_STAMP := $(R_file_stamp)
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(R_file_stamp)
endif
resource_export_package :=
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
# Put this module's resources into a PRODUCT-agnositc package that
# other packages can use to build their own PRODUCT-agnostic R.java (etc.)
# files.
resource_export_package := $(intermediates.COMMON)/package-export.apk
$(my_res_package): PRIVATE_RESOURCE_EXPORT_PACKAGE := $(resource_export_package)
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(resource_export_package)
endif
ifdef proguard_options_file
$(my_res_package): .KATI_IMPLICIT_OUTPUTS += $(proguard_options_file)
endif
$(my_res_package): $(full_android_manifest) $(my_static_library_resources) $(my_static_library_transitive_resource_packages_lists) $(my_shared_library_resources)
$(my_res_package): $(my_full_asset_paths)
$(my_res_package): $(my_res_resources_flat) $(my_overlay_resources_flat) \
$(my_resources_flata) $(my_static_library_resources) $(my_static_library_extra_packages) \
$(AAPT2) $(SOONG_ZIP) $(EXTRACT_JAR_PACKAGES)
@echo "AAPT2 link $@"
$(call aapt2-link)
ifdef R_file_stamp
@rm -f $(PRIVATE_R_FILE_STAMP)
$(call find-generated-R.java,$(PRIVATE_JAVA_GEN_DIR),$(PRIVATE_R_FILE_STAMP))
endif
ifdef LOCAL_EXPORT_PACKAGE_RESOURCES
@rm -f $(PRIVATE_RESOURCE_EXPORT_PACKAGE)
cp $@ $(PRIVATE_RESOURCE_EXPORT_PACKAGE)
endif
# Clear inputs only used in this file, so that they're not re-used during the next build
my_res_resources :=
my_overlay_resources :=
my_compiled_res_base_dir :=
my_asset_dirs :=
my_full_asset_paths :=
my_apk_split_configs :=
my_generated_res_dirs :=
my_generated_res_dirs_deps :=
my_generated_res_zips :=
================================================
FILE: core/aapt_flags.mk
================================================
## AAPT Flags
# aapt doesn't accept multiple --extra-packages flags.
# We have to collapse them into a single --extra-packages flag here.
LOCAL_AAPT_FLAGS := $(strip $(LOCAL_AAPT_FLAGS))
ifdef LOCAL_AAPT_FLAGS
ifeq ($(filter 0 1,$(words $(filter --extra-packages,$(LOCAL_AAPT_FLAGS)))),)
aapt_flags := $(subst --extra-packages$(space),--extra-packages@,$(LOCAL_AAPT_FLAGS))
aapt_flags_extra_packages := $(patsubst --extra-packages@%,%,$(filter --extra-packages@%,$(aapt_flags)))
aapt_flags_extra_packages := $(sort $(subst :,$(space),$(aapt_flags_extra_packages)))
LOCAL_AAPT_FLAGS := $(filter-out --extra-packages@%,$(aapt_flags)) \
--extra-packages $(subst $(space),:,$(aapt_flags_extra_packages))
aapt_flags_extra_packages :=
aapt_flags :=
endif
endif
================================================
FILE: core/allowed_ndk_types.mk
================================================
# Determines the types of NDK modules the current module is allowed to link to.
# Input variables:
# LOCAL_MODULE
# LOCAL_MODULE_CLASS
# LOCAL_NDK_STL_VARIANT
# LOCAL_SDK_VERSION
# Output variables:
# my_ndk_stl_family: Family of the NDK STL.
# my_ndk_stl_link_type: STL link type, static or shared.
# my_allowed_ndk_types: Types of NDK modules that may be linked.
# my_warn_ndk_types: Types of NDK modules that shouldn't be linked, but are.
my_allowed_ndk_types :=
my_warn_ndk_types :=
my_ndk_stl_family :=
my_ndk_stl_link_type :=
ifdef LOCAL_SDK_VERSION
ifeq ($(LOCAL_NDK_STL_VARIANT),)
my_ndk_stl_family := system
my_ndk_stl_link_type := shared
else ifeq ($(LOCAL_NDK_STL_VARIANT),system)
my_ndk_stl_family := system
my_ndk_stl_link_type := shared
else ifeq ($(LOCAL_NDK_STL_VARIANT),c++_shared)
my_ndk_stl_family := libc++
my_ndk_stl_link_type := shared
else ifeq ($(LOCAL_NDK_STL_VARIANT),c++_static)
my_ndk_stl_family := libc++
my_ndk_stl_link_type := static
else ifeq ($(LOCAL_NDK_STL_VARIANT),none)
my_ndk_stl_family := none
my_ndk_stl_link_type := none
else
$(call pretty-error,invalid LOCAL_NDK_STL_VARIANT: $(LOCAL_NDK_STL_VARIANT))
endif
ifeq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
# The "none" link type indicates that nothing is actually linked. Since
# this is a static library, it's still up to the final use of the
# library whether a static or shared STL should be used.
my_ndk_stl_link_type := none
endif
# The system STL is only the C++ ABI layer, so it's compatible with any STL.
my_allowed_ndk_types += native:ndk:system:shared
my_allowed_ndk_types += native:ndk:system:none
# Libaries that don't use the STL can be linked to anything.
my_allowed_ndk_types += native:ndk:none:none
# And it's always okay to link a static library that uses your own STL type.
# Since nothing was actually linked for the static library, it is up to the
# first linked library in the dependency chain which gets used.
my_allowed_ndk_types += native:ndk:$(my_ndk_stl_family):none
ifeq ($(LOCAL_MODULE_CLASS),APPS)
# For an app package, it's actually okay to depend on any set of STLs.
# If any of the individual libraries depend on each other they've
# already been checked for consistency, and if they don't they'll be
# kept isolated by RTLD_LOCAL anyway.
my_allowed_ndk_types += \
native:ndk:libc++:shared native:ndk:libc++:static
# The "none" link type that used by static libraries is intentionally
# omitted here. We should only be dealing with shared libraries in
# LOCAL_JNI_SHARED_LIBRARIES.
else ifeq ($(my_ndk_stl_link_type),shared)
# Modules linked to a shared STL can only use another shared STL.
my_allowed_ndk_types += native:ndk:$(my_ndk_stl_family):shared
endif
# Else we are a non-static library that uses a static STL, and are
# incompatible with all other shared libraries that use an STL.
else
my_allowed_ndk_types := \
native:ndk:none:none \
native:ndk:system:none \
native:ndk:system:shared \
ifeq ($(LOCAL_MODULE_CLASS),APPS)
# CTS is bad and it should feel bad: http://b/13249737
my_warn_ndk_types += native:ndk:libc++:static
endif
endif
================================================
FILE: core/android_manifest.mk
================================================
# Handle AndroidManifest.xmls
# Input: LOCAL_MANIFEST_FILE, LOCAL_FULL_MANIFEST_FILE, LOCAL_FULL_LIBS_MANIFEST_FILES,
# LOCAL_USE_EMBEDDED_NATIVE_LIBS
# Output: full_android_manifest
ifeq ($(strip $(LOCAL_MANIFEST_FILE)),)
LOCAL_MANIFEST_FILE := AndroidManifest.xml
endif
ifdef LOCAL_FULL_MANIFEST_FILE
main_android_manifest := $(LOCAL_FULL_MANIFEST_FILE)
else
main_android_manifest := $(LOCAL_PATH)/$(LOCAL_MANIFEST_FILE)
endif
LOCAL_STATIC_JAVA_AAR_LIBRARIES := $(strip $(LOCAL_STATIC_JAVA_AAR_LIBRARIES))
my_full_libs_manifest_files :=
ifndef LOCAL_DONT_MERGE_MANIFESTS
my_full_libs_manifest_files += $(LOCAL_FULL_LIBS_MANIFEST_FILES)
my_full_libs_manifest_files += $(foreach lib, $(LOCAL_STATIC_JAVA_AAR_LIBRARIES) $(LOCAL_STATIC_ANDROID_LIBRARIES),\
$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/manifest/AndroidManifest.xml)
endif
full_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml
ifneq (,$(strip $(my_full_libs_manifest_files)))
# Set up rules to merge library manifest files
fixed_android_manifest := $(intermediates.COMMON)/manifest/AndroidManifest.xml.fixed
$(full_android_manifest): PRIVATE_LIBS_MANIFESTS := $(my_full_libs_manifest_files)
$(full_android_manifest): $(ANDROID_MANIFEST_MERGER)
$(full_android_manifest) : $(fixed_android_manifest) $(my_full_libs_manifest_files)
@echo "Merge android manifest files: $@ <-- $< $(PRIVATE_LIBS_MANIFESTS)"
@mkdir -p $(dir $@)
$(hide) $(ANDROID_MANIFEST_MERGER) --main $< \
--libs $(call normalize-path-list,$(PRIVATE_LIBS_MANIFESTS)) \
--out $@
else
fixed_android_manifest := $(full_android_manifest)
endif
my_target_sdk_version := $(call module-target-sdk-version)
my_min_sdk_version := $(call module-min-sdk-version)
ifdef TARGET_BUILD_APPS
ifndef TARGET_BUILD_USE_PREBUILT_SDKS
ifeq ($(my_target_sdk_version),$(PLATFORM_VERSION_CODENAME))
ifdef UNBUNDLED_BUILD_TARGET_SDK_WITH_API_FINGERPRINT
my_target_sdk_version := $(my_target_sdk_version).$$(cat $(API_FINGERPRINT))
my_min_sdk_version := $(my_min_sdk_version).$$(cat $(API_FINGERPRINT))
$(fixed_android_manifest): $(API_FINGERPRINT)
else ifdef UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA
my_target_sdk_version := $(UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA)
my_min_sdk_version := $(UNBUNDLED_BUILD_TARGET_SDK_WITH_DESSERT_SHA)
endif
endif
endif
endif
$(fixed_android_manifest): PRIVATE_MIN_SDK_VERSION := $(my_min_sdk_version)
$(fixed_android_manifest): PRIVATE_TARGET_SDK_VERSION := $(my_target_sdk_version)
my_exported_sdk_libs_file := $(call local-intermediates-dir,COMMON)/exported-sdk-libs
$(fixed_android_manifest): PRIVATE_EXPORTED_SDK_LIBS_FILE := $(my_exported_sdk_libs_file)
$(fixed_android_manifest): $(my_exported_sdk_libs_file)
my_manifest_fixer_flags :=
ifneq ($(LOCAL_MODULE_CLASS),APPS)
my_manifest_fixer_flags += --library
endif
ifeq ($(LOCAL_PRIVATE_PLATFORM_APIS),true)
my_manifest_fixer_flags += --uses-non-sdk-api
endif
ifeq (true,$(LOCAL_USE_EMBEDDED_DEX))
my_manifest_fixer_flags += --use-embedded-dex
endif
ifeq ($(LOCAL_MODULE_CLASS),APPS)
ifeq (true,$(call math_gt_or_eq,$(patsubst $(PLATFORM_VERSION_CODENAME),100,$(call module-min-sdk-version)),23))
ifeq (true,$(LOCAL_USE_EMBEDDED_NATIVE_LIBS))
my_manifest_fixer_flags += --extract-native-libs=false
else
my_manifest_fixer_flags += --extract-native-libs=true
endif
else ifeq (true,$(LOCAL_USE_EMBEDDED_NATIVE_LIBS))
$(call pretty-error,LOCAL_USE_EMBEDDED_NATIVE_LIBS is set but minSdkVersion $(call module-min-sdk-version) does not support it)
endif
endif
# TODO: Replace this hardcoded list of optional uses-libraries with build logic
# that propagates optionality via the generated exported-sdk-libs files.
# Hardcodng doesn't scale and enforces a single choice on each library, while in
# reality this is a choice of the library users (which may differ).
my_optional_sdk_lib_names := \
android.test.base \
android.test.mock \
androidx.window.extensions \
androidx.window.sidecar
$(fixed_android_manifest): PRIVATE_MANIFEST_FIXER_FLAGS := $(my_manifest_fixer_flags)
# These two libs are added as optional dependencies ( with
# android:required set to false). This is because they haven't existed in pre-P
# devices, but classes in them were in bootclasspath jars, etc. So making them
# hard dependencies (andriod:required=true) would prevent apps from being
# installed to such legacy devices.
$(fixed_android_manifest): PRIVATE_OPTIONAL_SDK_LIB_NAMES := $(my_optional_sdk_lib_names)
$(fixed_android_manifest): $(MANIFEST_FIXER)
$(fixed_android_manifest): $(main_android_manifest)
echo $(PRIVATE_OPTIONAL_SDK_LIB_NAMES) | tr ' ' '\n' > $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional
@echo "Fix manifest: $@"
$(MANIFEST_FIXER) \
--minSdkVersion $(PRIVATE_MIN_SDK_VERSION) \
--targetSdkVersion $(PRIVATE_TARGET_SDK_VERSION) \
--raise-min-sdk-version \
$(PRIVATE_MANIFEST_FIXER_FLAGS) \
$(if (PRIVATE_EXPORTED_SDK_LIBS_FILE),\
$$(cat $(PRIVATE_EXPORTED_SDK_LIBS_FILE) | grep -v -f $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional | sort -u | sed -e 's/^/\ --uses-library\ /' | tr '\n' ' ') \
$$(cat $(PRIVATE_EXPORTED_SDK_LIBS_FILE) | grep -f $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional | sort -u | sed -e 's/^/\ --optional-uses-library\ /' | tr '\n' ' ') \
) \
$< $@
rm $(PRIVATE_EXPORTED_SDK_LIBS_FILE).optional
my_optional_sdk_lib_names :=
================================================
FILE: core/android_soong_config_vars.mk
================================================
# Copyright (C) 2020 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.
# This file defines the Soong Config Variable namespace ANDROID, and also any
# variables in that namespace.
# The expectation is that no vendor should be using the ANDROID namespace. This
# check ensures that we don't collide with any existing vendor usage.
ifdef SOONG_CONFIG_ANDROID
$(error The Soong config namespace ANDROID is reserved.)
endif
$(call add_soong_config_namespace,ANDROID)
# Add variables to the namespace below:
$(call add_soong_config_var,ANDROID,BOARD_USES_ODMIMAGE)
$(call soong_config_set_bool,ANDROID,BOARD_USES_RECOVERY_AS_BOOT,$(BOARD_USES_RECOVERY_AS_BOOT))
$(call soong_config_set_bool,ANDROID,BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT,$(BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT))
$(call add_soong_config_var,ANDROID,CHECK_DEV_TYPE_VIOLATIONS)
$(call soong_config_set_bool,ANDROID,HAS_BOARD_SYSTEM_EXT_PREBUILT_DIR,$(if $(BOARD_SYSTEM_EXT_PREBUILT_DIR),true,false))
$(call soong_config_set_bool,ANDROID,HAS_BOARD_PRODUCT_PREBUILT_DIR,$(if $(BOARD_PRODUCT_PREBUILT_DIR),true,false))
$(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_VERSION)
$(call add_soong_config_var,ANDROID,PLATFORM_SEPOLICY_COMPAT_VERSIONS)
$(call add_soong_config_var,ANDROID,PRODUCT_INSTALL_DEBUG_POLICY_TO_SYSTEM_EXT)
$(call soong_config_set_bool,ANDROID,RELEASE_BOARD_API_LEVEL_FROZEN,$(RELEASE_BOARD_API_LEVEL_FROZEN))
$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_DRMSERVER)
$(call add_soong_config_var,ANDROID,TARGET_ENABLE_MEDIADRM_64)
$(call add_soong_config_var,ANDROID,TARGET_DYNAMIC_64_32_MEDIASERVER)
$(call soong_config_set_bool,ANDROID,TARGET_SUPPORTS_32_BIT_APPS,$(if $(filter true,$(TARGET_SUPPORTS_32_BIT_APPS)),true,false))
$(call soong_config_set_bool,ANDROID,TARGET_SUPPORTS_64_BIT_APPS,$(if $(filter true,$(TARGET_SUPPORTS_64_BIT_APPS)),true,false))
$(call add_soong_config_var,ANDROID,BOARD_GENFS_LABELS_VERSION)
$(call soong_config_set_bool,ANDROID,PRODUCT_FSVERITY_GENERATE_METADATA,$(if $(filter true,$(PRODUCT_FSVERITY_GENERATE_METADATA)),true,false))
$(call add_soong_config_var,ANDROID,ADDITIONAL_M4DEFS,$(if $(BOARD_SEPOLICY_M4DEFS),$(addprefix -D,$(BOARD_SEPOLICY_M4DEFS))))
$(call add_soong_config_var,ANDROID,TARGET_ADD_ROOT_EXTRA_VENDOR_SYMLINKS)
# For BUILDING_GSI
$(call soong_config_set_bool,gsi,building_gsi,$(if $(filter true,$(BUILDING_GSI)),true,false))
# For bootable/recovery
RECOVERY_API_VERSION := 3
RECOVERY_FSTAB_VERSION := 2
$(call soong_config_set, recovery, recovery_api_version, $(RECOVERY_API_VERSION))
$(call soong_config_set, recovery, recovery_fstab_version, $(RECOVERY_FSTAB_VERSION))
$(call soong_config_set_bool, recovery ,target_userimages_use_f2fs ,$(if $(TARGET_USERIMAGES_USE_F2FS),true,false))
$(call soong_config_set_bool, recovery ,has_board_cacheimage_partition_size ,$(if $(BOARD_CACHEIMAGE_PARTITION_SIZE),true,false))
ifdef TARGET_RECOVERY_UI_LIB
$(call soong_config_set_string_list, recovery, target_recovery_ui_lib, $(TARGET_RECOVERY_UI_LIB))
endif
# For Sanitizers
$(call soong_config_set_bool,ANDROID,ASAN_ENABLED,$(if $(filter address,$(SANITIZE_TARGET)),true,false))
$(call soong_config_set_bool,ANDROID,HWASAN_ENABLED,$(if $(filter hwaddress,$(SANITIZE_TARGET)),true,false))
$(call soong_config_set_bool,ANDROID,SANITIZE_TARGET_SYSTEM_ENABLED,$(if $(filter true,$(SANITIZE_TARGET_SYSTEM)),true,false))
# For init.environ.rc
$(call soong_config_set_bool,ANDROID,GCOV_COVERAGE,$(NATIVE_COVERAGE))
$(call soong_config_set_bool,ANDROID,CLANG_COVERAGE,$(CLANG_COVERAGE))
$(call soong_config_set,ANDROID,SCUDO_ALLOCATION_RING_BUFFER_SIZE,$(PRODUCT_SCUDO_ALLOCATION_RING_BUFFER_SIZE))
$(call soong_config_set_bool,ANDROID,EMMA_INSTRUMENT,$(if $(filter true,$(EMMA_INSTRUMENT)),true,false))
# PRODUCT_PRECOMPILED_SEPOLICY defaults to true. Explicitly check if it's "false" or not.
$(call soong_config_set_bool,ANDROID,PRODUCT_PRECOMPILED_SEPOLICY,$(if $(filter false,$(PRODUCT_PRECOMPILED_SEPOLICY)),false,true))
# For art modules
$(call soong_config_set_bool,art_module,host_prefer_32_bit,$(if $(filter true,$(HOST_PREFER_32_BIT)),true,false))
ifdef ART_DEBUG_OPT_FLAG
$(call soong_config_set,art_module,art_debug_opt_flag,$(ART_DEBUG_OPT_FLAG))
endif
# The default value of ART_BUILD_HOST_DEBUG is true
$(call soong_config_set_bool,art_module,art_build_host_debug,$(if $(filter false,$(ART_BUILD_HOST_DEBUG)),false,true))
# For chre
$(call soong_config_set_bool,chre,chre_daemon_lpma_enabled,$(if $(filter true,$(CHRE_DAEMON_LPMA_ENABLED)),true,false))
$(call soong_config_set_bool,chre,chre_dedicated_transport_channel_enabled,$(if $(filter true,$(CHRE_DEDICATED_TRANSPORT_CHANNEL_ENABLED)),true,false))
$(call soong_config_set_bool,chre,chre_log_atom_extension_enabled,$(if $(filter true,$(CHRE_LOG_ATOM_EXTENSION_ENABLED)),true,false))
$(call soong_config_set_bool,chre,building_vendor_image,$(if $(filter true,$(BUILDING_VENDOR_IMAGE)),true,false))
$(call soong_config_set_bool,chre,chre_usf_daemon_enabled,$(if $(filter true,$(CHRE_USF_DAEMON_ENABLED)),true,false))
ifdef TARGET_BOARD_AUTO
$(call add_soong_config_var_value, ANDROID, target_board_auto, $(TARGET_BOARD_AUTO))
endif
# Apex build mode variables
ifdef APEX_BUILD_FOR_PRE_S_DEVICES
$(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static)
else
ifdef KEEP_APEX_INHERIT
$(call add_soong_config_var_value,ANDROID,library_linking_strategy,prefer_static)
endif
endif
# Enable SystemUI optimizations by default unless explicitly set.
SYSTEMUI_OPTIMIZE_JAVA ?= true
$(call add_soong_config_var,ANDROID,SYSTEMUI_OPTIMIZE_JAVA)
# Flag to use baseline profile for SystemUI.
$(call soong_config_set,ANDROID,release_systemui_use_speed_profile,$(RELEASE_SYSTEMUI_USE_SPEED_PROFILE))
# Flag for enabling compose for Launcher.
$(call soong_config_set,ANDROID,release_enable_compose_in_launcher,$(RELEASE_ENABLE_COMPOSE_IN_LAUNCHER))
ifdef PRODUCT_AVF_ENABLED
$(call add_soong_config_var_value,ANDROID,avf_enabled,$(PRODUCT_AVF_ENABLED))
endif
# Enable AVF remote attestation according to the flag value if PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED is not
# set to true explicitly.
ifneq (true,$(PRODUCT_AVF_REMOTE_ATTESTATION_DISABLED))
$(call add_soong_config_var_value,ANDROID,avf_remote_attestation_enabled,$(RELEASE_AVF_ENABLE_REMOTE_ATTESTATION))
endif
ifdef PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION
$(call add_soong_config_var_value,ANDROID,avf_microdroid_guest_gki_version,$(PRODUCT_AVF_MICRODROID_GUEST_GKI_VERSION))
endif
ifdef TARGET_BOOTS_16K
$(call soong_config_set_bool,ANDROID,target_boots_16k,$(filter true,$(TARGET_BOOTS_16K)))
endif
ifdef PRODUCT_CGROUP_V2_SYS_APP_ISOLATION_ENABLED
$(call add_soong_config_var_value,ANDROID,cgroup_v2_sys_app_isolation,$(PRODUCT_CGROUP_V2_SYS_APP_ISOLATION_ENABLED))
else
$(call add_soong_config_var_value,ANDROID,cgroup_v2_sys_app_isolation,true)
endif
$(call add_soong_config_var_value,ANDROID,release_avf_allow_preinstalled_apps,$(RELEASE_AVF_ALLOW_PREINSTALLED_APPS))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_device_assignment,$(RELEASE_AVF_ENABLE_DEVICE_ASSIGNMENT))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_dice_changes,$(RELEASE_AVF_ENABLE_DICE_CHANGES))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_early_vm,$(RELEASE_AVF_ENABLE_EARLY_VM))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_llpvm_changes,$(RELEASE_AVF_ENABLE_LLPVM_CHANGES))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_multi_tenant_microdroid_vm,$(RELEASE_AVF_ENABLE_MULTI_TENANT_MICRODROID_VM))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_network,$(RELEASE_AVF_ENABLE_NETWORK))
# TODO(b/341292601): This flag is needed until the V release. We with clean it up after V together
# with most of the release_avf_ flags here.
$(call add_soong_config_var_value,ANDROID,release_avf_enable_remote_attestation,$(RELEASE_AVF_ENABLE_REMOTE_ATTESTATION))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_vendor_modules,$(RELEASE_AVF_ENABLE_VENDOR_MODULES))
$(call add_soong_config_var_value,ANDROID,release_avf_enable_virt_cpufreq,$(RELEASE_AVF_ENABLE_VIRT_CPUFREQ))
$(call add_soong_config_var_value,ANDROID,release_avf_microdroid_kernel_version,$(RELEASE_AVF_MICRODROID_KERNEL_VERSION))
$(call add_soong_config_var_value,ANDROID,release_avf_support_custom_vm_with_paravirtualized_devices,$(RELEASE_AVF_SUPPORT_CUSTOM_VM_WITH_PARAVIRTUALIZED_DEVICES))
$(call add_soong_config_var_value,ANDROID,release_binder_death_recipient_weak_from_jni,$(RELEASE_BINDER_DEATH_RECIPIENT_WEAK_FROM_JNI))
$(call add_soong_config_var_value,ANDROID,release_libpower_no_lock_binder_txn,$(RELEASE_LIBPOWER_NO_LOCK_BINDER_TXN))
$(call add_soong_config_var_value,ANDROID,release_package_libandroid_runtime_punch_holes,$(RELEASE_PACKAGE_LIBANDROID_RUNTIME_PUNCH_HOLES))
$(call add_soong_config_var_value,ANDROID,release_selinux_data_data_ignore,$(RELEASE_SELINUX_DATA_DATA_IGNORE))
ifneq (,$(filter eng userdebug,$(TARGET_BUILD_VARIANT)))
# write appcompat system properties on userdebug and eng builds
$(call add_soong_config_var_value,ANDROID,release_write_appcompat_override_system_properties,true)
endif
# Enable system_server optimizations by default unless explicitly set or if
# there may be dependent runtime jars.
# TODO(b/240588226): Remove the off-by-default exceptions after handling
# system_server jars automatically w/ R8.
ifeq (true,$(PRODUCT_BROKEN_SUBOPTIMAL_ORDER_OF_SYSTEM_SERVER_JARS))
# If system_server jar ordering is broken, don't assume services.jar can be
# safely optimized in isolation, as there may be dependent jars.
SYSTEM_OPTIMIZE_JAVA ?= false
else ifneq (platform:services,$(lastword $(PRODUCT_SYSTEM_SERVER_JARS)))
# If services is not the final jar in the dependency ordering, don't assume
# it can be safely optimized in isolation, as there may be dependent jars.
# TODO(b/212737576): Remove this exception after integrating use of `$(system_server_trace_refs)`.
SYSTEM_OPTIMIZE_JAVA ?= false
else
SYSTEM_OPTIMIZE_JAVA ?= true
endif
ifeq (true,$(FULL_SYSTEM_OPTIMIZE_JAVA))
SYSTEM_OPTIMIZE_JAVA := true
endif
$(call add_soong_config_var,ANDROID,SYSTEM_OPTIMIZE_JAVA)
$(call add_soong_config_var,ANDROID,FULL_SYSTEM_OPTIMIZE_JAVA)
ifeq (true, $(SYSTEM_OPTIMIZE_JAVA))
# Create a list of (non-prefixed) system server jars that follow `services` in
# the classpath. This can be used when optimizing `services` to trace any
# downstream references that need keeping.
# Example: "foo:service1 platform:services bar:services2" -> "services2"
system_server_jars_dependent_on_services := $(shell \
echo "$(PRODUCT_SYSTEM_SERVER_JARS)" | \
awk '{found=0; for(i=1;i<=NF;i++){if($$i=="platform:services"){found=1; continue} if(found){split($$i,a,":"); print a[2]}}}' | \
xargs)
ifneq ($(strip $(system_server_jars_dependent_on_services)),)
$(call soong_config_set_string_list,ANDROID,system_server_trace_refs,$(system_server_jars_dependent_on_services))
endif
endif
# TODO(b/319697968): Remove this build flag support when metalava fully supports flagged api
$(call soong_config_set,ANDROID,release_hidden_api_exportable_stubs,$(RELEASE_HIDDEN_API_EXPORTABLE_STUBS))
# Check for SupplementalApi module.
ifeq ($(wildcard packages/modules/SupplementalApi),)
$(call add_soong_config_var_value,ANDROID,include_nonpublic_framework_api,false)
else
$(call add_soong_config_var_value,ANDROID,include_nonpublic_framework_api,true)
endif
# Add nfc build flag to soong
ifneq ($(RELEASE_PACKAGE_NFC_STACK),NfcNci)
$(call soong_config_set,bootclasspath,nfc_apex_bootclasspath_fragment,true)
endif
# Add uwb build flag to soong
$(call soong_config_set,bootclasspath,release_ranging_stack,$(RELEASE_RANGING_STACK))
# Add crashrecovery build flag to soong
$(call soong_config_set,ANDROID,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
# Add crashrecovery file move flags to soong, for both platform and module
ifeq (true,$(RELEASE_CRASHRECOVERY_FILE_MOVE))
$(call soong_config_set,ANDROID,crashrecovery_files_in_module,true)
$(call soong_config_set,ANDROID,crashrecovery_files_in_platform,false)
else
$(call soong_config_set,ANDROID,crashrecovery_files_in_module,false)
$(call soong_config_set,ANDROID,crashrecovery_files_in_platform,true)
endif
# Required as platform_bootclasspath is using this namespace
$(call soong_config_set,bootclasspath,release_crashrecovery_module,$(RELEASE_CRASHRECOVERY_MODULE))
# Add ondeviceintelligence module build flag to soong
ifeq (true,$(RELEASE_ONDEVICE_INTELLIGENCE_MODULE))
$(call soong_config_set,ANDROID,release_ondevice_intelligence_module,true)
# Required as platform_bootclasspath is using this namespace
$(call soong_config_set,bootclasspath,release_ondevice_intelligence_module,true)
else
$(call soong_config_set,ANDROID,release_ondevice_intelligence_platform,true)
$(call soong_config_set,bootclasspath,release_ondevice_intelligence_platform,true)
endif
# Add uprobestats build flag to soong
$(call soong_config_set,ANDROID,release_uprobestats_module,$(RELEASE_UPROBESTATS_MODULE))
# Add uprobestats file move flags to soong, for both platform and module
ifeq (true,$(RELEASE_UPROBESTATS_FILE_MOVE))
$(call soong_config_set,ANDROID,uprobestats_files_in_module,true)
$(call soong_config_set,ANDROID,uprobestats_files_in_platform,false)
else
$(call soong_config_set,ANDROID,uprobestats_files_in_module,false)
$(call soong_config_set,ANDROID,uprobestats_files_in_platform,true)
endif
# Enable Profiling module. Also used by platform_bootclasspath.
$(call soong_config_set,ANDROID,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
$(call soong_config_set,bootclasspath,release_package_profiling_module,$(RELEASE_PACKAGE_PROFILING_MODULE))
# Move VCN from platform to the Tethering module; used by both platform and module
$(call soong_config_set,ANDROID,is_vcn_in_mainline,$(RELEASE_MOVE_VCN_TO_MAINLINE))
# Add perf-setup build flag to soong
# Note: BOARD_PERFSETUP_SCRIPT location must be under platform_testing/scripts/perf-setup/.
ifdef BOARD_PERFSETUP_SCRIPT
$(call soong_config_set,perf,board_perfsetup_script,$(notdir $(BOARD_PERFSETUP_SCRIPT)))
endif
# Add target_use_pan_display flag for hardware/libhardware:gralloc.default
$(call soong_config_set_bool,gralloc,target_use_pan_display,$(if $(filter true,$(TARGET_USE_PAN_DISPLAY)),true,false))
# Add use_camera_v4l2_hal flag for hardware/libhardware/modules/camera/3_4:camera.v4l2
$(call soong_config_set_bool,camera,use_camera_v4l2_hal,$(if $(filter true,$(USE_CAMERA_V4L2_HAL)),true,false))
# Add audioserver_multilib flag for hardware/interfaces/soundtrigger/2.0/default:android.hardware.soundtrigger@2.0-impl
ifneq ($(strip $(AUDIOSERVER_MULTILIB)),)
$(call soong_config_set,soundtrigger,audioserver_multilib,$(AUDIOSERVER_MULTILIB))
endif
# Add sim_count, disable_rild_oem_hook, and use_aosp_rild flag for ril related modules
$(call soong_config_set,ril,sim_count,$(SIM_COUNT))
ifneq ($(DISABLE_RILD_OEM_HOOK), false)
$(call soong_config_set_bool,ril,disable_rild_oem_hook,true)
endif
ifneq ($(ENABLE_VENDOR_RIL_SERVICE), true)
$(call soong_config_set_bool,ril,use_aosp_rild,true)
endif
# Export target_board_platform to soong for hardware/google/graphics/common/libmemtrack:memtrack.$(TARGET_BOARD_PLATFORM)
$(call soong_config_set,ANDROID,target_board_platform,$(TARGET_BOARD_PLATFORM))
# Export board_uses_scaler_m2m1shot and board_uses_align_restriction to soong for hardware/google/graphics/common/libscaler:libexynosscaler
$(call soong_config_set_bool,google_graphics,board_uses_scaler_m2m1shot,$(if $(filter true,$(BOARD_USES_SCALER_M2M1SHOT)),true,false))
$(call soong_config_set_bool,google_graphics,board_uses_align_restriction,$(if $(filter true,$(BOARD_USES_ALIGN_RESTRICTION)),true,false))
# Export related variables to soong for hardware/google/graphics/common/libacryl:libacryl
ifdef BOARD_LIBACRYL_DEFAULT_COMPOSITOR
$(call soong_config_set,acryl,libacryl_default_compositor,$(BOARD_LIBACRYL_DEFAULT_COMPOSITOR))
endif
ifdef BOARD_LIBACRYL_DEFAULT_SCALER
$(call soong_config_set,acryl,libacryl_default_scaler,$(BOARD_LIBACRYL_DEFAULT_SCALER))
endif
ifdef BOARD_LIBACRYL_DEFAULT_BLTER
$(call soong_config_set,acryl,libacryl_default_blter,$(BOARD_LIBACRYL_DEFAULT_BLTER))
endif
ifdef BOARD_LIBACRYL_G2D_HDR_PLUGIN
#BOARD_LIBACRYL_G2D_HDR_PLUGIN is set in each board config
$(call soong_config_set_bool,acryl,libacryl_use_g2d_hdr_plugin,true)
endif
# Export related variables to soong for hardware/google/graphics/common/BoardConfigCFlags.mk
$(call soong_config_set_bool,google_graphics,hwc_no_support_skip_validate,$(if $(filter true,$(HWC_NO_SUPPORT_SKIP_VALIDATE)),true,false))
$(call soong_config_set_bool,google_graphics,hwc_support_color_transform,$(if $(filter true,$(HWC_SUPPORT_COLOR_TRANSFORM)),true,false))
$(call soong_config_set_bool,google_graphics,hwc_support_render_intent,$(if $(filter true,$(HWC_SUPPORT_RENDER_INTENT)),true,false))
$(call soong_config_set_bool,google_graphics,board_uses_virtual_display,$(if $(filter true,$(BOARD_USES_VIRTUAL_DISPLAY)),true,false))
$(call soong_config_set_bool,google_graphics,board_uses_dt,$(if $(filter true,$(BOARD_USES_DT)),true,false))
$(call soong_config_set_bool,google_graphics,board_uses_decon_64bit_address,$(if $(filter true,$(BOARD_USES_DECON_64BIT_ADDRESS)),true,false))
$(call soong_config_set_bool,google_graphics,board_uses_hdrui_gles_conversion,$(if $(filter true,$(BOARD_USES_HDRUI_GLES_CONVERSION)),true,false))
$(call soong_config_set_bool,google_graphics,uses_idisplay_intf_sec,$(if $(filter true,$(USES_IDISPLAY_INTF_SEC)),true,false))
# Variables for fs_config
$(call soong_config_set_bool,fs_config,vendor,$(if $(BOARD_USES_VENDORIMAGE)$(BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE),true,false))
$(call soong_config_set_bool,fs_config,oem,$(if $(BOARD_USES_OEMIMAGE)$(BOARD_OEMIMAGE_FILE_SYSTEM_TYPE),true,false))
$(call soong_config_set_bool,fs_config,odm,$(if $(BOARD_USES_ODMIMAGE)$(BOARD_ODMIMAGE_FILE_SYSTEM_TYPE),true,false))
$(call soong_config_set_bool,fs_config,vendor_dlkm,$(if $(BOARD_USES_VENDOR_DLKMIMAGE)$(BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE),true,false))
$(call soong_config_set_bool,fs_config,odm_dlkm,$(if $(BOARD_USES_ODM_DLKMIMAGE)$(BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE),true,false))
$(call soong_config_set_bool,fs_config,system_dlkm,$(if $(BOARD_USES_SYSTEM_DLKMIMAGE)$(BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE),true,false))
# Variables for telephony
$(call soong_config_set_bool,telephony,sec_cp_secure_boot,$(if $(filter true,$(SEC_CP_SECURE_BOOT)),true,false))
$(call soong_config_set_bool,telephony,cbd_protocol_sit,$(if $(filter true,$(CBD_PROTOCOL_SIT)),true,false))
$(call soong_config_set_bool,telephony,use_radioexternal_hal_aidl,$(if $(filter true,$(USE_RADIOEXTERNAL_HAL_AIDL)),true,false))
# Variables for hwcomposer.$(TARGET_BOARD_PLATFORM)
$(call soong_config_set_bool,google_graphics,board_uses_hwc_services,$(if $(filter true,$(BOARD_USES_HWC_SERVICES)),true,false))
# Variables for controlling android.hardware.composer.hwc3-service.pixel
$(call soong_config_set,google_graphics,board_hwc_version,$(BOARD_HWC_VERSION))
# Flag ExcludeExtractApk is to support "extract_apk" property for the following conditions.
ifneq ($(WITH_DEXPREOPT),true)
$(call soong_config_set_bool,PrebuiltGmsCore,ExcludeExtractApk,true)
endif
ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
$(call soong_config_set_bool,PrebuiltGmsCore,ExcludeExtractApk,true)
endif
ifeq ($(WITH_DEXPREOPT_BOOT_IMG_AND_SYSTEM_SERVER_ONLY),true)
$(call soong_config_set_bool,PrebuiltGmsCore,ExcludeExtractApk,true)
endif
# Variables for extra branches
# TODO(b/383238397): Use bootstrap_go_package to enable extra flags.
-include vendor/google/build/extra_soong_config_vars.mk
# Variable for CI test packages
ifneq ($(filter arm x86 true,$(TARGET_ARCH) $(TARGET_2ND_ARCH) $(TARGET_ENABLE_MEDIADRM_64)),)
$(call soong_config_set_bool,ci_tests,uses_widevine_tests, true)
endif
# Flags used in GTVS prebuilt apps
$(call soong_config_set_bool,GTVS,GTVS_COMPRESSED_PREBUILTS,$(if $(findstring $(GTVS_COMPRESSED_PREBUILTS),true yes),true,false))
$(call soong_config_set_bool,GTVS,GTVS_GMSCORE_BETA,$(if $(findstring $(GTVS_GMSCORE_BETA),true yes),true,false))
$(call soong_config_set_bool,GTVS,GTVS_SETUPWRAITH_BETA,$(if $(findstring $(GTVS_SETUPWRAITH_BETA),true yes),true,false))
$(call soong_config_set_bool,GTVS,PRODUCT_USE_PREBUILT_GTVS,$(if $(findstring $(PRODUCT_USE_PREBUILT_GTVS),true yes),true,false))
# Flags used in GTVS_GTV prebuilt apps
$(call soong_config_set_bool,GTVS_GTV,PRODUCT_USE_PREBUILT_GTVS_GTV,$(if $(findstring $(PRODUCT_USE_PREBUILT_GTVS_GTV),true yes),true,false))
# Check modules to be built in "otatools-package".
ifneq ($(wildcard vendor/google/tools/build_mixed_kernels_ramdisk),)
$(call soong_config_set_bool,otatools,use_build_mixed_kernels_ramdisk,true)
endif
ifneq ($(wildcard bootable/deprecated-ota/applypatch),)
$(call soong_config_set_bool,otatools,use_bootable_deprecated_ota_applypatch,true)
endif
================================================
FILE: core/app_certificate_validate.mk
================================================
ifeq (true,$(non_system_module))
ifneq (,$(filter $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))%,$(LOCAL_CERTIFICATE)))
CERTIFICATE_VIOLATION_MODULES += $(LOCAL_MODULE)
ifeq (true,$(PRODUCT_ENFORCE_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT))
$(if $(filter $(LOCAL_MODULE),$(PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST)),,\
$(call pretty-error,The module in product partition cannot be signed with certificate in system.))
endif
endif
endif
================================================
FILE: core/app_prebuilt_internal.mk
================================================
#
# Copyright (C) 2019 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.
#
############################################################
# Internal build rules for APPS prebuilt modules
############################################################
ifneq (APPS,$(LOCAL_MODULE_CLASS))
$(call pretty-error,app_prebuilt_internal.mk is for APPS modules only)
endif
ifdef LOCAL_COMPRESSED_MODULE
ifneq (true,$(LOCAL_COMPRESSED_MODULE))
$(call pretty-error, Unknown value for LOCAL_COMPRESSED_MODULE $(LOCAL_COMPRESSED_MODULE))
endif
LOCAL_BUILT_MODULE_STEM := package.apk.gz
ifndef LOCAL_INSTALLED_MODULE_STEM
PACKAGES.$(LOCAL_MODULE).COMPRESSED := gz
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk.gz
endif
else # LOCAL_COMPRESSED_MODULE
LOCAL_BUILT_MODULE_STEM := package.apk
ifndef LOCAL_INSTALLED_MODULE_STEM
LOCAL_INSTALLED_MODULE_STEM := $(LOCAL_MODULE).apk
endif
endif # LOCAL_COMPRESSED_MODULE
include $(BUILD_SYSTEM)/base_rules.mk
built_module := $(LOCAL_BUILT_MODULE)
# Run veridex on product, system_ext and vendor modules.
# We skip it for unbundled app builds where we cannot build veridex.
module_run_appcompat :=
ifeq (true,$(non_system_module))
ifeq (,$(TARGET_BUILD_APPS)) # ! unbundled app build
ifneq ($(UNSAFE_DISABLE_HIDDENAPI_FLAGS),true)
module_run_appcompat := true
endif
endif
endif
PACKAGES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_PACKAGES))
my_extract_apk := $(strip $(LOCAL_EXTRACT_APK))
# Select dpi-specific source
ifdef LOCAL_DPI_VARIANTS
my_dpi := $(firstword $(filter $(LOCAL_DPI_VARIANTS),$(PRODUCT_AAPT_PREF_CONFIG) $(PRODUCT_AAPT_PREBUILT_DPI)))
ifdef my_dpi
ifdef LOCAL_DPI_FILE_STEM
my_prebuilt_dpi_file_stem := $(LOCAL_DPI_FILE_STEM)
else
my_prebuilt_dpi_file_stem := $(LOCAL_MODULE)_%.apk
endif
my_prebuilt_src_file := $(dir $(my_prebuilt_src_file))$(subst %,$(my_dpi),$(my_prebuilt_dpi_file_stem))
ifneq ($(strip $(LOCAL_EXTRACT_DPI_APK)),)
my_extract_apk := $(subst %,$(my_dpi),$(LOCAL_EXTRACT_DPI_APK))
endif # LOCAL_EXTRACT_DPI_APK
endif # my_dpi
endif # LOCAL_DPI_VARIANTS
ifdef my_extract_apk
my_extracted_apk := $(intermediates)/extracted.apk
$(my_extracted_apk): PRIVATE_EXTRACT := $(my_extract_apk)
$(my_extracted_apk): $(my_prebuilt_src_file)
@echo Extract APK: $@
$(hide) mkdir -p $(dir $@) && rm -f $@
$(hide) unzip -p $< $(PRIVATE_EXTRACT) >$@
my_prebuilt_src_file := $(my_extracted_apk)
my_extracted_apk :=
my_extract_apk :=
endif
rs_compatibility_jni_libs :=
include $(BUILD_SYSTEM)/install_jni_libs.mk
ifeq ($(LOCAL_CERTIFICATE),EXTERNAL)
# The magic string "EXTERNAL" means this package will be signed with
# the default dev key throughout the build process, but we expect
# the final package to be signed with a different key.
#
# This can be used for packages where we don't have access to the
# keys, but want the package to be predexopt'ed.
LOCAL_CERTIFICATE := $(DEFAULT_SYSTEM_DEV_CERTIFICATE)
PACKAGES.$(LOCAL_MODULE).EXTERNAL_KEY := 1
$(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
$(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
$(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
endif
ifeq ($(LOCAL_CERTIFICATE),)
# It is now a build error to add a prebuilt .apk without
# specifying a key for it.
$(error No LOCAL_CERTIFICATE specified for prebuilt "$(my_prebuilt_src_file)")
else ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
# The magic string "PRESIGNED" means this package is already checked
# signed with its release key.
#
# By setting .CERTIFICATE but not .PRIVATE_KEY, this package will be
# mentioned in apkcerts.txt (with certificate set to "PRESIGNED")
# but the dexpreopt process will not try to re-sign the app.
PACKAGES.$(LOCAL_MODULE).CERTIFICATE := PRESIGNED
PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
else
# If this is not an absolute certificate, assign it to a generic one.
ifeq ($(dir $(strip $(LOCAL_CERTIFICATE))),./)
LOCAL_CERTIFICATE := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))$(LOCAL_CERTIFICATE)
endif
# NOTE(ruperts): Consider moving the logic below out of a conditional,
# to avoid the possibility of silently ignoring user settings.
PACKAGES.$(LOCAL_MODULE).PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
PACKAGES.$(LOCAL_MODULE).CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
PACKAGES := $(PACKAGES) $(LOCAL_MODULE)
$(built_module) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem
$(built_module) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
$(built_module) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
additional_certificates := $(foreach c,$(LOCAL_ADDITIONAL_CERTIFICATES), $(c).x509.pem $(c).pk8)
$(built_module): $(additional_certificates)
$(built_module): PRIVATE_ADDITIONAL_CERTIFICATES := $(additional_certificates)
$(built_module): $(LOCAL_CERTIFICATE_LINEAGE)
$(built_module): PRIVATE_CERTIFICATE_LINEAGE := $(LOCAL_CERTIFICATE_LINEAGE)
$(built_module): PRIVATE_ROTATION_MIN_SDK_VERSION := $(LOCAL_ROTATION_MIN_SDK_VERSION)
endif
ifneq ($(LOCAL_MODULE_STEM),)
PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE_STEM)
else
PACKAGES.$(LOCAL_MODULE).STEM := $(LOCAL_MODULE)
endif
include $(BUILD_SYSTEM)/app_certificate_validate.mk
# Set a actual_partition_tag (calculated in base_rules.mk) for the package.
PACKAGES.$(LOCAL_MODULE).PARTITION := $(actual_partition_tag)
# Disable dex-preopt of prebuilts to save space, if requested.
ifndef LOCAL_DEX_PREOPT
ifeq ($(DONT_DEXPREOPT_PREBUILTS),true)
LOCAL_DEX_PREOPT := false
endif
endif
# If the module is a compressed module, we don't pre-opt it because its final
# installation location will be the data partition.
ifdef LOCAL_COMPRESSED_MODULE
LOCAL_DEX_PREOPT := false
endif
my_dex_jar := $(my_prebuilt_src_file)
dex_preopt_profile_src_file := $(my_prebuilt_src_file)
#######################################
# defines built_odex along with rule to install odex
my_manifest_or_apk := $(my_prebuilt_src_file)
include $(BUILD_SYSTEM)/dex_preopt_odex_install.mk
my_manifest_or_apk :=
#######################################
ifneq ($(LOCAL_REPLACE_PREBUILT_APK_INSTALLED),)
# There is a replacement for the prebuilt .apk we can install without any processing.
$(built_module) : $(LOCAL_REPLACE_PREBUILT_APK_INSTALLED)
$(transform-prebuilt-to-target)
else # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
# If the SDK version is 30 or higher, the apk is signed with a v2+ scheme.
# Altering it will invalidate the signature. Just do error checks instead.
do_not_alter_apk :=
ifeq (PRESIGNED,$(LOCAL_CERTIFICATE))
ifneq (,$(LOCAL_SDK_VERSION))
ifeq ($(call math_is_number,$(LOCAL_SDK_VERSION)),true)
ifeq ($(call math_gt,$(LOCAL_SDK_VERSION),29),true)
do_not_alter_apk := true
endif
endif
# TODO: Add system_current after fixing the existing modules.
ifneq ($(filter current test_current core_current,$(LOCAL_SDK_VERSION)),)
do_not_alter_apk := true
endif
endif
endif
ifeq ($(do_not_alter_apk),true)
$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN)
$(transform-prebuilt-to-target)
$(check-jni-dex-compression)
$(check-package-alignment)
else
# Sign and align non-presigned .apks.
# The embedded prebuilt jni to uncompress.
ifeq ($(LOCAL_CERTIFICATE),PRESIGNED)
# For PRESIGNED apks we must uncompress every .so file:
# even if the .so file isn't for the current TARGET_ARCH,
# we can't strip the file.
embedded_prebuilt_jni_libs :=
endif
ifndef embedded_prebuilt_jni_libs
# No LOCAL_PREBUILT_JNI_LIBS, uncompress all.
embedded_prebuilt_jni_libs :=
endif
$(built_module): PRIVATE_EMBEDDED_JNI_LIBS := $(embedded_prebuilt_jni_libs)
ifdef LOCAL_COMPRESSED_MODULE
$(built_module) : $(GZIP)
endif
ifeq ($(module_run_appcompat),true)
$(built_module) : $(appcompat-files)
$(LOCAL_BUILT_MODULE): PRIVATE_INSTALLED_MODULE := $(LOCAL_INSTALLED_MODULE)
endif
ifeq ($(module_run_appcompat),true)
$(built_module) : $(AAPT2)
endif
$(built_module) : $(my_prebuilt_src_file) | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR) $(SIGNAPK_JNI_LIBRARY_PATH)
$(transform-prebuilt-to-target)
$(uncompress-prebuilt-embedded-jni-libs)
$(remove-unwanted-prebuilt-embedded-jni-libs)
ifeq (true, $(LOCAL_UNCOMPRESS_DEX))
$(uncompress-dexs)
endif # LOCAL_UNCOMPRESS_DEX
ifneq ($(LOCAL_CERTIFICATE),PRESIGNED)
ifeq ($(module_run_appcompat),true)
$(call appcompat-header, aapt2)
$(run-appcompat)
endif # module_run_appcompat
$(sign-package)
# No need for align-package because sign-package takes care of alignment
else # LOCAL_CERTIFICATE == PRESIGNED
$(align-package)
endif # LOCAL_CERTIFICATE
ifdef LOCAL_COMPRESSED_MODULE
$(compress-package)
endif # LOCAL_COMPRESSED_MODULE
endif # ! do_not_alter_apk
endif # ! LOCAL_REPLACE_PREBUILT_APK_INSTALLED
###############################
## Install split apks.
ifdef LOCAL_PACKAGE_SPLITS
ifdef LOCAL_COMPRESSED_MODULE
$(error $(LOCAL_MODULE): LOCAL_COMPRESSED_MODULE is not currently supported for split installs)
endif # LOCAL_COMPRESSED_MODULE
# LOCAL_PACKAGE_SPLITS is a list of apks to be installed.
built_apk_splits := $(addprefix $(intermediates)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
installed_apk_splits := $(addprefix $(my_module_path)/,$(notdir $(LOCAL_PACKAGE_SPLITS)))
# Rules to sign the split apks.
my_src_dir := $(sort $(dir $(LOCAL_PACKAGE_SPLITS)))
ifneq (1,$(words $(my_src_dir)))
$(error You must put all the split source apks in the same folder: $(LOCAL_PACKAGE_SPLITS))
endif
my_src_dir := $(LOCAL_PATH)/$(my_src_dir)
$(built_apk_splits) : $(LOCAL_CERTIFICATE).pk8 $(LOCAL_CERTIFICATE).x509.pem | $(ZIPALIGN) $(ZIP2ZIP) $(SIGNAPK_JAR) $(SIGNAPK_JNI_LIBRARY_PATH)
$(built_apk_splits) : PRIVATE_PRIVATE_KEY := $(LOCAL_CERTIFICATE).pk8
$(built_apk_splits) : PRIVATE_CERTIFICATE := $(LOCAL_CERTIFICATE).x509.pem
$(built_apk_splits) : $(intermediates)/%.apk : $(my_src_dir)/%.apk
$(copy-file-to-new-target)
$(sign-package)
# Rules to install the split apks.
$(installed_apk_splits) : $(my_module_path)/%.apk : $(intermediates)/%.apk
@echo "Install: $@"
$(copy-file-to-new-target)
# Register the additional built and installed files.
ALL_MODULES.$(my_register_name).INSTALLED += $(installed_apk_splits)
ALL_MODULES.$(my_register_name).BUILT_INSTALLED += \
$(foreach s,$(LOCAL_PACKAGE_SPLITS),$(intermediates)/$(notdir $(s)):$(my_module_path)/$(notdir $(s)))
# Make sure to install the splits when you run "make ".
$(my_all_targets): $(installed_apk_splits)
endif # LOCAL_PACKAGE_SPLITS
###########################################################
## SBOM generation
###########################################################
include $(BUILD_SBOM_GEN)
================================================
FILE: core/art_config.mk
================================================
# ART configuration that has to be determined after product config is resolved.
#
# Inputs:
# PRODUCT_ENABLE_UFFD_GC: See comments in build/make/core/product.mk.
# OVERRIDE_ENABLE_UFFD_GC: Overrides PRODUCT_ENABLE_UFFD_GC. Can be passed from the commandline for
# debugging purposes.
# BOARD_API_LEVEL: See comments in build/make/core/main.mk.
# BOARD_SHIPPING_API_LEVEL: See comments in build/make/core/main.mk.
# PRODUCT_SHIPPING_API_LEVEL: See comments in build/make/core/product.mk.
#
# Outputs:
# ENABLE_UFFD_GC: Whether to use userfaultfd GC.
config_enable_uffd_gc := \
$(firstword $(OVERRIDE_ENABLE_UFFD_GC) $(PRODUCT_ENABLE_UFFD_GC) default)
ifeq (,$(filter default true false,$(config_enable_uffd_gc)))
$(error Unknown PRODUCT_ENABLE_UFFD_GC value: $(config_enable_uffd_gc))
endif
ENABLE_UFFD_GC := $(config_enable_uffd_gc)
# Create APEX_BOOT_JARS_EXCLUDED which is a list of jars to be removed from
# ApexBoorJars when built from mainline prebuilts.
# Note that RELEASE_APEX_BOOT_JARS_PREBUILT_EXCLUDED_LIST is the list of module names
# and library names of jars that need to be removed. We have to keep separated list per
# release config due to possibility of different prebuilt content.
#
# If a device has opted to not use google prebuilts (determined using
# PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS), then no jars need to be removed.
# Example of products where PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS is true are
# 1. aosp devices (they do not use google apexes)
# 2. hwasan devices (apex prebuilts are not compatible with these devices)
# 3. coverage builds
ifneq (true, $(PRODUCT_BUILD_IGNORE_APEX_CONTRIBUTION_CONTENTS))
APEX_BOOT_JARS_EXCLUDED += $(RELEASE_APEX_BOOT_JARS_PREBUILT_EXCLUDED_LIST)
endif
================================================
FILE: core/artifact_path_requirements.mk
================================================
# This file contains logic to enforce artifact path requirements
# defined in product makefiles.
# Fakes don't get installed, and NDK stubs aren't installed to device.
static_allowed_patterns := $(TARGET_OUT_FAKE)/% $(SOONG_OUT_DIR)/ndk/%
# RROs become REQUIRED by the source module, but are always placed on the vendor partition.
static_allowed_patterns += %__auto_generated_characteristics_rro.apk
static_allowed_patterns += %__auto_generated_rro_product.apk
static_allowed_patterns += %__auto_generated_rro_vendor.apk
# Auto-included targets are not considered
static_allowed_patterns += $(call product-installed-files,)
# $(PRODUCT_OUT)/apex is where shared libraries in APEXes get installed.
# The path can be considered as a fake path, as the shared libraries
# are installed there just to have symbols files for them under
# $(PRODUCT_OUT)/symbols/apex for debugging purpose. The /apex directory
# is never compiled into a filesystem image.
static_allowed_patterns += $(PRODUCT_OUT)/apex/%
ifeq (true,$(BOARD_USES_SYSTEM_OTHER_ODEX))
# Allow system_other odex space optimization.
static_allowed_patterns += \
$(TARGET_OUT_SYSTEM_OTHER)/%.odex \
$(TARGET_OUT_SYSTEM_OTHER)/%.vdex \
$(TARGET_OUT_SYSTEM_OTHER)/%.art
endif
ifneq (,$(filter-out true false relaxed strict,$(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS))$(filter-out 1 0,$(words $(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS))))
$(error PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS must be one of [true, false, relaxed, strict], found: $(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS))
endif
all_offending_files :=
$(foreach makefile,$(ARTIFACT_PATH_REQUIREMENT_PRODUCTS),\
$(eval requirements := $(PRODUCTS.$(makefile).ARTIFACT_PATH_REQUIREMENTS)) \
$(eval ### Verify that the product only produces files inside its path requirements.) \
$(eval allowed := $(PRODUCTS.$(makefile).ARTIFACT_PATH_ALLOWED_LIST)) \
$(eval path_patterns := $(call resolve-product-relative-paths,$(requirements),%)) \
$(eval allowed_patterns := $(call resolve-product-relative-paths,$(allowed))) \
$(eval files := $(call product-installed-files, $(makefile))) \
$(eval offending_files := $(filter-out $(path_patterns) $(allowed_patterns) $(static_allowed_patterns),$(files))) \
$(call maybe-print-list-and-error,$(offending_files),\
$(makefile) produces files outside its artifact path requirement. \
Allowed paths are $(subst $(space),$(comma)$(space),$(addsuffix *,$(requirements)))) \
$(eval unused_allowed := $(filter-out $(files),$(allowed_patterns))) \
$(if $(PRODUCTS.$(makefile).ARTIFACT_PATH_REQUIREMENT_IS_RELAXED),, \
$(call maybe-print-list-and-error,$(unused_allowed),$(makefile) includes redundant allowed entries in its artifact path requirement.) \
) \
$(eval ### Optionally verify that nothing else produces files inside this artifact path requirement.) \
$(eval extra_files := $(filter-out $(files) $(HOST_OUT)/%,$(product_target_FILES))) \
$(eval files_in_requirement := $(filter $(path_patterns),$(extra_files))) \
$(eval all_offending_files += $(files_in_requirement)) \
$(eval allowed := $(PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST)) \
$(eval allowed_patterns := $(call resolve-product-relative-paths,$(allowed))) \
$(eval offending_files := $(filter-out $(allowed_patterns),$(files_in_requirement))) \
$(eval enforcement := $(PRODUCT_ENFORCE_ARTIFACT_PATH_REQUIREMENTS)) \
$(if $(filter-out false,$(enforcement)),\
$(call maybe-print-list-and-error,$(offending_files),\
$(INTERNAL_PRODUCT) produces files inside $(makefile)s artifact path requirement. \
$(PRODUCT_ARTIFACT_PATH_REQUIREMENT_HINT)) \
$(eval unused_allowed := $(if $(filter true strict,$(enforcement)),\
$(foreach p,$(allowed_patterns),$(if $(filter $(p),$(extra_files)),,$(p))))) \
$(call maybe-print-list-and-error,$(unused_allowed),$(INTERNAL_PRODUCT) includes redundant artifact path requirement allowed list entries.) \
) \
)
$(PRODUCT_OUT)/offending_artifacts.txt:
rm -f $@
$(foreach f,$(sort $(all_offending_files)),echo $(f) >> $@;)
================================================
FILE: core/autogen_test_config.mk
================================================
#
# Copyright (C) 2017 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.
#
# This build rule allows TradeFed test config file to be created based on
# following inputs:
# is_native: If the test is a native test.
# full_android_manifest: Name of the AndroidManifest file for the test.
# Output:
# autogen_test_config_file: Path to the test config file generated.
autogen_test_config_file := $(dir $(LOCAL_BUILT_MODULE))$(LOCAL_MODULE).config
# TODO: (b/167308193) Switch to /data/local/tests/unrestricted as the default install base.
autogen_test_install_base := /data/local/tmp
# Automatically setup test root for native test.
ifeq (true,$(is_native))
ifeq (true,$(LOCAL_VENDOR_MODULE))
autogen_test_install_base = /data/local/tests/vendor
endif
ifeq (true,$(call module-in-vendor-or-product))
autogen_test_install_base = /data/local/tests/vendor
endif
endif
ifeq (true,$(is_native))
ifeq ($(LOCAL_NATIVE_BENCHMARK),true)
autogen_test_config_template := $(NATIVE_BENCHMARK_TEST_CONFIG_TEMPLATE)
else
ifeq ($(LOCAL_IS_HOST_MODULE),true)
autogen_test_config_template := $(NATIVE_HOST_TEST_CONFIG_TEMPLATE)
else
autogen_test_config_template := $(NATIVE_TEST_CONFIG_TEMPLATE)
endif
endif
# Auto generating test config file for native test
$(autogen_test_config_file): PRIVATE_TEST_INSTALL_BASE := $(autogen_test_install_base)
$(autogen_test_config_file): PRIVATE_MODULE_NAME := $(LOCAL_MODULE)
$(autogen_test_config_file) : $(autogen_test_config_template)
@echo "Auto generating test config $(notdir $@)"
$(hide) sed 's&{MODULE}&$(PRIVATE_MODULE_NAME)&g;s&{TEST_INSTALL_BASE}&$(PRIVATE_TEST_INSTALL_BASE)&g;s&{EXTRA_CONFIGS}&&g' $< > $@
my_auto_generate_config := true
else
# Auto generating test config file for instrumentation test
ifneq (,$(full_android_manifest))
$(autogen_test_config_file): PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT := $(AUTOGEN_TEST_CONFIG_SCRIPT)
$(autogen_test_config_file): PRIVATE_TEST_CONFIG_ANDROID_MANIFEST := $(full_android_manifest)
$(autogen_test_config_file): PRIVATE_EMPTY_TEST_CONFIG := $(EMPTY_TEST_CONFIG)
$(autogen_test_config_file): PRIVATE_TEMPLATE := $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE)
$(autogen_test_config_file) : $(full_android_manifest) $(EMPTY_TEST_CONFIG) $(INSTRUMENTATION_TEST_CONFIG_TEMPLATE) $(AUTOGEN_TEST_CONFIG_SCRIPT)
@echo "Auto generating test config $(notdir $@)"
@rm -f $@
$(hide) $(PRIVATE_AUTOGEN_TEST_CONFIG_SCRIPT) $@ $(PRIVATE_TEST_CONFIG_ANDROID_MANIFEST) $(PRIVATE_EMPTY_TEST_CONFIG) $(PRIVATE_TEMPLATE)
my_auto_generate_config := true
endif # ifneq (,$(full_android_manifest))
endif # ifneq (true,$(is_native))
ifeq (true,$(my_auto_generate_config))
LOCAL_INTERMEDIATE_TARGETS += $(autogen_test_config_file)
$(LOCAL_BUILT_MODULE): $(autogen_test_config_file)
ALL_MODULES.$(my_register_name).auto_test_config := true
$(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_autogen := true
else
autogen_test_config_file :=
endif
my_auto_generate_config :=
================================================
FILE: core/base_rules.mk
================================================
#
# Copyright (C) 2008 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.
#
# Catch users that directly include base_rules.mk
$(call record-module-type,base_rules)
# Users can define base-rules-hook in their buildspec.mk to perform
# arbitrary operations as each module is included.
ifdef base-rules-hook
ifndef _has_warned_about_base_rules_hook
$(warning base-rules-hook is deprecated, please remove usages of it and/or convert to Soong.)
_has_warned_about_base_rules_hook := true
endif
$(if $(base-rules-hook),)
endif
###########################################################
## Common instructions for a generic module.
###########################################################
LOCAL_MODULE := $(strip $(LOCAL_MODULE))
ifeq ($(LOCAL_MODULE),)
$(error $(LOCAL_PATH): LOCAL_MODULE is not defined)
endif
$(call verify-module-name)
my_test_data :=
my_test_config :=
LOCAL_IS_HOST_MODULE := $(strip $(LOCAL_IS_HOST_MODULE))
ifdef LOCAL_IS_HOST_MODULE
ifneq ($(LOCAL_IS_HOST_MODULE),true)
$(error $(LOCAL_PATH): LOCAL_IS_HOST_MODULE must be "true" or empty, not "$(LOCAL_IS_HOST_MODULE)")
endif
ifeq ($(LOCAL_HOST_PREFIX),)
my_prefix := HOST_
else
my_prefix := $(LOCAL_HOST_PREFIX)
endif
my_host := host-
my_kind := HOST
else
my_prefix := TARGET_
my_kind :=
my_host :=
endif
ifeq ($(my_prefix),HOST_CROSS_)
my_host_cross := true
else
my_host_cross :=
endif
ifeq (true, $(LOCAL_PRODUCT_MODULE))
ifneq (,$(filter $(LOCAL_MODULE),$(PRODUCT_FORCE_PRODUCT_MODULES_TO_SYSTEM_PARTITION)))
LOCAL_PRODUCT_MODULE :=
endif
endif
_path := $(LOCAL_MODULE_PATH) $(LOCAL_MODULE_PATH_32) $(LOCAL_MODULE_PATH_64)
ifneq ($(filter $(TARGET_OUT_VENDOR)%,$(_path)),)
LOCAL_VENDOR_MODULE := true
else ifneq ($(filter $(TARGET_OUT_OEM)/%,$(_path)),)
LOCAL_OEM_MODULE := true
else ifneq ($(filter $(TARGET_OUT_ODM)/%,$(_path)),)
LOCAL_ODM_MODULE := true
else ifneq ($(filter $(TARGET_OUT_PRODUCT)/%,$(_path)),)
LOCAL_PRODUCT_MODULE := true
else ifneq ($(filter $(TARGET_OUT_SYSTEM_EXT)/%,$(_path)),)
LOCAL_SYSTEM_EXT_MODULE := true
endif
_path :=
# TODO(b/135957588) Remove following workaround
# LOCAL_PRODUCT_SERVICES_MODULE to LOCAL_PRODUCT_MODULE for all Android.mk
ifndef LOCAL_PRODUCT_MODULE
LOCAL_PRODUCT_MODULE := $(LOCAL_PRODUCT_SERVICES_MODULE)
endif
ifndef LOCAL_PROPRIETARY_MODULE
LOCAL_PROPRIETARY_MODULE := $(LOCAL_VENDOR_MODULE)
endif
ifndef LOCAL_VENDOR_MODULE
LOCAL_VENDOR_MODULE := $(LOCAL_PROPRIETARY_MODULE)
endif
ifneq ($(filter-out $(LOCAL_PROPRIETARY_MODULE),$(LOCAL_VENDOR_MODULE))$(filter-out $(LOCAL_VENDOR_MODULE),$(LOCAL_PROPRIETARY_MODULE)),)
$(call pretty-error,Only one of LOCAL_PROPRIETARY_MODULE[$(LOCAL_PROPRIETARY_MODULE)] and LOCAL_VENDOR_MODULE[$(LOCAL_VENDOR_MODULE)] may be set, or they must be equal)
endif
ifeq ($(LOCAL_HOST_MODULE),true)
my_image_variant := host
else ifeq ($(LOCAL_VENDOR_MODULE),true)
my_image_variant := vendor
else ifeq ($(LOCAL_OEM_MODULE),true)
my_image_variant := vendor
else ifeq ($(LOCAL_ODM_MODULE),true)
my_image_variant := vendor
else ifeq ($(LOCAL_PRODUCT_MODULE),true)
my_image_variant := product
else
my_image_variant := core
endif
non_system_module := $(filter true, \
$(LOCAL_PRODUCT_MODULE) \
$(LOCAL_SYSTEM_EXT_MODULE) \
$(LOCAL_VENDOR_MODULE) \
$(LOCAL_PROPRIETARY_MODULE))
include $(BUILD_SYSTEM)/local_vendor_product.mk
# local_current_sdk needs to run before local_systemsdk because the former may override
# LOCAL_SDK_VERSION which is used by the latter.
include $(BUILD_SYSTEM)/local_current_sdk.mk
# Check if the use of System SDK is correct. Note that, for Soong modules, the system sdk version
# check is done in Soong. No need to do it twice.
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
include $(BUILD_SYSTEM)/local_systemsdk.mk
endif
# Ninja has an implicit dependency on the command being run, and kati will
# regenerate the ninja manifest if any read makefile changes, so there is no
# need to have dependencies on makefiles.
# This won't catch all the cases where LOCAL_ADDITIONAL_DEPENDENCIES contains
# a .mk file, because a few users of LOCAL_ADDITIONAL_DEPENDENCIES don't include
# base_rules.mk, but it will fix the most common ones.
LOCAL_ADDITIONAL_DEPENDENCIES := $(filter-out %.mk,$(LOCAL_ADDITIONAL_DEPENDENCIES))
my_bad_deps := $(strip $(foreach dep,$(filter-out | ||,$(LOCAL_ADDITIONAL_DEPENDENCIES)),\
$(if $(findstring /,$(dep)),,$(dep))))
ifneq ($(my_bad_deps),)
$(call pretty-warning,"Bad LOCAL_ADDITIONAL_DEPENDENCIES: $(my_bad_deps)")
$(call pretty-error,"LOCAL_ADDITIONAL_DEPENDENCIES must only contain paths (not module names)")
endif
###########################################################
## Validate and define fallbacks for input LOCAL_* variables.
###########################################################
LOCAL_UNINSTALLABLE_MODULE := $(strip $(LOCAL_UNINSTALLABLE_MODULE))
# Only the tags mentioned in this test are expected to be set by module
# makefiles. Anything else is either a typo or a source of unexpected
# behaviors.
ifneq ($(filter-out tests optional samples,$(LOCAL_MODULE_TAGS)),)
$(call pretty-error,unusual tags: $(filter-out tests optional samples,$(LOCAL_MODULE_TAGS)))
endif
LOCAL_MODULE_CLASS := $(strip $(LOCAL_MODULE_CLASS))
ifneq ($(words $(LOCAL_MODULE_CLASS)),1)
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS must contain exactly one word, not "$(LOCAL_MODULE_CLASS)")
endif
my_32_64_bit_suffix := $(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32)
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
my_multilib_module_path := $(strip $(LOCAL_MODULE_PATH_$(my_32_64_bit_suffix)))
ifdef my_multilib_module_path
my_module_path := $(my_multilib_module_path)
else
my_module_path := $(strip $(LOCAL_MODULE_PATH))
endif
my_module_path := $(patsubst %/,%,$(my_module_path))
my_module_relative_path := $(strip $(LOCAL_MODULE_RELATIVE_PATH))
ifdef LOCAL_IS_HOST_MODULE
partition_tag :=
actual_partition_tag :=
else
ifeq (true,$(strip $(LOCAL_VENDOR_MODULE)))
partition_tag := _VENDOR
# A vendor module could be on the vendor partition at "vendor" or the system
# partition at "system/vendor".
actual_partition_tag := $(if $(filter true,$(BOARD_USES_VENDORIMAGE)),vendor,system)
else ifeq (true,$(strip $(LOCAL_OEM_MODULE)))
partition_tag := _OEM
actual_partition_tag := oem
else ifeq (true,$(strip $(LOCAL_ODM_MODULE)))
partition_tag := _ODM
# An ODM module could be on the odm partition at "odm", the vendor partition
# at "vendor/odm", or the system partition at "system/vendor/odm".
actual_partition_tag := $(if $(filter true,$(BOARD_USES_ODMIMAGE)),odm,$(if $(filter true,$(BOARD_USES_VENDORIMAGE)),vendor,system))
else ifeq (true,$(strip $(LOCAL_PRODUCT_MODULE)))
partition_tag := _PRODUCT
# A product module could be on the product partition at "product" or the
# system partition at "system/product".
actual_partition_tag := $(if $(filter true,$(BOARD_USES_PRODUCTIMAGE)),product,system)
else ifeq (true,$(strip $(LOCAL_SYSTEM_EXT_MODULE)))
partition_tag := _SYSTEM_EXT
# A system_ext-specific module could be on the system_ext partition at
# "system_ext" or the system partition at "system/system_ext".
actual_partition_tag := $(if $(filter true,$(BOARD_USES_SYSTEM_EXTIMAGE)),system_ext,system)
else ifeq (NATIVE_TESTS,$(LOCAL_MODULE_CLASS))
partition_tag := _DATA
actual_partition_tag := data
else
# The definition of should-install-to-system will be different depending
# on which goal (e.g., sdk or just droid) is being built.
partition_tag := $(if $(call should-install-to-system,$(LOCAL_MODULE_TAGS)),,_DATA)
actual_partition_tag := $(if $(partition_tag),data,system)
endif
endif
# if this is a soong module, verify that LOCAL_COMPATIBILITY_SUITE (legacy) matches
# LOCAL_SOONG_PROVIDER_TEST_SUITES (new, via TestSuiteInfoProvider instead of AndroidMk stuff),
# modulo "null-sute", "mts", and "mcts". mts/mcts are automatically added if there's a different
# suite starting with "m(c)ts-". null-suite seems useless and is sometimes automatically added
# if no other suites are added.
ifneq (,$(filter $(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)))
a := $(filter-out null-suite mts mcts,$(sort $(LOCAL_COMPATIBILITY_SUITE)))
b := $(filter-out null-suite mts mcts,$(sort $(LOCAL_SOONG_PROVIDER_TEST_SUITES)))
ifneq ($(a),$(b))
$(error $(LOCAL_MODULE): LOCAL_COMPATIBILITY_SUITE did not match LOCAL_SOONG_PROVIDER_TEST_SUITES$(newline) LOCAL_COMPATIBILITY_SUITE: $(a)$(newline) LOCAL_SOONG_PROVIDER_TEST_SUITES: $(b)$(newline))
endif
a :=
b :=
endif
# For test modules that lack a suite tag, set null-suite as the default.
# We only support adding a default suite to native tests, native benchmarks, and instrumentation tests.
# This is because they are the only tests we currently auto-generate test configs for.
ifndef LOCAL_COMPATIBILITY_SUITE
ifneq ($(filter NATIVE_TESTS NATIVE_BENCHMARK, $(LOCAL_MODULE_CLASS)),)
LOCAL_COMPATIBILITY_SUITE := null-suite
endif
ifneq ($(filter APPS, $(LOCAL_MODULE_CLASS)),)
ifneq ($(filter $(LOCAL_MODULE_TAGS),tests),)
LOCAL_COMPATIBILITY_SUITE := null-suite
endif
endif
endif
use_testcase_folder :=
ifeq ($(my_module_path),)
ifneq ($(LOCAL_MODULE),$(filter $(LOCAL_MODULE),$(DEFAULT_DATA_OUT_MODULES)))
ifdef LOCAL_COMPATIBILITY_SUITE
ifneq (true, $(LOCAL_IS_HOST_MODULE))
use_testcase_folder := true
endif
endif
endif
endif
ifeq ($(LOCAL_IS_UNIT_TEST),true)
ifeq ($(LOCAL_IS_HOST_MODULE),true)
LOCAL_COMPATIBILITY_SUITE += host-unit-tests
endif
endif
ifeq ($(my_module_path),)
install_path_var := $(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT$(partition_tag)_$(LOCAL_MODULE_CLASS)
ifeq (true,$(LOCAL_PRIVILEGED_MODULE))
install_path_var := $(install_path_var)_PRIVILEGED
endif
my_module_path := $($(install_path_var))
# If use_testcase_folder be set, and LOCAL_MODULE_PATH not set,
# overwrite the default path under testcase.
ifeq ($(use_testcase_folder),true)
arch_dir := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
testcase_folder := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)/$(arch_dir)
my_module_path := $(testcase_folder)
arch_dir :=
endif
ifeq ($(strip $(my_module_path)),)
$(error $(LOCAL_PATH): unhandled install path "$(install_path_var) for $(LOCAL_MODULE)")
endif
endif
ifneq ($(my_module_relative_path),)
my_module_path := $(my_module_path)/$(my_module_relative_path)
endif
endif # not LOCAL_UNINSTALLABLE_MODULE
ifneq ($(strip $(LOCAL_BUILT_MODULE)$(LOCAL_INSTALLED_MODULE)),)
$(error $(LOCAL_PATH): LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE must not be defined by component makefiles)
endif
my_register_name := $(LOCAL_MODULE)
ifeq ($(my_host_cross),true)
my_register_name := host_cross_$(LOCAL_MODULE)
endif
ifdef LOCAL_2ND_ARCH_VAR_PREFIX
ifndef LOCAL_NO_2ND_ARCH_MODULE_SUFFIX
my_register_name := $(my_register_name)$($(my_prefix)2ND_ARCH_MODULE_SUFFIX)
endif
endif
ifeq ($(my_host_cross),true)
my_all_targets := host_cross_$(my_register_name)_all_targets
else ifneq ($(LOCAL_IS_HOST_MODULE),)
my_all_targets := host_$(my_register_name)_all_targets
else
my_all_targets := device_$(my_register_name)_all_targets
endif
# Make sure that this IS_HOST/CLASS/MODULE combination is unique.
module_id := MODULE.$(if \
$(LOCAL_IS_HOST_MODULE),$($(my_prefix)OS),TARGET).$(LOCAL_MODULE_CLASS).$(my_register_name)
ifdef $(module_id)
$(error $(LOCAL_PATH): $(module_id) already defined by $($(module_id)))
endif
$(module_id) := $(LOCAL_PATH)
# These are the same as local-intermediates-dir / local-generated-sources dir, but faster
intermediates.COMMON := $($(my_prefix)OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
ifneq (,$(filter $(my_prefix)$(LOCAL_MODULE_CLASS),$(COMMON_MODULE_CLASSES)))
intermediates := $($(my_prefix)OUT_COMMON_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
generated_sources_dir := $($(my_prefix)OUT_COMMON_GEN)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
else
ifneq (,$(filter $(LOCAL_MODULE_CLASS),$(PER_ARCH_MODULE_CLASSES)))
intermediates := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)OUT_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
else
intermediates := $($(my_prefix)OUT_INTERMEDIATES)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
endif
generated_sources_dir := $($(my_prefix)OUT_GEN)/$(LOCAL_MODULE_CLASS)/$(LOCAL_MODULE)_intermediates
endif
ifneq ($(LOCAL_OVERRIDES_MODULES),)
ifndef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_MODULE_CLASS),EXECUTABLES)
EXECUTABLES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES))
else ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
SHARED_LIBRARIES.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES))
else ifeq ($(LOCAL_MODULE_CLASS),ETC)
ETC.$(LOCAL_MODULE).OVERRIDES := $(strip $(LOCAL_OVERRIDES_MODULES))
else
$(call pretty-error,LOCAL_MODULE_CLASS := $(LOCAL_MODULE_CLASS) cannot use LOCAL_OVERRIDES_MODULES)
endif
else
$(call pretty-error,host modules cannot use LOCAL_OVERRIDES_MODULES)
endif
endif
###########################################################
# Pick a name for the intermediate and final targets
###########################################################
include $(BUILD_SYSTEM)/configure_module_stem.mk
LOCAL_BUILT_MODULE := $(intermediates)/$(my_built_module_stem)
ifneq (,$(LOCAL_SOONG_INSTALLED_MODULE))
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(call pretty-error, LOCAL_MODULE_MAKEFILE can only be used from $(SOONG_ANDROID_MK))
endif
# Use the install path requested by Soong.
LOCAL_INSTALLED_MODULE := $(LOCAL_SOONG_INSTALLED_MODULE)
else ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
# Apk and its attachments reside in its own subdir.
ifeq ($(LOCAL_MODULE_CLASS),APPS)
# framework-res.apk doesn't like the additional layer.
ifeq ($(LOCAL_NO_STANDARD_LIBRARIES),true)
# Neither do Runtime Resource Overlay apks, which contain just the overlaid resources.
else ifeq ($(LOCAL_IS_RUNTIME_RESOURCE_OVERLAY),true)
else
ifneq ($(use_testcase_folder),true)
my_module_path := $(my_module_path)/$(LOCAL_MODULE)
endif
endif
endif
LOCAL_INSTALLED_MODULE := $(my_module_path)/$(my_installed_module_stem)
endif
# Assemble the list of targets to create PRIVATE_ variables for.
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE)
###########################################################
## Create .toc files from shared objects to reduce unnecessary rebuild
# .toc files have the list of external dynamic symbols without their addresses.
# As .KATI_RESTAT is specified to .toc files and commit-change-for-toc is used,
# dependent binaries of a .toc file will be rebuilt only when the content of
# the .toc file is changed.
#
# Don't create .toc files for Soong shared libraries, that is handled in
# Soong and soong_cc_prebuilt.mk
###########################################################
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
LOCAL_INTERMEDIATE_TARGETS += $(LOCAL_BUILT_MODULE).toc
$(LOCAL_BUILT_MODULE).toc: $(LOCAL_BUILT_MODULE)
$(call $(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)transform-shared-lib-to-toc,$<,$@.tmp)
$(call commit-change-for-toc,$@)
# Kati adds restat=1 to ninja. GNU make does nothing for this.
.KATI_RESTAT: $(LOCAL_BUILT_MODULE).toc
# Build .toc file when using mm, mma, or make $(my_register_name)
$(my_all_targets): $(LOCAL_BUILT_MODULE).toc
endif
endif
###########################################################
## logtags: Add .logtags files to global list
###########################################################
logtags_sources := $(filter %.logtags,$(LOCAL_SRC_FILES)) $(LOCAL_LOGTAGS_FILES)
ifneq ($(strip $(logtags_sources) $(LOCAL_SOONG_LOGTAGS_FILES)),)
event_log_tags := $(foreach f,$(LOCAL_SOONG_LOGTAGS_FILES) $(addprefix $(LOCAL_PATH)/,$(logtags_sources)),$(call clean-path,$(f)))
else
event_log_tags :=
endif
###########################################################
## make clean- targets
###########################################################
cleantarget := clean-$(my_register_name)
.PHONY: $(cleantarget)
$(cleantarget) : PRIVATE_MODULE := $(my_register_name)
$(cleantarget) : PRIVATE_CLEAN_FILES := \
$(LOCAL_BUILT_MODULE) \
$(LOCAL_INSTALLED_MODULE) \
$(intermediates)
$(cleantarget)::
@echo "Clean: $(PRIVATE_MODULE)"
$(hide) rm -rf $(PRIVATE_CLEAN_FILES)
###########################################################
## Common definitions for module.
###########################################################
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PATH:=$(LOCAL_PATH)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_IS_HOST_MODULE := $(LOCAL_IS_HOST_MODULE)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_HOST:= $(my_host)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_PREFIX := $(my_prefix)
$(LOCAL_INTERMEDIATE_TARGETS) : .KATI_TAGS += ;module_name=$(LOCAL_MODULE)
ifeq ($(LOCAL_MODULE_CLASS),)
$(error "$(LOCAL_MODULE) in $(LOCAL_PATH) does not set $(LOCAL_MODULE_CLASS)")
else
$(LOCAL_INTERMEDIATE_TARGETS) : .KATI_TAGS += ;module_type=$(LOCAL_MODULE_CLASS)
endif
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_INTERMEDIATES_DIR:= $(intermediates)
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
# Tell the module and all of its sub-modules who it is.
$(LOCAL_INTERMEDIATE_TARGETS) : PRIVATE_MODULE:= $(my_register_name)
# Provide a short-hand for building this module.
# We name both BUILT and INSTALLED in case
# LOCAL_UNINSTALLABLE_MODULE is set.
.PHONY: $(my_all_targets)
$(my_all_targets): $(LOCAL_BUILT_MODULE) $(LOCAL_INSTALLED_MODULE) $(LOCAL_ADDITIONAL_CHECKED_MODULE)
.PHONY: $(my_register_name)
$(my_register_name): $(my_all_targets)
ifneq ($(my_register_name),$(LOCAL_MODULE))
# $(LOCAL_MODULE) covers all the multilib targets.
.PHONY: $(LOCAL_MODULE)
$(LOCAL_MODULE) : $(my_all_targets)
endif
# Set up phony targets that covers all modules under the given paths.
# This allows us to build everything in given paths by running mmma/mma.
define my_path_comp
parent := $(patsubst %/,%,$(dir $(1)))
parent_target := MODULES-IN-$$(subst /,-,$$(parent))
.PHONY: $$(parent_target)
$$(parent_target): $(2)
ifndef $$(parent_target)
$$(parent_target) := true
ifneq (,$$(findstring /,$$(parent)))
$$(eval $$(call my_path_comp,$$(parent),$$(parent_target)))
endif
endif
endef
_local_path := $(patsubst %/,%,$(LOCAL_PATH))
_local_path_target := MODULES-IN-$(subst /,-,$(_local_path))
.PHONY: $(_local_path_target)
$(_local_path_target): $(my_register_name)
ifndef $(_local_path_target)
$(_local_path_target) := true
ifneq (,$(findstring /,$(_local_path)))
$(eval $(call my_path_comp,$(_local_path),$(_local_path_target)))
endif
endif
_local_path :=
_local_path_target :=
my_path_comp :=
###########################################################
## Module installation rule
###########################################################
my_installed_symlinks :=
ifneq (,$(LOCAL_SOONG_INSTALLED_MODULE))
# Soong already generated the copy rule, but make the installed location depend on the Make
# copy of the intermediates for now, as some rules that collect intermediates may expect
# them to exist.
$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
else ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
$(LOCAL_INSTALLED_MODULE): PRIVATE_POST_INSTALL_CMD := $(LOCAL_POST_INSTALL_CMD)
$(LOCAL_INSTALLED_MODULE): $(LOCAL_BUILT_MODULE)
@echo "Install: $@"
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(copy-file-or-link-to-new-target)
else
$(copy-file-to-new-target)
endif
$(PRIVATE_POST_INSTALL_CMD)
# Rule to install the module's companion symlinks
my_installed_symlinks := $(addprefix $(my_module_path)/,$(LOCAL_MODULE_SYMLINKS) $(LOCAL_MODULE_SYMLINKS_$(my_32_64_bit_suffix)))
$(foreach symlink,$(my_installed_symlinks),\
$(call symlink-file,$(LOCAL_INSTALLED_MODULE),$(my_installed_module_stem),$(symlink))\
$(call declare-0p-target,$(symlink)))
$(my_all_targets) : | $(my_installed_symlinks)
endif # !LOCAL_UNINSTALLABLE_MODULE
# Add dependencies on LOCAL_SOONG_INSTALL_SYMLINKS if we're installing any kind of module, not just
# ones that set LOCAL_SOONG_INSTALLED_MODULE. This is so we can have a soong module that only
# installs symlinks (e.g. install_symlink). We can't set LOCAL_SOONG_INSTALLED_MODULE to a symlink
# because cp commands will fail on symlinks.
ifneq (,$(or $(LOCAL_SOONG_INSTALLED_MODULE),$(call boolean-not,$(LOCAL_UNINSTALLABLE_MODULE))))
$(foreach symlink, $(LOCAL_SOONG_INSTALL_SYMLINKS), $(call declare-0p-target,$(symlink)))
$(my_all_targets) : | $(LOCAL_SOONG_INSTALL_SYMLINKS)
endif
###########################################################
## VINTF manifest fragment and init.rc goals
###########################################################
my_vintf_installed:=
my_vintf_path:=
my_vintf_pairs:=
my_init_rc_installed :=
my_init_rc_path :=
my_init_rc_pairs :=
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ifndef LOCAL_IS_HOST_MODULE
# Rule to install the module's companion vintf fragments.
ifneq ($(strip $(LOCAL_FULL_VINTF_FRAGMENTS)),)
my_vintf_fragments := $(LOCAL_FULL_VINTF_FRAGMENTS)
else
my_vintf_fragments := $(foreach xml,$(LOCAL_VINTF_FRAGMENTS),$(LOCAL_PATH)/$(xml))
endif
ifneq ($(strip $(my_vintf_fragments)),)
# Make doesn't support recovery as an output partition, but some Soong modules installed in recovery
# have init.rc files that need to be installed alongside them. Manually handle the case where the
# output file is in the recovery partition.
my_vintf_path := $(if $(filter $(TARGET_RECOVERY_ROOT_OUT)/%,$(my_module_path)),$(TARGET_RECOVERY_ROOT_OUT)/system/etc,$(TARGET_OUT$(partition_tag)_ETC))
my_vintf_pairs := $(foreach xml,$(my_vintf_fragments),$(xml):$(my_vintf_path)/vintf/manifest/$(notdir $(xml)))
my_vintf_installed := $(foreach xml,$(my_vintf_pairs),$(call word-colon,2,$(xml)))
# Only set up copy rules once, even if another arch variant shares it
my_vintf_new_pairs := $(filter-out $(ALL_VINTF_MANIFEST_FRAGMENTS_LIST),$(my_vintf_pairs))
ALL_VINTF_MANIFEST_FRAGMENTS_LIST += $(my_vintf_new_pairs)
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(call copy-many-vintf-manifest-files-checked,$(my_vintf_new_pairs))
$(my_all_targets) : $(my_vintf_installed)
# Install fragments together with the target
$(LOCAL_INSTALLED_MODULE) : | $(my_vintf_installed)
endif
endif # my_vintf_fragments
# Rule to install the module's companion init.rc.
ifneq ($(strip $(LOCAL_FULL_INIT_RC)),)
my_init_rc := $(LOCAL_FULL_INIT_RC)
else
my_init_rc := $(foreach rc,$(LOCAL_INIT_RC_$(my_32_64_bit_suffix)) $(LOCAL_INIT_RC),$(LOCAL_PATH)/$(rc))
endif
ifneq ($(strip $(my_init_rc)),)
# Make doesn't support recovery or ramdisk as an output partition,
# but some Soong modules installed in recovery or ramdisk
# have init.rc files that need to be installed alongside them.
# Manually handle the case where the
# output file is in the recovery or ramdisk partition.
ifneq (,$(filter $(TARGET_RECOVERY_ROOT_OUT)/%,$(my_module_path)))
ifneq (,$(filter $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/%,$(my_module_path)))
my_init_rc_path := $(TARGET_RECOVERY_ROOT_OUT)/first_stage_ramdisk/system/etc
else
my_init_rc_path := $(TARGET_RECOVERY_ROOT_OUT)/system/etc
endif
else ifneq (,$(filter $(TARGET_RAMDISK_OUT)/%,$(my_module_path)))
my_init_rc_path := $(TARGET_RAMDISK_OUT)/system/etc
else
my_init_rc_path := $(TARGET_OUT$(partition_tag)_ETC)
endif
my_init_rc_pairs := $(foreach rc,$(my_init_rc),$(rc):$(my_init_rc_path)/init/$(notdir $(rc)))
my_init_rc_installed := $(foreach rc,$(my_init_rc_pairs),$(call word-colon,2,$(rc)))
# Make sure we only set up the copy rules once, even if another arch variant
# shares a common LOCAL_INIT_RC.
my_init_rc_new_pairs := $(filter-out $(ALL_INIT_RC_INSTALLED_PAIRS),$(my_init_rc_pairs))
ALL_INIT_RC_INSTALLED_PAIRS += $(my_init_rc_new_pairs)
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
$(call copy-many-init-script-files-checked,$(my_init_rc_new_pairs))
$(my_all_targets) : $(my_init_rc_installed)
# Install init_rc together with the target
$(LOCAL_INSTALLED_MODULE) : | $(my_init_rc_installed)
endif
endif # my_init_rc
endif # !LOCAL_IS_HOST_MODULE
endif # !LOCAL_UNINSTALLABLE_MODULE
###########################################################
## CHECK_BUILD goals
###########################################################
my_checked_module :=
# If nobody has defined a more specific module for the
# checked modules, use LOCAL_BUILT_MODULE.
ifdef LOCAL_CHECKED_MODULE
my_checked_module := $(LOCAL_CHECKED_MODULE)
else
my_checked_module := $(LOCAL_BUILT_MODULE)
endif
my_checked_module += $(LOCAL_ADDITIONAL_CHECKED_MODULE)
# If they request that this module not be checked, then don't.
# PLEASE DON'T SET THIS. ANY PLACES THAT SET THIS WITHOUT
# GOOD REASON WILL HAVE IT REMOVED.
ifdef LOCAL_DONT_CHECK_MODULE
my_checked_module :=
endif
# Don't check build target module defined for the 2nd arch
ifndef LOCAL_IS_HOST_MODULE
ifdef LOCAL_2ND_ARCH_VAR_PREFIX
my_checked_module :=
endif
endif
###########################################################
## Test Data
###########################################################
my_test_data_pairs :=
my_installed_test_data :=
# Source to relative dst file paths for reuse in LOCAL_COMPATIBILITY_SUITE.
my_test_data_file_pairs :=
ifneq ($(strip $(filter NATIVE_TESTS,$(LOCAL_MODULE_CLASS)) $(LOCAL_IS_FUZZ_TARGET)),)
ifneq ($(strip $(LOCAL_TEST_DATA)),)
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
# Soong LOCAL_TEST_DATA is of the form ::
# or :, to be installed to
# // or /,
# respectively.
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
define copy_test_data_pairs
_src_base := $$(call word-colon,1,$$(td))
_file := $$(call word-colon,2,$$(td))
_relative_install_path := $$(call word-colon,3,$$(td))
ifeq (,$$(_relative_install_path))
_relative_dest_file := $$(_file)
else
_relative_dest_file := $$(call append-path,$$(_relative_install_path),$$(_file))
endif
my_test_data_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(call append-path,$$(my_module_path),$$(_relative_dest_file))
my_test_data_file_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(_relative_dest_file)
endef
else
define copy_test_data_pairs
_src_base := $$(call word-colon,1,$$(td))
_file := $$(call word-colon,2,$$(td))
ifndef _file
_file := $$(_src_base)
_src_base := $$(LOCAL_PATH)
endif
ifneq (,$$(findstring ..,$$(_file)))
$$(call pretty-error,LOCAL_TEST_DATA may not include '..': $$(_file))
endif
ifneq (,$$(filter/%,$$(_src_base) $$(_file)))
$$(call pretty-error,LOCAL_TEST_DATA may not include absolute paths: $$(_src_base) $$(_file))
endif
my_test_data_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(call append-path,$$(my_module_path),$$(_file))
my_test_data_file_pairs += $$(call append-path,$$(_src_base),$$(_file)):$$(_file)
endef
endif
$(foreach td,$(LOCAL_TEST_DATA),$(eval $(copy_test_data_pairs)))
copy_test_data_pairs :=
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
my_installed_test_data := $(call copy-many-files,$(my_test_data_pairs))
$(LOCAL_INSTALLED_MODULE): $(my_installed_test_data)
else
# Skip installing test data for Soong modules, it's already been handled.
# Just compute my_installed_test_data.
my_installed_test_data := $(foreach f, $(my_test_data_pairs), $(call word-colon,2,$(f)))
endif
endif
endif
endif
###########################################################
## SOONG INSTALL PAIRS
###########################################################
# Declare dependencies for LOCAL_SOONG_INSTALL_PAIRS in soong to the module it relies on.
ifneq (,$(LOCAL_SOONG_INSTALLED_MODULE))
$(my_all_targets): \
$(foreach f, $(LOCAL_SOONG_INSTALL_PAIRS),\
$(word 2,$(subst :,$(space),$(f))))
endif
###########################################################
## Compatibility suite files.
###########################################################
ifdef LOCAL_COMPATIBILITY_SUITE
ifneq (,$(LOCAL_FULL_TEST_CONFIG))
test_config := $(LOCAL_FULL_TEST_CONFIG)
else ifneq (,$(LOCAL_TEST_CONFIG))
test_config := $(LOCAL_PATH)/$(LOCAL_TEST_CONFIG)
else
test_config := $(wildcard $(LOCAL_PATH)/AndroidTest.xml)
endif
ifeq ($(EXCLUDE_MCTS),true)
ifeq (,$(filter $(LOCAL_MODULE),$(mcts_whitelist)))
ifneq (,$(test_config))
ifneq (,$(filter mcts-%,$(LOCAL_COMPATIBILITY_SUITE)))
LOCAL_COMPATIBILITY_SUITE := $(filter-out cts,$(LOCAL_COMPATIBILITY_SUITE))
endif
endif
endif
endif
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ifeq ($(EXCLUDE_MCTS),true)
ifneq (,$(test_config))
ifneq (,$(filter mcts-%,$(LOCAL_COMPATIBILITY_SUITE)))
LOCAL_COMPATIBILITY_SUITE := $(filter-out cts,$(LOCAL_COMPATIBILITY_SUITE))
endif
endif
endif
# If we are building a native test or benchmark and its stem variants are not defined,
# separate the multiple architectures into subdirectories of the testcase folder.
arch_dir :=
is_native :=
multi_arch :=
ifeq ($(LOCAL_MODULE_CLASS),NATIVE_TESTS)
is_native := true
multi_arch := true
endif
ifdef LOCAL_MULTILIB
multi_arch := true
# These conditionals allow this functionality to be mimicked in Soong
else ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
multi_arch := true
endif
endif
ifdef multi_arch
arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
else
ifeq ($(use_testcase_folder),true)
arch_dir := /$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
endif
endif
multi_arch :=
my_default_test_module :=
my_default_test_module := $($(my_prefix)OUT_TESTCASES)/$(LOCAL_MODULE)$(arch_dir)/$(my_installed_module_stem)
ifneq ($(LOCAL_INSTALLED_MODULE),$(my_default_test_module))
# Install into the testcase folder
$(LOCAL_INSTALLED_MODULE) : $(my_default_test_module)
endif
# The module itself.
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_$(suite) := $(patsubst %:$(LOCAL_INSTALLED_MODULE),$(LOCAL_INSTALLED_MODULE):$(LOCAL_INSTALLED_MODULE),\
$(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
$(LOCAL_BUILT_MODULE):$(dir)/$(my_installed_module_stem)))) \
$(eval my_compat_module_arch_dir_$(suite).$(my_register_name) :=) \
$(foreach dir,$(call compatibility_suite_dirs,$(suite),$(arch_dir)),$(eval my_compat_module_arch_dir_$(suite).$(my_register_name) += $(dir))) \
$(eval my_compat_dist_config_$(suite) := ))
ifneq (,$(LOCAL_SOONG_CLASSES_JAR))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_api_map_$(suite) += $(LOCAL_SOONG_CLASSES_JAR)))
endif
# Auto-generate build config.
ifeq (,$(test_config))
ifneq (true,$(is_native))
is_instrumentation_test := true
ifeq (true, $(LOCAL_IS_HOST_MODULE))
is_instrumentation_test := false
endif
# If LOCAL_MODULE_CLASS is not APPS, it's certainly not an instrumentation
# test. However, some packages for test data also have LOCAL_MODULE_CLASS
# set to APPS. These will require flag LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG
# to disable auto-generating test config file.
ifneq (APPS, $(LOCAL_MODULE_CLASS))
is_instrumentation_test := false
endif
endif
# CTS modules can be used for test data, so test config files must be
# explicitly created using AndroidTest.xml
ifeq (,$(filter cts, $(LOCAL_COMPATIBILITY_SUITE)))
ifneq (true, $(LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG))
ifeq (true, $(filter true,$(is_native) $(is_instrumentation_test)))
include $(BUILD_SYSTEM)/autogen_test_config.mk
test_config := $(autogen_test_config_file)
autogen_test_config_file :=
endif
endif
endif
endif
is_instrumentation_test :=
# Currently this flag variable is true only for the `android_test_helper_app` type module
# which should not have any .config file
ifeq (true, $(LOCAL_DISABLE_TEST_CONFIG))
test_config :=
endif
# Make sure we only add the files once for multilib modules.
ifdef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
# Sync the auto_test_config value for multilib modules.
ifdef $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_autogen
ALL_MODULES.$(my_register_name).auto_test_config := true
endif
else
$(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files := true
# LOCAL_COMPATIBILITY_SUPPORT_FILES is a list of [:].
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \
$(eval p := $(subst :,$(space),$(f))) \
$(eval s := $(word 1,$(p))) \
$(eval n := $(or $(word 2,$(p)),$(notdir $(word 1, $(p))))) \
$(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
$(s):$(dir)/$(n)))))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_api_map_$(suite) += $(foreach f, $(LOCAL_COMPATIBILITY_SUPPORT_FILES), \
$(eval p := $(subst :,$(space),$(f))) \
$(eval s := $(word 1,$(p))) \
$(if $(filter %.apk,$(s)) $(filter %.jar,$(s)),$(s),))))
ifneq (,$(test_config))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
$(test_config):$(dir)/$(LOCAL_MODULE).config$(LOCAL_TEST_CONFIG_SUFFIX))))
endif
ifneq (,$(LOCAL_EXTRA_FULL_TEST_CONFIGS))
$(foreach test_config_file, $(LOCAL_EXTRA_FULL_TEST_CONFIGS), \
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
$(test_config_file):$(dir)/$(basename $(notdir $(test_config_file))).config))))
endif
ifneq (,$(wildcard $(LOCAL_PATH)/DynamicConfig.xml))
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_config_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite)), \
$(LOCAL_PATH)/DynamicConfig.xml:$(dir)/$(LOCAL_MODULE).dynamic)))
endif
endif # $(my_prefix)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_compat_files
ifeq ($(use_testcase_folder),true)
ifneq ($(my_test_data_file_pairs),)
# Filter out existng installed test data paths when collecting test data files to be installed and
# indexed as they cause build rule conflicts. Instead put them in a separate list which is only
# used for indexing.
$(foreach pair, $(my_test_data_file_pairs), \
$(eval parts := $(subst :,$(space),$(pair))) \
$(eval src_path := $(word 1,$(parts))) \
$(eval file := $(word 2,$(parts))) \
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
$(call filter-copy-pair,$(src_path),$(call append-path,$(dir),$(file)),$(my_installed_test_data)))) \
$(eval my_compat_dist_test_data_$(suite) += \
$(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
$(filter $(my_installed_test_data),$(call append-path,$(dir),$(file))))) \
$(eval my_compat_api_map_$(suite) += \
$(if $(filter %.apk,$(src_path)) $(filter %.jar,$(src_path)),$(src_path),))))
endif
else
ifneq ($(my_test_data_file_pairs),)
$(foreach pair, $(my_test_data_file_pairs), \
$(eval parts := $(subst :,$(space),$(pair))) \
$(eval src_path := $(word 1,$(parts))) \
$(eval file := $(word 2,$(parts))) \
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_$(suite) += $(foreach dir, $(call compatibility_suite_dirs,$(suite),$(arch_dir)), \
$(src_path):$(call append-path,$(dir),$(file)))) \
$(eval my_compat_api_map_$(suite) += \
$(if $(filter %.apk,$(src_path)) $(filter %.jar,$(src_path)),$(src_path),))))
endif
endif
arch_dir :=
is_native :=
$(call create-suite-dependencies)
$(foreach suite, $(LOCAL_COMPATIBILITY_SUITE), \
$(eval my_compat_dist_config_$(suite) := ) \
$(eval my_compat_dist_test_data_$(suite) := ) \
$(eval my_compat_api_map_$(suite) := ))
endif # LOCAL_UNINSTALLABLE_MODULE
# HACK: pretend a soong LOCAL_FULL_TEST_CONFIG is autogenerated by setting the flag in
# module-info.json
# TODO: (b/113029686) Add explicit flag from Soong to determine if a test was
# autogenerated.
ifneq (,$(filter $(SOONG_OUT_DIR)%,$(LOCAL_FULL_TEST_CONFIG)))
ifeq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
ALL_MODULES.$(my_register_name).auto_test_config := true
endif
endif
endif # LOCAL_COMPATIBILITY_SUITE
my_supported_variant :=
ifeq ($(my_host_cross),true)
my_supported_variant := HOST_CROSS
else
ifdef LOCAL_IS_HOST_MODULE
my_supported_variant := HOST
else
my_supported_variant := DEVICE
endif
endif
###########################################################
## Register with ALL_MODULES
###########################################################
ifndef ALL_MODULES.$(my_register_name).PATH
# These keys are no longer used, they've been replaced by keys that specify
# target/host/host_cross (REQUIRED_FROM_TARGET / REQUIRED_FROM_HOST) and similar.
#
# Marking them obsolete to ensure that anyone using these internal variables looks for
# alternates.
$(KATI_obsolete_var ALL_MODULES.$(my_register_name).REQUIRED)
$(KATI_obsolete_var ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED)
$(KATI_obsolete_var ALL_MODULES.$(my_register_name).HOST_REQUIRED)
$(KATI_obsolete_var ALL_MODULES.$(my_register_name).TARGET_REQUIRED)
endif
ALL_MODULES += $(my_register_name)
# Don't use += on subvars, or else they'll end up being
# recursively expanded.
ALL_MODULES.$(my_register_name).CLASS := \
$(ALL_MODULES.$(my_register_name).CLASS) $(LOCAL_MODULE_CLASS)
ALL_MODULES.$(my_register_name).PATH := \
$(ALL_MODULES.$(my_register_name).PATH) $(LOCAL_PATH)
ALL_MODULES.$(my_register_name).TAGS := \
$(ALL_MODULES.$(my_register_name).TAGS) $(LOCAL_MODULE_TAGS)
ALL_MODULES.$(my_register_name).CHECKED := \
$(ALL_MODULES.$(my_register_name).CHECKED) $(my_checked_module)
ALL_MODULES.$(my_register_name).BUILT := \
$(ALL_MODULES.$(my_register_name).BUILT) $(LOCAL_BUILT_MODULE)
ALL_MODULES.$(my_register_name).SOONG_MODULE_TYPE := \
$(ALL_MODULES.$(my_register_name).SOONG_MODULE_TYPE) $(LOCAL_SOONG_MODULE_TYPE)
ALL_MODULES.$(my_register_name).IS_SOONG_MODULE := \
$(if $(filter $(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK)),true)
ifndef LOCAL_IS_HOST_MODULE
ALL_MODULES.$(my_register_name).TARGET_BUILT := \
$(ALL_MODULES.$(my_register_name).TARGET_BUILT) $(LOCAL_BUILT_MODULE)
endif
ifneq (,$(LOCAL_SOONG_INSTALLED_MODULE))
# Store the list of paths to installed locations of files provided by this
# module. Used as dependencies of the image packaging rules when the module
# is installed by the current product.
ALL_MODULES.$(my_register_name).INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
$(foreach f, $(LOCAL_SOONG_INSTALL_PAIRS),\
$(word 2,$(subst :,$(space),$(f)))) \
$(LOCAL_SOONG_INSTALL_SYMLINKS) \
$(my_init_rc_installed) \
$(my_installed_test_data) \
$(my_vintf_installed))
ALL_MODULES.$(my_register_name).INSTALLED_SYMLINKS := $(LOCAL_SOONG_INSTALL_SYMLINKS)
# Store the list of colon-separated pairs of the built and installed locations
# of files provided by this module. Used by custom packaging rules like
# package-modules.mk that need to copy the built files to a custom install
# location during packaging.
#
# Translate copies from $(LOCAL_PREBUILT_MODULE_FILE) to $(LOCAL_BUILT_MODULE)
# so that package-modules.mk gets any transtive dependencies added to
# $(LOCAL_BUILT_MODULE), for example unstripped symbols files.
ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
$(patsubst $(LOCAL_PREBUILT_MODULE_FILE):%,$(LOCAL_BUILT_MODULE):%,$(LOCAL_SOONG_INSTALL_PAIRS)) \
$(my_init_rc_pairs) \
$(my_test_data_pairs) \
$(my_vintf_pairs))
# Store the list of vintf/init_rc as order-only dependencies
ALL_MODULES.$(my_register_name).ORDERONLY_INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).ORDERONLY_INSTALLED) \
$(my_init_rc_installed) \
$(my_vintf_installed))
else ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ALL_MODULES.$(my_register_name).INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).INSTALLED) \
$(LOCAL_INSTALLED_MODULE) $(my_init_rc_installed) $(my_installed_symlinks) \
$(my_installed_test_data) $(my_vintf_installed))
ALL_MODULES.$(my_register_name).BUILT_INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).BUILT_INSTALLED) \
$(LOCAL_BUILT_MODULE):$(LOCAL_INSTALLED_MODULE) \
$(my_init_rc_pairs) $(my_test_data_pairs) $(my_vintf_pairs))
ALL_MODULES.$(my_register_name).ORDERONLY_INSTALLED := \
$(strip $(ALL_MODULES.$(my_register_name).ORDERONLY_INSTALLED) \
$(my_init_rc_installed) \
$(my_vintf_installed))
endif
# Mark LOCAL_SOONG_INSTALL_SYMLINKS as installed if we're installing any kind of module, not just
# ones that set LOCAL_SOONG_INSTALLED_MODULE. This is so we can have a soong module that only
# installs symlinks (e.g. installed_symlink). We can't set LOCAL_SOONG_INSTALLED_MODULE to a symlink
# because cp commands will fail on symlinks.
ifneq (,$(or $(LOCAL_SOONG_INSTALLED_MODULE),$(call boolean-not,$(LOCAL_UNINSTALLABLE_MODULE))))
ALL_MODULES.$(my_register_name).INSTALLED += $(LOCAL_SOONG_INSTALL_SYMLINKS)
ALL_MODULES.$(my_register_name).INSTALLED_SYMLINKS := $(LOCAL_SOONG_INSTALL_SYMLINKS)
endif
ifdef LOCAL_PICKUP_FILES
# Files or directories ready to pick up by the build system
# when $(LOCAL_BUILT_MODULE) is done.
ALL_MODULES.$(my_register_name).PICKUP_FILES := \
$(ALL_MODULES.$(my_register_name).PICKUP_FILES) $(LOCAL_PICKUP_FILES)
endif
# Record the platform availability of this module. Note that the availability is not
# meaningful for non-installable modules (e.g., static libs) or host modules.
# We only care about modules that are installable to the device.
ifeq (true,$(LOCAL_NOT_AVAILABLE_FOR_PLATFORM))
ifneq (true,$(LOCAL_UNINSTALLABLE_MODULE))
ifndef LOCAL_IS_HOST_MODULE
ALL_MODULES.$(my_register_name).NOT_AVAILABLE_FOR_PLATFORM := true
endif
endif
endif
my_required_modules := $(LOCAL_REQUIRED_MODULES) \
$(LOCAL_REQUIRED_MODULES_$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
ifdef LOCAL_IS_HOST_MODULE
my_required_modules += $(LOCAL_REQUIRED_MODULES_$($(my_prefix)OS))
endif
ifdef LOCAL_ACONFIG_FILES
ALL_MODULES.$(my_register_name).ACONFIG_FILES := \
$(ALL_MODULES.$(my_register_name).ACONFIG_FILES) $(LOCAL_ACONFIG_FILES)
endif
ifdef LOCAL_FILESYSTEM_FILELIST
ALL_MODULES.$(my_register_name).FILESYSTEM_FILELIST := \
$(ALL_MODULES.$(my_register_name).FILESYSTEM_FILELIST) $(LOCAL_FILESYSTEM_FILELIST)
endif
ifndef LOCAL_SOONG_MODULE_INFO_JSON
ALL_MAKE_MODULE_INFO_JSON_MODULES += $(my_register_name)
ALL_MODULES.$(my_register_name).SHARED_LIBS := \
$(ALL_MODULES.$(my_register_name).SHARED_LIBS) $(LOCAL_SHARED_LIBRARIES)
ALL_MODULES.$(my_register_name).STATIC_LIBS := \
$(ALL_MODULES.$(my_register_name).STATIC_LIBS) $(LOCAL_STATIC_LIBRARIES)
ALL_MODULES.$(my_register_name).SYSTEM_SHARED_LIBS := \
$(ALL_MODULES.$(my_register_name).SYSTEM_SHARED_LIBS) $(LOCAL_SYSTEM_SHARED_LIBRARIES)
ALL_MODULES.$(my_register_name).LOCAL_RUNTIME_LIBRARIES := \
$(ALL_MODULES.$(my_register_name).LOCAL_RUNTIME_LIBRARIES) $(LOCAL_RUNTIME_LIBRARIES) \
$(LOCAL_JAVA_LIBRARIES)
ALL_MODULES.$(my_register_name).LOCAL_STATIC_LIBRARIES := \
$(ALL_MODULES.$(my_register_name).LOCAL_STATIC_LIBRARIES) $(LOCAL_STATIC_JAVA_LIBRARIES)
ifneq ($(my_test_data_file_pairs),)
# Export the list of targets that are handled as data inputs and required
# by tests at runtime. The format of my_test_data_file_pairs is
# is $(path):$(relative_file) but for module-info, only the string after
# ":" is needed.
ALL_MODULES.$(my_register_name).TEST_DATA := \
$(strip $(ALL_MODULES.$(my_register_name).TEST_DATA) \
$(foreach f, $(my_test_data_file_pairs),\
$(call word-colon,2,$(f))))
endif
ifdef LOCAL_TEST_DATA_BINS
ALL_MODULES.$(my_register_name).TEST_DATA_BINS := \
$(ALL_MODULES.$(my_register_name).TEST_DATA_BINS) $(LOCAL_TEST_DATA_BINS)
endif
ALL_MODULES.$(my_register_name).SUPPORTED_VARIANTS := \
$(ALL_MODULES.$(my_register_name).SUPPORTED_VARIANTS) \
$(filter-out $(ALL_MODULES.$(my_register_name).SUPPORTED_VARIANTS),$(my_supported_variant))
ALL_MODULES.$(my_register_name).COMPATIBILITY_SUITES := \
$(ALL_MODULES.$(my_register_name).COMPATIBILITY_SUITES) $(LOCAL_COMPATIBILITY_SUITE)
ALL_MODULES.$(my_register_name).MODULE_NAME := $(LOCAL_MODULE)
ALL_MODULES.$(my_register_name).TEST_CONFIG := $(test_config)
ALL_MODULES.$(my_register_name).EXTRA_TEST_CONFIGS := $(LOCAL_EXTRA_FULL_TEST_CONFIGS)
ALL_MODULES.$(my_register_name).TEST_MAINLINE_MODULES := $(LOCAL_TEST_MAINLINE_MODULES)
ifdef LOCAL_IS_UNIT_TEST
ALL_MODULES.$(my_register_name).IS_UNIT_TEST := $(LOCAL_IS_UNIT_TEST)
endif
ifdef LOCAL_TEST_OPTIONS_TAGS
ALL_MODULES.$(my_register_name).TEST_OPTIONS_TAGS := $(LOCAL_TEST_OPTIONS_TAGS)
endif
##########################################################
# Track module-level dependencies.
# (b/204397180) Unlock RECORD_ALL_DEPS was acknowledged reasonable for better Atest performance.
ALL_MODULES.$(my_register_name).ALL_DEPS := \
$(ALL_MODULES.$(my_register_name).ALL_DEPS) \
$(LOCAL_STATIC_LIBRARIES) \
$(LOCAL_WHOLE_STATIC_LIBRARIES) \
$(LOCAL_SHARED_LIBRARIES) \
$(LOCAL_DYLIB_LIBRARIES) \
$(LOCAL_RLIB_LIBRARIES) \
$(LOCAL_PROC_MACRO_LIBRARIES) \
$(LOCAL_HEADER_LIBRARIES) \
$(LOCAL_STATIC_JAVA_LIBRARIES) \
$(LOCAL_JAVA_LIBRARIES) \
$(LOCAL_JNI_SHARED_LIBRARIES)
endif
ALL_MODULES.$(my_register_name).TEST_MODULE_CONFIG_BASE := $(LOCAL_TEST_MODULE_CONFIG_BASE)
##########################################################################
## When compiling against API imported module, use API import stub
## libraries.
##########################################################################
ifneq ($(call module-in-vendor-or-product),)
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
apiimport_postfix := .apiimport
ifeq ($(LOCAL_IN_PRODUCT),true)
apiimport_postfix := .apiimport.product
else
apiimport_postfix := .apiimport.vendor
endif
my_required_modules := $(foreach l,$(my_required_modules), \
$(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
endif
endif
##########################################################################
## When compiling against the VNDK, add the .vendor or .product suffix to
## required modules.
##########################################################################
ifneq ($(call module-in-vendor-or-product),)
#####################################################
## Soong modules may be built three times, once for
## /system, once for /vendor and once for /product.
## If we're using the VNDK, switch all soong
## libraries over to the /vendor or /product variant.
#####################################################
ifneq ($(LOCAL_MODULE_MAKEFILE),$(SOONG_ANDROID_MK))
# We don't do this renaming for soong-defined modules since they already
# have correct names (with .vendor or .product suffix when necessary) in
# their LOCAL_*_LIBRARIES.
ifeq ($(LOCAL_IN_PRODUCT),true)
my_required_modules := $(foreach l,$(my_required_modules),\
$(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
else
my_required_modules := $(foreach l,$(my_required_modules),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
endif
endif
endif
ifdef LOCAL_IS_HOST_MODULE
ifneq ($(my_host_cross),true)
ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST := \
$(strip $(ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST) $(my_required_modules))
ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST := \
$(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST)\
$(my_required_modules))
ALL_MODULES.$(my_register_name).TARGET_REQUIRED_FROM_HOST := \
$(strip $(ALL_MODULES.$(my_register_name).TARGET_REQUIRED_FROM_HOST)\
$(LOCAL_TARGET_REQUIRED_MODULES))
else
ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST_CROSS := \
$(strip $(ALL_MODULES.$(my_register_name).REQUIRED_FROM_HOST_CROSS) $(my_required_modules))
ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST_CROSS := \
$(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_HOST_CROSS)\
$(my_required_modules))
ifdef LOCAL_TARGET_REQUIRED_MODULES
$(call pretty-error,LOCAL_TARGET_REQUIRED_MODULES may not be used from host_cross modules)
endif
endif
ifdef LOCAL_HOST_REQUIRED_MODULES
$(call pretty-error,LOCAL_HOST_REQUIRED_MODULES may not be used from host modules. Use LOCAL_REQUIRED_MODULES instead)
endif
else
ALL_MODULES.$(my_register_name).REQUIRED_FROM_TARGET := \
$(strip $(ALL_MODULES.$(my_register_name).REQUIRED_FROM_TARGET) $(my_required_modules))
ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_TARGET := \
$(strip $(ALL_MODULES.$(my_register_name).EXPLICITLY_REQUIRED_FROM_TARGET)\
$(my_required_modules))
ALL_MODULES.$(my_register_name).HOST_REQUIRED_FROM_TARGET := \
$(strip $(ALL_MODULES.$(my_register_name).HOST_REQUIRED_FROM_TARGET)\
$(LOCAL_HOST_REQUIRED_MODULES))
ifdef LOCAL_TARGET_REQUIRED_MODULES
$(call pretty-error,LOCAL_TARGET_REQUIRED_MODULES may not be used from target modules. Use LOCAL_REQUIRED_MODULES instead)
endif
endif
ifdef event_log_tags
ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS := \
$(ALL_MODULES.$(my_register_name).EVENT_LOG_TAGS) $(event_log_tags)
endif
ALL_MODULES.$(my_register_name).MAKEFILE := \
$(ALL_MODULES.$(my_register_name).MAKEFILE) $(LOCAL_MODULE_MAKEFILE)
ifdef LOCAL_MODULE_OWNER
ALL_MODULES.$(my_register_name).OWNER := \
$(sort $(ALL_MODULES.$(my_register_name).OWNER) $(LOCAL_MODULE_OWNER))
endif
ifdef LOCAL_2ND_ARCH_VAR_PREFIX
ALL_MODULES.$(my_register_name).FOR_2ND_ARCH := true
endif
ALL_MODULES.$(my_register_name).FOR_HOST_CROSS := $(my_host_cross)
ifndef LOCAL_IS_HOST_MODULE
ALL_MODULES.$(my_register_name).APEX_KEYS_FILE := $(LOCAL_APEX_KEY_PATH)
endif
test_config :=
INSTALLABLE_FILES.$(LOCAL_INSTALLED_MODULE).MODULE := $(my_register_name)
###########################################################
## umbrella targets used to verify builds
###########################################################
j_or_n :=
ifneq (,$(filter EXECUTABLES SHARED_LIBRARIES STATIC_LIBRARIES HEADER_LIBRARIES NATIVE_TESTS RLIB_LIBRARIES DYLIB_LIBRARIES PROC_MACRO_LIBRARIES,$(LOCAL_MODULE_CLASS)))
j_or_n := native
else
ifneq (,$(filter JAVA_LIBRARIES APPS,$(LOCAL_MODULE_CLASS)))
j_or_n := java
endif
endif
ifdef LOCAL_IS_HOST_MODULE
h_or_t := host
ifeq ($(my_host_cross),true)
h_or_hc_or_t := host-cross
else
h_or_hc_or_t := host
endif
else
h_or_hc_or_t := target
h_or_t := target
endif
ifdef j_or_n
$(j_or_n) $(h_or_t) $(j_or_n)-$(h_or_hc_or_t) : $(my_checked_module)
ifneq (,$(filter $(LOCAL_MODULE_TAGS),tests))
$(j_or_n)-$(h_or_t)-tests $(j_or_n)-tests $(h_or_t)-tests : $(my_checked_module)
endif
$(LOCAL_MODULE)-$(h_or_hc_or_t) : $(my_all_targets)
.PHONY: $(LOCAL_MODULE)-$(h_or_hc_or_t)
ifeq ($(j_or_n),native)
$(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix) : $(my_all_targets)
.PHONY: $(LOCAL_MODULE)-$(h_or_hc_or_t)$(my_32_64_bit_suffix)
endif
endif
$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=base_rules))
###########################################################
# Ensure privileged applications always have LOCAL_PRIVILEGED_MODULE
###########################################################
ifndef LOCAL_PRIVILEGED_MODULE
ifneq (,$(filter $(TARGET_OUT_APPS_PRIVILEGED)/% $(TARGET_OUT_VENDOR_APPS_PRIVILEGED)/%,$(my_module_path)))
LOCAL_PRIVILEGED_MODULE := true
endif
endif
###########################################################
## NOTICE files
###########################################################
include $(BUILD_NOTICE_FILE)
###########################################################
## SBOM generation
###########################################################
include $(BUILD_SBOM_GEN)
================================================
FILE: core/binary.mk
================================================
###########################################################
## Standard rules for building binary object files from
## asm/c/cpp/yacc/lex/etc source files.
##
## The list of object files is exported in $(all_objects).
###########################################################
#######################################
include $(BUILD_SYSTEM)/base_rules.mk
include $(BUILD_SYSTEM)/use_lld_setup.mk
#######################################
##################################################
# Compute the dependency of the shared libraries
##################################################
# On the target, we compile with -nostdlib, so we must add in the
# default system shared libraries, unless they have requested not
# to by supplying a LOCAL_SYSTEM_SHARED_LIBRARIES value. One would
# supply that, for example, when building libc itself.
ifdef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
ifdef USE_HOST_MUSL
my_system_shared_libraries := libc_musl
else
my_system_shared_libraries :=
endif
else
my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
endif
else
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
my_system_shared_libraries := libc libm libdl
else
my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries))
endif
endif
# Third party code has additional no-override flags.
is_third_party :=
ifneq ($(filter external/% hardware/% vendor/%,$(LOCAL_PATH)),)
is_third_party := true
endif
my_soong_problems :=
# The following LOCAL_ variables will be modified in this file.
# Because the same LOCAL_ variables may be used to define modules for both 1st arch and 2nd arch,
# we can't modify them in place.
my_src_files := $(LOCAL_SRC_FILES)
my_src_files_exclude := $(LOCAL_SRC_FILES_EXCLUDE)
my_static_libraries := $(LOCAL_STATIC_LIBRARIES)
my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES)
my_shared_libraries := $(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES))
my_header_libraries := $(LOCAL_HEADER_LIBRARIES)
my_cflags := $(LOCAL_CFLAGS)
my_conlyflags := $(LOCAL_CONLYFLAGS)
my_cppflags := $(LOCAL_CPPFLAGS)
my_cflags_no_override := $(GLOBAL_CLANG_CFLAGS_NO_OVERRIDE)
my_cppflags_no_override := $(GLOBAL_CLANG_CPPFLAGS_NO_OVERRIDE)
ifeq ($(my_32_64_bit_suffix), 64)
my_cflags_no_override += $(GLOBAL_CLANG_CFLAGS_64_NO_OVERRIDE)
endif
ifdef is_third_party
my_cflags_no_override += $(GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE)
my_cppflags_no_override += $(GLOBAL_CLANG_EXTERNAL_CFLAGS_NO_OVERRIDE)
endif
my_ldflags := $(LOCAL_LDFLAGS)
my_ldlibs := $(LOCAL_LDLIBS)
my_asflags := $(LOCAL_ASFLAGS)
my_cc := $(LOCAL_CC)
my_cc_wrapper := $(CC_WRAPPER)
my_cxx := $(LOCAL_CXX)
my_cxx_link := $(LOCAL_CXX)
my_cxx_ldlibs :=
my_cxx_wrapper := $(CXX_WRAPPER)
my_c_includes := $(LOCAL_C_INCLUDES)
my_generated_sources := $(LOCAL_GENERATED_SOURCES)
my_additional_dependencies := $(LOCAL_ADDITIONAL_DEPENDENCIES)
my_export_c_include_dirs := $(LOCAL_EXPORT_C_INCLUDE_DIRS)
my_export_c_include_deps := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
my_arflags :=
# Disable clang-tidy if it is not found.
ifeq ($(PATH_TO_CLANG_TIDY),)
my_tidy_enabled := false
else
# If LOCAL_TIDY is not defined, use global WITH_TIDY
my_tidy_enabled := $(LOCAL_TIDY)
ifeq ($(my_tidy_enabled),)
my_tidy_enabled := $(WITH_TIDY)
endif
endif
# my_tidy_checks is empty if clang-tidy is disabled.
my_tidy_checks :=
my_tidy_flags :=
ifneq (,$(filter 1 true,$(my_tidy_enabled)))
# Set up global default checks
my_tidy_checks := $(WITH_TIDY_CHECKS)
ifeq ($(my_tidy_checks),)
my_tidy_checks := $(call default_global_tidy_checks,$(LOCAL_PATH))
endif
# Append local clang-tidy checks.
ifneq ($(LOCAL_TIDY_CHECKS),)
my_tidy_checks := $(my_tidy_checks),$(LOCAL_TIDY_CHECKS)
endif
my_tidy_flags := $(strip $(WITH_TIDY_FLAGS) $(LOCAL_TIDY_FLAGS))
# If tidy flags are not specified, default to check all header files.
ifeq ($(my_tidy_flags),)
my_tidy_flags := $(call default_tidy_header_filter,$(LOCAL_PATH))
endif
# If clang-tidy is not enabled globally, add the -quiet flag.
ifeq (,$(filter 1 true,$(WITH_TIDY)))
my_tidy_flags += -quiet -extra-arg-before=-fno-caret-diagnostics
endif
ifneq ($(my_tidy_checks),)
# We might be using the static analyzer through clang-tidy.
# https://bugs.llvm.org/show_bug.cgi?id=32914
my_tidy_flags += -extra-arg-before=-D__clang_analyzer__
# A recent change in clang-tidy (r328258) enabled destructor inlining,
# which appears to cause a number of false positives. Until that's
# resolved, this turns off the effects of r328258.
# https://bugs.llvm.org/show_bug.cgi?id=37459
my_tidy_flags += -extra-arg-before=-Xclang
my_tidy_flags += -extra-arg-before=-analyzer-config
my_tidy_flags += -extra-arg-before=-Xclang
my_tidy_flags += -extra-arg-before=c++-temp-dtor-inlining=false
endif
endif
my_tidy_checks := $(subst $(space),,$(my_tidy_checks))
# Configure the pool to use for clang rules.
# If LOCAL_CC or LOCAL_CXX is set don't use goma or RBE.
# If clang-tidy is being used, don't use the RBE pool (as clang-tidy runs in
# the same action, and is not remoted)
my_pool :=
ifeq (,$(strip $(my_cc))$(strip $(my_cxx))$(strip $(my_tidy_checks)))
my_pool := $(GOMA_OR_RBE_POOL)
endif
ifneq (,$(strip $(foreach dir,$(NATIVE_COVERAGE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
ifeq (,$(strip $(foreach dir,$(NATIVE_COVERAGE_EXCLUDE_PATHS),$(filter $(dir)%,$(LOCAL_PATH)))))
my_native_coverage := true
my_clang_coverage := true
else
my_native_coverage := false
my_clang_coverage := false
endif
else
my_native_coverage := false
my_clang_coverage := false
endif
ifneq ($(NATIVE_COVERAGE),true)
my_native_coverage := false
endif
ifneq ($(CLANG_COVERAGE),true)
my_clang_coverage := false
endif
# Exclude directories from checking allowed manual binder interface lists.
# TODO(b/145621474): Move this check into IInterface.h when clang-tidy no longer uses absolute paths.
ifneq (,$(filter $(addsuffix %,$(ALLOWED_MANUAL_INTERFACE_PATHS)),$(LOCAL_PATH)))
my_cflags += -DDO_NOT_CHECK_MANUAL_BINDER_INTERFACES
endif
my_allow_undefined_symbols := $(strip $(LOCAL_ALLOW_UNDEFINED_SYMBOLS))
ifdef SANITIZE_HOST
ifdef LOCAL_IS_HOST_MODULE
my_allow_undefined_symbols := true
endif
endif
my_ndk_sysroot :=
my_ndk_sysroot_lib :=
my_api_level := 10000
my_arch := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
ifneq ($(LOCAL_SDK_VERSION),)
ifdef LOCAL_IS_HOST_MODULE
$(error $(LOCAL_PATH): LOCAL_SDK_VERSION cannot be used in host module)
endif
# Make sure we've built the NDK.
my_additional_dependencies += $(SOONG_OUT_DIR)/ndk_base.timestamp
my_min_sdk_version := $(MIN_SUPPORTED_SDK_VERSION)
# Historically we've just set up a bunch of symlinks in prebuilts/ndk to map
# missing API levels to existing ones where necessary, but we're not doing
# that for the generated libraries. Clip the API level to the minimum where
# appropriate.
my_ndk_api := $(LOCAL_SDK_VERSION)
ifneq ($(my_ndk_api),current)
my_ndk_api := $(call math_max,$(my_ndk_api),$(my_min_sdk_version))
endif
my_ndk_crt_version := $(my_ndk_api)
ifneq ($(my_ndk_api),current)
my_api_level := $(my_ndk_api)
endif
my_built_ndk := $(SOONG_OUT_DIR)/ndk
my_ndk_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_NDK_TRIPLE)
my_ndk_sysroot := $(my_built_ndk)/sysroot
my_ndk_sysroot_lib := $(my_ndk_sysroot)/usr/lib/$(my_ndk_triple)/$(my_ndk_api)
# The bionic linker now has support for packed relocations and gnu style
# hashes (which are much faster!), but shipping to older devices requires
# the old style hash. Fortunately, we can build with both and it'll work
# anywhere.
my_ldflags += -Wl,--hash-style=both
# We don't want to expose the relocation packer to the NDK just yet.
LOCAL_PACK_MODULE_RELOCATIONS := false
# Set up the NDK stl variant. Starting from NDK-r5 the c++ stl resides in a separate location.
# See ndk/docs/CPLUSPLUS-SUPPORT.html
my_ndk_stl_include_path :=
my_ndk_stl_shared_lib_fullpath :=
my_ndk_stl_static_lib :=
my_cpu_variant := $(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)CPU_ABI)
LOCAL_NDK_STL_VARIANT := $(strip $(LOCAL_NDK_STL_VARIANT))
ifeq (,$(LOCAL_NDK_STL_VARIANT))
LOCAL_NDK_STL_VARIANT := system
endif
ifneq (1,$(words $(filter none system c++_static c++_shared, $(LOCAL_NDK_STL_VARIANT))))
$(error $(LOCAL_PATH): Unknown LOCAL_NDK_STL_VARIANT $(LOCAL_NDK_STL_VARIANT))
endif
ifeq (system,$(LOCAL_NDK_STL_VARIANT))
my_ndk_source_root := \
$(HISTORICAL_NDK_VERSIONS_ROOT)/$(LOCAL_NDK_VERSION)/sources
my_ndk_stl_include_path := $(my_ndk_source_root)/cxx-stl/system/include
my_system_shared_libraries += libstdc++
else ifneq (,$(filter c++_%, $(LOCAL_NDK_STL_VARIANT)))
my_llvm_dir := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)
my_libcxx_arch_dir := $(my_llvm_dir)/android_libc++/ndk/$($(LOCAL_2ND_ARCH_VAR_PREFIX)PREBUILT_LIBCXX_ARCH_DIR)
# Include the target-specific __config_site file followed by the generic libc++ headers.
my_ndk_stl_include_path := $(my_libcxx_arch_dir)/include/c++/v1
my_ndk_stl_include_path += $(my_llvm_dir)/include/c++/v1
my_libcxx_libdir := $(my_libcxx_arch_dir)/lib
ifeq (c++_static,$(LOCAL_NDK_STL_VARIANT))
my_ndk_stl_static_lib := \
$(my_libcxx_libdir)/libc++_static.a \
$(my_libcxx_libdir)/libc++abi.a
else
my_ndk_stl_shared_lib_fullpath := $(my_libcxx_libdir)/libc++_shared.so
endif
my_ndk_stl_static_lib += $($(LOCAL_2ND_ARCH_VAR_PREFIX)TARGET_LIBUNWIND)
my_ldlibs += -ldl
else # LOCAL_NDK_STL_VARIANT must be none
# Do nothing.
endif
# Clang's coverage/profile runtime needs symbols like 'stderr' that were not
# exported from libc prior to API level 23
ifneq ($(my_ndk_api),current)
ifeq ($(call math_lt, $(my_ndk_api),23),true)
my_native_coverage := false
my_clang_coverage := false
endif
endif
endif
ifneq ($(LOCAL_MIN_SDK_VERSION),)
ifdef LOCAL_IS_HOST_MODULE
$(error $(LOCAL_PATH): LOCAL_MIN_SDK_VERSION cannot be used in host module)
endif
my_api_level := $(LOCAL_MIN_SDK_VERSION)
endif
ifeq ($(NATIVE_COVERAGE),true)
ifndef LOCAL_IS_HOST_MODULE
my_ldflags += -Wl,--wrap,getenv
ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
ifeq ($(LOCAL_SDK_VERSION),)
my_whole_static_libraries += libprofile-extras
else
my_whole_static_libraries += libprofile-extras_ndk
endif
endif
endif
endif
ifeq ($(CLANG_COVERAGE),true)
ifndef LOCAL_IS_HOST_MODULE
my_ldflags += $(CLANG_COVERAGE_HOST_LDFLAGS)
ifneq ($(LOCAL_MODULE_CLASS),STATIC_LIBRARIES)
my_whole_static_libraries += libclang_rt.profile
ifeq ($(LOCAL_SDK_VERSION),)
my_whole_static_libraries += libprofile-clang-extras
else
my_whole_static_libraries += libprofile-clang-extras_ndk
endif
endif
endif
ifeq ($(my_clang_coverage),true)
my_profile_instr_generate := $(CLANG_COVERAGE_INSTR_PROFILE)
ifeq ($(CLANG_COVERAGE_CONTINUOUS_MODE),true)
my_cflags += $(CLANG_COVERAGE_CONTINUOUS_FLAGS)
my_ldflags += $(CLANG_COVERAGE_CONTINUOUS_FLAGS)
endif
my_profile_instr_generate += $(CLANG_COVERAGE_CONFIG_COMMFLAGS)
my_cflags += $(CLANG_COVERAGE_INSTR_PROFILE) $(CLANG_COVERAGE_CONFIG_CFLAGS) $(CLANG_COVERAGE_CONFIG_COMMFLAGS)
my_ldflags += $(CLANG_COVERAGE_CONFIG_COMMFLAGS)
ifneq ($(filter hwaddress,$(my_sanitize)),)
my_cflags += $(CLANG_COVERAGE_HWASAN_FLAGS)
my_ldflags += $(CLANG_COVERAGE_HWASAN_FLAGS)
endif
endif
endif
ifneq ($(call module-in-vendor-or-product),)
my_cflags += -D__ANDROID_VNDK__
ifneq ($(LOCAL_IN_VENDOR),)
# Vendor modules have LOCAL_IN_VENDOR
my_cflags += -D__ANDROID_VENDOR__
else ifneq ($(LOCAL_IN_PRODUCT),)
# Product modules have LOCAL_IN_PRODUCT
my_cflags += -D__ANDROID_PRODUCT__
endif
# Define __ANDROID_VENDOR_API__ for both product and vendor variants because
# they both use the same LLNDK libraries.
ifeq ($(BOARD_API_LEVEL),)
# TODO(b/314036847): This is a fallback for UDC targets.
# This must be a build failure when UDC is no longer built from this source tree.
my_cflags += -D__ANDROID_VENDOR_API__=$(PLATFORM_SDK_VERSION)
else
my_cflags += -D__ANDROID_VENDOR_API__=$(BOARD_API_LEVEL)
endif
endif
ifndef LOCAL_IS_HOST_MODULE
# For device libraries, move LOCAL_LDLIBS references to my_shared_libraries. We
# no longer need to use my_ldlibs to pick up NDK prebuilt libraries since we're
# linking my_shared_libraries by full path now.
my_allowed_ldlibs :=
# Sort ldlibs and ldflags between -l and other linker flags
# We'll do this again later, since there are still changes happening, but that's fine.
my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
my_ldlibs := $(filter -l%,$(my_ldlib_flags))
my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
my_ldlib_flags :=
# Move other ldlibs back to shared libraries
my_shared_libraries += $(patsubst -l%,lib%,$(filter-out $(my_allowed_ldlibs),$(my_ldlibs)))
my_ldlibs := $(filter $(my_allowed_ldlibs),$(my_ldlibs))
else # LOCAL_IS_HOST_MODULE
# Add -ldl, -lpthread, -lm and -lrt to host builds to match the default behavior of
# device builds
ifndef USE_HOST_MUSL
my_ldlibs += -ldl -lpthread -lm
ifneq ($(HOST_OS),darwin)
my_ldlibs += -lrt
endif
endif
endif
ifneq ($(LOCAL_SDK_VERSION),)
my_all_ndk_libraries := $(NDK_KNOWN_LIBS)
my_ndk_shared_libraries := \
$(filter $(my_all_ndk_libraries),\
$(my_shared_libraries) $(my_system_shared_libraries))
my_shared_libraries := \
$(filter-out $(my_all_ndk_libraries),$(my_shared_libraries))
my_system_shared_libraries := \
$(filter-out $(my_all_ndk_libraries),$(my_system_shared_libraries))
endif
# MinGW spits out warnings about -fPIC even for -fpie?!) being ignored because
# all code is position independent, and then those warnings get promoted to
# errors.
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
my_cflags += -fPIE
ifndef BUILD_HOST_static
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_ldflags += -pie
endif
endif
else
my_cflags += -fPIC
endif
ifdef LOCAL_IS_HOST_MODULE
my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)OS)) $(LOCAL_SRC_FILES_$($(my_prefix)OS)_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH))
my_static_libraries += $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)OS))
my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)OS))
my_header_libraries += $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)OS))
my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)OS))
my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)OS))
my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)OS))
my_ldlibs += $(LOCAL_LDLIBS_$($(my_prefix)OS))
my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)OS))
my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)OS))
my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)OS))
endif
my_src_files += $(LOCAL_SRC_FILES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_$(my_32_64_bit_suffix))
my_src_files_exclude += $(LOCAL_SRC_FILES_EXCLUDE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SRC_FILES_EXCLUDE_$(my_32_64_bit_suffix))
my_shared_libraries += $(LOCAL_SHARED_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_SHARED_LIBRARIES_$(my_32_64_bit_suffix))
my_cflags += $(LOCAL_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CFLAGS_$(my_32_64_bit_suffix))
my_cppflags += $(LOCAL_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CPPFLAGS_$(my_32_64_bit_suffix))
my_ldflags += $(LOCAL_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_LDFLAGS_$(my_32_64_bit_suffix))
my_asflags += $(LOCAL_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_ASFLAGS_$(my_32_64_bit_suffix))
my_c_includes += $(LOCAL_C_INCLUDES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_C_INCLUDES_$(my_32_64_bit_suffix))
my_generated_sources += $(LOCAL_GENERATED_SOURCES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_GENERATED_SOURCES_$(my_32_64_bit_suffix))
my_missing_exclude_files := $(filter-out $(my_src_files),$(my_src_files_exclude))
ifneq ($(my_missing_exclude_files),)
$(warning Files are listed in LOCAL_SRC_FILES_EXCLUDE but not LOCAL_SRC_FILES)
$(error $(my_missing_exclude_files))
endif
my_src_files := $(filter-out $(my_src_files_exclude),$(my_src_files))
# Strip '/' from the beginning of each src file. This helps the ../ detection in case
# the source file is in the form of /../file
my_src_files := $(patsubst /%,%,$(my_src_files))
my_clang := $(strip $(LOCAL_CLANG))
ifdef LOCAL_CLANG_$(my_32_64_bit_suffix)
my_clang := $(strip $(LOCAL_CLANG_$(my_32_64_bit_suffix)))
endif
ifdef LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
my_clang := $(strip $(LOCAL_CLANG_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)))
endif
ifeq ($(my_clang),false)
$(call pretty-error,LOCAL_CLANG false is no longer supported)
endif
ifeq ($(LOCAL_C_STD),)
my_c_std_version := $(DEFAULT_C_STD_VERSION)
else ifeq ($(LOCAL_C_STD),experimental)
my_c_std_version := $(EXPERIMENTAL_C_STD_VERSION)
else
my_c_std_version := $(LOCAL_C_STD)
endif
ifeq ($(LOCAL_CPP_STD),)
my_cpp_std_version := $(DEFAULT_CPP_STD_VERSION)
else ifeq ($(LOCAL_CPP_STD),experimental)
my_cpp_std_version := $(EXPERIMENTAL_CPP_STD_VERSION)
else
my_cpp_std_version := $(LOCAL_CPP_STD)
endif
my_c_std_conlyflags :=
my_cpp_std_cppflags :=
ifneq (,$(my_c_std_version))
my_c_std_conlyflags := -std=$(my_c_std_version)
endif
ifneq (,$(my_cpp_std_version))
my_cpp_std_cppflags := -std=$(my_cpp_std_version)
endif
# Extra cflags for projects under external/ directory
ifneq ($(filter external/%,$(LOCAL_PATH)),)
my_cflags += $(CLANG_EXTERNAL_CFLAGS)
endif
# Extra cflags for projects under hardware/ directory.
# This should match the definition of `thirdPartyDirPrefixExceptions`
# in build/soong/android/paths.go.
# Get the second element of LOCAL_PATH
ifneq ($(filter hardware/%,$(LOCAL_PATH)),)
my_subdir := $(word 2,$(subst /,$(space),$(LOCAL_PATH)))
must_compile_hardware_subdirs := \
hardware/google/% \
hardware/interfaces/% \
hardware/libhardware/% \
hardware/libhardware_legacy/% \
hardware/ril/%
ifeq ($(filter $(must_compile_hardware_subdirs),$(my_subdir)),)
my_cflags += $(CLANG_EXTERNAL_CFLAGS)
endif
endif
# Extra cflags for projects under vendor/ directory.
# This should match the definition of `thirdPartyDirPrefixExceptions`
# in build/soong/android/paths.go.
ifneq ($(filter vendor/%,$(LOCAL_PATH)),)
my_subdir := $(word 2,$(subst /,$(space),$(LOCAL_PATH)))
# Do not add the flags for any subdir that contains the string "google".
ifneq ($(findstring google,$(my_subdir)),)
my_cflags += $(CLANG_EXTERNAL_CFLAGS)
endif
endif
# arch-specific static libraries go first so that generic ones can depend on them
my_static_libraries := $(LOCAL_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_static_libraries)
my_whole_static_libraries := $(LOCAL_WHOLE_STATIC_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_WHOLE_STATIC_LIBRARIES_$(my_32_64_bit_suffix)) $(my_whole_static_libraries)
my_header_libraries := $(LOCAL_HEADER_LIBRARIES_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_HEADER_LIBRARIES_$(my_32_64_bit_suffix)) $(my_header_libraries)
include $(BUILD_SYSTEM)/cxx_stl_setup.mk
ifneq ($(strip $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)),)
my_linker := $(CUSTOM_$(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)LINKER)
else
my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LINKER)
endif
include $(BUILD_SYSTEM)/config_sanitizers.mk
ifneq ($(filter ../%,$(my_src_files)),)
my_soong_problems += dotdot_srcs
endif
ifneq ($(foreach i,$(my_c_includes),$(filter %/..,$(i))$(findstring /../,$(i))),)
my_soong_problems += dotdot_incs
endif
###########################################################
## Explicitly declare assembly-only __ASSEMBLY__ macro for
## assembly source
###########################################################
my_asflags += -D__ASSEMBLY__
###########################################################
# TODO: support a mix of standard extensions so that this isn't necessary
LOCAL_CPP_EXTENSION := $(strip $(LOCAL_CPP_EXTENSION))
ifeq ($(LOCAL_CPP_EXTENSION),)
LOCAL_CPP_EXTENSION := .cpp
endif
# Certain modules like libdl have to have symbols resolved at runtime and blow
# up if --no-undefined is passed to the linker.
ifeq ($(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS)),)
ifeq ($(my_allow_undefined_symbols),)
ifneq ($(HOST_OS),darwin)
my_ldflags += -Wl,--no-undefined
endif
else
ifdef LOCAL_IS_HOST_MODULE
ifeq ($(HOST_OS),darwin)
# darwin defaults to treating undefined symbols as errors
my_ldflags += -Wl,-undefined,dynamic_lookup
endif
endif
endif
endif
ifeq (true,$(LOCAL_GROUP_STATIC_LIBRARIES))
$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES := true
else
$(LOCAL_BUILT_MODULE): PRIVATE_GROUP_STATIC_LIBRARIES :=
endif
###########################################################
## Define arm-vs-thumb-mode flags.
###########################################################
LOCAL_ARM_MODE := $(strip $(LOCAL_ARM_MODE))
ifeq ($($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH),arm)
normal_objects_mode := $(if $(LOCAL_ARM_MODE),$(LOCAL_ARM_MODE),thumb)
# Read the values from something like TARGET_arm_CFLAGS or
# TARGET_thumb_CFLAGS. HOST_(arm|thumb)_CFLAGS values aren't
# actually used (although they are usually empty).
normal_objects_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)$(normal_objects_mode)_CFLAGS)
else
normal_objects_mode :=
normal_objects_cflags :=
endif
###########################################################
## Define per-module debugging flags. Users can turn on
## debugging for a particular module by setting DEBUG_MODULE_ModuleName
## to a non-empty value in their environment or buildspec.mk,
## and setting HOST_/TARGET_CUSTOM_DEBUG_CFLAGS to the
## debug flags that they want to use.
###########################################################
ifdef DEBUG_MODULE_$(strip $(LOCAL_MODULE))
debug_cflags := $($(my_prefix)CUSTOM_DEBUG_CFLAGS)
else
debug_cflags :=
endif
####################################################
## Keep track of src -> obj mapping
####################################################
my_tracked_gen_files :=
my_tracked_src_files :=
###########################################################
## Stuff source generated from one-off tools
###########################################################
$(my_generated_sources): PRIVATE_MODULE := $(my_register_name)
my_gen_sources_copy := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(filter $(generated_sources_dir)/%,$(my_generated_sources)))
$(my_gen_sources_copy): $(intermediates)/% : $(generated_sources_dir)/%
@echo "Copy: $@"
$(copy-file-to-target)
my_generated_sources := $(patsubst $(generated_sources_dir)/%,$(intermediates)/%,$(my_generated_sources))
# Generated sources that will actually produce object files.
# Other files (like headers) are allowed in LOCAL_GENERATED_SOURCES,
# since other compiled sources may depend on them, and we set up
# the dependencies.
my_gen_src_files := $(filter %.c %$(LOCAL_CPP_EXTENSION) %.S %.s,$(my_generated_sources))
####################################################
## Compile RenderScript with reflected C++
####################################################
renderscript_sources := $(filter %.rscript %.fs,$(my_src_files))
ifneq (,$(renderscript_sources))
my_soong_problems += rs
renderscript_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(renderscript_sources))
RenderScript_file_stamp := $(intermediates)/RenderScriptCPP.stamp
renderscript_intermediate := $(intermediates)/renderscript
renderscript_target_api :=
ifneq (,$(LOCAL_RENDERSCRIPT_TARGET_API))
renderscript_target_api := $(LOCAL_RENDERSCRIPT_TARGET_API)
else
ifneq (,$(LOCAL_SDK_VERSION))
# Set target-api for LOCAL_SDK_VERSIONs other than current.
ifneq (,$(filter-out current system_current test_current, $(LOCAL_SDK_VERSION)))
renderscript_target_api := $(call get-numeric-sdk-version,$(LOCAL_SDK_VERSION))
endif
endif # LOCAL_SDK_VERSION is set
endif # LOCAL_RENDERSCRIPT_TARGET_API is set
ifeq ($(LOCAL_RENDERSCRIPT_CC),)
LOCAL_RENDERSCRIPT_CC := $(LLVM_RS_CC)
endif
# Turn on all warnings and warnings as errors for RS compiles.
# This can be disabled with LOCAL_RENDERSCRIPT_FLAGS := -Wno-error
renderscript_flags := -Wall -Werror
renderscript_flags += $(LOCAL_RENDERSCRIPT_FLAGS)
# -m32 or -m64
renderscript_flags += -m$(my_32_64_bit_suffix)
renderscript_includes := \
$(TOPDIR)external/clang/lib/Headers \
$(TOPDIR)frameworks/rs/script_api/include \
$(LOCAL_RENDERSCRIPT_INCLUDES)
ifneq ($(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE),)
renderscript_includes := $(LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE)
endif
bc_dep_files := $(addprefix $(renderscript_intermediate)/, \
$(patsubst %.fs,%.d, $(patsubst %.rscript,%.d, $(notdir $(renderscript_sources)))))
$(RenderScript_file_stamp): PRIVATE_RS_INCLUDES := $(renderscript_includes)
$(RenderScript_file_stamp): PRIVATE_RS_CC := $(LOCAL_RENDERSCRIPT_CC)
$(RenderScript_file_stamp): PRIVATE_RS_FLAGS := $(renderscript_flags)
$(RenderScript_file_stamp): PRIVATE_RS_SOURCE_FILES := $(renderscript_sources_fullpath)
$(RenderScript_file_stamp): PRIVATE_RS_OUTPUT_DIR := $(renderscript_intermediate)
$(RenderScript_file_stamp): PRIVATE_RS_TARGET_API := $(patsubst current,0,$(renderscript_target_api))
$(RenderScript_file_stamp): PRIVATE_DEP_FILES := $(bc_dep_files)
$(RenderScript_file_stamp): $(renderscript_sources_fullpath) $(LOCAL_RENDERSCRIPT_CC)
$(transform-renderscripts-to-cpp-and-bc)
# include the dependency files (.d) generated by llvm-rs-cc.
$(call include-depfile,$(RenderScript_file_stamp).d,$(RenderScript_file_stamp))
LOCAL_INTERMEDIATE_TARGETS += $(RenderScript_file_stamp)
rs_generated_cpps := $(addprefix \
$(renderscript_intermediate)/ScriptC_,$(patsubst %.fs,%.cpp, $(patsubst %.rscript,%.cpp, \
$(notdir $(renderscript_sources)))))
$(call track-src-file-gen,$(renderscript_sources),$(rs_generated_cpps))
# This is just a no-op rule to make sure gmake doesn't skip updating the dependents.
$(rs_generated_cpps) : $(RenderScript_file_stamp)
@echo "Updated RS generated cpp file $@."
$(hide) touch $@
my_c_includes += $(renderscript_intermediate)
my_generated_sources += $(rs_generated_cpps)
endif
###########################################################
## Compile the .proto files to .cc (or .c) and then to .o
###########################################################
ifeq ($(strip $(LOCAL_PROTOC_OPTIMIZE_TYPE)),)
LOCAL_PROTOC_OPTIMIZE_TYPE := lite
endif
proto_sources := $(filter %.proto,$(my_src_files))
ifneq ($(proto_sources),)
proto_gen_dir := $(generated_sources_dir)/proto
proto_sources_fullpath := $(addprefix $(LOCAL_PATH)/, $(proto_sources))
my_rename_cpp_ext :=
ifneq (,$(filter nanopb-c nanopb-c-enable_malloc nanopb-c-16bit nanopb-c-enable_malloc-16bit nanopb-c-32bit nanopb-c-enable_malloc-32bit, $(LOCAL_PROTOC_OPTIMIZE_TYPE)))
my_proto_source_suffix := .c
my_proto_c_includes := external/nanopb-c
my_protoc_flags := --nanopb_out=$(proto_gen_dir) \
--plugin=$(HOST_OUT_EXECUTABLES)/protoc-gen-nanopb
my_protoc_deps := $(NANOPB_SRCS) $(proto_sources_fullpath:%.proto=%.options)
else
my_proto_source_suffix := $(LOCAL_CPP_EXTENSION)
ifneq ($(my_proto_source_suffix),.cc)
# aprotoc is hardcoded to write out only .cc file.
# We need to rename the extension to $(LOCAL_CPP_EXTENSION) if it's not .cc.
my_rename_cpp_ext := true
endif
my_proto_c_includes := external/protobuf/src
my_cflags += -DGOOGLE_PROTOBUF_NO_RTTI
my_protoc_flags := --cpp_out=$(if $(filter lite lite-static,$(LOCAL_PROTOC_OPTIMIZE_TYPE)),lite:,)$(proto_gen_dir)
my_protoc_deps :=
endif
my_proto_c_includes += $(proto_gen_dir)
proto_generated_cpps := $(addprefix $(proto_gen_dir)/, \
$(patsubst %.proto,%.pb$(my_proto_source_suffix),$(proto_sources_fullpath)))
# Ensure the transform-proto-to-cc rule is only defined once in multilib build.
ifndef $(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined
$(proto_generated_cpps): PRIVATE_PROTO_INCLUDES := $(TOP)
$(proto_generated_cpps): PRIVATE_PROTOC_FLAGS := $(LOCAL_PROTOC_FLAGS) $(my_protoc_flags)
$(proto_generated_cpps): PRIVATE_RENAME_CPP_EXT := $(my_rename_cpp_ext)
$(proto_generated_cpps): $(proto_gen_dir)/%.pb$(my_proto_source_suffix): %.proto $(my_protoc_deps) $(PROTOC)
$(transform-proto-to-cc)
$(my_host)$(LOCAL_MODULE_CLASS)_$(LOCAL_MODULE)_proto_defined := true
endif
# Ideally we can generate the source directly into $(intermediates).
# But many Android.mks assume the .pb.hs are in $(generated_sources_dir).
# As a workaround, we make a copy in the $(intermediates).
proto_intermediate_dir := $(intermediates)/proto
proto_intermediate_cpps := $(patsubst $(proto_gen_dir)/%,$(proto_intermediate_dir)/%,\
$(proto_generated_cpps))
$(proto_intermediate_cpps) : $(proto_intermediate_dir)/% : $(proto_gen_dir)/%
@echo "Copy: $@"
$(copy-file-to-target)
$(hide) cp $(basename $<).h $(basename $@).h
$(call track-src-file-gen,$(proto_sources),$(proto_intermediate_cpps))
my_generated_sources += $(proto_intermediate_cpps)
my_c_includes += $(my_proto_c_includes)
# Auto-export the generated proto source dir.
my_export_c_include_dirs += $(my_proto_c_includes)
ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc)
my_static_libraries += libprotobuf-c-nano-enable_malloc
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c)
my_static_libraries += libprotobuf-c-nano
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc-16bit)
my_static_libraries += libprotobuf-c-nano-enable_malloc-16bit
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-16bit)
my_static_libraries += libprotobuf-c-nano-16bit
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-enable_malloc-32bit)
my_static_libraries += libprotobuf-c-nano-enable_malloc-32bit
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),nanopb-c-32bit)
my_static_libraries += libprotobuf-c-nano-32bit
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),full)
ifdef LOCAL_SDK_VERSION
my_static_libraries += libprotobuf-cpp-full-ndk
else
my_shared_libraries += libprotobuf-cpp-full
endif
else ifeq ($(LOCAL_PROTOC_OPTIMIZE_TYPE),lite-static)
my_static_libraries += libprotobuf-cpp-lite
else
ifdef LOCAL_SDK_VERSION
my_static_libraries += libprotobuf-cpp-lite-ndk
else
my_shared_libraries += libprotobuf-cpp-lite
endif
endif
endif # $(proto_sources) non-empty
###########################################################
## AIDL: Compile .aidl files to .cpp and .h files
###########################################################
aidl_src := $(strip $(filter %.aidl,$(my_src_files)))
aidl_gen_cpp :=
ifneq ($(aidl_src),)
# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
aidl_gen_cpp_root := $(intermediates)/aidl-generated/src
aidl_gen_include_root := $(intermediates)/aidl-generated/include
# Multi-architecture builds have distinct intermediates directories.
# Thus we'll actually generate source for each architecture.
$(foreach s,$(aidl_src),\
$(eval $(call define-aidl-cpp-rule,$(s),$(aidl_gen_cpp_root),aidl_gen_cpp)))
$(foreach cpp,$(aidl_gen_cpp), \
$(call include-depfile,$(addsuffix .aidl.d,$(basename $(cpp))),$(cpp)))
$(call track-src-file-gen,$(aidl_src),$(aidl_gen_cpp))
$(aidl_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
$(aidl_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(aidl_gen_include_root)
$(aidl_gen_cpp) : PRIVATE_AIDL_FLAGS := $(addprefix -I,$(LOCAL_AIDL_INCLUDES))
# Add generated headers to include paths.
my_c_includes += $(aidl_gen_include_root)
my_export_c_include_dirs += $(aidl_gen_include_root)
# Pick up the generated C++ files later for transformation to .o files.
my_generated_sources += $(aidl_gen_cpp)
endif # $(aidl_src) non-empty
###########################################################
## Compile the .vts files to .cc (or .c) and then to .o
###########################################################
vts_src := $(strip $(filter %.vts,$(my_src_files)))
vts_gen_cpp :=
ifneq ($(vts_src),)
my_soong_problems += vts
# Use the intermediates directory to avoid writing our own .cpp -> .o rules.
vts_gen_cpp_root := $(intermediates)/vts-generated/src
vts_gen_include_root := $(intermediates)/vts-generated/include
# Multi-architecture builds have distinct intermediates directories.
# Thus we'll actually generate source for each architecture.
$(foreach s,$(vts_src),\
$(eval $(call define-vts-cpp-rule,$(s),$(vts_gen_cpp_root),vts_gen_cpp)))
$(call track-src-file-gen,$(vts_src),$(vts_gen_cpp))
$(vts_gen_cpp) : PRIVATE_MODULE := $(LOCAL_MODULE)
$(vts_gen_cpp) : PRIVATE_HEADER_OUTPUT_DIR := $(vts_gen_include_root)
$(vts_gen_cpp) : PRIVATE_VTS_FLAGS := $(addprefix -I,$(LOCAL_VTS_INCLUDES)) $(addprefix -m,$(LOCAL_VTS_MODE))
# Add generated headers to include paths.
my_c_includes += $(vts_gen_include_root)
my_export_c_include_dirs += $(vts_gen_include_root)
# Pick up the generated C++ files later for transformation to .o files.
my_generated_sources += $(vts_gen_cpp)
endif # $(vts_src) non-empty
###########################################################
## YACC: Compile .y/.yy files to .c/.cpp and then to .o.
###########################################################
y_yacc_sources := $(filter %.y,$(my_src_files))
y_yacc_cs := $(addprefix \
$(intermediates)/,$(y_yacc_sources:.y=.c))
ifneq ($(y_yacc_cs),)
$(y_yacc_cs): $(intermediates)/%.c: \
$(TOPDIR)$(LOCAL_PATH)/%.y $(BISON) $(BISON_DATA) $(M4) \
$(my_additional_dependencies)
$(call transform-y-to-c-or-cpp)
$(call track-src-file-gen,$(y_yacc_sources),$(y_yacc_cs))
my_generated_sources += $(y_yacc_cs)
endif
yy_yacc_sources := $(filter %.yy,$(my_src_files))
yy_yacc_cpps := $(addprefix \
$(intermediates)/,$(yy_yacc_sources:.yy=$(LOCAL_CPP_EXTENSION)))
ifneq ($(yy_yacc_cpps),)
$(yy_yacc_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
$(TOPDIR)$(LOCAL_PATH)/%.yy $(BISON) $(BISON_DATA) $(M4) \
$(my_additional_dependencies)
$(call transform-y-to-c-or-cpp)
$(call track-src-file-gen,$(yy_yacc_sources),$(yy_yacc_cpps))
my_generated_sources += $(yy_yacc_cpps)
endif
###########################################################
## LEX: Compile .l/.ll files to .c/.cpp and then to .o.
###########################################################
l_lex_sources := $(filter %.l,$(my_src_files))
l_lex_cs := $(addprefix \
$(intermediates)/,$(l_lex_sources:.l=.c))
ifneq ($(l_lex_cs),)
$(l_lex_cs): $(LEX) $(M4)
$(l_lex_cs): $(intermediates)/%.c: \
$(TOPDIR)$(LOCAL_PATH)/%.l
$(transform-l-to-c-or-cpp)
$(call track-src-file-gen,$(l_lex_sources),$(l_lex_cs))
my_generated_sources += $(l_lex_cs)
endif
ll_lex_sources := $(filter %.ll,$(my_src_files))
ll_lex_cpps := $(addprefix \
$(intermediates)/,$(ll_lex_sources:.ll=$(LOCAL_CPP_EXTENSION)))
ifneq ($(ll_lex_cpps),)
$(ll_lex_cpps): $(LEX) $(M4)
$(ll_lex_cpps): $(intermediates)/%$(LOCAL_CPP_EXTENSION): \
$(TOPDIR)$(LOCAL_PATH)/%.ll
$(transform-l-to-c-or-cpp)
$(call track-src-file-gen,$(ll_lex_sources),$(ll_lex_cpps))
my_generated_sources += $(ll_lex_cpps)
endif
###########################################################
## C++: Compile .cpp files to .o.
###########################################################
ifneq ($(filter %$(LOCAL_CPP_EXTENSION).arm,$(my_src_files)),)
$(call pretty-error,Files ending in $(LOCAL_CPP_EXTENSION).arm are deprecated. See $(CHANGES_URL)#file_arm)
endif
dotdot_sources := $(filter ../%$(LOCAL_CPP_EXTENSION),$(my_src_files))
dotdot_objects :=
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-cpp-file,$(s),\
$(my_additional_dependencies),\
dotdot_objects,\
$(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
cpp_normal_sources := $(filter-out ../%,$(filter %$(LOCAL_CPP_EXTENSION),$(my_src_files)))
cpp_objects := $(addprefix $(intermediates)/,$(cpp_normal_sources:$(LOCAL_CPP_EXTENSION)=.o))
$(call track-src-file-obj,$(cpp_normal_sources),$(cpp_objects))
$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(dotdot_objects) $(cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
ifneq ($(strip $(cpp_objects)),)
$(cpp_objects): .KATI_NINJA_POOL := $(my_pool)
$(cpp_objects): $(intermediates)/%.o: \
$(TOPDIR)$(LOCAL_PATH)/%$(LOCAL_CPP_EXTENSION) \
$(my_additional_dependencies) $(CLANG_CXX)
$(transform-$(PRIVATE_HOST)cpp-to-o)
$(call include-depfiles-for-objs, $(cpp_objects))
endif
cpp_objects += $(dotdot_objects)
###########################################################
## C++: Compile generated .cpp files to .o.
###########################################################
gen_cpp_sources := $(filter %$(LOCAL_CPP_EXTENSION),$(my_generated_sources))
gen_cpp_objects := $(gen_cpp_sources:%$(LOCAL_CPP_EXTENSION)=%.o)
$(call track-gen-file-obj,$(gen_cpp_sources),$(gen_cpp_objects))
ifneq ($(strip $(gen_cpp_objects)),)
# Compile all generated files as thumb.
$(gen_cpp_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_cpp_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(gen_cpp_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
$(gen_cpp_objects): $(intermediates)/%.o: \
$(intermediates)/%$(LOCAL_CPP_EXTENSION) \
$(my_additional_dependencies) $(CLANG_CXX)
$(transform-$(PRIVATE_HOST)cpp-to-o)
$(call include-depfiles-for-objs, $(gen_cpp_objects))
endif
###########################################################
## S: Compile generated .S and .s files to .o.
###########################################################
gen_S_sources := $(filter %.S,$(my_generated_sources))
gen_S_objects := $(gen_S_sources:%.S=%.o)
$(call track-gen-file-obj,$(gen_S_sources),$(gen_S_objects))
ifneq ($(strip $(gen_S_sources)),)
$(gen_S_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_S_objects): $(intermediates)/%.o: $(intermediates)/%.S \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
$(call include-depfiles-for-objs, $(gen_S_objects))
endif
gen_s_sources := $(filter %.s,$(my_generated_sources))
gen_s_objects := $(gen_s_sources:%.s=%.o)
$(call track-gen-file-obj,$(gen_s_sources),$(gen_s_objects))
ifneq ($(strip $(gen_s_objects)),)
$(gen_s_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_s_objects): $(intermediates)/%.o: $(intermediates)/%.s \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
endif
gen_asm_objects := $(gen_S_objects) $(gen_s_objects)
$(gen_asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
###########################################################
## o: Include generated .o files in output.
###########################################################
gen_o_objects := $(filter %.o,$(my_generated_sources))
###########################################################
## C: Compile .c files to .o.
###########################################################
ifneq ($(filter %.c.arm,$(my_src_files)),)
$(call pretty-error,Files ending in .c.arm are deprecated. See $(CHANGES_URL)#file_arm)
endif
dotdot_sources := $(filter ../%.c, $(my_src_files))
dotdot_objects :=
$(foreach s, $(dotdot_sources),\
$(eval $(call compile-dotdot-c-file,$(s),\
$(my_additional_dependencies),\
dotdot_objects,\
$(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects))
c_normal_sources := $(filter-out ../%,$(filter %.c,$(my_src_files)))
c_objects := $(addprefix $(intermediates)/,$(c_normal_sources:.c=.o))
$(call track-src-file-obj,$(c_normal_sources),$(c_objects))
$(dotdot_objects) $(c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(dotdot_objects) $(c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
ifneq ($(strip $(c_objects)),)
$(c_objects): .KATI_NINJA_POOL := $(my_pool)
$(c_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.c \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)c-to-o)
$(call include-depfiles-for-objs, $(c_objects))
endif
c_objects += $(dotdot_objects)
###########################################################
## C: Compile generated .c files to .o.
###########################################################
gen_c_sources := $(filter %.c,$(my_generated_sources))
gen_c_objects := $(gen_c_sources:%.c=%.o)
$(call track-gen-file-obj,$(gen_c_sources),$(gen_c_objects))
ifneq ($(strip $(gen_c_objects)),)
# Compile all generated files as thumb.
$(gen_c_objects): .KATI_NINJA_POOL := $(my_pool)
$(gen_c_objects): PRIVATE_ARM_MODE := $(normal_objects_mode)
$(gen_c_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
$(gen_c_objects): $(intermediates)/%.o: $(intermediates)/%.c \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)c-to-o)
$(call include-depfiles-for-objs, $(gen_c_objects))
endif
###########################################################
## ObjC: Compile .m files to .o
###########################################################
objc_sources := $(filter %.m,$(my_src_files))
objc_objects := $(addprefix $(intermediates)/,$(objc_sources:.m=.o))
$(call track-src-file-obj,$(objc_sources),$(objc_objects))
ifneq ($(strip $(objc_objects)),)
my_soong_problems += objc
$(objc_objects): .KATI_NINJA_POOL := $(my_pool)
$(objc_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.m \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)m-to-o)
$(call include-depfiles-for-objs, $(objc_objects))
endif
###########################################################
## ObjC++: Compile .mm files to .o
###########################################################
objcpp_sources := $(filter %.mm,$(my_src_files))
objcpp_objects := $(addprefix $(intermediates)/,$(objcpp_sources:.mm=.o))
$(call track-src-file-obj,$(objcpp_sources),$(objcpp_objects))
ifneq ($(strip $(objcpp_objects)),)
$(objcpp_objects): .KATI_NINJA_POOL := $(my_pool)
$(objcpp_objects): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.mm \
$(my_additional_dependencies) $(CLANG_CXX)
$(transform-$(PRIVATE_HOST)mm-to-o)
$(call include-depfiles-for-objs, $(objcpp_objects))
endif
###########################################################
## AS: Compile .S files to .o.
###########################################################
asm_sources_S := $(filter %.S,$(my_src_files))
dotdot_sources := $(filter ../%,$(asm_sources_S))
asm_sources_S := $(filter-out ../%,$(asm_sources_S))
asm_objects_S := $(addprefix $(intermediates)/,$(asm_sources_S:.S=.o))
$(call track-src-file-obj,$(asm_sources_S),$(asm_objects_S))
dotdot_objects_S :=
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-s-file,$(s),\
$(my_additional_dependencies),\
dotdot_objects_S,\
$(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_S))
ifneq ($(strip $(asm_objects_S)),)
$(asm_objects_S): .KATI_NINJA_POOL := $(my_pool)
$(asm_objects_S): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.S \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
$(call include-depfiles-for-objs, $(asm_objects_S))
endif
asm_sources_s := $(filter %.s,$(my_src_files))
dotdot_sources := $(filter ../%,$(asm_sources_s))
asm_sources_s := $(filter-out ../%,$(asm_sources_s))
asm_objects_s := $(addprefix $(intermediates)/,$(asm_sources_s:.s=.o))
$(call track-src-file-obj,$(asm_sources_s),$(asm_objects_s))
dotdot_objects_s :=
$(foreach s,$(dotdot_sources),\
$(eval $(call compile-dotdot-s-file-no-deps,$(s),\
$(my_additional_dependencies),\
dotdot_objects_s,\
$(my_pool))))
$(call track-src-file-obj,$(dotdot_sources),$(dotdot_objects_s))
ifneq ($(strip $(asm_objects_s)),)
$(asm_objects_s): .KATI_NINJA_POOL := $(my_pool)
$(asm_objects_s): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.s \
$(my_additional_dependencies) $(CLANG)
$(transform-$(PRIVATE_HOST)s-to-o)
endif
asm_objects := $(dotdot_objects_S) $(dotdot_objects_s) $(asm_objects_S) $(asm_objects_s)
$(asm_objects): PRIVATE_ARM_CFLAGS := $(normal_objects_cflags)
# .asm for x86/x86_64 needs to be compiled with yasm.
asm_sources_asm := $(filter %.asm,$(my_src_files))
ifneq ($(strip $(asm_sources_asm)),)
asm_objects_asm := $(addprefix $(intermediates)/,$(asm_sources_asm:.asm=.o))
$(asm_objects_asm): $(intermediates)/%.o: $(TOPDIR)$(LOCAL_PATH)/%.asm \
$(my_additional_dependencies) $(YASM)
$(transform-asm-to-o)
$(call track-src-file-obj,$(asm_sources_asm),$(asm_objects_asm))
asm_objects += $(asm_objects_asm)
endif
###################################################################
## Convert to sanitized names where they exist.
## These lists come from sanitizerStaticLibsMap; see
## build/soong/cc/sanitize.go
##
## $(1): list of static dependencies
## $(2): name of sanitizer (e.g. cfi, hwasan)
##################################################################
define use_soong_sanitized_static_libraries
$(foreach lib,$(1),$(if $(filter $(lib),\
$(SOONG_$(2)_$(my_image_variant)_$(my_arch)_STATIC_LIBRARIES)),\
$(lib).$(2),$(lib)))
endef
###################################################################
## When compiling a CFI enabled target, use the .cfi variant of any
## static dependencies (where they exist).
##################################################################
ifneq ($(filter cfi,$(my_sanitize)),)
my_whole_static_libraries := $(call use_soong_sanitized_static_libraries,\
$(my_whole_static_libraries),cfi)
my_static_libraries := $(call use_soong_sanitized_static_libraries,\
$(my_static_libraries),cfi)
endif
###################################################################
## When compiling a hwasan enabled target, use the .hwasan variant
## of any static dependencies (where they exist).
##################################################################
ifneq ($(filter hwaddress,$(my_sanitize)),)
my_whole_static_libraries := $(call use_soong_sanitized_static_libraries,\
$(my_whole_static_libraries),hwasan)
my_static_libraries := $(call use_soong_sanitized_static_libraries,\
$(my_static_libraries),hwasan)
endif
###################################################################
## When compiling a memtag_stack enabled target, use the .memtag_stack variant
## of any static dependencies (where they exist).
##################################################################
ifneq ($(filter memtag_stack,$(my_sanitize)),)
my_whole_static_libraries := $(call use_soong_sanitized_static_libraries,\
$(my_whole_static_libraries),memtag_stack)
my_static_libraries := $(call use_soong_sanitized_static_libraries,\
$(my_static_libraries),memtag_stack)
endif
###################################################################
## When compiling against API imported module, use API import stub
## libraries.
##################################################################
apiimport_postfix := .apiimport
ifneq ($(call module-in-vendor-or-product),)
ifeq ($(LOCAL_IN_PRODUCT),true)
apiimport_postfix := .apiimport.product
else
apiimport_postfix := .apiimport.vendor
endif
endif
my_shared_libraries := $(foreach l,$(my_shared_libraries), \
$(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries), \
$(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
my_header_libraries := $(foreach l,$(my_header_libraries), \
$(if $(filter $(l), $(API_IMPORTED_HEADER_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
###########################################################
## When compiling against the VNDK, use LL-NDK libraries
###########################################################
ifneq ($(call module-in-vendor-or-product),)
#####################################################
## Soong modules may be built three times, once for
## /system, once for /vendor and once for /product.
## If we're using the VNDK, switch all soong
## libraries over to the /vendor or /product variant.
#####################################################
ifeq ($(LOCAL_IN_PRODUCT),true)
my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
$(if $(SPLIT_PRODUCT.STATIC_LIBRARIES.$(l)),$(l).product,$(l)))
my_static_libraries := $(foreach l,$(my_static_libraries),\
$(if $(SPLIT_PRODUCT.STATIC_LIBRARIES.$(l)),$(l).product,$(l)))
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
$(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
my_header_libraries := $(foreach l,$(my_header_libraries),\
$(if $(SPLIT_PRODUCT.HEADER_LIBRARIES.$(l)),$(l).product,$(l)))
else
my_whole_static_libraries := $(foreach l,$(my_whole_static_libraries),\
$(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_static_libraries := $(foreach l,$(my_static_libraries),\
$(if $(SPLIT_VENDOR.STATIC_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
my_header_libraries := $(foreach l,$(my_header_libraries),\
$(if $(SPLIT_VENDOR.HEADER_LIBRARIES.$(l)),$(l).vendor,$(l)))
endif
endif
# Platform can use vendor public libraries. If a required shared lib is one of
# the vendor public libraries, the lib is switched to the stub version of the lib.
ifeq ($(call module-in-vendor-or-product),)
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(filter $(l),$(VENDOR_PUBLIC_LIBRARIES)),$(l).vendorpublic,$(l)))
endif
###########################################################
## When compiling against the NDK, use SDK variants of Soong libraries
###########################################################
ifneq ($(LOCAL_SDK_VERSION),)
my_whole_static_libraries := $(call use_soong_sdk_libraries,$(my_whole_static_libraries))
my_static_libraries := $(call use_soong_sdk_libraries,$(my_static_libraries))
my_shared_libraries := $(call use_soong_sdk_libraries,$(my_shared_libraries))
my_system_shared_libraries := $(call use_soong_sdk_libraries,$(my_system_shared_libraries))
my_header_libraries := $(call use_soong_sdk_libraries,$(my_header_libraries))
endif
##########################################################
## Set up installed module dependency
## We cannot compute the full path of the LOCAL_SHARED_LIBRARIES for
## they may cusomize their install path with LOCAL_MODULE_PATH
##########################################################
# Get the list of INSTALLED libraries as module names.
ifneq ($(LOCAL_SDK_VERSION),)
installed_shared_library_module_names := \
$(my_shared_libraries)
else
installed_shared_library_module_names := \
$(my_shared_libraries) $(my_system_shared_libraries)
endif
# The real dependency will be added after all Android.mks are loaded and the install paths
# of the shared libraries are determined.
ifdef LOCAL_INSTALLED_MODULE
ifdef installed_shared_library_module_names
$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
$(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(installed_shared_library_module_names))
endif
endif
####################################################
## Verify that NDK-built libraries only link against
## other NDK-built libraries
####################################################
include $(BUILD_SYSTEM)/allowed_ndk_types.mk
ifdef LOCAL_SDK_VERSION
my_link_type := native:ndk:$(my_ndk_stl_family):$(my_ndk_stl_link_type)
my_warn_types := $(my_warn_ndk_types)
my_allowed_types := $(my_allowed_ndk_types)
else ifeq ($(call module-in-vendor-or-product),true)
_name := $(patsubst %.vendor,%,$(LOCAL_MODULE))
_name := $(patsubst %.product,%,$(LOCAL_MODULE))
ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),)
ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),)
my_link_type := native:vndk
else
my_link_type := native:vndk_private
endif
my_warn_types :=
my_allowed_types := native:vndk native:vndk_private
else ifeq ($(LOCAL_IN_PRODUCT),true)
# Modules installed to /product cannot directly depend on modules marked
# with vendor_available: false
my_link_type := native:product
my_warn_types :=
my_allowed_types := native:product native:vndk native:platform_vndk
else
# Modules installed to /vendor cannot directly depend on modules marked
# with vendor_available: false
my_link_type := native:vendor
my_warn_types :=
my_allowed_types := native:vendor native:vndk native:platform_vndk
endif
else ifneq ($(filter $(TARGET_RECOVERY_OUT)/%,$(call get_non_asan_path,$(LOCAL_MODULE_PATH))),)
my_link_type := native:recovery
my_warn_types :=
# TODO(b/113303515) remove native:platform and my_allowed_ndk_types
my_allowed_types := native:recovery native:platform native:platform_vndk $(my_allowed_ndk_types)
else
my_link_type := native:platform
my_warn_types := $(my_warn_ndk_types)
my_allowed_types := $(my_allowed_ndk_types) native:platform native:platform_vndk
endif
ALL_MODULES.$(my_register_name).WHOLE_STATIC_LIBS := $(my_whole_static_libraries)
my_link_deps := $(addprefix STATIC_LIBRARIES:,$(my_whole_static_libraries) $(my_static_libraries))
ifneq ($(filter-out STATIC_LIBRARIES HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
my_link_deps += $(addprefix SHARED_LIBRARIES:,$(my_shared_libraries))
endif
my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
my_common :=
include $(BUILD_SYSTEM)/link_type.mk
###########################################################
## Common object handling.
###########################################################
my_unused_src_files := $(filter-out $(logtags_sources) $(my_tracked_src_files),$(my_src_files) $(my_gen_src_files))
ifneq ($(my_unused_src_files),)
$(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Unused source files: $(my_unused_src_files))
endif
# some rules depend on asm_objects being first. If your code depends on
# being first, it's reasonable to require it to be assembly
normal_objects := \
$(asm_objects) \
$(cpp_objects) \
$(gen_cpp_objects) \
$(gen_asm_objects) \
$(c_objects) \
$(gen_c_objects) \
$(objc_objects) \
$(objcpp_objects)
new_order_normal_objects := $(foreach f,$(my_src_files),$(my_src_file_obj_$(f)))
new_order_normal_objects += $(foreach f,$(my_gen_src_files),$(my_src_file_obj_$(f)))
ifneq ($(sort $(normal_objects)),$(sort $(new_order_normal_objects)))
$(warning $(LOCAL_MODULE_MAKEFILE) Internal build system warning: New object list does not match old)
$(info Only in old: $(filter-out $(new_order_normal_objects),$(sort $(normal_objects))))
$(info Only in new: $(filter-out $(normal_objects),$(sort $(new_order_normal_objects))))
endif
ifeq ($(BINARY_OBJECTS_ORDER),soong)
normal_objects := $(new_order_normal_objects)
endif
normal_objects += $(addprefix $(TOPDIR)$(LOCAL_PATH)/,$(LOCAL_PREBUILT_OBJ_FILES))
all_objects := $(normal_objects) $(gen_o_objects)
LOCAL_INTERMEDIATE_TARGETS += $(all_objects)
# Cleanup file tracking
$(foreach f,$(my_tracked_gen_files),$(eval my_src_file_gen_$(s):=))
my_tracked_gen_files :=
$(foreach f,$(my_tracked_src_files),$(eval my_src_file_obj_$(s):=))
my_tracked_src_files :=
my_c_includes += $(TOPDIR)$(LOCAL_PATH) $(intermediates) $(generated_sources_dir)
my_c_includes := $(foreach inc,$(my_c_includes),$(call clean-path,$(inc)))
my_outside_includes := $(filter-out $(OUT_DIR)/%,$(filter /%,$(my_c_includes)) $(filter ../%,$(my_c_includes)))
ifneq ($(my_outside_includes),)
ifeq ($(BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS),true)
$(call pretty-warning,C_INCLUDES must be under the source or output directories: $(my_outside_includes))
else
$(call pretty-error,C_INCLUDES must be under the source or output directories: $(my_outside_includes))
endif
endif
# all_objects includes gen_o_objects which were part of LOCAL_GENERATED_SOURCES;
# use normal_objects here to avoid creating circular dependencies. This assumes
# that custom build rules which generate .o files don't consume other generated
# sources as input (or if they do they take care of that dependency themselves).
$(normal_objects) : | $(my_generated_sources)
ALL_C_CPP_ETC_OBJECTS += $(all_objects)
###########################################################
# Standard library handling.
###########################################################
###########################################################
# The list of libraries that this module will link against are in
# these variables. Each is a list of bare module names like "libc libm".
#
# LOCAL_SHARED_LIBRARIES
# LOCAL_STATIC_LIBRARIES
# LOCAL_WHOLE_STATIC_LIBRARIES
#
# We need to convert the bare names into the dependencies that
# we'll use for LOCAL_BUILT_MODULE and LOCAL_INSTALLED_MODULE.
# LOCAL_BUILT_MODULE should depend on the BUILT versions of the
# libraries, so that simply building this module doesn't force
# an install of a library. Similarly, LOCAL_INSTALLED_MODULE
# should depend on the INSTALLED versions of the libraries so
# that they get installed when this module does.
###########################################################
# NOTE:
# WHOLE_STATIC_LIBRARIES are libraries that are pulled into the
# module without leaving anything out, which is useful for turning
# a collection of .a files into a .so file. Linking against a
# normal STATIC_LIBRARY will only pull in code/symbols that are
# referenced by the module. (see gcc/ld's --whole-archive option)
###########################################################
# Get the list of BUILT libraries, which are under
# various intermediates directories.
so_suffix := $($(my_prefix)SHLIB_SUFFIX)
a_suffix := $($(my_prefix)STATIC_LIB_SUFFIX)
ifneq ($(LOCAL_SDK_VERSION),)
built_shared_libraries := \
$(foreach lib,$(my_shared_libraries), \
$(call intermediates-dir-for, \
SHARED_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(so_suffix))
built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
# Add the NDK libraries to the built module dependency
my_system_shared_libraries_fullpath := \
$(my_ndk_stl_shared_lib_fullpath) \
$(addprefix $(my_ndk_sysroot_lib)/, \
$(addsuffix $(so_suffix), $(my_system_shared_libraries)))
# We need to preserve the ordering of LOCAL_SHARED_LIBRARIES regardless of
# whether the libs are generated or prebuilt, so we simply can't split into two
# lists and use addprefix.
my_ndk_shared_libraries_fullpath := \
$(foreach _lib,$(my_ndk_shared_libraries),\
$(if $(filter $(NDK_KNOWN_LIBS),$(_lib)),\
$(my_ndk_sysroot_lib)/$(_lib)$(so_suffix)))
built_shared_libraries += \
$(my_ndk_shared_libraries_fullpath) \
$(my_system_shared_libraries_fullpath) \
built_shared_library_deps += \
$(my_ndk_shared_libraries_fullpath) \
$(my_system_shared_libraries_fullpath) \
else
built_shared_libraries := \
$(foreach lib,$(installed_shared_library_module_names), \
$(call intermediates-dir-for, \
SHARED_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(so_suffix))
built_shared_library_deps := $(addsuffix .toc, $(built_shared_libraries))
my_system_shared_libraries_fullpath :=
endif
built_static_libraries := \
$(foreach lib,$(my_static_libraries), \
$(call intermediates-dir-for, \
STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
ifdef LOCAL_SDK_VERSION
built_static_libraries += $(my_ndk_stl_static_lib)
endif
built_whole_libraries := \
$(foreach lib,$(my_whole_static_libraries), \
$(call intermediates-dir-for, \
STATIC_LIBRARIES,$(lib),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))/$(lib)$(a_suffix))
# Default is -fno-rtti.
ifeq ($(strip $(LOCAL_RTTI_FLAG)),)
LOCAL_RTTI_FLAG := -fno-rtti
endif
###########################################################
# Rule-specific variable definitions
###########################################################
my_cflags += $(LOCAL_CLANG_CFLAGS)
my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS)
my_cppflags += $(LOCAL_CLANG_CPPFLAGS)
my_asflags += $(LOCAL_CLANG_ASFLAGS)
my_ldflags += $(LOCAL_CLANG_LDFLAGS)
my_cflags += $(LOCAL_CLANG_CFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CFLAGS_$(my_32_64_bit_suffix))
my_conlyflags += $(LOCAL_CLANG_CONLYFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CONLYFLAGS_$(my_32_64_bit_suffix))
my_cppflags += $(LOCAL_CLANG_CPPFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_CPPFLAGS_$(my_32_64_bit_suffix))
my_ldflags += $(LOCAL_CLANG_LDFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_LDFLAGS_$(my_32_64_bit_suffix))
my_asflags += $(LOCAL_CLANG_ASFLAGS_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) $(LOCAL_CLANG_ASFLAGS_$(my_32_64_bit_suffix))
my_cflags := $(call convert-to-clang-flags,$(my_cflags))
my_cppflags := $(call convert-to-clang-flags,$(my_cppflags))
my_asflags := $(call convert-to-clang-flags,$(my_asflags))
my_ldflags := $(call convert-to-clang-flags,$(my_ldflags))
# No one should ever use this flag. On GCC it's mere presence will disable all
# warnings, even those that are specified after it (contrary to typical warning
# flag behavior). This circumvents CFLAGS_NO_OVERRIDE from forcibly enabling the
# warnings that are *always* bugs.
my_illegal_flags := -w
my_cflags := $(filter-out $(my_illegal_flags),$(my_cflags))
my_cppflags := $(filter-out $(my_illegal_flags),$(my_cppflags))
my_conlyflags := $(filter-out $(my_illegal_flags),$(my_conlyflags))
# We can enforce some rules more strictly in the code we own. my_strict
# indicates if this is code that we can be stricter with. If we have rules that
# we want to apply to *our* code (but maybe can't for vendor/device specific
# things), we could extend this to be a ternary value.
my_strict := true
ifneq ($(filter external/%,$(LOCAL_PATH)),)
my_strict := false
endif
# Can be used to make some annotations stricter for code we can fix (such as
# when we mark functions as deprecated).
ifeq ($(my_strict),true)
my_cflags += -DANDROID_STRICT
endif
# Check if -Werror or -Wno-error is used in C compiler flags.
# Header libraries do not need cflags.
my_all_cflags := $(my_cflags) $(my_cppflags) $(my_cflags_no_override)
ifneq (HEADER_LIBRARIES,$(LOCAL_MODULE_CLASS))
# Prebuilt modules do not need cflags.
ifeq (,$(LOCAL_PREBUILT_MODULE_FILE))
# Issue warning if -Wno-error is used.
ifneq (,$(filter -Wno-error,$(my_all_cflags)))
$(eval MODULES_USING_WNO_ERROR := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
else
# Issue warning if -Werror is not used. Add it.
ifeq (,$(filter -Werror,$(my_all_cflags)))
# Add -Wall -Werror unless the project is in the WARNING_ALLOWED project list.
ifeq (,$(strip $(call find_warning_allowed_projects,$(LOCAL_PATH))))
my_cflags := -Wall -Werror $(my_cflags)
else
$(eval MODULES_WARNINGS_ALLOWED := $(MODULES_USING_WNO_ERROR) $(LOCAL_MODULE_MAKEFILE):$(LOCAL_MODULE))
my_cflags := -Wall $(my_cflags)
endif
endif
endif
endif
endif
ifneq (,$(filter -Weverything,$(my_all_cflags)))
ifeq (,$(ANDROID_TEMPORARILY_ALLOW_WEVERYTHING))
$(call pretty-error, -Weverything is not allowed in Android.mk files.\
Build with `m ANDROID_TEMPORARILY_ALLOW_WEVERYTHING=true` to experiment locally with -Weverything.)
endif
endif
ifneq ($(my_tidy_checks),)
tidy_only: $(cpp_objects) $(c_objects) $(gen_c_objects) $(gen_cpp_objects)
# Add dependency of clang-tidy and clang-tidy.sh
$(cpp_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
$(c_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
$(gen_cpp_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
$(gen_c_objects): $(intermediates)/%.o: $(PATH_TO_CLANG_TIDY)
endif
# Move -l* entries from ldflags to ldlibs, and everything else to ldflags
my_ldlib_flags := $(my_ldflags) $(my_ldlibs)
my_ldlibs := $(filter -l%,$(my_ldlib_flags))
my_ldflags := $(filter-out -l%,$(my_ldlib_flags))
# One last verification check for ldlibs
my_allowed_ldlibs :=
ifndef LOCAL_IS_HOST_MODULE
ifneq ($(LOCAL_SDK_VERSION),)
my_allowed_ldlibs := $(NDK_KNOWN_LIBS:lib%=-l%)
endif
else
my_allowed_ldlibs := $($(my_prefix)AVAILABLE_LIBRARIES)
endif
my_bad_ldlibs := $(filter-out $(my_allowed_ldlibs),$(my_ldlibs))
ifneq ($(my_bad_ldlibs),)
$(error $(LOCAL_MODULE_MAKEFILE): $(LOCAL_MODULE): Bad LOCAL_LDLIBS entries: $(my_bad_ldlibs))
endif
# my_cxx_ldlibs may contain linker flags need to wrap certain libraries
# (start-group/end-group), so append after the check above.
my_ldlibs += $(my_cxx_ldlibs)
###########################################################
## Define PRIVATE_ variables from global vars
###########################################################
ifndef LOCAL_IS_HOST_MODULE
my_target_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
my_target_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
my_target_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
ifeq ($(my_use_clang_lld),true)
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
include $(BUILD_SYSTEM)/pack_dyn_relocs_setup.mk
ifeq ($(my_pack_module_relocations),true)
my_target_global_ldflags += -Wl,--pack-dyn-relocs=android+relr -Wl,--use-android-relr-tags
else
my_target_global_ldflags += -Wl,--pack-dyn-relocs=none
endif
else
my_target_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
endif # my_use_clang_lld
ifeq ($(call module-in-vendor-or-product),true)
my_target_global_c_includes :=
my_target_global_c_system_includes := $(TARGET_OUT_HEADERS)
my_target_global_cflags += -nostdlibinc
else ifdef LOCAL_SDK_VERSION
my_target_global_c_includes :=
my_target_global_c_system_includes := $(my_ndk_stl_include_path)
my_target_global_cflags += --sysroot $(my_ndk_sysroot)
else
my_target_global_c_includes := $(SRC_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
my_target_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
my_target_global_cflags += -nostdlibinc
endif
my_target_triple := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)TRIPLE)
ifndef LOCAL_IS_HOST_MODULE
my_target_triple_flag := -target $(my_target_triple)$(my_api_level)
else
my_target_triple_flag := -target $(my_target_triple)
endif
my_asflags += $(my_target_triple_flag)
my_cflags += $(my_target_triple_flag)
my_ldflags += $(my_target_triple_flag)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_target_global_c_includes)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_target_global_c_system_includes)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CFLAGS := $(my_target_global_cflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CONLYFLAGS := $(my_target_global_conlyflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_CPPFLAGS := $(my_target_global_cppflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_GLOBAL_LDFLAGS := $(my_target_global_ldflags)
else # LOCAL_IS_HOST_MODULE
my_host_global_c_includes := $(SRC_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_INCLUDES)
my_host_global_c_system_includes := $(SRC_SYSTEM_HEADERS) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)C_SYSTEM_INCLUDES)
my_host_global_cflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CFLAGS)
my_host_global_conlyflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CONLYFLAGS) $(my_c_std_conlyflags)
my_host_global_cppflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_CPPFLAGS) $(my_cpp_std_cppflags)
ifeq ($(my_use_clang_lld),true)
my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LLDFLAGS)
else
my_host_global_ldflags := $($(LOCAL_2ND_ARCH_VAR_PREFIX)CLANG_$(my_prefix)GLOBAL_LDFLAGS)
endif # my_use_clang_lld
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_INCLUDES := $(my_host_global_c_includes)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_GLOBAL_C_SYSTEM_INCLUDES := $(my_host_global_c_system_includes)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CFLAGS := $(my_host_global_cflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CONLYFLAGS := $(my_host_global_conlyflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_CPPFLAGS := $(my_host_global_cppflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_HOST_GLOBAL_LDFLAGS := $(my_host_global_ldflags)
endif # LOCAL_IS_HOST_MODULE
# To enable coverage for a given module, set LOCAL_NATIVE_COVERAGE=true and
# build with NATIVE_COVERAGE=true in your enviornment.
ifeq ($(NATIVE_COVERAGE),true)
ifeq ($(my_native_coverage),true)
# Note that clang coverage doesn't play nicely with acov out of the box.
# Clang apparently generates .gcno files that aren't compatible with
# gcov-4.8. This can be solved by installing gcc-4.6 and invoking lcov
# with `--gcov-tool /usr/bin/gcov-4.6`.
#
# http://stackoverflow.com/questions/17758126/clang-code-coverage-invalid-output
my_cflags += --coverage -O0
my_ldflags += --coverage
endif
my_coverage_lib := $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)LIBPROFILE_RT)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TARGET_COVERAGE_LIB := $(my_coverage_lib)
$(LOCAL_INTERMEDIATE_TARGETS): $(my_coverage_lib)
endif
####################################################
## Import includes
####################################################
imported_includes :=
ifeq (true,$(call module-in-vendor-or-product))
imported_includes += $(call intermediates-dir-for,HEADER_LIBRARIES,device_kernel_headers,$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))
else
# everything else should manually specify headers
endif
imported_includes := $(strip \
$(imported_includes) \
$(foreach l, $(installed_shared_library_module_names), \
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
$(foreach l, $(my_static_libraries) $(my_whole_static_libraries), \
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))) \
$(foreach l, $(my_header_libraries), \
$(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
$(foreach dep,$(imported_includes),\
$(eval EXPORTS.$$(dep).USERS := $$(EXPORTS.$$(dep).USERS) $$(all_objects)))
###########################################################
## Define PRIVATE_ variables used by multiple module types
###########################################################
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_NO_DEFAULT_COMPILER_FLAGS := \
$(strip $(LOCAL_NO_DEFAULT_COMPILER_FLAGS))
ifeq ($(strip $(WITH_STATIC_ANALYZER)),)
LOCAL_NO_STATIC_ANALYZER := true
endif
ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
my_syntax_arch := host
else
my_syntax_arch := $($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)
endif
ifeq ($(strip $(my_cc)),)
my_cc := $(my_cc_wrapper) $(CLANG)
endif
SYNTAX_TOOLS_PREFIX := \
$(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/libexec
ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
my_cc := CCC_CC=$(CLANG) CLANG=$(CLANG) \
$(SYNTAX_TOOLS_PREFIX)/ccc-analyzer
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CC := $(my_cc)
ifeq ($(strip $(my_cxx)),)
my_cxx := $(my_cxx_wrapper) $(CLANG_CXX)
endif
ifeq ($(strip $(my_cxx_link)),)
my_cxx_link := $(CLANG_CXX)
endif
ifneq ($(LOCAL_NO_STATIC_ANALYZER),true)
my_cxx := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
$(SYNTAX_TOOLS_PREFIX)/c++-analyzer
my_cxx_link := CCC_CXX=$(CLANG_CXX) CLANG_CXX=$(CLANG_CXX) \
$(SYNTAX_TOOLS_PREFIX)/c++-analyzer
endif
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LINKER := $(my_linker)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX := $(my_cxx)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CXX_LINK := $(my_cxx_link)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_YACCFLAGS := $(LOCAL_YACCFLAGS)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ASFLAGS := $(my_asflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CONLYFLAGS := $(my_conlyflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS := $(my_cflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS := $(my_cppflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CFLAGS_NO_OVERRIDE := $(my_cflags_no_override)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_CPPFLAGS_NO_OVERRIDE := $(my_cppflags_no_override)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_RTTI_FLAG := $(LOCAL_RTTI_FLAG)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_DEBUG_CFLAGS := $(debug_cflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_C_INCLUDES := $(my_c_includes)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_IMPORTED_INCLUDES := $(imported_includes)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDFLAGS := $(my_ldflags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_LDLIBS := $(my_ldlibs)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_CHECKS := $(my_tidy_checks)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_TIDY_FLAGS := $(my_tidy_flags)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ARFLAGS := $(my_arflags)
# this is really the way to get the files onto the command line instead
# of using $^, because then LOCAL_ADDITIONAL_DEPENDENCIES doesn't work
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_SHARED_LIBRARIES := $(built_shared_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_STATIC_LIBRARIES := $(built_static_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_WHOLE_STATIC_LIBRARIES := $(built_whole_libraries)
$(LOCAL_INTERMEDIATE_TARGETS): PRIVATE_ALL_OBJECTS := $(strip $(all_objects))
###########################################################
# Define library dependencies.
###########################################################
# all_libraries is used for the dependencies on LOCAL_BUILT_MODULE.
all_libraries := \
$(built_shared_library_deps) \
$(my_system_shared_libraries_fullpath) \
$(built_static_libraries) \
$(built_whole_libraries)
###########################################################
# Export includes
###########################################################
# Headers exported by whole static libraries are also exported by this library.
export_include_deps := $(strip \
$(foreach l,$(my_whole_static_libraries), \
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
# Re-export requested headers from shared libraries.
export_include_deps += $(strip \
$(foreach l,$(LOCAL_EXPORT_SHARED_LIBRARY_HEADERS), \
$(call intermediates-dir-for,SHARED_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
# Re-export requested headers from static libraries.
export_include_deps += $(strip \
$(foreach l,$(LOCAL_EXPORT_STATIC_LIBRARY_HEADERS), \
$(call intermediates-dir-for,STATIC_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
# Re-export requested headers from header libraries.
export_include_deps += $(strip \
$(foreach l,$(LOCAL_EXPORT_HEADER_LIBRARY_HEADERS), \
$(call intermediates-dir-for,HEADER_LIBRARIES,$(l),$(my_kind),,$(LOCAL_2ND_ARCH_VAR_PREFIX),$(my_host_cross))))
ifneq ($(strip $(my_export_c_include_dirs)$(export_include_deps)),)
EXPORTS_LIST += $(intermediates)
EXPORTS.$(intermediates).FLAGS := $(foreach d,$(my_export_c_include_dirs),-I $(call clean-path,$(d)))
EXPORTS.$(intermediates).REEXPORT := $(export_include_deps)
EXPORTS.$(intermediates).DEPS := $(my_export_c_include_deps) $(my_generated_sources) $(LOCAL_EXPORT_C_INCLUDE_DEPS)
endif
ifneq (,$(filter-out $(LOCAL_PATH)/%,$(my_export_c_include_dirs)))
my_soong_problems += non_local__export_c_include_dirs
endif
SOONG_CONV.$(LOCAL_MODULE).PROBLEMS := \
$(SOONG_CONV.$(LOCAL_MODULE).PROBLEMS) $(my_soong_problems)
SOONG_CONV.$(LOCAL_MODULE).DEPS := \
$(SOONG_CONV.$(LOCAL_MODULE).DEPS) \
$(filter-out $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY),\
$(my_static_libraries) \
$(my_whole_static_libraries) \
$(my_shared_libraries) \
$(my_system_shared_libraries))
SOONG_CONV.$(LOCAL_MODULE).TYPE := native
SOONG_CONV.$(LOCAL_MODULE).MAKEFILES := \
$(SOONG_CONV.$(LOCAL_MODULE).MAKEFILES) $(LOCAL_MODULE_MAKEFILE)
SOONG_CONV.$(LOCAL_MODULE).INSTALLED:= \
$(SOONG_CONV.$(LOCAL_MODULE).INSTALLED) $(LOCAL_INSTALLED_MODULE)
SOONG_CONV := $(SOONG_CONV) $(LOCAL_MODULE)
###########################################################
# Coverage packaging.
###########################################################
ifeq ($(my_native_coverage),true)
my_gcno_objects := \
$(cpp_objects) \
$(gen_cpp_objects) \
$(c_objects) \
$(gen_c_objects) \
$(objc_objects) \
$(objcpp_objects)
LOCAL_GCNO_FILES := $(patsubst %.o,%.gcno,$(my_gcno_objects))
$(foreach f,$(my_gcno_objects),$(eval $(call gcno-touch-rule,$(f),$(f:.o=.gcno))))
endif
================================================
FILE: core/board_config.mk
================================================
#
# Copyright (C) 2019 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.
#
# ###############################################################
# This file includes BoardConfig.mk for the device being built,
# and checks the variable defined therein.
# ###############################################################
_board_strip_readonly_list :=
_board_strip_readonly_list += BOARD_BOOTLOADER_IN_UPDATE_PACKAGE
_board_strip_readonly_list += BOARD_EGL_CFG
_board_strip_readonly_list += BOARD_HAVE_BLUETOOTH
_board_strip_readonly_list += BOARD_INSTALLER_CMDLINE
_board_strip_readonly_list += BOARD_KERNEL_CMDLINE
_board_strip_readonly_list += BOARD_BOOT_HEADER_VERSION
_board_strip_readonly_list += BOARD_BOOTCONFIG
_board_strip_readonly_list += BOARD_BOOTCONFIG_FILE
_board_strip_readonly_list += BOARD_KERNEL_BASE
_board_strip_readonly_list += BOARD_USES_GENERIC_AUDIO
_board_strip_readonly_list += BOARD_USES_RECOVERY_AS_BOOT
_board_strip_readonly_list += BOARD_VENDOR_USE_AKMD
_board_strip_readonly_list += BOARD_WPA_SUPPLICANT_DRIVER
_board_strip_readonly_list += BOARD_WLAN_DEVICE
_board_strip_readonly_list += TARGET_BOARD_PLATFORM
_board_strip_readonly_list += TARGET_BOARD_PLATFORM_GPU
_board_strip_readonly_list += TARGET_BOOTLOADER_BOARD_NAME
_board_strip_readonly_list += TARGET_FS_CONFIG_GEN
_board_strip_readonly_list += TARGET_NO_BOOTLOADER
_board_strip_readonly_list += TARGET_NO_KERNEL
_board_strip_readonly_list += TARGET_NO_RECOVERY
_board_strip_readonly_list += TARGET_NO_RADIOIMAGE
_board_strip_readonly_list += TARGET_HARDWARE_3D
_board_strip_readonly_list += WITH_DEXPREOPT
# Arch variables
_board_strip_readonly_list += TARGET_ARCH
_board_strip_readonly_list += TARGET_ARCH_VARIANT
_board_strip_readonly_list += TARGET_CPU_ABI
_board_strip_readonly_list += TARGET_CPU_ABI2
_board_strip_readonly_list += TARGET_CPU_VARIANT
_board_strip_readonly_list += TARGET_CPU_VARIANT_RUNTIME
_board_strip_readonly_list += TARGET_2ND_ARCH
_board_strip_readonly_list += TARGET_2ND_ARCH_VARIANT
_board_strip_readonly_list += TARGET_2ND_CPU_ABI
_board_strip_readonly_list += TARGET_2ND_CPU_ABI2
_board_strip_readonly_list += TARGET_2ND_CPU_VARIANT
_board_strip_readonly_list += TARGET_2ND_CPU_VARIANT_RUNTIME
# TARGET_ARCH_SUITE is an alternative arch configuration to TARGET_ARCH (and related variables),
# that can be used for soong-only builds to build for several architectures at once.
# Allowed values currently are "ndk" and "mainline_sdk".
_board_strip_readonly_list += TARGET_ARCH_SUITE
# File system variables
_board_strip_readonly_list += BOARD_FLASH_BLOCK_SIZE
_board_strip_readonly_list += BOARD_BOOTIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_RECOVERYIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_SYSTEMIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_SYSTEMIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_USERDATAIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_USERDATAIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_CACHEIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_VENDORIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_PRODUCTIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_ODMIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_ODM_DLKMIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE
_board_strip_readonly_list += BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE
_board_strip_readonly_list += BOARD_PVMFWIMAGE_PARTITION_SIZE
# Logical partitions related variables.
_board_strip_readonly_list += BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_SYSTEM_DLKMIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE
_board_strip_readonly_list += BOARD_SUPER_PARTITION_SIZE
_board_strip_readonly_list += BOARD_SUPER_PARTITION_GROUPS
# Kernel related variables
_board_strip_readonly_list += BOARD_KERNEL_BINARIES
_board_strip_readonly_list += BOARD_KERNEL_MODULE_INTERFACE_VERSIONS
# Variables related to generic kernel image (GKI) and generic boot image
# - BOARD_USES_GENERIC_KERNEL_IMAGE is the global variable that defines if the
# board uses GKI and generic boot image.
# Update mechanism of the boot image is not enforced by this variable.
# - BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE controls whether the recovery image
# contains a kernel or not.
# - BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT controls whether ramdisk
# recovery resources are built to vendor_boot.
# - BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT controls whether recovery
# resources are built as a standalone recovery ramdisk in vendor_boot.
# - BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT controls whether GSI AVB keys are
# built to vendor_boot.
# - BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES controls whether boot images in $OUT are added
# to target files package directly.
_board_strip_readonly_list += BOARD_USES_GENERIC_KERNEL_IMAGE
_board_strip_readonly_list += BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE
_board_strip_readonly_list += BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT
_board_strip_readonly_list += BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT
_board_strip_readonly_list += BOARD_MOVE_GSI_AVB_KEYS_TO_VENDOR_BOOT
_board_strip_readonly_list += BOARD_COPY_BOOT_IMAGE_TO_TARGET_FILES
# Prebuilt image variables
_board_strip_readonly_list += BOARD_PREBUILT_INIT_BOOT_IMAGE
# Defines the list of logical vendor ramdisk names to build or include in vendor_boot.
_board_strip_readonly_list += BOARD_VENDOR_RAMDISK_FRAGMENTS
# These are all variables used to build $(INSTALLED_MISC_INFO_TARGET)
# in build/make/core/Makefile. Their values get used in command line
# arguments, so they have to be stripped to make the ninja files stable.
_board_strip_list :=
_board_strip_list += BOARD_DTBOIMG_PARTITION_SIZE
_board_strip_list += BOARD_AVB_DTBO_KEY_PATH
_board_strip_list += BOARD_AVB_DTBO_ALGORITHM
_board_strip_list += BOARD_AVB_DTBO_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_AVB_PVMFW_KEY_PATH
_board_strip_list += BOARD_AVB_PVMFW_ALGORITHM
_board_strip_list += BOARD_AVB_PVMFW_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_PARTIAL_OTA_UPDATE_PARTITIONS_LIST
_board_strip_list += BOARD_AVB_VBMETA_VENDOR_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_AVB_VBMETA_VENDOR_ALGORITHM
_board_strip_list += BOARD_AVB_VBMETA_VENDOR_KEY_PATH
_board_strip_list += BOARD_AVB_VBMETA_VENDOR
_board_strip_list += BOARD_AVB_VBMETA_SYSTEM_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_AVB_VBMETA_SYSTEM_ALGORITHM
_board_strip_list += BOARD_AVB_VBMETA_SYSTEM_KEY_PATH
_board_strip_list += BOARD_AVB_VBMETA_SYSTEM
_board_strip_list += BOARD_AVB_RECOVERY_KEY_PATH
_board_strip_list += BOARD_AVB_RECOVERY_ALGORITHM
_board_strip_list += BOARD_AVB_RECOVERY_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_AVB_VENDOR_BOOT_KEY_PATH
_board_strip_list += BOARD_AVB_VENDOR_BOOT_ALGORITHM
_board_strip_list += BOARD_AVB_VENDOR_BOOT_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_AVB_VENDOR_KERNEL_BOOT_KEY_PATH
_board_strip_list += BOARD_AVB_VENDOR_KERNEL_BOOT_ALGORITHM
_board_strip_list += BOARD_AVB_VENDOR_KERNEL_BOOT_ROLLBACK_INDEX_LOCATION
_board_strip_list += BOARD_MKBOOTIMG_ARGS
_board_strip_list += BOARD_VENDOR_BOOTIMAGE_PARTITION_SIZE
_board_strip_list += BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE
_board_strip_list += ODM_MANIFEST_SKUS
_build_broken_var_list := \
BUILD_BROKEN_CLANG_PROPERTY \
BUILD_BROKEN_CLANG_ASFLAGS \
BUILD_BROKEN_CLANG_CFLAGS \
BUILD_BROKEN_DEPFILE \
BUILD_BROKEN_DUP_RULES \
BUILD_BROKEN_DUP_SYSPROP \
BUILD_BROKEN_ELF_PREBUILT_PRODUCT_COPY_FILES \
BUILD_BROKEN_ENFORCE_SYSPROP_OWNER \
BUILD_BROKEN_INPUT_DIR_MODULES \
BUILD_BROKEN_MISSING_REQUIRED_MODULES \
BUILD_BROKEN_OUTSIDE_INCLUDE_DIRS \
BUILD_BROKEN_PREBUILT_ELF_FILES \
BUILD_BROKEN_TREBLE_SYSPROP_NEVERALLOW \
BUILD_BROKEN_USES_NETWORK \
BUILD_BROKEN_VENDOR_PROPERTY_NAMESPACE \
BUILD_BROKEN_VINTF_PRODUCT_COPY_FILES \
BUILD_BROKEN_INCORRECT_PARTITION_IMAGES \
BUILD_BROKEN_GENRULE_SANDBOXING \
BUILD_BROKEN_DONT_CHECK_SYSTEMSDK \
_build_broken_var_list += \
$(foreach m,$(AVAILABLE_BUILD_MODULE_TYPES) \
$(DEFAULT_WARNING_BUILD_MODULE_TYPES) \
$(DEFAULT_ERROR_BUILD_MODULE_TYPES), \
BUILD_BROKEN_USES_$(m))
_board_true_false_vars := $(_build_broken_var_list)
_board_strip_readonly_list += $(_build_broken_var_list) \
BUILD_BROKEN_NINJA_USES_ENV_VARS
# Conditional to building on linux, as dex2oat currently does not work on darwin.
ifeq ($(HOST_OS),linux)
WITH_DEXPREOPT ?= true
endif
# ###############################################################
# Broken build defaults
# ###############################################################
$(foreach v,$(_build_broken_var_list),$(eval $(v) :=))
BUILD_BROKEN_NINJA_USES_ENV_VARS :=
# Boards may be defined under $(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)
# or under vendor/*/$(TARGET_DEVICE). Search in both places, but
# make sure only one exists.
# Real boards should always be associated with an OEM vendor.
ifdef TARGET_DEVICE_DIR
ifneq ($(origin TARGET_DEVICE_DIR),command line)
$(error TARGET_DEVICE_DIR may not be set manually)
endif
board_config_mk := $(TARGET_DEVICE_DIR)/BoardConfig.mk
else
board_config_mk := \
$(strip $(sort $(wildcard \
$(SRC_TARGET_DIR)/board/$(TARGET_DEVICE)/BoardConfig.mk \
device/generic/goldfish/board/$(TARGET_DEVICE)/BoardConfig.mk \
device/google/cuttlefish/board/$(TARGET_DEVICE)/BoardConfig.mk \
vendor/google/products/cuttlefish/pixel_watch/board/$(TARGET_DEVICE)/BoardConfig.mk \
$(shell test -d device && find -L device -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
$(shell test -d vendor && find -L vendor -maxdepth 4 -path '*/$(TARGET_DEVICE)/BoardConfig.mk') \
)))
ifeq ($(board_config_mk),)
$(error No config file found for TARGET_DEVICE $(TARGET_DEVICE))
endif
ifneq ($(words $(board_config_mk)),1)
$(error Multiple board config files for TARGET_DEVICE $(TARGET_DEVICE): $(board_config_mk))
endif
TARGET_DEVICE_DIR := $(patsubst %/,%,$(dir $(board_config_mk)))
.KATI_READONLY := TARGET_DEVICE_DIR
endif
$(call dump-phase-start,BOARD,,,, build/make/core/board_config.mk)
ifndef RBC_PRODUCT_CONFIG
include $(board_config_mk)
else
$(shell mkdir -p $(OUT_DIR)/rbc)
$(call dump-variables-rbc, $(OUT_DIR)/rbc/make_vars_pre_board_config.mk)
$(shell $(OUT_DIR)/mk2rbc \
--mode=write -r --outdir $(OUT_DIR)/rbc \
--boardlauncher=$(OUT_DIR)/rbc/boardlauncher.rbc \
--input_variables=$(OUT_DIR)/rbc/make_vars_pre_board_config.mk \
--makefile_list=$(OUT_DIR)/.module_paths/configuration.list \
$(board_config_mk))
ifneq ($(.SHELLSTATUS),0)
$(error board configuration converter failed: $(.SHELLSTATUS))
endif
$(shell build/soong/scripts/update_out $(OUT_DIR)/rbc/rbc_board_config_results.mk \
$(OUT_DIR)/rbcrun --mode=rbc $(OUT_DIR)/rbc/boardlauncher.rbc)
ifneq ($(.SHELLSTATUS),0)
$(error board configuration runner failed: $(.SHELLSTATUS))
endif
include $(OUT_DIR)/rbc/rbc_board_config_results.mk
endif
$(call dump-phase-end, build/make/core/board_config.mk)
ifneq (,$(and $(TARGET_ARCH),$(TARGET_ARCH_SUITE)))
$(error $(board_config_mk) erroneously sets both TARGET_ARCH and TARGET_ARCH_SUITE)
endif
ifeq ($(TARGET_ARCH)$(TARGET_ARCH_SUITE),)
$(error Target architectures not defined by board config: $(board_config_mk))
endif
ifeq ($(TARGET_CPU_ABI)$(TARGET_ARCH_SUITE),)
$(error TARGET_CPU_ABI not defined by board config: $(board_config_mk))
endif
ifneq ($(MALLOC_IMPL),)
$(warning *** Unsupported option MALLOC_IMPL defined by board config: $(board_config_mk).)
$(error Use `MALLOC_LOW_MEMORY := true` to use low-memory allocator config)
endif
board_config_mk :=
# Clean up and verify BoardConfig variables
$(foreach var,$(_board_strip_readonly_list),$(eval $(var) := $$(strip $$($(var)))))
$(foreach var,$(_board_strip_list),$(eval $(var) := $$(strip $$($(var)))))
$(foreach var,$(_board_true_false_vars), \
$(if $(filter-out true false,$($(var))), \
$(error Valid values of $(var) are "true", "false", and "". Not "$($(var))")))
include $(BUILD_SYSTEM)/board_config_wifi.mk
include $(BUILD_SYSTEM)/board_config_wpa_supplicant.mk
# Set up soong config for "soong_config_value_variable".
-include hardware/interfaces/configstore/1.1/default/surfaceflinger.mk
-include vendor/google/build/soong/soong_config_namespace/camera.mk
# Default *_CPU_VARIANT_RUNTIME to CPU_VARIANT if unspecified.
TARGET_CPU_VARIANT_RUNTIME := $(or $(TARGET_CPU_VARIANT_RUNTIME),$(TARGET_CPU_VARIANT))
TARGET_2ND_CPU_VARIANT_RUNTIME := $(or $(TARGET_2ND_CPU_VARIANT_RUNTIME),$(TARGET_2ND_CPU_VARIANT))
ifdef TARGET_ARCH
# The combo makefiles check and set defaults for various CPU configuration
combo_target := TARGET_
combo_2nd_arch_prefix :=
include $(BUILD_SYSTEM)/combo/select.mk
endif
ifdef TARGET_2ND_ARCH
combo_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
include $(BUILD_SYSTEM)/combo/select.mk
endif
.KATI_READONLY := $(_board_strip_readonly_list)
INTERNAL_KERNEL_CMDLINE := $(BOARD_KERNEL_CMDLINE)
ifneq (,$(BOARD_BOOTCONFIG)$(BOARD_BOOTCONFIG_FILE))
INTERNAL_KERNEL_CMDLINE += bootconfig
INTERNAL_BOOTCONFIG := $(BOARD_BOOTCONFIG)
INTERNAL_BOOTCONFIG_FILE := $(BOARD_BOOTCONFIG_FILE)
endif
ifneq ($(filter %64,$(TARGET_ARCH)),)
TARGET_IS_64_BIT := true
endif
ifeq (,$(filter true,$(TARGET_SUPPORTS_32_BIT_APPS) $(TARGET_SUPPORTS_64_BIT_APPS)))
TARGET_SUPPORTS_32_BIT_APPS := true
endif
# Quick check to warn about likely cryptic errors later in the build.
ifeq ($(TARGET_IS_64_BIT),true)
ifeq (,$(filter true false,$(TARGET_SUPPORTS_64_BIT_APPS)))
$(error Building a 32-bit-app-only product on a 64-bit device. \
If this is intentional, set TARGET_SUPPORTS_64_BIT_APPS := false)
endif
endif
# "ro.product.cpu.abilist32" and "ro.product.cpu.abilist64" are
# comma separated lists of the 32 and 64 bit ABIs (in order of
# preference) that the target supports. If TARGET_CPU_ABI_LIST_{32,64}_BIT
# are defined by the board config, we use them. Else, we construct
# these lists based on whether TARGET_IS_64_BIT is set.
#
# Note that this assumes that the 2ND_CPU_ABI for a 64 bit target
# is always 32 bits. If this isn't the case, these variables should
# be overriden in the board configuration.
#
# Similarly, TARGET_NATIVE_BRIDGE_2ND_ABI for a 64 bit target is always
# 32 bits. Note that all CPU_ABIs are preferred over all NATIVE_BRIDGE_ABIs.
_target_native_bridge_abi_list_32_bit :=
_target_native_bridge_abi_list_64_bit :=
ifeq (,$(TARGET_CPU_ABI_LIST_64_BIT))
ifeq (true|true,$(TARGET_IS_64_BIT)|$(TARGET_SUPPORTS_64_BIT_APPS))
TARGET_CPU_ABI_LIST_64_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
_target_native_bridge_abi_list_64_bit := $(TARGET_NATIVE_BRIDGE_ABI)
endif
endif
# "arm64-v8a-hwasan", the ABI for libraries compiled with HWASAN, is supported
# in all builds with SANITIZE_TARGET=hwaddress.
ifneq ($(filter hwaddress,$(SANITIZE_TARGET)),)
ifneq ($(filter arm64-v8a,$(TARGET_CPU_ABI_LIST_64_BIT)),)
TARGET_CPU_ABI_LIST_64_BIT := arm64-v8a-hwasan $(TARGET_CPU_ABI_LIST_64_BIT)
endif
endif
ifeq (,$(TARGET_CPU_ABI_LIST_32_BIT))
ifneq (true,$(TARGET_IS_64_BIT))
TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_CPU_ABI) $(TARGET_CPU_ABI2)
_target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_ABI)
else
ifeq (true,$(TARGET_SUPPORTS_32_BIT_APPS))
# For a 64 bit target, assume that the 2ND_CPU_ABI
# is a 32 bit ABI.
TARGET_CPU_ABI_LIST_32_BIT := $(TARGET_2ND_CPU_ABI) $(TARGET_2ND_CPU_ABI2)
_target_native_bridge_abi_list_32_bit := $(TARGET_NATIVE_BRIDGE_2ND_ABI)
endif
endif
endif
# "ro.product.cpu.abilist" is a comma separated list of ABIs (in order
# of preference) that the target supports. If a TARGET_CPU_ABI_LIST
# is specified by the board configuration, we use that. If not, we
# build a list out of the TARGET_CPU_ABIs specified by the config.
# Add NATIVE_BRIDGE_ABIs at the end to keep order of preference.
ifeq (,$(TARGET_CPU_ABI_LIST))
TARGET_CPU_ABI_LIST := $(TARGET_CPU_ABI_LIST_64_BIT) $(TARGET_CPU_ABI_LIST_32_BIT) \
$(_target_native_bridge_abi_list_64_bit) $(_target_native_bridge_abi_list_32_bit)
endif
# Add NATIVE_BRIDGE_ABIs at the end of 32 and 64 bit CPU_ABIs to keep order of preference.
TARGET_CPU_ABI_LIST_32_BIT += $(_target_native_bridge_abi_list_32_bit)
TARGET_CPU_ABI_LIST_64_BIT += $(_target_native_bridge_abi_list_64_bit)
# Strip whitespace from the ABI list string.
TARGET_CPU_ABI_LIST := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST)))
TARGET_CPU_ABI_LIST_32_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_32_BIT)))
TARGET_CPU_ABI_LIST_64_BIT := $(subst $(space),$(comma),$(strip $(TARGET_CPU_ABI_LIST_64_BIT)))
# Check if config about image building is valid or not.
define check_image_config
$(eval _uc_name := $(call to-upper,$(1))) \
$(eval _lc_name := $(call to-lower,$(1))) \
$(if $(filter $(_lc_name),$(TARGET_COPY_OUT_$(_uc_name))), \
$(if $(BOARD_USES_$(_uc_name)IMAGE),, \
$(error If TARGET_COPY_OUT_$(_uc_name) is '$(_lc_name)', either BOARD_PREBUILT_$(_uc_name)IMAGE or BOARD_$(_uc_name)IMAGE_FILE_SYSTEM_TYPE must be set)), \
$(if $(BOARD_USES_$(_uc_name)IMAGE), \
$(error TARGET_COPY_OUT_$(_uc_name) must be set to '$(_lc_name)' to use a $(_lc_name) image))) \
$(eval _uc_name :=) \
$(eval _lc_name :=)
endef
###########################################
# Configure whether we're building the system image
BUILDING_SYSTEM_IMAGE := true
ifeq ($(PRODUCT_BUILD_SYSTEM_IMAGE),)
ifndef PRODUCT_USE_DYNAMIC_PARTITION_SIZE
ifndef BOARD_SYSTEMIMAGE_PARTITION_SIZE
BUILDING_SYSTEM_IMAGE :=
endif
endif
else ifeq ($(PRODUCT_BUILD_SYSTEM_IMAGE),false)
BUILDING_SYSTEM_IMAGE :=
endif
.KATI_READONLY := BUILDING_SYSTEM_IMAGE
# Are we building a system_other image
BUILDING_SYSTEM_OTHER_IMAGE :=
ifeq ($(PRODUCT_BUILD_SYSTEM_OTHER_IMAGE),)
ifdef BUILDING_SYSTEM_IMAGE
ifeq ($(BOARD_USES_SYSTEM_OTHER_ODEX),true)
BUILDING_SYSTEM_OTHER_IMAGE := true
endif
endif
else ifeq ($(PRODUCT_BUILD_SYSTEM_OTHER_IMAGE),true)
BUILDING_SYSTEM_OTHER_IMAGE := true
ifndef BUILDING_SYSTEM_IMAGE
$(error PRODUCT_BUILD_SYSTEM_OTHER_IMAGE = true requires building the system image)
endif
endif
.KATI_READONLY := BUILDING_SYSTEM_OTHER_IMAGE
# Are we building a cache image
BUILDING_CACHE_IMAGE :=
ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),)
ifdef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
BUILDING_CACHE_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_CACHE_IMAGE),true)
BUILDING_CACHE_IMAGE := true
ifndef BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_CACHE_IMAGE set to true, but BOARD_CACHEIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
.KATI_READONLY := BUILDING_CACHE_IMAGE
# Are we building a boot image
BUILDING_BOOT_IMAGE :=
ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
BUILDING_BOOT_IMAGE :=
else ifdef BOARD_PREBUILT_BOOTIMAGE
BUILDING_BOOT_IMAGE :=
else ifdef BOARD_BOOTIMAGE_PARTITION_SIZE
BUILDING_BOOT_IMAGE := true
else ifneq (,$(foreach kernel,$(BOARD_KERNEL_BINARIES),$(BOARD_$(call to-upper,$(kernel))_BOOTIMAGE_PARTITION_SIZE)))
BUILDING_BOOT_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_BOOT_IMAGE),true)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
$(warning *** PRODUCT_BUILD_BOOT_IMAGE is true, but so is BOARD_USES_RECOVERY_AS_BOOT.)
$(warning *** Skipping building boot image.)
BUILDING_BOOT_IMAGE :=
else
BUILDING_BOOT_IMAGE := true
endif
endif
.KATI_READONLY := BUILDING_BOOT_IMAGE
# Are we building an init boot image
BUILDING_INIT_BOOT_IMAGE :=
ifeq ($(PRODUCT_BUILD_INIT_BOOT_IMAGE),)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
BUILDING_INIT_BOOT_IMAGE :=
else ifdef BOARD_PREBUILT_INIT_BOOT_IMAGE
BUILDING_INIT_BOOT_IMAGE :=
else ifdef BOARD_INIT_BOOT_IMAGE_PARTITION_SIZE
BUILDING_INIT_BOOT_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_INIT_BOOT_IMAGE),true)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
$(error PRODUCT_BUILD_INIT_BOOT_IMAGE is true, but so is BOARD_USES_RECOVERY_AS_BOOT. Use only one option.)
else
BUILDING_INIT_BOOT_IMAGE := true
endif
endif
.KATI_READONLY := BUILDING_INIT_BOOT_IMAGE
# Are we building a recovery image
BUILDING_RECOVERY_IMAGE :=
ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),)
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
BUILDING_RECOVERY_IMAGE := true
else ifeq ($(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT),true)
# Set to true to build recovery resources for vendor_boot
BUILDING_RECOVERY_IMAGE := true
else ifdef BOARD_RECOVERYIMAGE_PARTITION_SIZE
ifeq (,$(filter true, $(TARGET_NO_KERNEL) $(TARGET_NO_RECOVERY)))
BUILDING_RECOVERY_IMAGE := true
endif
endif
else ifeq ($(PRODUCT_BUILD_RECOVERY_IMAGE),true)
BUILDING_RECOVERY_IMAGE := true
endif
.KATI_READONLY := BUILDING_RECOVERY_IMAGE
# Are we building a vendor boot image
BUILDING_VENDOR_BOOT_IMAGE :=
ifdef BOARD_BOOT_HEADER_VERSION
ifneq ($(call math_gt_or_eq,$(BOARD_BOOT_HEADER_VERSION),3),)
ifeq ($(PRODUCT_BUILD_VENDOR_BOOT_IMAGE),)
BUILDING_VENDOR_BOOT_IMAGE := true
else ifeq ($(PRODUCT_BUILD_VENDOR_BOOT_IMAGE),true)
BUILDING_VENDOR_BOOT_IMAGE := true
endif
endif
endif
.KATI_READONLY := BUILDING_VENDOR_BOOT_IMAGE
# Are we building a vendor kernel boot image
BUILDING_VENDOR_KERNEL_BOOT_IMAGE :=
ifeq ($(PRODUCT_BUILD_VENDOR_KERNEL_BOOT_IMAGE),true)
ifneq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
$(error BUILDING_VENDOR_BOOT_IMAGE is required, but BUILDING_VENDOR_BOOT_IMAGE is not true)
endif
ifndef BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE
$(error BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE is required when PRODUCT_BUILD_VENDOR_KERNEL_BOOT_IMAGE is true)
endif
BUILDING_VENDOR_KERNEL_BOOT_IMAGE := true
else ifeq ($(PRODUCT_BUILD_VENDOR_KERNEL),)
ifdef BOARD_VENDOR_KERNEL_BOOTIMAGE_PARTITION_SIZE
ifeq ($(BUILDING_VENDOR_BOOT_IMAGE),true)
BUILDING_VENDOR_KERNEL_BOOT_IMAGE := true
endif
endif
endif # end of PRODUCT_BUILD_VENDOR_KERNEL_BOOT_IMAGE
.KATI_READONLY := BUILDING_VENDOR_KERNEL_BOOT_IMAGE
# Are we building a ramdisk image
BUILDING_RAMDISK_IMAGE := true
ifeq ($(PRODUCT_BUILD_RAMDISK_IMAGE),)
# TODO: Be smarter about this. This probably only needs to happen when one of the follow is true:
# BUILDING_BOOT_IMAGE
# BUILDING_RECOVERY_IMAGE
else ifeq ($(PRODUCT_BUILD_RAMDISK_IMAGE),false)
BUILDING_RAMDISK_IMAGE :=
endif
.KATI_READONLY := BUILDING_RAMDISK_IMAGE
# Are we building a debug vendor_boot image
BUILDING_DEBUG_VENDOR_BOOT_IMAGE :=
# Can't build vendor_boot-debug.img if we're not building a ramdisk.
ifndef BUILDING_RAMDISK_IMAGE
ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
$(warning PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE is true, but we're not building a ramdisk image. \
Skip building the debug vendor_boot image.)
endif
# Can't build vendor_boot-debug.img if we're not building a vendor_boot.img.
else ifndef BUILDING_VENDOR_BOOT_IMAGE
ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
$(warning PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE is true, but we're not building a vendor_boot image. \
Skip building the debug vendor_boot image.)
endif
else
ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),)
BUILDING_DEBUG_VENDOR_BOOT_IMAGE := true
else ifeq ($(PRODUCT_BUILD_DEBUG_VENDOR_BOOT_IMAGE),true)
BUILDING_DEBUG_VENDOR_BOOT_IMAGE := true
endif
endif
.KATI_READONLY := BUILDING_DEBUG_VENDOR_BOOT_IMAGE
_has_boot_img_artifact :=
ifneq ($(strip $(TARGET_NO_KERNEL)),true)
ifdef BUILDING_BOOT_IMAGE
_has_boot_img_artifact := true
endif
# BUILDING_RECOVERY_IMAGE && BOARD_USES_RECOVERY_AS_BOOT implies that
# recovery is being built with the file name *boot.img*, which still counts
# as "building boot.img".
ifdef BUILDING_RECOVERY_IMAGE
ifeq ($(BOARD_USES_RECOVERY_AS_BOOT),true)
_has_boot_img_artifact := true
endif
endif
endif
# Are we building a debug boot image
BUILDING_DEBUG_BOOT_IMAGE :=
# Can't build boot-debug.img if we're not building a ramdisk.
ifndef BUILDING_RAMDISK_IMAGE
ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
$(warning PRODUCT_BUILD_DEBUG_BOOT_IMAGE is true, but we're not building a ramdisk image. \
Skip building the debug boot image.)
endif
# Can't build boot-debug.img if we're not building a boot.img.
else ifndef _has_boot_img_artifact
ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
$(warning PRODUCT_BUILD_DEBUG_BOOT_IMAGE is true, but we're not building a boot image. \
Skip building the debug boot image.)
endif
else ifdef BUILDING_INIT_BOOT_IMAGE
ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
$(warning PRODUCT_BUILD_DEBUG_BOOT_IMAGE is true, but we don't have a ramdisk in the boot image. \
Skip building the debug boot image.)
endif
else
ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),)
BUILDING_DEBUG_BOOT_IMAGE := true
# Don't build boot-debug.img if we're already building vendor_boot-debug.img.
ifdef BUILDING_DEBUG_VENDOR_BOOT_IMAGE
BUILDING_DEBUG_BOOT_IMAGE :=
endif
else ifeq ($(PRODUCT_BUILD_DEBUG_BOOT_IMAGE),true)
BUILDING_DEBUG_BOOT_IMAGE := true
endif
endif
.KATI_READONLY := BUILDING_DEBUG_BOOT_IMAGE
_has_boot_img_artifact :=
# Are we building a userdata image
BUILDING_USERDATA_IMAGE :=
ifeq ($(PRODUCT_BUILD_USERDATA_IMAGE),)
ifdef BOARD_USERDATAIMAGE_PARTITION_SIZE
BUILDING_USERDATA_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_USERDATA_IMAGE),true)
BUILDING_USERDATA_IMAGE := true
endif
.KATI_READONLY := BUILDING_USERDATA_IMAGE
# Are we building a vbmeta image
BUILDING_VBMETA_IMAGE := true
ifeq ($(PRODUCT_BUILD_VBMETA_IMAGE),false)
BUILDING_VBMETA_IMAGE :=
endif
.KATI_READONLY := BUILDING_VBMETA_IMAGE
# Are we building a super_empty image
BUILDING_SUPER_EMPTY_IMAGE :=
ifeq ($(PRODUCT_BUILD_SUPER_EMPTY_IMAGE),)
ifeq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
BUILDING_SUPER_EMPTY_IMAGE := true
endif
endif
else ifeq ($(PRODUCT_BUILD_SUPER_EMPTY_IMAGE),true)
ifneq (true,$(PRODUCT_USE_DYNAMIC_PARTITIONS))
$(error PRODUCT_BUILD_SUPER_EMPTY_IMAGE set to true, but PRODUCT_USE_DYNAMIC_PARTITIONS is not true)
endif
ifeq ($(BOARD_SUPER_PARTITION_SIZE),)
$(error PRODUCT_BUILD_SUPER_EMPTY_IMAGE set to true, but BOARD_SUPER_PARTITION_SIZE is not defined)
endif
BUILDING_SUPER_EMPTY_IMAGE := true
endif
.KATI_READONLY := BUILDING_SUPER_EMPTY_IMAGE
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR
ifeq ($(TARGET_COPY_OUT_VENDOR),$(_vendor_path_placeholder))
TARGET_COPY_OUT_VENDOR := system/vendor
else ifeq ($(filter vendor system/vendor,$(TARGET_COPY_OUT_VENDOR)),)
$(error TARGET_COPY_OUT_VENDOR must be either 'vendor' or 'system/vendor', seeing '$(TARGET_COPY_OUT_VENDOR)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_vendor_path_placeholder),$(TARGET_COPY_OUT_VENDOR),$(PRODUCT_COPY_FILES))
BOARD_USES_VENDORIMAGE :=
ifdef BOARD_PREBUILT_VENDORIMAGE
BOARD_USES_VENDORIMAGE := true
endif
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_VENDORIMAGE := true
endif
# TODO(b/137169253): For now, some AOSP targets build with prebuilt vendor image.
# But target's BOARD_PREBUILT_VENDORIMAGE is not filled.
ifeq ($(TARGET_COPY_OUT_VENDOR),vendor)
BOARD_USES_VENDORIMAGE := true
else ifdef BOARD_USES_VENDORIMAGE
$(error TARGET_COPY_OUT_VENDOR must be set to 'vendor' to use a vendor image)
endif
.KATI_READONLY := BOARD_USES_VENDORIMAGE
BUILDING_VENDOR_IMAGE :=
ifeq ($(PRODUCT_BUILD_VENDOR_IMAGE),)
ifdef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
BUILDING_VENDOR_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_VENDOR_IMAGE),true)
BUILDING_VENDOR_IMAGE := true
ifndef BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_VENDOR_IMAGE set to true, but BOARD_VENDORIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_VENDORIMAGE
BUILDING_VENDOR_IMAGE :=
endif
.KATI_READONLY := BUILDING_VENDOR_IMAGE
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_PRODUCT
ifeq ($(TARGET_COPY_OUT_PRODUCT),$(_product_path_placeholder))
TARGET_COPY_OUT_PRODUCT := system/product
else ifeq ($(filter product system/product,$(TARGET_COPY_OUT_PRODUCT)),)
$(error TARGET_COPY_OUT_PRODUCT must be either 'product' or 'system/product', seeing '$(TARGET_COPY_OUT_PRODUCT)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_product_path_placeholder),$(TARGET_COPY_OUT_PRODUCT),$(PRODUCT_COPY_FILES))
BOARD_USES_PRODUCTIMAGE :=
ifdef BOARD_PREBUILT_PRODUCTIMAGE
BOARD_USES_PRODUCTIMAGE := true
endif
ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_PRODUCTIMAGE := true
endif
$(call check_image_config,product)
.KATI_READONLY := BOARD_USES_PRODUCTIMAGE
BUILDING_PRODUCT_IMAGE :=
ifeq ($(PRODUCT_BUILD_PRODUCT_IMAGE),)
ifdef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
BUILDING_PRODUCT_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_PRODUCT_IMAGE),true)
BUILDING_PRODUCT_IMAGE := true
ifndef BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_PRODUCT_IMAGE set to true, but BOARD_PRODUCTIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_PRODUCTIMAGE
BUILDING_PRODUCT_IMAGE :=
endif
.KATI_READONLY := BUILDING_PRODUCT_IMAGE
###########################################
# TODO(b/135957588) TARGET_COPY_OUT_PRODUCT_SERVICES will be set to
# TARGET_COPY_OUT_PRODUCT as a workaround.
TARGET_COPY_OUT_PRODUCT_SERVICES := $(TARGET_COPY_OUT_PRODUCT)
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_SYSTEM_EXT
ifeq ($(TARGET_COPY_OUT_SYSTEM_EXT),$(_system_ext_path_placeholder))
TARGET_COPY_OUT_SYSTEM_EXT := system/system_ext
else ifeq ($(filter system_ext system/system_ext,$(TARGET_COPY_OUT_SYSTEM_EXT)),)
$(error TARGET_COPY_OUT_SYSTEM_EXT must be either 'system_ext' or 'system/system_ext', seeing '$(TARGET_COPY_OUT_SYSTEM_EXT)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_system_ext_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_EXT),$(PRODUCT_COPY_FILES))
BOARD_USES_SYSTEM_EXTIMAGE :=
ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
BOARD_USES_SYSTEM_EXTIMAGE := true
endif
ifdef BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_SYSTEM_EXTIMAGE := true
endif
$(call check_image_config,system_ext)
.KATI_READONLY := BOARD_USES_SYSTEM_EXTIMAGE
BUILDING_SYSTEM_EXT_IMAGE :=
ifeq ($(PRODUCT_BUILD_SYSTEM_EXT_IMAGE),)
ifdef BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
BUILDING_SYSTEM_EXT_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_SYSTEM_EXT_IMAGE),true)
BUILDING_SYSTEM_EXT_IMAGE := true
ifndef BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_SYSTEM_EXT_IMAGE set to true, but BOARD_SYSTEM_EXTIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_SYSTEM_EXTIMAGE
BUILDING_SYSTEM_EXT_IMAGE :=
endif
.KATI_READONLY := BUILDING_SYSTEM_EXT_IMAGE
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_VENDOR_DLKM
ifeq ($(TARGET_COPY_OUT_VENDOR_DLKM),$(_vendor_dlkm_path_placeholder))
TARGET_COPY_OUT_VENDOR_DLKM := $(TARGET_COPY_OUT_VENDOR)/vendor_dlkm
else ifeq ($(filter vendor_dlkm system/vendor/vendor_dlkm vendor/vendor_dlkm,$(TARGET_COPY_OUT_VENDOR_DLKM)),)
$(error TARGET_COPY_OUT_VENDOR_DLKM must be either 'vendor_dlkm', 'system/vendor/vendor_dlkm' or 'vendor/vendor_dlkm', seeing '$(TARGET_COPY_OUT_VENDOR_DLKM)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_vendor_dlkm_path_placeholder),$(TARGET_COPY_OUT_VENDOR_DLKM),$(PRODUCT_COPY_FILES))
BOARD_USES_VENDOR_DLKMIMAGE :=
ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
BOARD_USES_VENDOR_DLKMIMAGE := true
endif
ifdef BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_VENDOR_DLKMIMAGE := true
endif
$(call check_image_config,vendor_dlkm)
BUILDING_VENDOR_DLKM_IMAGE :=
ifeq ($(PRODUCT_BUILD_VENDOR_DLKM_IMAGE),)
ifdef BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
BUILDING_VENDOR_DLKM_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_VENDOR_DLKM_IMAGE),true)
BUILDING_VENDOR_DLKM_IMAGE := true
ifndef BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_VENDOR_DLKM_IMAGE set to true, but BOARD_VENDOR_DLKMIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_VENDOR_DLKMIMAGE
BUILDING_VENDOR_DLKM_IMAGE :=
endif
.KATI_READONLY := BUILDING_VENDOR_DLKM_IMAGE
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_ODM
ifeq ($(TARGET_COPY_OUT_ODM),$(_odm_path_placeholder))
TARGET_COPY_OUT_ODM := $(TARGET_COPY_OUT_VENDOR)/odm
else ifeq ($(filter odm system/vendor/odm vendor/odm,$(TARGET_COPY_OUT_ODM)),)
$(error TARGET_COPY_OUT_ODM must be either 'odm', 'system/vendor/odm' or 'vendor/odm', seeing '$(TARGET_COPY_OUT_ODM)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_odm_path_placeholder),$(TARGET_COPY_OUT_ODM),$(PRODUCT_COPY_FILES))
BOARD_USES_ODMIMAGE :=
ifdef BOARD_PREBUILT_ODMIMAGE
BOARD_USES_ODMIMAGE := true
endif
ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_ODMIMAGE := true
endif
$(call check_image_config,odm)
BUILDING_ODM_IMAGE :=
ifeq ($(PRODUCT_BUILD_ODM_IMAGE),)
ifdef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
BUILDING_ODM_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_ODM_IMAGE),true)
BUILDING_ODM_IMAGE := true
ifndef BOARD_ODMIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_ODM_IMAGE set to true, but BOARD_ODMIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_ODMIMAGE
BUILDING_ODM_IMAGE :=
endif
.KATI_READONLY := BUILDING_ODM_IMAGE
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_ODM_DLKM
ifeq ($(TARGET_COPY_OUT_ODM_DLKM),$(_odm_dlkm_path_placeholder))
TARGET_COPY_OUT_ODM_DLKM := $(TARGET_COPY_OUT_VENDOR)/odm_dlkm
else ifeq ($(filter odm_dlkm system/vendor/odm_dlkm vendor/odm_dlkm,$(TARGET_COPY_OUT_ODM_DLKM)),)
$(error TARGET_COPY_OUT_ODM_DLKM must be either 'odm_dlkm', 'system/vendor/odm_dlkm' or 'vendor/odm_dlkm', seeing '$(TARGET_COPY_OUT_ODM_DLKM)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_odm_dlkm_path_placeholder),$(TARGET_COPY_OUT_ODM_DLKM),$(PRODUCT_COPY_FILES))
BOARD_USES_ODM_DLKMIMAGE :=
ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
BOARD_USES_ODM_DLKMIMAGE := true
endif
ifdef BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_ODM_DLKMIMAGE := true
endif
$(call check_image_config,odm_dlkm)
BUILDING_ODM_DLKM_IMAGE :=
ifeq ($(PRODUCT_BUILD_ODM_DLKM_IMAGE),)
ifdef BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
BUILDING_ODM_DLKM_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_ODM_DLKM_IMAGE),true)
BUILDING_ODM_DLKM_IMAGE := true
ifndef BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_ODM_DLKM_IMAGE set to true, but BOARD_ODM_DLKMIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_ODM_DLKMIMAGE
BUILDING_ODM_DLKM_IMAGE :=
endif
.KATI_READONLY := BUILDING_ODM_DLKM_IMAGE
###########################################
# Now we can substitute with the real value of TARGET_COPY_OUT_SYSTEM_DLKM
ifeq ($(TARGET_COPY_OUT_SYSTEM_DLKM),$(_system_dlkm_path_placeholder))
TARGET_COPY_OUT_SYSTEM_DLKM := $(TARGET_COPY_OUT_SYSTEM)/system_dlkm
else ifeq ($(filter system_dlkm system/system_dlkm,$(TARGET_COPY_OUT_SYSTEM_DLKM)),)
$(error TARGET_COPY_OUT_SYSTEM_DLKM must be either 'system_dlkm' or 'system/system_dlkm', seeing '$(TARGET_COPY_OUT_ODM_DLKM)'.)
endif
PRODUCT_COPY_FILES := $(subst $(_system_dlkm_path_placeholder),$(TARGET_COPY_OUT_SYSTEM_DLKM),$(PRODUCT_COPY_FILES))
BOARD_USES_SYSTEM_DLKMIMAGE :=
ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
BOARD_USES_SYSTEM_DLKMIMAGE := true
endif
ifdef BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE
BOARD_USES_SYSTEM_DLKMIMAGE := true
endif
$(call check_image_config,system_dlkm)
BUILDING_SYSTEM_DLKM_IMAGE :=
ifeq ($(PRODUCT_BUILD_SYSTEM_DLKM_IMAGE),)
ifdef BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE
BUILDING_SYSTEM_DLKM_IMAGE := true
endif
else ifeq ($(PRODUCT_BUILD_SYSTEM_DLKM_IMAGE),true)
BUILDING_SYSTEM_DLKM_IMAGE := true
ifndef BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE
$(error PRODUCT_BUILD_SYSTEM_DLKM_IMAGE set to true, but BOARD_SYSTEM_DLKMIMAGE_FILE_SYSTEM_TYPE not defined)
endif
endif
ifdef BOARD_PREBUILT_SYSTEM_DLKMIMAGE
BUILDING_SYSTEM_DLKM_IMAGE :=
endif
.KATI_READONLY := BUILDING_SYSTEM_DLKM_IMAGE
BOARD_USES_PVMFWIMAGE :=
ifeq ($(PRODUCT_BUILD_PVMFW_IMAGE),true)
BOARD_USES_PVMFWIMAGE := true
endif
.KATI_READONLY := BOARD_USES_PVMFWIMAGE
BOARD_USES_DESKTOP_RECOVERY_IMAGE :=
ifeq ($(PRODUCT_BUILD_DESKTOP_RECOVERY_IMAGE),true)
BOARD_USES_DESKTOP_RECOVERY_IMAGE := true
endif
.KATI_READONLY := BOARD_USES_DESKTOP_RECOVERY_IMAGE
BOARD_USES_DESKTOP_RECOVERY_SWAP_KERNEL :=
ifeq ($(PRODUCT_USES_DESKTOP_RECOVERY_SWAP_KERNEL),true)
BOARD_USES_DESKTOP_RECOVERY_SWAP_KERNEL := true
endif
.KATI_READONLY := BOARD_USES_DESKTOP_RECOVERY_SWAP_KERNEL
BOARD_USES_DESKTOP_UPDATE_IMAGE :=
ifeq ($(PRODUCT_BUILD_DESKTOP_UPDATE_IMAGE),true)
BOARD_USES_DESKTOP_UPDATE_IMAGE := true
endif
.KATI_READONLY := BOARD_USES_DESKTOP_UPDATE_IMAGE
###########################################
# Ensure consistency among TARGET_RECOVERY_UPDATER_LIBS, AB_OTA_UPDATER, and PRODUCT_OTA_FORCE_NON_AB_PACKAGE.
TARGET_RECOVERY_UPDATER_LIBS ?=
ifeq ($(AB_OTA_UPDATER),)
AB_OTA_UPDATER := true
endif
.KATI_READONLY := TARGET_RECOVERY_UPDATER_LIBS AB_OTA_UPDATER
# Ensure that if PRODUCT_OTA_FORCE_NON_AB_PACKAGE == true, then AB_OTA_UPDATER must be true
ifeq ($(PRODUCT_OTA_FORCE_NON_AB_PACKAGE),true)
ifneq ($(AB_OTA_UPDATER),true)
$(error AB_OTA_UPDATER must be set to true when PRODUCT_OTA_FORCE_NON_AB_PACKAGE is true)
endif
endif
# In some configurations, A/B and non-A/B may coexist. Check TARGET_OTA_ALLOW_NON_AB
# to see if non-A/B is supported.
TARGET_OTA_ALLOW_NON_AB := false
ifneq ($(AB_OTA_UPDATER),true)
TARGET_OTA_ALLOW_NON_AB := true
else ifeq ($(PRODUCT_OTA_FORCE_NON_AB_PACKAGE),true)
TARGET_OTA_ALLOW_NON_AB := true
endif
.KATI_READONLY := TARGET_OTA_ALLOW_NON_AB
ifneq ($(TARGET_OTA_ALLOW_NON_AB),true)
ifneq ($(strip $(TARGET_RECOVERY_UPDATER_LIBS)),)
$(error Do not use TARGET_RECOVERY_UPDATER_LIBS when using TARGET_OTA_ALLOW_NON_AB)
endif
endif
# For Non A/B full OTA, disable brotli compression.
ifeq ($(TARGET_OTA_ALLOW_NON_AB),true)
BOARD_NON_AB_OTA_DISABLE_COMPRESSION := true
endif
# Quick check for building generic OTA packages. Currently it only supports A/B OTAs.
ifeq ($(PRODUCT_BUILD_GENERIC_OTA_PACKAGE),true)
ifneq ($(AB_OTA_UPDATER),true)
$(error PRODUCT_BUILD_GENERIC_OTA_PACKAGE with 'AB_OTA_UPDATER != true' is not supported)
endif
endif
ifdef BOARD_PREBUILT_DTBIMAGE_DIR
ifneq ($(BOARD_INCLUDE_DTB_IN_BOOTIMG),true)
$(error BOARD_PREBUILT_DTBIMAGE_DIR with 'BOARD_INCLUDE_DTB_IN_BOOTIMG != true' is not supported)
endif
endif
# Check BOARD_VNDK_VERSION
define check_vndk_version
$(eval vndk_path := prebuilts/vndk/v$(1)) \
$(if $(wildcard $(vndk_path)/*/Android.bp),,$(error VNDK version $(1) not found))
endef
TARGET_VENDOR_TEST_SUFFIX := /vendor
ifeq (,$(TARGET_BUILD_UNBUNDLED))
ifdef PRODUCT_EXTRA_VNDK_VERSIONS
$(foreach v,$(PRODUCT_EXTRA_VNDK_VERSIONS),$(call check_vndk_version,$(v)))
endif
endif
# Ensure that BOARD_SYSTEMSDK_VERSIONS are all within PLATFORM_SYSTEMSDK_VERSIONS
_unsupported_systemsdk_versions := $(filter-out $(PLATFORM_SYSTEMSDK_VERSIONS),$(BOARD_SYSTEMSDK_VERSIONS))
ifneq (,$(_unsupported_systemsdk_versions))
$(error System SDK versions '$(_unsupported_systemsdk_versions)' in BOARD_SYSTEMSDK_VERSIONS are not supported.\
Supported versions are $(PLATFORM_SYSTEMSDK_VERSIONS))
endif
###########################################
# BOARD_API_LEVEL for vendor API surface
ifdef RELEASE_BOARD_API_LEVEL
ifdef BOARD_API_LEVEL
$(error BOARD_API_LEVEL must not be set manually. The build system automatically sets this value.)
endif
BOARD_API_LEVEL := $(RELEASE_BOARD_API_LEVEL)
.KATI_READONLY := BOARD_API_LEVEL
endif
###########################################
# Handle BUILD_BROKEN_USES_BUILD_*
$(foreach m,$(DEFAULT_WARNING_BUILD_MODULE_TYPES),\
$(if $(filter false,$(BUILD_BROKEN_USES_$(m))),\
$(KATI_obsolete_var $(m),Please convert to Soong),\
$(KATI_deprecated_var $(m),Please convert to Soong)))
$(if $(filter true,$(BUILD_BROKEN_USES_BUILD_COPY_HEADERS)),\
$(KATI_deprecated_var BUILD_COPY_HEADERS,See $(CHANGES_URL)\#copy_headers),\
$(KATI_obsolete_var BUILD_COPY_HEADERS,See $(CHANGES_URL)\#copy_headers))
$(foreach m,$(filter-out BUILD_COPY_HEADERS,$(DEFAULT_ERROR_BUILD_MODULE_TYPES)),\
$(if $(filter true,$(BUILD_BROKEN_USES_$(m))),\
$(KATI_deprecated_var $(m),Please convert to Soong),\
$(KATI_obsolete_var $(m),Please convert to Soong)))
ifndef BUILDING_RECOVERY_IMAGE
ifeq (true,$(BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE))
$(error Should not set BOARD_EXCLUDE_KERNEL_FROM_RECOVERY_IMAGE if not building recovery image)
endif
endif
ifndef BUILDING_VENDOR_BOOT_IMAGE
ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
$(error Should not set BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT if not building vendor_boot image)
endif
ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
$(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if not building vendor_boot image)
endif
else # BUILDING_VENDOR_BOOT_IMAGE
ifneq (,$(call math_lt,$(BOARD_BOOT_HEADER_VERSION),4))
ifdef BOARD_VENDOR_RAMDISK_FRAGMENTS
$(error Should not set BOARD_VENDOR_RAMDISK_FRAGMENTS if \
BOARD_BOOT_HEADER_VERSION is less than 4)
endif
ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
$(error Should not set BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT if \
BOARD_BOOT_HEADER_VERSION is less than 4)
endif
endif
endif # BUILDING_VENDOR_BOOT_IMAGE
ifneq ($(words $(BOARD_VENDOR_RAMDISK_FRAGMENTS)),$(words $(sort $(BOARD_VENDOR_RAMDISK_FRAGMENTS))))
$(error BOARD_VENDOR_RAMDISK_FRAGMENTS has duplicate entries: $(BOARD_VENDOR_RAMDISK_FRAGMENTS))
endif
ifeq (true,$(BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT))
ifneq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
$(error Should not set BOARD_INCLUDE_RECOVERY_RAMDISK_IN_VENDOR_BOOT if \
BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT is not set)
endif
endif
# If BOARD_USES_GENERIC_KERNEL_IMAGE is set, BOARD_USES_RECOVERY_AS_BOOT must not be set.
# Devices without a dedicated recovery partition uses BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT to
# build recovery into vendor_boot.
ifeq (true,$(BOARD_USES_GENERIC_KERNEL_IMAGE))
ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
$(error BOARD_USES_RECOVERY_AS_BOOT cannot be true if BOARD_USES_GENERIC_KERNEL_IMAGE is true. \
Use BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT instead)
endif
endif
ifeq (true,$(BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT))
ifeq (true,$(BOARD_USES_RECOVERY_AS_BOOT))
$(error BOARD_MOVE_RECOVERY_RESOURCES_TO_VENDOR_BOOT and BOARD_USES_RECOVERY_AS_BOOT cannot be \
both true. Recovery resources should be installed to either boot or vendor_boot, but not both)
endif
endif
================================================
FILE: core/board_config_wifi.mk
================================================
#
# Copyright (C) 2022 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.
#
# ###############################################################
# This file adds WIFI variables into soong config namespace (`wifi`)
# ###############################################################
ifdef BOARD_WLAN_DEVICE
$(call soong_config_set,wifi,board_wlan_device,$(BOARD_WLAN_DEVICE))
endif
ifdef WIFI_DRIVER_MODULE_PATH
$(call soong_config_set,wifi,driver_module_path,$(WIFI_DRIVER_MODULE_PATH))
endif
ifdef WIFI_DRIVER_MODULE_ARG
$(call soong_config_set,wifi,driver_module_arg,$(WIFI_DRIVER_MODULE_ARG))
endif
ifdef WIFI_DRIVER_MODULE_NAME
$(call soong_config_set,wifi,driver_module_name,$(WIFI_DRIVER_MODULE_NAME))
endif
ifdef WIFI_DRIVER_FW_PATH_STA
$(call soong_config_set,wifi,driver_fw_path_sta,$(WIFI_DRIVER_FW_PATH_STA))
endif
ifdef WIFI_DRIVER_FW_PATH_AP
$(call soong_config_set,wifi,driver_fw_path_ap,$(WIFI_DRIVER_FW_PATH_AP))
endif
ifdef WIFI_DRIVER_FW_PATH_P2P
$(call soong_config_set,wifi,driver_fw_path_p2p,$(WIFI_DRIVER_FW_PATH_P2P))
endif
ifdef WIFI_DRIVER_FW_PATH_PARAM
$(call soong_config_set,wifi,driver_fw_path_param,$(WIFI_DRIVER_FW_PATH_PARAM))
endif
ifdef WIFI_DRIVER_STATE_CTRL_PARAM
$(call soong_config_set,wifi,driver_state_ctrl_param,$(WIFI_DRIVER_STATE_CTRL_PARAM))
endif
ifdef WIFI_DRIVER_STATE_ON
$(call soong_config_set,wifi,driver_state_on,$(WIFI_DRIVER_STATE_ON))
endif
ifdef WIFI_DRIVER_STATE_OFF
$(call soong_config_set,wifi,driver_state_off,$(WIFI_DRIVER_STATE_OFF))
endif
ifdef WIFI_MULTIPLE_VENDOR_HALS
$(call soong_config_set,wifi,multiple_vendor_hals,$(WIFI_MULTIPLE_VENDOR_HALS))
endif
ifneq ($(wildcard vendor/google/libraries/GoogleWifiConfigLib),)
$(call soong_config_set,wifi,google_wifi_config_lib,true)
endif
ifdef WIFI_HAL_INTERFACE_COMBINATIONS
$(call soong_config_set,wifi,hal_interface_combinations,$(WIFI_HAL_INTERFACE_COMBINATIONS))
endif
ifdef WIFI_HIDL_FEATURE_AWARE
$(call soong_config_set,wifi,hidl_feature_aware,true)
endif
ifdef WIFI_HIDL_FEATURE_DUAL_INTERFACE
$(call soong_config_set,wifi,hidl_feature_dual_interface,true)
endif
ifdef WIFI_HIDL_FEATURE_DISABLE_AP
$(call soong_config_set,wifi,hidl_feature_disable_ap,true)
endif
ifdef WIFI_HIDL_FEATURE_DISABLE_AP_MAC_RANDOMIZATION
$(call soong_config_set,wifi,hidl_feature_disable_ap_mac_randomization,true)
endif
ifdef WIFI_AVOID_IFACE_RESET_MAC_CHANGE
$(call soong_config_set,wifi,avoid_iface_reset_mac_change,true)
endif
ifdef WIFI_SKIP_STATE_TOGGLE_OFF_ON_FOR_NAN
$(call soong_config_set,wifi,wifi_skip_state_toggle_off_on_for_nan,true)
endif
ifeq ($(strip $(TARGET_USES_AOSP_FOR_WLAN)),true)
$(call soong_config_set,wifi,target_uses_aosp_for_wlan,true)
endif
================================================
FILE: core/board_config_wpa_supplicant.mk
================================================
#
# Copyright (C) 2024 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.
#
# ###############################################################
# This file adds wpa_supplicant_8 variables into soong config namespace (`wpa_supplicant_8`)
# ###############################################################
ifdef BOARD_HOSTAPD_DRIVER
$(call soong_config_set_bool,wpa_supplicant_8,wpa_build_hostapd,true)
ifneq ($(BOARD_HOSTAPD_DRIVER),NL80211)
$(error BOARD_HOSTAPD_DRIVER set to $(BOARD_HOSTAPD_DRIVER) but current soong expected it should be NL80211 only!)
endif
endif
ifdef BOARD_WPA_SUPPLICANT_DRIVER
ifneq ($(BOARD_WPA_SUPPLICANT_DRIVER),NL80211)
$(error BOARD_WPA_SUPPLICANT_DRIVER set to $(BOARD_WPA_SUPPLICANT_DRIVER) but current soong expected it should be NL80211 only!)
endif
endif
# This is for CONFIG_DRIVER_NL80211_BRCM, CONFIG_DRIVER_NL80211_SYNA, CONFIG_DRIVER_NL80211_QCA
# And it is only used for a cflags setting in driver.
$(call soong_config_set,wpa_supplicant_8,board_wlan_device,$(BOARD_WLAN_DEVICE))
# Belong to CONFIG_IEEE80211AX definition
ifeq ($(WIFI_FEATURE_HOSTAPD_11AX),true)
$(call soong_config_set_bool,wpa_supplicant_8,hostapd_11ax,true)
endif
# Belong to CONFIG_IEEE80211BE definition
ifeq ($(WIFI_FEATURE_HOSTAPD_11BE),true)
$(call soong_config_set_bool,wpa_supplicant_8,hostapd_11be,true)
endif
# PLATFORM_VERSION
$(call soong_config_set,wpa_supplicant_8,platform_version,$(PLATFORM_VERSION))
# BOARD_HOSTAPD_PRIVATE_LIB
ifeq ($(BOARD_HOSTAPD_PRIVATE_LIB),)
$(call soong_config_set_bool,wpa_supplicant_8,hostapd_use_stub_lib,true)
else
$(call soong_config_set,wpa_supplicant_8,board_hostapd_private_lib,$(BOARD_HOSTAPD_PRIVATE_LIB))
endif
ifeq ($(BOARD_HOSTAPD_CONFIG_80211W_MFP_OPTIONAL),true)
$(call soong_config_set_bool,wpa_supplicant_8,board_hostapd_config_80211w_mfp_optional,true)
endif
ifneq ($(BOARD_HOSTAPD_PRIVATE_LIB_EVENT),)
$(call soong_config_set_bool,wpa_supplicant_8,board_hostapd_private_lib_event,true)
endif
# BOARD_WPA_SUPPLICANT_PRIVATE_LIB
ifeq ($(BOARD_WPA_SUPPLICANT_PRIVATE_LIB),)
$(call soong_config_set_bool,wpa_supplicant_8,wpa_supplicant_use_stub_lib,true)
else
$(call soong_config_set,wpa_supplicant_8,board_wpa_supplicant_private_lib,$(BOARD_WPA_SUPPLICANT_PRIVATE_LIB))
endif
ifneq ($(BOARD_WPA_SUPPLICANT_PRIVATE_LIB_EVENT),)
$(call soong_config_set_bool,wpa_supplicant_8,board_wpa_supplicant_private_lib_event,true)
endif
ifeq ($(WIFI_PRIV_CMD_UPDATE_MBO_CELL_STATUS), enabled)
$(call soong_config_set_bool,wpa_supplicant_8,wifi_priv_cmd_update_mbo_cell_status,true)
endif
ifeq ($(WIFI_HIDL_UNIFIED_SUPPLICANT_SERVICE_RC_ENTRY), true)
$(call soong_config_set_bool,wpa_supplicant_8,wifi_hidl_unified_supplicant_service_rc_entry,true)
endif
# New added in internal main
ifeq ($(WIFI_BRCM_OPEN_SOURCE_MULTI_AKM), enabled)
$(call soong_config_set_bool,wpa_supplicant_8,wifi_brcm_open_source_multi_akm,true)
endif
================================================
FILE: core/build-system.html
================================================
Android Build System
Android Build System
Status:Draft
(as of May 18, 2006)
Contents
Objective
The primary goals of reworking the build system are (1) to make dependencies
work more reliably, so that when files need to rebuilt, they are, and (2) to
improve performance of the build system so that unnecessary modules are not
rebuilt, and so doing a top-level build when little or nothing needs to be done
for a build takes as little time as possible.
Principles and Use Cases and Policy
Given the above objective, these are the overall principles and use cases
that we will support. This is not an exhaustive list.
Multiple Targets
It needs to be possible to build the Android platform for multiple targets.
This means:
The build system will support building tools for the host platform,
both ones that are used in the build process itself, and developer tools
like the simulator.
The build system will need to be able to build tools on Linux
(definitely Goobuntu and maybe Grhat), MacOS, and to some degree on
Windows.
The build system will need to be able to build the OS on Linux, and in
the short-term, MacOS. Note that this is a conscious decision to stop
building the OS on Windows. We are going to rely on the emulator there
and not attempt to use the simulator. This is a requirement change now
that the emulator story is looking brighter.
When developing a component, for example a C++ shared library, it must be
possible to easily rebuild just that component, and not have to wait more than a
couple seconds for dependency checks, and not have to wait for unneeded
components to be built.
Both Environment and Config File Based Settings
To set the target, and other options, some people on the team like to have a
configuration file in a directory so they do not have an environment setup
script to run, and others want an environment setup script to run so they can
run builds in different terminals on the same tree, or switch back and forth
in one terminal. We will support both.
Object File Directory / make clean
Object files and other intermediate files will be generated into a directory
that is separate from the source tree. The goal is to have make clean be
"rm -rf " in the tree root directory. The primary goals of
this are to simplify searching the source tree, and to make "make clean" more
reliable.
SDK
The SDK will be a tarball that will allow non-OS-developers to write apps.
The apps will actually be built by first building the SDK, and then building
the apps against that SDK. This will hopefully (1) make writing apps easier
for us, because we won't have to rebuild the OS as much, and we can use the
standard java-app development tools, and (2) allow us to dog-food the SDK, to
help ensure its quality. Cedric has suggested (and I agree) that apps built
from the SDK should be built with ant. Stay tuned for more details as we
figure out exactly how this will work.
Dependecies
Dependencies should all be automatic. Unless there is a custom tool involved
(e.g. the webkit has several), the dependencies for shared and static libraries,
.c, .cpp, .h, .java, java libraries, etc., should all work without intervention
in the Android.mk file.
Wildcard source files
Wildcarding source file will be discouraged. It may be useful in some
scenarios. The default $(wildcard *) will not work due to the
current directory being set to the root of the build tree.
Multiple targets in one directory
It will be possible to generate more than one target from a given
subdirectory. For example, libutils generates a shared library for the target
and a static library for the host.
Makefile fragments for modules
Android.mk is the standard name for the makefile fragments that
control the building of a given module. Only the top directory should
have a file named "Makefile".
Use shared libraries
Currently, the simulator is not built to use shared libraries. This should
be fixed, and now is a good time to do it. This implies getting shared
libraries to work on Mac OS.
Nice to Have
These things would be nice to have, and this is a good place to record them,
however these are not promises.
Simultaneous Builds
The hope is to be able to do two builds for different combos in the same
tree at the same time, but this is a stretch goal, not a requirement.
Doing two builds in the same tree, not at the same time must work. (update:
it's looking like we'll get the two builds at the same time working)
Deleting headers (or other dependecies)
Problems can arise if you delete a header file that is referenced in
".d" files. The easy way to deal with this is "make clean". There
should be a better way to handle it. (from fadden)
One way of solving this is introducing a dependency on the directory. The
problem is that this can create extra dependecies and slow down the build.
It's a tradeoff.
Multiple builds
General way to perform builds across the set of known platforms. This
would make it easy to perform multiple platform builds when testing a
change, and allow a wide-scale "make clean". Right now the buildspec.mk
or environment variables need to be updated before each build. (from fadden)
Aftermarket Locales and Carrier
We will eventually need to add support for creating locales and carrier
customizations to the SDK, but that will not be addressed right now.
Usage
You've read (or scrolled past) all of the motivations for this build system,
and you want to know how to use it. This is the place.
If you source the file build/envsetup.sh into your bash environment,
. build/envsetup.shyou'll get a few helpful shell functions:
printconfig - Prints the current configuration as set by the
lunch and choosecombo commands.
m - Runs make from the top of the tree. This is
useful because you can run make from within subdirectories. If you have the
TOP environment variable set, it uses that. If you don't, it looks
up the tree from the current directory, trying to find the top of the tree.
croot - cd to the top of the tree.
sgrep - grep for the regex you provide in all .c, .cpp, .h, .java,
and .xml files below the current directory.
Build flavors/types
When building for a particular product, it's often useful to have minor
variations on what is ultimately the final release build. These are the
currently-defined "flavors" or "types" (we need to settle on a real name
for these).
eng
This is the default flavor. A plain "make" is the
same as "make eng". droid is an alias
for eng.
Installs non-APK modules that have no tags specified.
Installs APKs according to the product definition files, in
addition to tagged APKs.
ro.secure=0
ro.debuggable=1
ro.kernel.android.checkjni=1
adb is enabled by default.
user
"make user"
This is the flavor intended to be the final release bits.
Installs modules tagged with user.
Installs non-APK modules that have no tags specified.
Installs APKs according to the product definition files; tags
are ignored for APK modules.
ro.adb.secure=1
ro.secure=1
ro.debuggable=0
adb is disabled by default.
userdebug
"make userdebug"
The same as user, except:
Also installs modules tagged with debug.
ro.debuggable=1
adb is enabled by default.
If you build one flavor and then want to build another, you should run
"make installclean" between the two makes to guarantee that
you don't pick up files installed by the previous flavor. "make
clean" will also suffice, but it takes a lot longer.
More pseudotargets
Sometimes you want to just build one thing. The following pseudotargets are
there for your convenience:
droid - make droid is the normal build. This target
is here because the default target has to have a name.
all - make all builds everything make
droid does, plus everything whose LOCAL_MODULE_TAGS do not
include the "droid" tag. The build server runs this to make sure
that everything that is in the tree and has an Android.mk builds.
clean-$(LOCAL_MODULE) and clean-$(LOCAL_PACKAGE_NAME) -
Let you selectively clean one target. For example, you can type
make clean-libutils and it will delete libutils.so and all of the
intermediate files, or you can type make clean-Home and it will
clean just the Home app.
clean - make clean deletes all of the output and
intermediate files for this configuration. This is the same as rm -rf
out/<configuration>/
clobber - make clobber deletes all of the output
and intermediate files for all configurations. This is the same as
rm -rf out/.
dataclean - make dataclean deletes contents of the data
directory inside the current combo directory. This is especially useful on the
simulator and emulator, where the persistent data remains present between
builds.
LOCAL_MODULE - Anything you specify as a LOCAL_MODULE
in an Android.mk is made into a pseudotarget. For example, make
runtime might be shorthand for make
out/linux-x86-debug/system/bin/runtime (which would work), and
make libkjs might be shorthand for make
out/linux-x86-debug/system/lib/libkjs.so (which would also work).
targets - make targets will print a list of all of
the LOCAL_MODULE names you can make.
How to add another component to the build - Android.mk templates
You have a new library, a new app, or a new executable. For each of the
common types of modules, there is a corresponding file in the templates
directory. It will usually be enough to copy one of these, and fill in your
own values. Some of the more esoteric values are not included in the
templates, but are instead just documented here, as is the documentation
on using custom tools to generate files.
Mostly, you can just look for the TODO comments in the templates and do
what it says. Please remember to delete the TODO comments when you're done
to keep the files clean. The templates have minimal documentation in them,
because they're going to be copied, and when that gets stale, the copies just
won't get updated. So read on...
Apps
Use the templates/apps file.
This template is pretty self-explanitory. See the variables below for more
details.
Java Libraries
Use the templates/java_library file.
The interesting thing here is the value of LOCAL_MODULE, which becomes
the name of the jar file. (Actually right now, we're not making jar files yet,
just directories of .class files, but the directory is named according to
what you put in LOCAL_MODULE). This name will be what goes in the
LOCAL_JAVA_LIBRARIES variable in modules that depend on your java library.
C/C++ Executables
Use the templates/executable file, or the
templates/executable_host file.
This template has a couple extra options that you usually don't need.
Please delete the ones you don't need, and remove the TODO comments. It makes
the rest of them easier to read, and you can always refer back to the templates
if you need them again later.
By default, on the target these are built into /system/bin, and on the
host, they're built into /host/bin. These can be overridden by setting
LOCAL_MODULE_PATH or LOCAL_MODULE_RELATIVE_PATH. See
Putting targets elsewhere
for more.
Shared Libraries
Use the templates/shared_library file, or the
templates/shared_library_host file.
Remember that on the target, we use shared libraries, and on the host,
we use static libraries, since executable size isn't as big an issue, and it
simplifies distribution in the SDK.
Static Libraries
Use the templates/static_library file, or the
templates/static_library_host file.
Remember that on the target, we use shared libraries, and on the host,
we use static libraries, since executable size isn't as big an issue, and it
simplifies distribution in the SDK.
Using Custom Tools
If you have a tool that generates source files for you, it's possible
to have the build system get the dependencies correct for it. Here are
a couple of examples. $@ is the make built-in variable for
"the current target." The red parts are the parts you'll
need to change.
You need to put this after you have declared LOCAL_PATH and
LOCAL_MODULE, because the $(local-generated-sources-dir)
and $(local-host-generated-sources-dir) macros use these variables
to determine where to put the files.
Example 1
Here, there is one generated file, called
chartables.c, which doesn't depend on anything. And is built by the tool
built to $(HOST_OUT_EXECUTABLES)/dftables. Note on the second to last line
that a dependency is created on the tool.
Here as a hypothetical example, we use use cat as if it were to transform
a file. Pretend that it does something useful. Note how we use a
target-specific variable called PRIVATE_INPUT_FILE to store the name of the
input file.
If you have several files that are all similar in
name, and use the same tool, you can combine them. (here the *.lut.h files are
the generated ones, and the *.cpp files are the input files)
Unbundled build has several meanings by the context.
Let me explain the meaning by the flags related to "unbundled build"
TARGET_BUILD_UNBUNDLED
The source tree might not have the full platform sources. It turns on
TARGET_BUILD_USE_PREBUILT_SDKS, unless
UNBUNDLED_BUILD_SDKS_FROM_SOURCE is set. It is always set if
TARGET_BUILD_APPS or TARGET_BUILD_UNBUNDLED_IMAGE is set.
TARGET_BUILD_USE_PREBUILT_SDKS
It is an internal flag. If it is set, prebuilt SDKs are used, even if a module's
LOCAL_SDK_VERSION is current (including system_current,
core_current, and so on). If it is unset, build current SDKs,
and use them as usual.
DISABLE_PREOPT
It is an internal flag as well. If it is set, dexpreopt is disabled.
It is always set if TARGET_BUILD_APPS or TARGET_BUILD_UNBUNDLED_IMAGE is set,
because dexpreopt tightly depends on the platform.
TARGET_BUILD_APPS
Build the apps that can be distributed outside the platform, so it turns on
TARGET_BUILD_UNBUNDLED and DISABLE_PREOPT.
Also, it turns on TARGET_BUILD_USE_PREBUILT_SDKS, unless
UNBUNDLED_BUILD_SDKS_FROM_SOURCE is set.
TARGET_BUILD_UNBUNDLED_IMAGE
It is similar to TARGET_BUILD_APPS, but its target is an unbundled partition
(such as the vendor partition). Accordingly, it sets TARGET_BUILD_UNBUNDLED and DISABLE_PREOPT.
We can call the partition unbundled, because the partition can be distributed outside the platform.
And also, it turns on TARGET_BUILD_USE_PREBUILT_SDKS, unless
UNBUNDLED_BUILD_SDKS_FROM_SOURCE is set.
Platform specific conditionals
Sometimes you need to set flags specifically for different platforms. Here
is a list of which values the different build-system defined variables will be
set to and some examples.
HOST_OS
linux
darwin
HOST_ARCH
x86
x86_64
HOST_BUILD_TYPE
release
debug
TARGET_ARCH
arm
arm64
x86
x86_64
TARGET_BUILD_TYPE
release
debug
There are also special variables to use instead of conditionals. Many of the
normal variables (LOCAL_SRC_FILES, LOCAL_CFLAGS, etc) can be conditionally added
to with _{arch} _{32|64}, and for the host, _{os}.
Some Examples
ifeq ($(TARGET_BUILD_TYPE),release)
LOCAL_CFLAGS += -DNDEBUG=1
endif
LOCAL_CFLAGS_arm += -DTARGET_IS_ARM
LOCAL_CFLAGS_64 += -DBIG_POINTER
# from libutils
# Use the futex based mutex and condition variable
# implementation from android-arm because it's shared mem safe
LOCAL_SRC_FILES_linux += futex_synchro.c
LOCAL_LDLIBS_linux += -lrt -ldl
Putting modules elsewhere
If you have modules that normally go somewhere, and you need to have them
build somewhere else, read this.
If you have modules that need to go in a subdirectory of their normal
location, for example HAL modules that need to go in /system/lib/hw or
/vendor/lib/hw, set LOCAL_MODULE_RELATIVE_PATH in your Android.mk, for
example:
LOCAL_MODULE_RELATIVE_PATH := hw
If you have modules that need to go in an entirely different location, for
example the root filesystem instead of in /system, add these lines to your
Android.mk:
For executables and libraries, you need to specify a
LOCAL_UNSTRIPPED_PATH location if you specified a
LOCAL_MODULE_PATH, because on target builds, we keep
the unstripped executables so GDB can find the symbols.
LOCAL_UNSTRIPPED_PATH is not necessary if you only specified
LOCAL_MODULE_RELATIVE_PATH.
Look in core/envsetup.mk for all of the variables defining
places to build things.
Android.mk variables
These are the variables that you'll commonly see in Android.mk files, listed
alphabetically.
But first, a note on variable naming:
LOCAL_ - These variables are set per-module. They are cleared
by the include $(CLEAR_VARS) line, so you can rely on them
being empty after including that file. Most of the variables you'll use
in most modules are LOCAL_ variables.
PRIVATE_ - These variables are make-target-specific variables. That
means they're only usable within the commands for that module. It also
means that they're unlikely to change behind your back from modules that
are included after yours. This
link to the make documentation
describes more about target-specific variables. Please note that there
are a couple of these laying around the tree that aren't prefixed with
PRIVATE_. It is safe, and they will be fixed as they are discovered.
Sorry for the confusion.
INTERNAL_ - These variables are critical to functioning of
the build system, so you shouldn't create variables named like this, and
you probably shouldn't be messing with these variables in your makefiles.
HOST_ and TARGET_ - These contain the directories
and definitions that are specific to either the host or the target builds.
Do not set variables that start with HOST_ or TARGET_ in your makefiles.
HOST_CROSS_ - These contain the directories and definitions that
are specific to cross-building host binaries. The common case is building
windows host tools on linux. Do not set variables that start with
HOST_CROSS_ in your makefiles.
BUILD_ and CLEAR_VARS - These contain the names of
well-defined template makefiles to include. Some examples are CLEAR_VARS
and BUILD_HOST_PACKAGE.
Any other name is fair-game for you to use in your Android.mk. However,
remember that this is a non-recursive build system, so it is possible that
your variable will be changed by another Android.mk included later, and be
different when the commands for your rule / module are executed.
LOCAL_ANNOTATION_PROCESSORS
Set this to a list of modules built with BUILD_HOST_JAVA_LIBRARY
to have their jars passed to javac with -processorpath for use as annotation
processors.
LOCAL_ANNOTATION_PROCESSOR_CLASSES
Set this to a list of classes to be passed to javac as -processor arguments.
This list is would be unnecessary, as javac will autodetect annotation processor
classes, except that the Grok tool that is used on the Android source code
does not autodetect them and requires listing them manually.
LOCAL_ASSET_FILES
In Android.mk files that include $(BUILD_PACKAGE) set this
to the set of files you want built into your app. Usually:
LOCAL_ASSET_FILES += $(call find-subdir-assets)
This will probably change when we switch to ant for the apps' build
system.
LOCAL_CC
If you want to use a different C compiler for this module, set LOCAL_CC
to the path to the compiler. If LOCAL_CC is blank, the appropriate default
compiler is used.
LOCAL_CXX
If you want to use a different C++ compiler for this module, set LOCAL_CXX
to the path to the compiler. If LOCAL_CXX is blank, the appropriate default
compiler is used.
LOCAL_CFLAGS
If you have additional flags to pass into the C or C++ compiler, add
them here. For example:
LOCAL_CFLAGS += -DLIBUTILS_NATIVE=1
LOCAL_CPPFLAGS
If you have additional flags to pass into only the C++ compiler, add
them here. For example:
LOCAL_CPPFLAGS += -ffriend-injection
LOCAL_CPPFLAGS is guaranteed to be after LOCAL_CFLAGS
on the compile line, so you can use it to override flags listed in
LOCAL_CFLAGS.
LOCAL_CPP_EXTENSION
If your C++ files end in something other than ".cpp",
you can specify the custom extension here. For example:
LOCAL_CPP_EXTENSION := .cc
Note that all C++ files for a given module must have the same
extension; it is not currently possible to mix different extensions.
LOCAL_NO_DEFAULT_COMPILER_FLAGS
Normally, the compile line for C and C++ files includes global include
paths and global cflags. If LOCAL_NO_DEFAULT_COMPILER_FLAGS
is non-empty, none of the default includes or flags will be used when compiling
C and C++ files in this module.
LOCAL_C_INCLUDES, LOCAL_CFLAGS, and
LOCAL_CPPFLAGS will still be used in this case, as will
any DEBUG_CFLAGS that are defined for the module.
LOCAL_COPY_HEADERS
This will be going away.
The set of files to copy to the install include tree. You must also
supply LOCAL_COPY_HEADERS_TO.
This is going away because copying headers messes up the error messages, and
may lead to people editing those headers instead of the correct ones. It also
makes it easier to do bad layering in the system, which we want to avoid. We
also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any
headers.
LOCAL_COPY_HEADERS_TO
This will be going away.
The directory within "include" to copy the headers listed in
LOCAL_COPY_HEADERS to.
This is going away because copying headers messes up the error messages, and
may lead to people editing those headers instead of the correct ones. It also
makes it easier to do bad layering in the system, which we want to avoid. We
also aren't doing a C/C++ SDK, so there is no ultimate requirement to copy any
headers.
LOCAL_C_INCLUDES
Additional directories to instruct the C/C++ compilers to look for header
files in. These paths are rooted at the top of the tree. Use
LOCAL_PATH if you have subdirectories of your own that you
want in the include paths. For example:
You should not add subdirectories of include to
LOCAL_C_INCLUDES, instead you should reference those files
in the #include statement with their subdirectories. For
example:
#include <utils/KeyedVector.h>
not #include <KeyedVector.h>
There are some components that are doing this wrong, and should be cleaned
up.
LOCAL_MODULE_TAGS
Set LOCAL_MODULE_TAGS to any number of whitespace-separated
tags. If the tag list is empty or contains droid, the module
will get installed as part of a make droid. Otherwise, it will
only get installed by running make <your-module>
or with the make all pseudotarget.
LOCAL_REQUIRED_MODULES
Set LOCAL_REQUIRED_MODULES to any number of whitespace-separated
module names, like "libblah" or "Email". If this module is installed, all
of the modules that it requires will be installed as well. This can be
used to, e.g., ensure that necessary shared libraries or providers are
installed when a given app is installed.
LOCAL_FORCE_STATIC_EXECUTABLE
If your executable should be linked statically, set
LOCAL_FORCE_STATIC_EXECUTABLE:=true. There is a very short
list of libraries that we have in static form (currently only libc).
LOCAL_GENERATED_SOURCES
Files that you add to LOCAL_GENERATED_SOURCES will be
automatically generated and then linked in when your module is built.
See the Custom Tools template makefile for an
example.
LOCAL_JAVACFLAGS
If you have additional flags to pass into the javac compiler, add
them here. For example:
LOCAL_JAVACFLAGS += -Xlint:deprecation
LOCAL_ERROR_PRONE_FLAGS
If you have additional flags to pass into the error prone compiler, add
them here. For example:
When linking Java apps and libraries, LOCAL_JAVA_LIBRARIES
specifies which sets of java classes to include. Currently there are
two of these: core and framework.
In most cases, it will look like this:
LOCAL_JAVA_LIBRARIES := core framework
Note that setting LOCAL_JAVA_LIBRARIES is not necessary
(and is not allowed) when building an APK with
"include $(BUILD_PACKAGE)". The appropriate libraries
will be included automatically.
LOCAL_LDFLAGS
You can pass additional flags to the linker by setting
LOCAL_LDFLAGS. Keep in mind that the order of parameters is
very important to ld, so test whatever you do on all platforms.
LOCAL_LDLIBS
LOCAL_LDLIBS allows you to specify additional libraries
that are not part of the build for your executable or library. Specify
the libraries you want in -lxxx format; they're passed directly to the
link line. However, keep in mind that there will be no dependency generated
for these libraries. It's most useful in simulator builds where you want
to use a library preinstalled on the host. The linker (ld) is a particularly
fussy beast, so it's sometimes necessary to pass other flags here if you're
doing something sneaky. Some examples:
If your package doesn't have a manifest (AndroidManifest.xml), then
set LOCAL_NO_MANIFEST:=true. The common resources package
does this.
LOCAL_PACKAGE_NAME
LOCAL_PACKAGE_NAME is the name of an app. For example,
Dialer, Contacts, etc. This will probably change or go away when we switch
to an ant-based build system for the apps.
LOCAL_PATCH_MODULE (experimental option)
As of January 2018, you almost certainly don't need this option, so please
ask and only use it if you understand what you're doing. This feature is
experimental and may go away in future.
When compiling language level 9+ .java code in packages that are part of a
a system module, LOCAL_PATCH_MODULE names the module that your
sources and dependencies should be patched into. The Android runtime currently
(Jan 2018) doesn't implement the JEP 261 module system so this option is only
supported at compile time. It should only be needed to compile tests in packages
that exist in libcore and which are inconvenient to move elsewhere.
LOCAL_PATH
The directory your Android.mk file is in. You can set it by putting the
following as the first line in your Android.mk:
LOCAL_PATH := $(my-dir)
The my-dir macro uses the
MAKEFILE_LIST
variable, so you must call it before you include any other makefiles. Also,
consider that any subdirectories you inlcude might reset LOCAL_PATH, so do your
own stuff before you include them. This also means that if you try to write
several include lines that reference LOCAL_PATH,
it won't work, because those included makefiles might reset LOCAL_PATH.
LOCAL_POST_PROCESS_COMMAND
For host executables, you can specify a command to run on the module
after it's been linked. You might have to go through some contortions
to get variables right because of early or late variable evaluation:
When including $(BUILD_MULTI_PREBUILT) or $(BUILD_HOST_PREBUILT), set these
to executables that you want copied. They're located automatically into the
right bin directory.
LOCAL_PREBUILT_LIBS
When including $(BUILD_MULTI_PREBUILT) or $(BUILD_HOST_PREBUILT), set these
to libraries that you want copied. They're located automatically into the
right lib directory.
LOCAL_SHARED_LIBRARIES
These are the libraries you directly link against. You don't need to
pass transitively included libraries. Specify the name without the suffix:
The build system looks at LOCAL_SRC_FILES to know what source
files to compile -- .cpp .c .y .l .java. For lex and yacc files, it knows
how to correctly do the intermediate .h and .c/.cpp files automatically. If
the files are in a subdirectory of the one containing the Android.mk, prefix
them with the directory name:
LOCAL_SRC_FILES := \
file1.cpp \
dir/file2.cpp
LOCAL_STATIC_LIBRARIES
These are the static libraries that you want to include in your module.
Mostly, we use shared libraries, but there are a couple of places, like
host executables where we use static libraries instead.
LOCAL_STATIC_LIBRARIES := \
libutils \
libtinyxml
LOCAL_MODULE
LOCAL_MODULE is the name of what's supposed to be generated
from your Android.mk. For exmample, for libkjs, the LOCAL_MODULE
is "libkjs" (the build system adds the appropriate suffix -- .so .dylib .dll).
For app modules, use LOCAL_PACKAGE_NAME instead of
LOCAL_MODULE. We're planning on switching to ant for the apps,
so this might become moot.
LOCAL_MODULE_PATH
Instructs the build system to put the module somewhere other than what's
normal for its type. If you override this, make sure you also set
LOCAL_UNSTRIPPED_PATH if it's an executable or a shared library
so the unstripped binary has somewhere to go. An error will occur if you forget
to.
Instructs the build system to put the module in a subdirectory under the
directory that is normal for its type. If you set this you do not need to
set LOCAL_UNSTRIPPED_PATH, the unstripped binaries will also use
the relative path.
This specifies which OSes are supported by this host module. It is not used
for target builds. The accepted values here are combinations of
linux, darwin, and windows. By default,
linux and darwin(MacOS) are considered to be supported. If a module should
build under windows, you must specify windows, and any others to be supported.
Some examples:
LOCAL_MODULE_HOST_OS := linux
LOCAL_MODULE_HOST_OS := darwin linux windows
LOCAL_UNSTRIPPED_PATH
Instructs the build system to put the unstripped version of the module
somewhere other than what's normal for its type. Usually, you override this
because you overrode LOCAL_MODULE_PATH for an executable or a
shared library. If you overrode LOCAL_MODULE_PATH, but not
LOCAL_UNSTRIPPED_PATH, an error will occur.
These are the static libraries that you want to include in your module without allowing
the linker to remove dead code from them. This is mostly useful if you want to add a static library
to a shared library and have the static library's content exposed from the shared library.
Any flags to pass to invocations of yacc for your module. A known limitation
here is that the flags will be the same for all invocations of YACC for your
module. This can be fixed. If you ever need it to be, just ask.
LOCAL_YACCFLAGS := -p kjsyy
Implementation Details
You should never have to touch anything in the config directory unless
you're adding a new platform, new tools, or adding new features to the
build system. In general, please consult with the build system owner(s)
(android-build-team) before you go
mucking around in here. That said, here are some notes on what's going on
under the hood.
Environment Setup / buildspec.mk Versioning
In order to make easier for people when the build system changes, when
it is necessary to make changes to buildspec.mk or to rerun the environment
setup scripts, they contain a version number in the variable
BUILD_ENV_SEQUENCE_NUMBER. If this variable does not match what the build
system expects, it fails printing an error message explaining what happened.
If you make a change that requires an update, you need to update two places
so this message will be printed.
In core/envsetup.mk, increment the
CORRECT_BUILD_ENV_SEQUENCE_NUMBER definition.
In buildspec.mk.default, update the BUILD_ENV_SEQUENCE_DUMBER
definition to match the one in core/envsetup.mk
The scripts automatically get the value from the build system, so they will
trigger the warning as well.
Additional makefile variables
You probably shouldn't use these variables. Please consult
android-build-team before using them.
These are mostly there for workarounds for other issues, or things that aren't
completely done right.
LOCAL_ADDITIONAL_DEPENDENCIES
If your module needs to depend on anything else that
isn't actually built in to it, you can add those make targets to
LOCAL_ADDITIONAL_DEPENDENCIES. Usually this is a workaround
for some other dependency that isn't created automatically.
LOCAL_BUILT_MODULE
This should not be used, since multiple binaries are now
created from a single module defintiion.
When a module is built, the module is created in an intermediate
directory then copied to its final location. LOCAL_BUILT_MODULE is
the full path to the intermediate file. See LOCAL_INSTALLED_MODULE
for the path to the final installed location of the module.
LOCAL_IS_HOST_MODULE
Set by the host_xxx.mk includes to tell base_rules.mk and the other
includes that we're building for the host.
LOCAL_INSTALLED_MODULE
This should not be used, since multiple binaries are now
created from a single module defintiion.
The fully qualified path name of the final location of the module.
See LOCAL_BUILT_MODULE for the location of the intermediate file that
the make rules should actually be constructing.
LOCAL_MODULE_CLASS
Which kind of module this is. This variable is used to construct other
variable names used to locate the modules. See base_rules.mk and
envsetup.mk.
LOCAL_MODULE_SUFFIX
The suffix that will be appended to LOCAL_MODULE to form
LOCAL_MODULE_NAME. For example, .so, .a, .dylib.
LOCAL_STRIP_MODULE
If set to true (the default), the binary will be stripped and a debug
link will be set up so that GDB will still work. If set to no_debuglink,
the binary will be stripped, but no debug link will be added. If set to
keep_symbols, it will strip the debug information, but keep the symbol table.
Any other value will prevent stripping.
LOCAL_SYSTEM_SHARED_LIBRARIES
Used while building the base libraries: libc, libm, libdl. Usually
it should be set to "none," as it is in $(CLEAR_VARS). When building
these libraries, it's set to the ones they link against. For example,
libc, libstdc++ and libdl don't link against anything, and libm links against
libc. Normally, when the value is none, these libraries are automatically
linked in to executables and libraries, so you don't need to specify them
manually.
================================================
FILE: core/build_id.mk
================================================
#
# Copyright (C) 2008 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.
#
# BUILD_ID is usually used to specify the branch name
# (like "MAIN") or a branch name and a release candidate
# (like "CRB01"). It must be a single word, and is
# capitalized by convention.
BUILD_ID=MAIN
================================================
FILE: core/build_rro_package.mk
================================================
#############################################################################
## Standard rules for installing runtime resouce overlay APKs.
##
## Set LOCAL_RRO_THEME to the theme name if the package should apply only to
## a particular theme as set by ro.boot.vendor.overlay.theme system property.
##
## If LOCAL_RRO_THEME is not set, the package will apply always, independent
## of themes.
##
#############################################################################
LOCAL_IS_RUNTIME_RESOURCE_OVERLAY := true
ifneq ($(LOCAL_SRC_FILES),)
$(error runtime resource overlay package should not contain sources)
endif
partition :=
ifeq ($(strip $(LOCAL_ODM_MODULE)),true)
partition := $(TARGET_OUT_ODM)
else ifeq ($(strip $(LOCAL_VENDOR_MODULE)),true)
partition := $(TARGET_OUT_VENDOR)
else ifeq ($(strip $(LOCAL_SYSTEM_EXT_MODULE)),true)
partition := $(TARGET_OUT_SYSTEM_EXT)
else
partition := $(TARGET_OUT_PRODUCT)
endif
ifeq ($(LOCAL_RRO_THEME),)
LOCAL_MODULE_PATH := $(partition)/overlay
else
LOCAL_MODULE_PATH := $(partition)/overlay/$(LOCAL_RRO_THEME)
endif
# Do not remove resources without default values nor dedupe resource
# configurations with the same value
LOCAL_AAPT_FLAGS += \
--no-resource-deduping \
--no-resource-removal
partition :=
include $(BUILD_SYSTEM)/package.mk
================================================
FILE: core/cc_prebuilt_internal.mk
================================================
#
# Copyright (C) 2019 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.
#
############################################################
# Internal build rules for native prebuilt modules
############################################################
prebuilt_module_classes := STATIC_LIBRARIES SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS
ifeq ($(filter $(prebuilt_module_classes),$(LOCAL_MODULE_CLASS)),)
$(call pretty-error,cc_prebuilt_internal.mk is for $(prebuilt_module_classes) modules only)
endif
my_strip_module := $(firstword \
$(LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)) \
$(LOCAL_STRIP_MODULE))
ifeq (SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS))
ifeq ($(LOCAL_IS_HOST_MODULE)$(my_strip_module),)
# Strip but not try to add debuglink
my_strip_module := no_debuglink
endif
endif
ifneq ($(filter STATIC_LIBRARIES SHARED_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
prebuilt_module_is_a_library := true
else
prebuilt_module_is_a_library :=
endif
# Don't install static libraries by default.
ifndef LOCAL_UNINSTALLABLE_MODULE
ifeq (STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS))
LOCAL_UNINSTALLABLE_MODULE := true
endif
endif
my_check_elf_file_shared_lib_files :=
ifneq ($(filter true keep_symbols no_debuglink mini-debug-info,$(my_strip_module)),)
ifdef LOCAL_IS_HOST_MODULE
$(call pretty-error,Cannot strip/pack host module)
endif
ifeq ($(filter SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
$(call pretty-error,Can strip/pack only shared libraries or executables)
endif
# Set the arch-specific variables to set up the strip rules
LOCAL_STRIP_MODULE_$($(my_prefix)$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH) := $(my_strip_module)
include $(BUILD_SYSTEM)/dynamic_binary.mk
built_module := $(linked_module)
ifneq ($(LOCAL_SDK_VERSION),)
# binary.mk filters out NDK_KNOWN_LIBS from my_shared_libs, thus those NDK libs are not added
# to DEPENDENCIES_ON_SHARED_LIBRARIES. Assign $(my_ndk_shared_libraries_fullpath) to
# my_check_elf_file_shared_lib_files so that check_elf_file.py can see those NDK stub libs.
my_check_elf_file_shared_lib_files := $(my_ndk_shared_libraries_fullpath)
endif
else # my_strip_module not true
include $(BUILD_SYSTEM)/base_rules.mk
built_module := $(LOCAL_BUILT_MODULE)
ifdef prebuilt_module_is_a_library
EXPORTS_LIST += $(intermediates)
EXPORTS.$(intermediates).FLAGS := $(foreach d,$(LOCAL_EXPORT_C_INCLUDE_DIRS),-I $(d))
EXPORTS.$(intermediates).DEPS := $(LOCAL_EXPORT_C_INCLUDE_DEPS)
include $(BUILD_SYSTEM)/allowed_ndk_types.mk
ifdef LOCAL_SDK_VERSION
my_link_type := native:ndk:$(my_ndk_stl_family):$(my_ndk_stl_link_type)
else ifeq ($(call module-in-vendor-or-product),true)
_name := $(patsubst %.vendor,%,$(LOCAL_MODULE))
_name := $(patsubst %.product,%,$(LOCAL_MODULE))
ifneq ($(filter $(_name),$(VNDK_CORE_LIBRARIES) $(VNDK_SAMEPROCESS_LIBRARIES) $(LLNDK_LIBRARIES)),)
ifeq ($(filter $(_name),$(VNDK_PRIVATE_LIBRARIES)),)
my_link_type := native:vndk
else
my_link_type := native:vndk_private
endif
else
ifeq ($(LOCAL_IN_PRODUCT),true)
my_link_type := native:product
else
my_link_type := native:vendor
endif
endif
else ifneq ($(filter $(TARGET_RECOVERY_OUT)/%,$(LOCAL_MODULE_PATH)),)
my_link_type := native:recovery
else
my_link_type := native:platform
endif
# TODO: check dependencies of prebuilt files
my_link_deps :=
my_2nd_arch_prefix := $(LOCAL_2ND_ARCH_VAR_PREFIX)
my_common :=
include $(BUILD_SYSTEM)/link_type.mk
endif # prebuilt_module_is_a_library
# The real dependency will be added after all Android.mks are loaded and the install paths
# of the shared libraries are determined.
ifdef LOCAL_INSTALLED_MODULE
ifdef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
my_system_shared_libraries :=
else
my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
endif
else
ifeq ($(LOCAL_SYSTEM_SHARED_LIBRARIES),none)
my_system_shared_libraries := libc libm libdl
else
my_system_shared_libraries := $(LOCAL_SYSTEM_SHARED_LIBRARIES)
my_system_shared_libraries := $(patsubst libc,libc libdl,$(my_system_shared_libraries))
endif
endif
my_shared_libraries := $(strip \
$(filter-out $(my_system_shared_libraries),$(LOCAL_SHARED_LIBRARIES)) \
$(my_system_shared_libraries))
# Extra shared libraries introduced by LOCAL_CXX_STL (may append some libraries to
# my_shared_libraries).
include $(BUILD_SYSTEM)/cxx_stl_setup.mk
# When compiling against API imported module, use API import stub libraries.
apiimport_postfix := .apiimport
ifeq ($(call module-in-vendor-or-product),true)
ifeq ($(LOCAL_IN_PRODUCT),true)
apiimport_postfix := .apiimport.product
else
apiimport_postfix := .apiimport.vendor
endif
endif
ifdef my_shared_libraries
my_shared_libraries := $(foreach l,$(my_shared_libraries), \
$(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
endif #my_shared_libraries
ifdef my_system_shared_libraries
my_system_shared_libraries := $(foreach l,$(my_system_shared_libraries), \
$(if $(filter $(l), $(API_IMPORTED_SHARED_LIBRARIES)), $(l)$(apiimport_postfix), $(l)))
endif #my_system_shared_libraries
ifdef my_shared_libraries
ifeq ($(call module-in-vendor-or-product),true)
ifeq ($(LOCAL_IN_PRODUCT),true)
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(SPLIT_PRODUCT.SHARED_LIBRARIES.$(l)),$(l).product,$(l)))
else
my_shared_libraries := $(foreach l,$(my_shared_libraries),\
$(if $(SPLIT_VENDOR.SHARED_LIBRARIES.$(l)),$(l).vendor,$(l)))
endif
endif
$(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)DEPENDENCIES_ON_SHARED_LIBRARIES += \
$(my_register_name):$(LOCAL_INSTALLED_MODULE):$(subst $(space),$(comma),$(my_shared_libraries))
endif # my_shared_libraries
endif # LOCAL_INSTALLED_MODULE
# We need to enclose the above export_includes and my_built_shared_libraries in
# "my_strip_module not true" because otherwise the rules are defined in dynamic_binary.mk.
endif # my_strip_module not true
# Check prebuilt ELF binaries.
include $(BUILD_SYSTEM)/check_elf_file.mk
ifeq ($(NATIVE_COVERAGE),true)
ifneq (,$(strip $(LOCAL_PREBUILT_COVERAGE_ARCHIVE)))
$(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(intermediates)/$(LOCAL_MODULE).gcnodir))
ifneq ($(LOCAL_UNINSTALLABLE_MODULE),true)
ifdef LOCAL_IS_HOST_MODULE
my_coverage_path := $($(my_prefix)OUT_COVERAGE)/$(patsubst $($(my_prefix)OUT)/%,%,$(my_module_path))
else
my_coverage_path := $(TARGET_OUT_COVERAGE)/$(patsubst $(PRODUCT_OUT)/%,%,$(my_module_path))
endif
my_coverage_path := $(my_coverage_path)/$(patsubst %.so,%,$(my_installed_module_stem)).gcnodir
$(eval $(call copy-one-file,$(LOCAL_PREBUILT_COVERAGE_ARCHIVE),$(my_coverage_path)))
$(LOCAL_BUILT_MODULE): $(my_coverage_path)
endif
else
# Coverage information is needed when static lib is a dependency of another
# coverage-enabled module.
ifeq (STATIC_LIBRARIES, $(LOCAL_MODULE_CLASS))
GCNO_ARCHIVE := $(LOCAL_MODULE).gcnodir
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_OBJECTS :=
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_ALL_WHOLE_STATIC_LIBRARIES :=
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_PREFIX := $(my_prefix)
$(intermediates)/$(GCNO_ARCHIVE) : PRIVATE_2ND_ARCH_VAR_PREFIX := $(LOCAL_2ND_ARCH_VAR_PREFIX)
$(intermediates)/$(GCNO_ARCHIVE) :
$(transform-o-to-static-lib)
endif
endif
endif
$(built_module) : $(my_prebuilt_src_file)
$(transform-prebuilt-to-target)
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
$(hide) chmod +x $@
endif
================================================
FILE: core/ccache.mk
================================================
#
# Copyright (C) 2015 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.
#
# We no longer provide a ccache prebuilt.
#
# Ours was old, and had a number of issues that triggered non-reproducible
# results and other failures. Newer ccache versions may fix some of those
# issues, but at the large scale of our build servers, we weren't seeing
# significant performance gains from using ccache -- you end up needing very
# good locality and/or very large caches if you're building many different
# configurations.
#
# Local no-change full rebuilds were showing better results, but why not just
# use incremental builds at that point?
#
# So if you still want to use ccache, continue setting USE_CCACHE, but also set
# the CCACHE_EXEC environment variable to the path to your ccache executable.
ifneq ($(CCACHE_EXEC),)
ifneq ($(filter-out false,$(USE_CCACHE)),)
# The default check uses size and modification time, causing false misses
# since the mtime depends when the repo was checked out
CCACHE_COMPILERCHECK ?= content
# See man page, optimizations to get more cache hits
# implies that __DATE__ and __TIME__ are not critical for functionality.
# Ignore include file modification time since it will depend on when
# the repo was checked out
CCACHE_SLOPPINESS := time_macros,include_file_mtime,file_macro
# Turn all preprocessor absolute paths into relative paths.
# Fixes absolute paths in preprocessed source due to use of -g.
# We don't really use system headers much so the rootdir is
# fine; ensures these paths are relative for all Android trees
# on a workstation.
CCACHE_BASEDIR := /
# Workaround for ccache with clang.
# See http://petereisentraut.blogspot.com/2011/09/ccache-and-clang-part-2.html
CCACHE_CPP2 := true
ifndef CC_WRAPPER
CC_WRAPPER := $(CCACHE_EXEC)
endif
ifndef CXX_WRAPPER
CXX_WRAPPER := $(CCACHE_EXEC)
endif
endif
endif
================================================
FILE: core/check_elf_file.mk
================================================
# Check the correctness of the prebuilt ELF files
#
# This check ensures that DT_SONAME matches with the filename, DT_NEEDED
# matches the shared libraries specified in LOCAL_SHARED_LIBRARIES, and all
# undefined symbols in the prebuilt binary can be found in one of the shared
# libraries specified in LOCAL_SHARED_LIBRARIES.
#
# Inputs:
# - LOCAL_ALLOW_UNDEFINED_SYMBOLS
# - LOCAL_IGNORE_MAX_PAGE_SIZE
# - LOCAL_BUILT_MODULE
# - LOCAL_IS_HOST_MODULE
# - LOCAL_MODULE_CLASS
# - TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE
# - TARGET_MAX_PAGE_SIZE_SUPPORTED
# - intermediates
# - my_installed_module_stem
# - my_prebuilt_src_file
# - my_check_elf_file_shared_lib_files
# - my_system_shared_libraries
ifndef LOCAL_IS_HOST_MODULE
ifneq ($(filter $(LOCAL_MODULE_CLASS),SHARED_LIBRARIES EXECUTABLES NATIVE_TESTS),)
check_elf_files_stamp := $(intermediates)/check_elf_files.timestamp
$(check_elf_files_stamp): PRIVATE_SONAME := $(if $(filter $(LOCAL_MODULE_CLASS),SHARED_LIBRARIES),$(my_installed_module_stem))
$(check_elf_files_stamp): PRIVATE_ALLOW_UNDEFINED_SYMBOLS := $(LOCAL_ALLOW_UNDEFINED_SYMBOLS)
$(check_elf_files_stamp): PRIVATE_SYSTEM_SHARED_LIBRARIES := $(my_system_shared_libraries)
# PRIVATE_SHARED_LIBRARY_FILES are file paths to built shared libraries.
# In addition to $(my_check_elf_file_shared_lib_files), some file paths are
# added by `resolve-shared-libs-for-elf-file-check` from `core/main.mk`.
$(check_elf_files_stamp): PRIVATE_SHARED_LIBRARY_FILES := $(my_check_elf_file_shared_lib_files)
# For different page sizes to work, we must support a larger max page size
# as well as properly reflect page size at runtime. Limit this check, since many
# devices set the max page size (for future proof) than actually use the
# larger page size.
ifeq ($(strip $(TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE)),true)
ifeq ($(strip $(LOCAL_IGNORE_MAX_PAGE_SIZE)),true)
$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE :=
else
$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE := $(TARGET_MAX_PAGE_SIZE_SUPPORTED)
endif
else
$(check_elf_files_stamp): PRIVATE_MAX_PAGE_SIZE :=
endif
$(check_elf_files_stamp): $(my_prebuilt_src_file) $(my_check_elf_file_shared_lib_files) $(CHECK_ELF_FILE) $(LLVM_READOBJ)
@echo Check prebuilt ELF binary: $<
$(hide) mkdir -p $(dir $@)
$(hide) rm -f $@
$(hide) $(CHECK_ELF_FILE) \
--skip-bad-elf-magic \
--skip-unknown-elf-machine \
$(if $(PRIVATE_MAX_PAGE_SIZE),--max-page-size=$(PRIVATE_MAX_PAGE_SIZE)) \
$(if $(PRIVATE_SONAME),--soname $(PRIVATE_SONAME)) \
$(foreach l,$(PRIVATE_SHARED_LIBRARY_FILES),--shared-lib $(l)) \
$(foreach l,$(PRIVATE_SYSTEM_SHARED_LIBRARIES),--system-shared-lib $(l)) \
$(if $(PRIVATE_ALLOW_UNDEFINED_SYMBOLS),--allow-undefined-symbols) \
--llvm-readobj=$(LLVM_READOBJ) \
$<
$(hide) touch $@
CHECK_ELF_FILES.$(check_elf_files_stamp) := 1
ifneq ($(strip $(LOCAL_CHECK_ELF_FILES)),false)
ifneq ($(strip $(BUILD_BROKEN_PREBUILT_ELF_FILES)),true)
$(LOCAL_BUILT_MODULE): $(check_elf_files_stamp)
check-elf-files: $(check_elf_files_stamp)
endif # BUILD_BROKEN_PREBUILT_ELF_FILES
endif # LOCAL_CHECK_ELF_FILES
endif # SHARED_LIBRARIES, EXECUTABLES, NATIVE_TESTS
endif # !LOCAL_IS_HOST_MODULE
================================================
FILE: core/checktree
================================================
#!/usr/bin/python -E
import sys, os, re
excludes = [r'.*?/\.obj.*?',
r'.*?~',
r'.*?\/.DS_Store',
r'.*?\/.gdb_history',
r'.*?\/buildspec.mk',
r'.*?/\..*?\.swp',
r'.*?/out/.*?',
r'.*?/install/.*?']
excludes_compiled = map(re.compile, excludes)
def filter_excludes(str):
for e in excludes_compiled:
if e.match(str):
return False
return True
def split_perforce_parts(s):
spaces = ((s.count(" ") + 1) / 3) * 2
pos = 0
while spaces > 0:
pos = s.find(" ", pos) + 1
spaces = spaces - 1
return s[pos:]
def quotate(s):
return '"' + s + '"'
class PerforceError(Exception):
def __init__(self,value):
self.value = value
def __str__(self):
return repr(self.value)
def run(command, regex, filt):
def matchit(s):
m = regex_compiled.match(s)
if m:
return m.group(1)
else:
return ""
def filterit(s):
if filt_compiled.match(s):
return True
else:
return False
fd = os.popen(command);
lines = fd.readlines()
status = fd.close()
if status:
raise PerforceError("error calling " + command)
regex_compiled = re.compile(regex)
filt_compiled = re.compile(filt)
if len(lines) >= 1:
lines = filter(filterit, lines)
if len(lines) >= 1:
return map(matchit, lines)
return None
try:
if len(sys.argv) == 1:
do_exclude = True
elif len(sys.argv) == 2 and sys.argv[1] == "-a":
do_exclude = False
else:
print "usage: checktree [-a]"
print " -a don't filter common crud in the tree"
sys.exit(1)
have = run("p4 have ...", r'[^#]+#[0-9]+ - (.*)', r'.*')
cwd = os.getcwd()
files = run("find . -not -type d", r'.(.*)', r'.*')
files = map(lambda s: cwd+s, files)
added_depot_path = run("p4 opened ...", r'([^#]+)#.*', r'.*?#[0-9]+ - add .*');
added = []
if added_depot_path:
added_depot_path = map(quotate, added_depot_path)
where = "p4 where " + " ".join(added_depot_path)
added = run(where, r'(.*)', r'.*')
added = map(split_perforce_parts, added)
extras = []
# Python 2.3 -- still default on Mac OS X -- does not have set()
# Make dict's here to support the "in" operations below
have = dict().fromkeys(have, 1)
added = dict().fromkeys(added, 1)
for file in files:
if not file in have:
if not file in added:
extras.append(file)
if do_exclude:
extras = filter(filter_excludes, extras)
for s in extras:
print s.replace(" ", "\\ ")
except PerforceError, e:
sys.exit(2)
================================================
FILE: core/clang/HOST_x86.mk
================================================
$(clang_2nd_arch_prefix)HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i386.a
$(clang_2nd_arch_prefix)HOST_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-i386.a
================================================
FILE: core/clang/HOST_x86_64.mk
================================================
HOST_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64.a
HOST_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-x86_64.a
================================================
FILE: core/clang/TARGET_arm.mk
================================================
$(clang_2nd_arch_prefix)RS_TRIPLE := renderscript32-linux-androideabi
$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS :=
$(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := armv7-none-linux-gnueabi
$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-arm-android.a
$(clang_2nd_arch_prefix)TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-arm-android.a
$(clang_2nd_arch_prefix)TARGET_LIBUNWIND := $(LLVM_RTLIB_PATH)/arm/libunwind.a
# Address sanitizer clang config
$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan
$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER_FILE := /system/bin/bootstrap/linker_asan
$(clang_2nd_arch_prefix)PREBUILT_LIBCXX_ARCH_DIR := arm
================================================
FILE: core/clang/TARGET_arm64.mk
================================================
RS_TRIPLE := renderscript64-linux-android
RS_TRIPLE_CFLAGS :=
RS_COMPAT_TRIPLE := aarch64-linux-android
TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-aarch64-android.a
TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-aarch64-android.a
TARGET_LIBUNWIND := $(LLVM_RTLIB_PATH)/aarch64/libunwind.a
# Address sanitizer clang config
ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64
ADDRESS_SANITIZER_LINKER_FILE := /system/bin/bootstrap/linker_asan64
PREBUILT_LIBCXX_ARCH_DIR := aarch64
================================================
FILE: core/clang/TARGET_riscv64.mk
================================================
RS_TRIPLE := renderscript64-linux-android
RS_TRIPLE_CFLAGS := -D__riscv64__
RS_COMPAT_TRIPLE := riscv64-linux-android
TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-riscv64-android.a
TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-riscv64-android.a
TARGET_LIBUNWIND := $(LLVM_RTLIB_PATH)/riscv64/libunwind.a
# Address sanitizer clang config
ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64
ADDRESS_SANITIZER_LINKER_FILE := /system/bin/bootstrap/linker_asan64
PREBUILT_LIBCXX_ARCH_DIR := riscv64
================================================
FILE: core/clang/TARGET_x86.mk
================================================
$(clang_2nd_arch_prefix)RS_TRIPLE := renderscript32-linux-androideabi
$(clang_2nd_arch_prefix)RS_TRIPLE_CFLAGS := -D__i386__
$(clang_2nd_arch_prefix)RS_COMPAT_TRIPLE := i686-linux-android
$(clang_2nd_arch_prefix)TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-i686-android.a
$(clang_2nd_arch_prefix)TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-i686-android.a
$(clang_2nd_arch_prefix)TARGET_LIBUNWIND := $(LLVM_RTLIB_PATH)/i386/libunwind.a
# Address sanitizer clang config
$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan
$(clang_2nd_arch_prefix)ADDRESS_SANITIZER_LINKER_FILE := /system/bin/bootstrap/linker_asan
$(clang_2nd_arch_prefix)PREBUILT_LIBCXX_ARCH_DIR := i386
================================================
FILE: core/clang/TARGET_x86_64.mk
================================================
RS_TRIPLE := renderscript64-linux-android
RS_TRIPLE_CFLAGS := -D__x86_64__
RS_COMPAT_TRIPLE := x86_64-linux-android
TARGET_LIBPROFILE_RT := $(LLVM_RTLIB_PATH)/libclang_rt.profile-x86_64-android.a
TARGET_LIBCRT_BUILTINS := $(LLVM_RTLIB_PATH)/libclang_rt.builtins-x86_64-android.a
TARGET_LIBUNWIND := $(LLVM_RTLIB_PATH)/x86_64/libunwind.a
# Address sanitizer clang config
ADDRESS_SANITIZER_LINKER := /system/bin/linker_asan64
ADDRESS_SANITIZER_LINKER_FILE := /system/bin/bootstrap/linker_asan64
PREBUILT_LIBCXX_ARCH_DIR := x86_64
================================================
FILE: core/clang/config.mk
================================================
## Clang configurations.
LLVM_READOBJ := $(LLVM_PREBUILTS_BASE)/$(BUILD_OS)-x86/$(LLVM_PREBUILTS_VERSION)/bin/llvm-readobj
LLVM_RTLIB_PATH := $(LLVM_PREBUILTS_BASE)/linux-x86/$(LLVM_PREBUILTS_VERSION)/lib/clang/$(LLVM_RELEASE_VERSION)/lib/linux/
define convert-to-clang-flags
$(strip $(filter-out $(CLANG_CONFIG_UNKNOWN_CFLAGS),$(1)))
endef
CLANG_DEFAULT_UB_CHECKS := \
bool \
integer-divide-by-zero \
return \
returns-nonnull-attribute \
shift-exponent \
unreachable \
vla-bound \
# TODO(danalbert): The following checks currently have compiler performance
# issues.
# CLANG_DEFAULT_UB_CHECKS += alignment
# CLANG_DEFAULT_UB_CHECKS += bounds
# CLANG_DEFAULT_UB_CHECKS += enum
# CLANG_DEFAULT_UB_CHECKS += float-cast-overflow
# CLANG_DEFAULT_UB_CHECKS += float-divide-by-zero
# CLANG_DEFAULT_UB_CHECKS += nonnull-attribute
# CLANG_DEFAULT_UB_CHECKS += null
# CLANG_DEFAULT_UB_CHECKS += shift-base
# CLANG_DEFAULT_UB_CHECKS += signed-integer-overflow
# TODO(danalbert): Fix UB in libc++'s __tree so we can turn this on.
# https://llvm.org/PR19302
# http://reviews.llvm.org/D6974
# CLANG_DEFAULT_UB_CHECKS += object-size
# HOST config
clang_2nd_arch_prefix :=
include $(BUILD_SYSTEM)/clang/HOST_$(HOST_ARCH).mk
# HOST_2ND_ARCH config
ifdef HOST_2ND_ARCH
clang_2nd_arch_prefix := $(HOST_2ND_ARCH_VAR_PREFIX)
include $(BUILD_SYSTEM)/clang/HOST_$(HOST_2ND_ARCH).mk
endif
# TARGET config
clang_2nd_arch_prefix :=
include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_ARCH).mk
# TARGET_2ND_ARCH config
ifdef TARGET_2ND_ARCH
clang_2nd_arch_prefix := $(TARGET_2ND_ARCH_VAR_PREFIX)
include $(BUILD_SYSTEM)/clang/TARGET_$(TARGET_2ND_ARCH).mk
endif
include $(BUILD_SYSTEM)/clang/tidy.mk
================================================
FILE: core/clang/tidy.mk
================================================
#
# Copyright (C) 2016 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.
#
# Returns 2nd word of $(1) if $(2) has prefix of the 1st word of $(1).
define find_default_local_tidy_check2
$(if $(filter $(word 1,$(1))%,$(2)/),$(word 2,$(1)))
endef
# Returns 2nd part of $(1) if $(2) has prefix of the 1st part of $(1).
define find_default_local_tidy_check
$(call find_default_local_tidy_check2,$(subst :,$(space),$(1)),$(2))
endef
# Returns the default tidy check list for local project path $(1).
# Match $(1) with all patterns in DEFAULT_LOCAL_TIDY_CHECKS and use the last
# most specific pattern.
define default_global_tidy_checks
$(lastword \
$(DEFAULT_GLOBAL_TIDY_CHECKS) \
$(foreach pattern,$(DEFAULT_LOCAL_TIDY_CHECKS), \
$(call find_default_local_tidy_check,$(pattern),$(1)) \
) \
)
endef
# Default filter contains current directory $1 and optional DEFAULT_TIDY_HEADER_DIRS.
define default_tidy_header_filter
-header-filter=$(if $(DEFAULT_TIDY_HEADER_DIRS),"($1/|$(DEFAULT_TIDY_HEADER_DIRS))",$1/)
endef
================================================
FILE: core/cleanbuild.mk
================================================
# Copyright (C) 2007 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.
#
# Absolute path of the present working direcotry.
# This overrides the shell variable $PWD, which does not necessarily points to
# the top of the source tree, for example when "make -C" is used in m/mm/mmm.
PWD := $(shell pwd)
TOP := .
TOPDIR :=
BUILD_SYSTEM := $(TOPDIR)build/make/core
# Set up various standard variables based on configuration
# and host information.
include $(BUILD_SYSTEM)/config.mk
include $(SOONG_MAKEVARS_MK)
include $(BUILD_SYSTEM)/clang/config.mk
# CTS-specific config.
-include cts/build/config.mk
# device-tests-specific-config.
-include tools/tradefederation/build/suites/device-tests/config.mk
# general-tests-specific-config.
-include tools/tradefederation/build/suites/general-tests/config.mk
INTERNAL_CLEAN_STEPS :=
# Builds up a list of clean steps. Creates a unique
# id for each step by taking makefile path, INTERNAL_CLEAN_BUILD_VERSION
# and appending an increasing number of '@' characters.
#
# $(1): shell command to run
# $(2): indicate to not use makefile path as part of step id if not empty.
# $(2) should only be used in build/make/core/cleanspec.mk: just for compatibility.
define _add-clean-step
$(if $(strip $(INTERNAL_CLEAN_BUILD_VERSION)),, \
$(error INTERNAL_CLEAN_BUILD_VERSION not set))
$(eval _acs_makefile_prefix := $(lastword $(MAKEFILE_LIST)))
$(eval _acs_makefile_prefix := $(subst /,_,$(_acs_makefile_prefix)))
$(eval _acs_makefile_prefix := $(subst .,-,$(_acs_makefile_prefix)))
$(eval _acs_makefile_prefix := $(_acs_makefile_prefix)_acs)
$(if $($(_acs_makefile_prefix)),,\
$(eval $(_acs_makefile_prefix) := $(INTERNAL_CLEAN_BUILD_VERSION)))
$(eval $(_acs_makefile_prefix) := $($(_acs_makefile_prefix))@)
$(if $(strip $(2)),$(eval _acs_id := $($(_acs_makefile_prefix))),\
$(eval _acs_id := $(_acs_makefile_prefix)$($(_acs_makefile_prefix))))
$(eval INTERNAL_CLEAN_STEPS += $(_acs_id))
$(eval INTERNAL_CLEAN_STEP.$(_acs_id) := $(1))
$(eval _acs_id :=)
$(eval _acs_makefile_prefix :=)
endef
define add-clean-step
$(eval # for build/make/core/cleanspec.mk, dont use makefile path as part of step id) \
$(if $(filter %/cleanspec.mk,$(lastword $(MAKEFILE_LIST))),\
$(eval $(call _add-clean-step,$(1),true)),\
$(eval $(call _add-clean-step,$(1))))
endef
# Defines INTERNAL_CLEAN_BUILD_VERSION and the individual clean steps.
# cleanspec.mk is outside of the core directory so that more people
# can have permission to touch it.
include $(BUILD_SYSTEM)/cleanspec.mk
INTERNAL_CLEAN_BUILD_VERSION := $(strip $(INTERNAL_CLEAN_BUILD_VERSION))
INTERNAL_CLEAN_STEPS := $(strip $(INTERNAL_CLEAN_STEPS))
# If the clean_steps.mk file is missing (usually after a clean build)
# then we won't do anything.
CURRENT_CLEAN_BUILD_VERSION := MISSING
CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)
# Read the current state from the file, if present.
# Will set CURRENT_CLEAN_BUILD_VERSION and CURRENT_CLEAN_STEPS.
#
clean_steps_file := $(PRODUCT_OUT)/clean_steps.mk
-include $(clean_steps_file)
ifeq ($(CURRENT_CLEAN_BUILD_VERSION),MISSING)
# Do nothing
else ifneq ($(CURRENT_CLEAN_BUILD_VERSION),$(INTERNAL_CLEAN_BUILD_VERSION))
# The major clean version is out-of-date. Do a full clean, and
# don't even bother with the clean steps.
$(info *** A clean build is required because of a recent change.)
$(shell rm -rf $(OUT_DIR))
$(info *** Done with the cleaning, now starting the real build.)
else
# The major clean version is correct. Find the list of clean steps
# that we need to execute to get up-to-date.
steps := \
$(filter-out $(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_STEPS))
$(foreach step,$(steps), \
$(info Clean step: $(INTERNAL_CLEAN_STEP.$(step))) \
$(shell $(INTERNAL_CLEAN_STEP.$(step))) \
)
# Rewrite the clean step for the second arch.
ifdef TARGET_2ND_ARCH
# $(1): the clean step cmd
# $(2): the prefix to search for
# $(3): the prefix to replace with
define -cs-rewrite-cleanstep
$(if $(filter $(2)/%,$(1)),\
$(eval _crs_new_cmd := $(patsubst $(2)/%,$(3)/%,$(1)))\
$(info Clean step: $(_crs_new_cmd))\
$(shell $(_crs_new_cmd)))
endef
$(foreach step,$(steps), \
$(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_INTERMEDIATES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES))\
$(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES))\
$(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES))\
$(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_INTERMEDIATES),$(TARGET_OUT_INTERMEDIATES))\
$(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_SHARED_LIBRARIES),$(TARGET_OUT_SHARED_LIBRARIES))\
$(call -cs-rewrite-cleanstep,$(INTERNAL_CLEAN_STEP.$(step)),$($(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_OUT_VENDOR_SHARED_LIBRARIES),$(TARGET_OUT_VENDOR_SHARED_LIBRARIES))\
)
endif
_crs_new_cmd :=
steps :=
endif
# Write the new state to the file.
#
ifneq ($(CURRENT_CLEAN_BUILD_VERSION)-$(CURRENT_CLEAN_STEPS),$(INTERNAL_CLEAN_BUILD_VERSION)-$(INTERNAL_CLEAN_STEPS))
$(shell mkdir -p $(dir $(clean_steps_file)))
$(file >$(clean_steps_file).tmp,CURRENT_CLEAN_BUILD_VERSION := $(INTERNAL_CLEAN_BUILD_VERSION)$(newline)CURRENT_CLEAN_STEPS := $(INTERNAL_CLEAN_STEPS)$(newline))
$(shell if ! cmp -s $(clean_steps_file).tmp $(clean_steps_file); then \
mv $(clean_steps_file).tmp $(clean_steps_file); \
else \
rm $(clean_steps_file).tmp; \
fi)
endif
CURRENT_CLEAN_BUILD_VERSION :=
CURRENT_CLEAN_STEPS :=
clean_steps_file :=
INTERNAL_CLEAN_STEPS :=
INTERNAL_CLEAN_BUILD_VERSION :=
================================================
FILE: core/cleanspec.mk
================================================
# Copyright (C) 2007 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.
#
# Just bump this if you want to force a clean build.
# **********************************************************************
# WHEN DOING SO
# 1. DELETE ANY "add-clean-step" ENTRIES THAT HAVE PILED UP IN THIS FILE.
# 2. REMOVE ALL FILES NAMED CleanSpec.mk.
# 3. BUMP THE VERSION.
# IDEALLY, THOSE STEPS SHOULD BE DONE ATOMICALLY.
# **********************************************************************
#
INTERNAL_CLEAN_BUILD_VERSION := 6
#
# ***********************************************************************
# Do not touch INTERNAL_CLEAN_BUILD_VERSION if you've added a clean step!
# ***********************************************************************
# If you don't need to do a full clean build but would like to touch
# a file or delete some intermediate files, add a clean step to the end
# of the list. These steps will only be run once, if they haven't been
# run before.
#
# E.g.:
# $(call add-clean-step, touch -c external/sqlite/sqlite3.h)
# $(call add-clean-step, rm -rf $(PRODUCT_OUT)/obj/STATIC_LIBRARIES/libz_intermediates)
#
# Always use "touch -c" and "rm -f" or "rm -rf" to gracefully deal with
# files that are missing or have been moved.
#
# Use $(PRODUCT_OUT) to get to the "out/target/product/blah/" directory.
# Use $(OUT_DIR) to refer to the "out" directory.
#
# If you need to re-do something that's already mentioned, just copy
# the command and add it to the bottom of the list. E.g., if a change
# that you made last week required touching a file and a change you
# made today requires touching the same file, just copy the old
# touch step and add it to the end of the list.
#
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
# For example:
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/APPS/AndroidTests_intermediates)
#$(call add-clean-step, rm -rf $(OUT_DIR)/target/common/obj/JAVA_LIBRARIES/core_intermediates)
#$(call add-clean-step, find $(OUT_DIR) -type f -name "IGTalkSession*" -print0 | xargs -0 rm -f)
#$(call add-clean-step, rm -rf $(PRODUCT_OUT)/data/*)
$(call add-clean-step, rm -rf $(OUT_DIR)/obj/ETC/build_manifest-vendor_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/obj/ETC/build_manifest-odm_intermediates)
$(call add-clean-step, rm -rf $(OUT_DIR)/obj/ETC/build_manifest-product_intermediates)
$(call add-clean-step, rm -rf $(TARGET_OUT_VENDOR)/etc/security/fsverity)
$(call add-clean-step, rm -rf $(TARGET_OUT_ODM)/etc/security/fsverity)
$(call add-clean-step, rm -rf $(TARGET_OUT_PRODUCT)/etc/security/fsverity)
# ************************************************
# NEWER CLEAN STEPS MUST BE AT THE END OF THE LIST
# ************************************************
subdir_cleanspecs := \
$(file <$(OUT_DIR)/.module_paths/CleanSpec.mk.list)
include $(subdir_cleanspecs)
subdir_cleanspecs :=
================================================
FILE: core/clear_vars.mk
================================================
###########################################################
## Clear out values of all variables used by rule templates.
###########################################################
# '',true
LOCAL_2ND_ARCH_VAR_PREFIX:=
LOCAL_32_BIT_ONLY:=
LOCAL_AAPT_FLAGS:=
LOCAL_AAPT_INCLUDE_ALL_RESOURCES:=
LOCAL_AAPT_NAMESPACES:=
LOCAL_ACONFIG_FILES:=
LOCAL_ADDITIONAL_CERTIFICATES:=
LOCAL_ADDITIONAL_CHECKED_MODULE:=
LOCAL_ADDITIONAL_DEPENDENCIES:=
LOCAL_AIDL_INCLUDES:=
LOCAL_ALLOW_UNDEFINED_SYMBOLS:=
LOCAL_ANNOTATION_PROCESSORS:=
LOCAL_ANNOTATION_PROCESSOR_CLASSES:=
LOCAL_APEX_KEY_PATH:=
LOCAL_APK_LIBRARIES:=
LOCAL_APK_SET_INSTALL_FILE:=
LOCAL_APKCERTS_FILE:=
LOCAL_ARM_MODE:=
LOCAL_ASFLAGS:=
LOCAL_ASSET_DIR:=
LOCAL_BUILT_MODULE:=
LOCAL_BUILT_MODULE_STEM:=
LOCAL_CC:=
LOCAL_CERTIFICATE:=
LOCAL_CFLAGS:=
LOCAL_CHECK_SAME_VNDK_VARIANTS:=
LOCAL_CHECKED_MODULE:=
LOCAL_C_INCLUDES:=
LOCAL_CLANG:=
LOCAL_CLANG_ASFLAGS:=
LOCAL_CLANG_CFLAGS:=
LOCAL_CLANG_CONLYFLAGS:=
LOCAL_CLANG_CPPFLAGS:=
LOCAL_CLANG_LDFLAGS:=
LOCAL_CLASSPATH:=
LOCAL_COMPATIBILITY_SUITE:=
LOCAL_COMPATIBILITY_PER_TESTCASE_DIRECTORY:=
LOCAL_COMPATIBILITY_SUPPORT_FILES:=
LOCAL_COMPRESSED_MODULE:=
LOCAL_CONLYFLAGS:=
LOCAL_COPY_HEADERS:=
LOCAL_COPY_HEADERS_TO:=
LOCAL_CPP_EXTENSION:=
LOCAL_CPPFLAGS:=
LOCAL_CPP_STD:=
LOCAL_C_STD:=
LOCAL_CXX:=
LOCAL_CXX_STL := default
LOCAL_DEX_PREOPT_APP_IMAGE:=
LOCAL_DEX_PREOPT_FLAGS:=
LOCAL_DEX_PREOPT_GENERATE_PROFILE:=
LOCAL_DEX_PREOPT_PROFILE_CLASS_LISTING:=
LOCAL_DEX_PREOPT:= # '',true,false
LOCAL_DISABLE_AUTO_GENERATE_TEST_CONFIG:=
LOCAL_DISABLE_TEST_CONFIG:=
LOCAL_DISABLE_RESOLVE_SUPPORT_LIBRARIES:=
LOCAL_DONT_CHECK_MODULE:=
# Don't delete the META_INF dir when merging static Java libraries.
LOCAL_DONT_DELETE_JAR_META_INF:=
LOCAL_DONT_MERGE_MANIFESTS:=
LOCAL_DPI_FILE_STEM:=
LOCAL_DPI_VARIANTS:=
LOCAL_DROIDDOC_ANNOTATIONS_ZIP :=
LOCAL_DROIDDOC_API_VERSIONS_XML :=
LOCAL_DROIDDOC_DOC_ZIP :=
LOCAL_DROIDDOC_METADATA_ZIP:=
LOCAL_DROIDDOC_STUBS_SRCJAR :=
LOCAL_DX_FLAGS:=
LOCAL_DYLIB_LIBRARIES:=
LOCAL_EMMA_INSTRUMENT:=
LOCAL_ENFORCE_USES_LIBRARIES:=
LOCAL_ERROR_PRONE_FLAGS:=
LOCAL_EXPORT_CFLAGS:=
LOCAL_EXPORT_C_INCLUDE_DEPS:=
LOCAL_EXPORT_C_INCLUDE_DIRS:=
LOCAL_EXPORT_HEADER_LIBRARY_HEADERS:=
LOCAL_EXPORT_PACKAGE_RESOURCES:=
LOCAL_EXPORT_PROGUARD_FLAG_FILES:=
LOCAL_EXPORT_SDK_LIBRARIES:=
LOCAL_EXPORT_SHARED_LIBRARY_HEADERS:=
LOCAL_EXPORT_STATIC_LIBRARY_HEADERS:=
LOCAL_EXTRA_FULL_TEST_CONFIGS:=
LOCAL_EXTRACT_APK:=
LOCAL_EXTRACT_DPI_APK:=
LOCAL_FILESYSTEM_FILELIST:=
LOCAL_FINDBUGS_FLAGS:=
LOCAL_FORCE_STATIC_EXECUTABLE:=
LOCAL_FULL_CLASSES_JACOCO_JAR:=
LOCAL_FULL_CLASSES_PRE_JACOCO_JAR:=
LOCAL_FULL_INIT_RC:=
LOCAL_FULL_LIBS_MANIFEST_FILES:=
LOCAL_FULL_MANIFEST_FILE:=
LOCAL_FULL_TEST_CONFIG:=
LOCAL_FULL_VINTF_FRAGMENTS:=
LOCAL_FUZZ_ENGINE:=
LOCAL_FUZZ_INSTALLED_SHARED_DEPS:=
LOCAL_GCNO_FILES:=
LOCAL_GENERATED_SOURCES:=
# Group static libraries with "-Wl,--start-group" and "-Wl,--end-group" when linking.
LOCAL_GROUP_STATIC_LIBRARIES:=
LOCAL_GTEST:=true
LOCAL_HEADER_LIBRARIES:=
LOCAL_HOST_PREFIX:=
LOCAL_HOST_REQUIRED_MODULES:=
LOCAL_IGNORE_MAX_PAGE_SIZE:=
LOCAL_INIT_RC:=
LOCAL_INJECT_BSSL_HASH:=
LOCAL_INSTALLED_MODULE:=
LOCAL_INSTALLED_MODULE_STEM:=
LOCAL_INSTRUMENTATION_FOR:=
LOCAL_INTERMEDIATE_SOURCES:=
LOCAL_INTERMEDIATE_TARGETS:=
LOCAL_IS_FUZZ_TARGET:=
LOCAL_IS_HOST_MODULE:=
LOCAL_IS_RUNTIME_RESOURCE_OVERLAY:=
LOCAL_IS_UNIT_TEST:=
LOCAL_TEST_OPTIONS_TAGS:=
LOCAL_JACK_COVERAGE_EXCLUDE_FILTER:=
LOCAL_JACK_COVERAGE_INCLUDE_FILTER:=
LOCAL_JAR_EXCLUDE_FILES:=
LOCAL_JAR_EXCLUDE_PACKAGES:=
LOCAL_JARJAR_RULES:=
LOCAL_JAR_MANIFEST:=
LOCAL_JAR_PACKAGES:=
LOCAL_JAR_PROCESSOR:=
LOCAL_JAR_PROCESSOR_ARGS:=
LOCAL_JAVACFLAGS:=
LOCAL_JAVA_LANGUAGE_VERSION:=
LOCAL_JAVA_LIBRARIES:=
LOCAL_JAVA_RESOURCE_DIRS:=
LOCAL_JAVA_RESOURCE_FILES:=
LOCAL_JNI_SHARED_LIBRARIES:=
LOCAL_JNI_SHARED_LIBRARIES_ABI:=
LOCAL_CERTIFICATE_LINEAGE:=
LOCAL_LDFLAGS:=
LOCAL_LDLIBS:=
LOCAL_LICENSE_CONDITIONS:=
LOCAL_LICENSE_KINDS:=
LOCAL_LICENSE_INSTALL_MAP:=
LOCAL_LICENSE_PACKAGE_NAME:=
LOCAL_LOGTAGS_FILES:=
LOCAL_MANIFEST_FILE:=
LOCAL_MANIFEST_INSTRUMENTATION_FOR:=
LOCAL_MANIFEST_PACKAGE_NAME:=
LOCAL_MIN_SDK_VERSION:=
LOCAL_MODULE:=
LOCAL_MODULE_CLASS:=
LOCAL_MODULE_HOST_ARCH:=
LOCAL_MODULE_HOST_ARCH_WARN:=
LOCAL_MODULE_HOST_CROSS_ARCH:=
LOCAL_MODULE_HOST_OS:=
LOCAL_MODULE_IS_CONTAINER:=
LOCAL_MODULE_OWNER:=
LOCAL_MODULE_PATH:=
LOCAL_MODULE_RELATIVE_PATH :=
LOCAL_MODULE_STEM:=
LOCAL_MODULE_SUFFIX:=
LOCAL_MODULE_SYMLINKS:=
LOCAL_MODULE_TAGS:=
LOCAL_MODULE_TARGET_ARCH:=
LOCAL_MODULE_TARGET_ARCH_WARN:=
LOCAL_MODULE_TYPE:=
LOCAL_MODULE_UNSUPPORTED_HOST_ARCH:=
LOCAL_MODULE_UNSUPPORTED_HOST_ARCH_WARN:=
LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH:=
LOCAL_MODULE_UNSUPPORTED_TARGET_ARCH_WARN:=
LOCAL_MULTILIB:=
LOCAL_NATIVE_BENCHMARK:=
LOCAL_NDK_STL_VARIANT:=
LOCAL_NDK_VERSION:=current
LOCAL_NO_CRT:=
LOCAL_NO_DEFAULT_COMPILER_FLAGS:=
LOCAL_NO_LIBCRT_BUILTINS:=
LOCAL_NO_NOTICE_FILE:=
LOCAL_NOSANITIZE:=
LOCAL_NO_STANDARD_LIBRARIES:=
LOCAL_NO_STATIC_ANALYZER:=
LOCAL_NOT_AVAILABLE_FOR_PLATFORM:=
LOCAL_NOTICE_FILE:=
LOCAL_ODM_MODULE:=
LOCAL_OEM_MODULE:=
LOCAL_OPTIONAL_USES_LIBRARIES:=
LOCAL_OVERRIDES_PACKAGES:=
LOCAL_OVERRIDES_MODULES:=
LOCAL_PACKAGE_NAME:=
LOCAL_PACKAGE_SPLITS:=
LOCAL_PACK_MODULE_RELOCATIONS:=
LOCAL_PATCH_MODULE:=
LOCAL_PICKUP_FILES:=
LOCAL_POST_INSTALL_CMD:=
LOCAL_POST_LINK_CMD:=
LOCAL_PREBUILT_COVERAGE_ARCHIVE:=
LOCAL_PREBUILT_EXECUTABLES:=
LOCAL_PREBUILT_JAVA_LIBRARIES:=
LOCAL_PREBUILT_JNI_LIBS:=
LOCAL_PREBUILT_LIBS:=
LOCAL_PREBUILT_MODULE_FILE:=
LOCAL_PREBUILT_OBJ_FILES:=
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES:=
LOCAL_USE_EMBEDDED_DEX:=
LOCAL_USE_EMBEDDED_NATIVE_LIBS:=
LOCAL_PRIVATE_PLATFORM_APIS:=
LOCAL_PRIVILEGED_MODULE:=
LOCAL_PROC_MACRO_LIBRARIES:=
# '',full,custom,disabled,obfuscation,optimization
LOCAL_PRODUCT_MODULE:=
# TODO(b/135957588) Remove LOCAL_PRODUCT_SERVICES_MODULE
LOCAL_PRODUCT_SERVICES_MODULE :=
LOCAL_PROGUARD_ENABLED:=
LOCAL_PROGUARD_FLAG_FILES:=
LOCAL_PROGUARD_FLAGS:=
LOCAL_PROGUARD_FLAGS_DEPS:=
LOCAL_PROPRIETARY_MODULE:=
LOCAL_PROTOC_FLAGS:=
# lite(default),micro,nano,stream,full,nanopb-c,nanopb-c-enable_malloc,nanopb-c-16bit,nanopb-c-enable_malloc-16bit,nanopb-c-32bit,nanopb-c-enable_malloc-32bit
LOCAL_PROTOC_OPTIMIZE_TYPE:=
LOCAL_PROTO_JAVA_OUTPUT_PARAMS:=
LOCAL_PROVIDES_USES_LIBRARY:=
LOCAL_R8_FLAG_FILES:=
LOCAL_RECORDED_MODULE_TYPE:=
LOCAL_RENDERSCRIPT_CC:=
LOCAL_RENDERSCRIPT_COMPATIBILITY:=
LOCAL_RENDERSCRIPT_FLAGS:=
LOCAL_RENDERSCRIPT_INCLUDES:=
LOCAL_RENDERSCRIPT_INCLUDES_OVERRIDE:=
LOCAL_RENDERSCRIPT_TARGET_API:=
# Used to replace the installed file of a presigned prebuilt apk in PDK fusion build,
# to avoid installing the presigned apks with classes.dex unstripped.
LOCAL_REPLACE_PREBUILT_APK_INSTALLED:=
LOCAL_REQUIRED_MODULES:=
LOCAL_RES_LIBRARIES:=
LOCAL_RESOURCE_DIR:=
LOCAL_RLIB_LIBRARIES:=
LOCAL_ROTATION_MIN_SDK_VERSION:=
LOCAL_RUNTIME_LIBRARIES:=
LOCAL_RRO_THEME:=
LOCAL_RTTI_FLAG:=
LOCAL_SANITIZE:=
LOCAL_SANITIZE_DIAG:=
LOCAL_SANITIZE_RECOVER:=
LOCAL_SANITIZE_NO_RECOVER:=
LOCAL_SANITIZE_BLOCKLIST :=
LOCAL_SDK_LIBRARIES :=
LOCAL_SDK_RES_VERSION:=
LOCAL_SDK_VERSION:=
LOCAL_SHARED_ANDROID_LIBRARIES:=
LOCAL_SHARED_LIBRARIES:=
LOCAL_SOONG_AAR :=
LOCAL_SOONG_BUILT_INSTALLED :=
LOCAL_SOONG_BUNDLE :=
LOCAL_SOONG_CLASSES_JAR :=
LOCAL_SOONG_DEX_JAR :=
LOCAL_SOONG_DEXPREOPT_CONFIG :=
LOCAL_SOONG_EXPORT_PROGUARD_FLAGS :=
LOCAL_SOONG_HEADER_JAR :=
LOCAL_SOONG_INSTALL_PAIRS :=
LOCAL_SOONG_INSTALL_SYMLINKS :=
LOCAL_SOONG_INSTALLED_COMPATIBILITY_SUPPORT_FILES:=
LOCAL_SOONG_INSTALLED_MODULE :=
LOCAL_SOONG_JACOCO_REPORT_CLASSES_JAR :=
LOCAL_SOONG_LICENSE_METADATA :=
LOCAL_SOONG_LINK_TYPE :=
LOCAL_SOONG_LINT_REPORTS :=
LOCAL_SOONG_LOGTAGS_FILES :=
LOCAL_SOONG_MODULE_INFO_JSON :=
LOCAL_SOONG_MODULE_TYPE :=
LOCAL_SOONG_PROGUARD_DICT :=
LOCAL_SOONG_PROGUARD_USAGE_ZIP :=
LOCAL_SOONG_PROVIDER_TEST_SUITES :=
LOCAL_SOONG_RESOURCE_EXPORT_PACKAGE :=
LOCAL_SOONG_TRANSITIVE_RES_PACKAGES :=
LOCAL_SOONG_DEVICE_RRO_DIRS :=
LOCAL_SOONG_PRODUCT_RRO_DIRS :=
LOCAL_SOONG_STATIC_LIBRARY_EXTRA_PACKAGES :=
LOCAL_SOONG_SYMBOL_PATH :=
LOCAL_SOONG_TOC :=
LOCAL_SOONG_UNSTRIPPED_BINARY :=
LOCAL_SOONG_VNDK_VERSION :=
# '',true
LOCAL_SOURCE_FILES_ALL_GENERATED:=
LOCAL_SRC_FILES:=
LOCAL_SRC_FILES_EXCLUDE:=
LOCAL_SRCJARS:=
LOCAL_STATIC_ANDROID_LIBRARIES:=
LOCAL_STATIC_JAVA_AAR_LIBRARIES:=
LOCAL_STATIC_JAVA_LIBRARIES:=
LOCAL_STATIC_LIBRARIES:=
LOCAL_SYSTEM_EXT_MODULE:=
LOCAL_STRIP_MODULE:=
LOCAL_SYSTEM_SHARED_LIBRARIES:=none
LOCAL_TARGET_REQUIRED_MODULES:=
LOCAL_TEST_CONFIG:=
LOCAL_TEST_CONFIG_SUFFIX:=
LOCAL_TEST_DATA:=
LOCAL_TEST_DATA_BINS:=
LOCAL_TEST_MAINLINE_MODULES:=
LOCAL_TEST_MODULE_TO_PROGUARD_WITH:=
LOCAL_TEST_MODULE_CONFIG_BASE:=
LOCAL_TIDY:=
LOCAL_TIDY_CHECKS:=
LOCAL_TIDY_FLAGS:=
LOCAL_UNCOMPRESS_DEX:=
LOCAL_UNINSTALLABLE_MODULE:=
LOCAL_UNSTRIPPED_PATH:=
LOCAL_USE_AAPT2:=
LOCAL_USE_CLANG_LLD:=
LOCAL_USE_VNDK:=
LOCAL_IN_VENDOR:=
LOCAL_IN_PRODUCT:=
LOCAL_USES_LIBRARIES:=
LOCAL_VENDOR_MODULE:=
LOCAL_VINTF_FRAGMENTS:=
LOCAL_VNDK_DEPEND_ON_CORE_VARIANT:=
LOCAL_WARNINGS_ENABLE:=
LOCAL_WHOLE_STATIC_LIBRARIES:=
LOCAL_YACCFLAGS:=
LOCAL_CHECK_ELF_FILES:=
# arch specific variables
LOCAL_ASFLAGS_$(TARGET_ARCH):=
LOCAL_CFLAGS_$(TARGET_ARCH):=
LOCAL_C_INCLUDES_$(TARGET_ARCH):=
LOCAL_CLANG_ASFLAGS_$(TARGET_ARCH):=
LOCAL_CLANG_CFLAGS_$(TARGET_ARCH):=
LOCAL_CLANG_CPPFLAGS_$(TARGET_ARCH):=
LOCAL_CLANG_LDFLAGS_$(TARGET_ARCH):=
LOCAL_CLANG_$(TARGET_ARCH):=
LOCAL_CPPFLAGS_$(TARGET_ARCH):=
LOCAL_GENERATED_SOURCES_$(TARGET_ARCH):=
LOCAL_HEADER_LIBRARIES_$(TARGET_ARCH):=
LOCAL_LDFLAGS_$(TARGET_ARCH):=
LOCAL_PACK_MODULE_RELOCATIONS_$(TARGET_ARCH):=
LOCAL_PREBUILT_JNI_LIBS_$(TARGET_ARCH):=
LOCAL_REQUIRED_MODULES_$(TARGET_ARCH):=
LOCAL_RUNTIME_LIBRARIES_$(TARGET_ARCH):=
LOCAL_SHARED_LIBRARIES_$(TARGET_ARCH):=
LOCAL_SOONG_JNI_LIBS_$(TARGET_ARCH):=
LOCAL_SOONG_JNI_LIBS_SYMBOLS:=
LOCAL_SRC_FILES_EXCLUDE_$(TARGET_ARCH):=
LOCAL_SRC_FILES_$(TARGET_ARCH):=
LOCAL_STATIC_LIBRARIES_$(TARGET_ARCH):=
LOCAL_STRIP_MODULE_$(TARGET_ARCH):=
LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_ARCH):=
ifdef TARGET_2ND_ARCH
LOCAL_ASFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_CFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_C_INCLUDES_$(TARGET_2ND_ARCH):=
LOCAL_CLANG_ASFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_CLANG_CFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_CLANG_CPPFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_CLANG_LDFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_CLANG_$(TARGET_2ND_ARCH):=
LOCAL_CPPFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_GENERATED_SOURCES_$(TARGET_2ND_ARCH):=
LOCAL_HEADER_LIBRARIES_$(TARGET_2ND_ARCH):=
LOCAL_LDFLAGS_$(TARGET_2ND_ARCH):=
LOCAL_PACK_MODULE_RELOCATIONS_$(TARGET_2ND_ARCH):=
LOCAL_PREBUILT_JNI_LIBS_$(TARGET_2ND_ARCH):=
LOCAL_REQUIRED_MODULES_$(TARGET_2ND_ARCH):=
LOCAL_RUNTIME_LIBRARIES_$(TARGET_2ND_ARCH):=
LOCAL_SHARED_LIBRARIES_$(TARGET_2ND_ARCH):=
LOCAL_SOONG_JNI_LIBS_$(TARGET_2ND_ARCH):=
LOCAL_SRC_FILES_EXCLUDE_$(TARGET_2ND_ARCH):=
LOCAL_SRC_FILES_$(TARGET_2ND_ARCH):=
LOCAL_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
LOCAL_STRIP_MODULE_$(TARGET_2ND_ARCH):=
LOCAL_WHOLE_STATIC_LIBRARIES_$(TARGET_2ND_ARCH):=
endif
LOCAL_ASFLAGS_$(HOST_ARCH):=
LOCAL_CFLAGS_$(HOST_ARCH):=
LOCAL_C_INCLUDES_$(HOST_ARCH):=
LOCAL_CLANG_ASFLAGS_$(HOST_ARCH):=
LOCAL_CLANG_CFLAGS_$(HOST_ARCH):=
LOCAL_CLANG_CPPFLAGS_$(HOST_ARCH):=
LOCAL_CLANG_$(HOST_ARCH):=
LOCAL_CLANG_LDFLAGS_$(HOST_ARCH):=
LOCAL_CPPFLAGS_$(HOST_ARCH):=
LOCAL_GENERATED_SOURCES_$(HOST_ARCH):=
LOCAL_HEADER_LIBRARIES_$(HOST_ARCH):=
LOCAL_LDFLAGS_$(HOST_ARCH):=
LOCAL_REQUIRED_MODULES_$(HOST_ARCH):=
LOCAL_RUNTIME_LIBRARIES_$(HOST_ARCH):=
LOCAL_SHARED_LIBRARIES_$(HOST_ARCH):=
LOCAL_SRC_FILES_EXCLUDE_$(HOST_ARCH):=
LOCAL_SRC_FILES_$(HOST_ARCH):=
LOCAL_STATIC_LIBRARIES_$(HOST_ARCH):=
LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_ARCH):=
ifdef HOST_2ND_ARCH
LOCAL_ASFLAGS_$(HOST_2ND_ARCH):=
LOCAL_CFLAGS_$(HOST_2ND_ARCH):=
LOCAL_C_INCLUDES_$(HOST_2ND_ARCH):=
LOCAL_CLANG_ASFLAGS_$(HOST_2ND_ARCH):=
LOCAL_CLANG_CFLAGS_$(HOST_2ND_ARCH):=
LOCAL_CLANG_CPPFLAGS_$(HOST_2ND_ARCH):=
LOCAL_CLANG_$(HOST_2ND_ARCH):=
LOCAL_CLANG_LDFLAGS_$(HOST_2ND_ARCH):=
LOCAL_CPPFLAGS_$(HOST_2ND_ARCH):=
LOCAL_GENERATED_SOURCES_$(HOST_2ND_ARCH):=
LOCAL_HEADER_LIBRARIES_$(HOST_2ND_ARCH):=
LOCAL_LDFLAGS_$(HOST_2ND_ARCH):=
LOCAL_REQUIRED_MODULES_$(HOST_2ND_ARCH):=
LOCAL_RUNTIME_LIBRARIES_$(HOST_2ND_ARCH):=
LOCAL_SHARED_LIBRARIES_$(HOST_2ND_ARCH):=
LOCAL_SRC_FILES_EXCLUDE_$(HOST_2ND_ARCH):=
LOCAL_SRC_FILES_$(HOST_2ND_ARCH):=
LOCAL_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
LOCAL_WHOLE_STATIC_LIBRARIES_$(HOST_2ND_ARCH):=
endif
LOCAL_ASFLAGS_$(HOST_OS):=
LOCAL_CFLAGS_$(HOST_OS):=
LOCAL_C_INCLUDES_$(HOST_OS):=
LOCAL_CPPFLAGS_$(HOST_OS):=
LOCAL_GENERATED_SOURCES_$(HOST_OS):=
LOCAL_HEADER_LIBRARIES_$(HOST_OS):=
LOCAL_LDFLAGS_$(HOST_OS):=
LOCAL_LDLIBS_$(HOST_OS):=
LOCAL_REQUIRED_MODULES_$(HOST_OS):=
LOCAL_RUNTIME_LIBRARIES_$(HOST_OS):=
LOCAL_SHARED_LIBRARIES_$(HOST_OS):=
LOCAL_SRC_FILES_$(HOST_OS):=
LOCAL_STATIC_LIBRARIES_$(HOST_OS):=
LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_ARCH):=
ifdef HOST_2ND_ARCH
LOCAL_SRC_FILES_$(HOST_OS)_$(HOST_2ND_ARCH):=
endif
LOCAL_ASFLAGS_32:=
LOCAL_ASFLAGS_64:=
LOCAL_CFLAGS_32:=
LOCAL_CFLAGS_64:=
LOCAL_C_INCLUDES_32:=
LOCAL_C_INCLUDES_64:=
LOCAL_CLANG_32:=
LOCAL_CLANG_64:=
LOCAL_CLANG_ASFLAGS_32:=
LOCAL_CLANG_ASFLAGS_64:=
LOCAL_CLANG_CFLAGS_32:=
LOCAL_CLANG_CFLAGS_64:=
LOCAL_CLANG_CPPFLAGS_32:=
LOCAL_CLANG_CPPFLAGS_64:=
LOCAL_CLANG_LDFLAGS_32:=
LOCAL_CLANG_LDFLAGS_64:=
LOCAL_CPPFLAGS_32:=
LOCAL_CPPFLAGS_64:=
LOCAL_GENERATED_SOURCES_32:=
LOCAL_GENERATED_SOURCES_64:=
LOCAL_HEADER_LIBRARIES_32:=
LOCAL_HEADER_LIBRARIES_64:=
LOCAL_INIT_RC_32:=
LOCAL_INIT_RC_64:=
LOCAL_LDFLAGS_32:=
LOCAL_LDFLAGS_64:=
LOCAL_MODULE_PATH_32:=
LOCAL_MODULE_PATH_64:=
LOCAL_MODULE_STEM_32:=
LOCAL_MODULE_STEM_64:=
LOCAL_MODULE_SYMLINKS_32:=
LOCAL_MODULE_SYMLINKS_64:=
LOCAL_RUNTIME_LIBRARIES_32:=
LOCAL_RUNTIME_LIBRARIES_64:=
LOCAL_SHARED_LIBRARIES_32:=
LOCAL_SHARED_LIBRARIES_64:=
LOCAL_SRC_FILES_32:=
LOCAL_SRC_FILES_64:=
LOCAL_SRC_FILES_EXCLUDE_32:=
LOCAL_SRC_FILES_EXCLUDE_64:=
LOCAL_STATIC_LIBRARIES_32:=
LOCAL_STATIC_LIBRARIES_64:=
LOCAL_WHOLE_STATIC_LIBRARIES_32:=
LOCAL_WHOLE_STATIC_LIBRARIES_64:=
# Robolectric variables
LOCAL_INSTRUMENT_SOURCE_DIRS :=
LOCAL_INSTRUMENT_SRCJARS :=
LOCAL_ROBOTEST_FAILURE_FATAL :=
LOCAL_ROBOTEST_FILES :=
LOCAL_ROBOTEST_TIMEOUT :=
LOCAL_TEST_PACKAGE :=
full_android_manifest :=
non_system_module :=
module_license_metadata :=
# Trim MAKEFILE_LIST so that $(call my-dir) doesn't need to
# iterate over thousands of entries every time.
# Leave the current makefile to make sure we don't break anything
# that expects to be able to find the name of the current makefile.
MAKEFILE_LIST := $(lastword $(MAKEFILE_LIST))
================================================
FILE: core/combo/HOST_darwin.mk
================================================
#
# Copyright (C) 2006 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.
#
# Configuration for Darwin (Mac OS X).
# Included by combo/select.mk
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_macho,$(1),$(2))
endef
HOST_GLOBAL_ARFLAGS := cqs
HOST_CUSTOM_LD_COMMAND := true
define transform-host-o-to-shared-lib-inner
$(hide) $(PRIVATE_CXX) \
-dynamiclib -single_module -read_only_relocs suppress \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
) \
$(PRIVATE_ALL_OBJECTS) \
$(addprefix -force_load , $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(PRIVATE_LDLIBS) \
-o $@ \
-install_name @rpath/$(notdir $@) \
-Wl,-rpath,@loader_path/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
-Wl,-rpath,@loader_path/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)HOST_OUT_SHARED_LIBRARIES)) \
$(PRIVATE_LDFLAGS)
endef
define transform-host-o-to-executable-inner
$(hide) $(PRIVATE_CXX) \
$(foreach path,$(PRIVATE_RPATHS), \
-Wl,-rpath,@loader_path/$(path)) \
-o $@ \
-Wl,-headerpad_max_install_names \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
$(PRIVATE_ALL_OBJECTS) \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_LDLIBS)
endef
================================================
FILE: core/combo/HOST_linux.mk
================================================
#
# Copyright (C) 2006 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.
#
# Configuration for builds hosted on linux.
# Included by combo/select.mk
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
endef
############################################################
## Macros after this line are shared by the 64-bit config.
================================================
FILE: core/combo/TARGET_linux-arm.mk
================================================
#
# Copyright (C) 2006 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.
#
# Configuration for Linux on ARM.
# Included by combo/select.mk
# You can set TARGET_ARCH_VARIANT to use an arch version other
# than ARMv5TE. Each value should correspond to a file named
# $(BUILD_COMBOS)/arch/.mk which must contain
# makefile variable definitions. Their
# purpose is to allow module Android.mk files to selectively compile
# different versions of code based upon the funtionality and
# instructions available in a given architecture version.
#
# The blocks also define specific arch_variant_cflags, which
# include defines, and compiler settings for the given architecture
# version.
#
KNOWN_ARMv8_CORES := cortex-a53 cortex-a53.a57 cortex-a55 cortex-a73 cortex-a75 cortex-a76
KNOWN_ARMv8_CORES += kryo kryo385 exynos-m1 exynos-m2
KNOWN_ARMv82a_CORES := cortex-a55 cortex-a75 kryo385
ifeq (,$(strip $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT)))
TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT := generic
endif
# This quickly checks TARGET_2ND_ARCH_VARIANT against the lists above.
ifneq (,$(filter $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT), $(KNOWN_ARMv82a_CORES)))
ifeq (,$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv8-2a
else ifneq (armv8-2a,$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
$(error Incorrect TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT, $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT). Use armv8-2a instead.)
endif
else ifneq (,$(filter $(TARGET_$(combo_2nd_arch_prefix)CPU_VARIANT), $(KNOWN_ARMv8_CORES)))
ifeq (,$(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT))
TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := armv8-a
else ifneq ($(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT),armv8-a)
$(error Incorrect TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT, $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT). Use armv8-a instead.)
endif
endif
ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
$(error TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT must be set)
endif
# NEON is mandatory, see: https://developer.android.com/ndk/guides/abis#v7a
ARCH_ARM_HAVE_VFP := true
ARCH_ARM_HAVE_VFP_D32 := true
ARCH_ARM_HAVE_NEON := true
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
endef
$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
================================================
FILE: core/combo/TARGET_linux-arm64.mk
================================================
#
# Copyright (C) 2013 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.
#
# Configuration for Linux on ARM.
# Included by combo/select.mk
# You can set TARGET_ARCH_VARIANT to use an arch version other
# than ARMv5TE. Each value should correspond to a file named
# $(BUILD_COMBOS)/arch/.mk which must contain
# makefile variable definitions. Their
# purpose is to allow module Android.mk files to selectively compile
# different versions of code based upon the funtionality and
# instructions available in a given architecture version.
#
# The blocks also define specific arch_variant_cflags, which
# include defines, and compiler settings for the given architecture
# version.
#
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := armv8
endif
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
endef
TARGET_PACK_MODULE_RELOCATIONS := true
TARGET_LINKER := /system/bin/linker64
================================================
FILE: core/combo/TARGET_linux-riscv64.mk
================================================
#
# Copyright (C) 2022 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.
#
# Configuration for Linux on riscv64 as a target.
# Included by combo/select.mk
# Provide a default variant.
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := riscv64
endif
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
endef
TARGET_LINKER := /system/bin/linker64
================================================
FILE: core/combo/TARGET_linux-x86.mk
================================================
#
# Copyright (C) 2006 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.
#
# Configuration for Linux on x86 as a target.
# Included by combo/select.mk
# Provide a default variant.
ifeq ($(strip $(TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT)),)
TARGET_$(combo_2nd_arch_prefix)ARCH_VARIANT := x86
endif
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
endef
$(combo_2nd_arch_prefix)TARGET_PACK_MODULE_RELOCATIONS := true
$(combo_2nd_arch_prefix)TARGET_LINKER := /system/bin/linker
$(combo_2nd_arch_prefix)TARGET_GLOBAL_YASM_FLAGS := -f elf32 -m x86
================================================
FILE: core/combo/TARGET_linux-x86_64.mk
================================================
#
# Copyright (C) 2006 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.
#
# Configuration for Linux on x86_64 as a target.
# Included by combo/select.mk
# Provide a default variant.
ifeq ($(strip $(TARGET_ARCH_VARIANT)),)
TARGET_ARCH_VARIANT := x86_64
endif
define $(combo_var_prefix)transform-shared-lib-to-toc
$(call _gen_toc_command_for_elf,$(1),$(2))
endef
TARGET_LINKER := /system/bin/linker64
TARGET_GLOBAL_YASM_FLAGS := -f elf64 -m amd64
================================================
FILE: core/combo/javac.mk
================================================
# Selects a Java compiler.
#
# Outputs:
# ANDROID_JAVA_TOOLCHAIN -- Directory that contains javac and other java tools
#
ANDROID_COMPILE_WITH_JACK := false
ifdef TARGET_BUILD_APPS
ifndef TURBINE_ENABLED
TURBINE_ENABLED := false
endif
endif
ANDROID_JAVA_TOOLCHAIN := $(ANDROID_JAVA_HOME)/bin
# TODO(ccross): remove this, it is needed for now because it is used by
# config.mk before makevars from soong are loaded
JAVA := $(ANDROID_JAVA_TOOLCHAIN)/java -XX:OnError="cat hs_err_pid%p.log" -XX:CICompilerCount=6 -XX:+UseDynamicNumberOfGCThreads
================================================
FILE: core/combo/select.mk
================================================
#
# Copyright (C) 2006 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.
#
# Select a combo based on the compiler being used.
#
# Inputs:
# combo_target -- prefix for final variables (HOST_ or TARGET_)
# combo_2nd_arch_prefix -- it's defined if this is loaded for the 2nd arch.
#
ifeq ($(combo_target),HOST_)
combo_os_arch := $(HOST_OS)
else
# Build a target string like "linux-arm" or "darwin-x86".
combo_os_arch := $($(combo_target)OS)-$($(combo_target)$(combo_2nd_arch_prefix)ARCH)
endif
combo_var_prefix := $(combo_2nd_arch_prefix)$(combo_target)
# Set reasonable defaults for the various variables
ifeq ($(combo_target),HOST_CROSS_)
$(KATI_obsolete_var \
$(combo_var_prefix)GLOBAL_ARFLAGS \
$(combo_var_prefix)STATIC_LIB_SUFFIX \
$(combo_var_prefix)transform-shared-lib-to-toc \
,HOST_CROSS builds are not supported in Make)
else
$(combo_var_prefix)GLOBAL_ARFLAGS := crsPD --format=gnu
$(combo_var_prefix)STATIC_LIB_SUFFIX := .a
# Now include the combo for this specific target.
include $(BUILD_COMBOS)/$(combo_target)$(combo_os_arch).mk
endif
================================================
FILE: core/config.mk
================================================
# This is included by the top-level Makefile.
# It sets up standard variables based on the
# current configuration and platform, which
# are not specific to what is being built.
ifndef KATI
$(warning Directly using config.mk from make is no longer supported.)
$(warning )
$(warning If you are just attempting to build, you probably need to re-source envsetup.sh:)
$(warning )
$(warning $$ source build/envsetup.sh)
$(warning )
$(warning If you are attempting to emulate get_build_var, use one of the following:)
$(warning $$ build/soong/soong_ui.bash --dumpvar-mode)
$(warning $$ build/soong/soong_ui.bash --dumpvars-mode)
$(warning )
$(error done)
endif
BUILD_SYSTEM :=$= build/make/core
BUILD_SYSTEM_COMMON :=$= build/make/common
include $(BUILD_SYSTEM_COMMON)/core.mk
# -----------------------------------------------------------------
# Rules and functions to help copy important files to DIST_DIR
# when requested. This must be included once only, and must be included before
# soong_config (as soong_config calls make_vars-$(TARGET).mk, and soong may
# propagate calls to dist-for-goals there).
include $(BUILD_SYSTEM)/distdir.mk
# Mark variables that should be coming as environment variables from soong_ui
# as readonly
.KATI_READONLY := OUT_DIR TMPDIR BUILD_DATETIME_FILE
ifdef CALLED_FROM_SETUP
.KATI_READONLY := CALLED_FROM_SETUP
endif
ifdef KATI_PACKAGE_MK_DIR
.KATI_READONLY := KATI_PACKAGE_MK_DIR
endif
# Mark variables deprecated/obsolete
CHANGES_URL := https://android.googlesource.com/platform/build/+/master/Changes.md
.KATI_READONLY := CHANGES_URL
$(KATI_deprecated_var TARGET_USES_64_BIT_BINDER,All devices use 64-bit binder by default now. Uses of TARGET_USES_64_BIT_BINDER should be removed.)
$(KATI_deprecated_var PRODUCT_SEPOLICY_SPLIT,All devices are built with split sepolicy.)
$(KATI_deprecated_var PRODUCT_SEPOLICY_SPLIT_OVERRIDE,All devices are built with split sepolicy.)
$(KATI_obsolete_var PATH,Do not use PATH directly. See $(CHANGES_URL)#PATH)
$(KATI_obsolete_var PYTHONPATH,Do not use PYTHONPATH directly. See $(CHANGES_URL)#PYTHONPATH)
$(KATI_obsolete_var OUT,Use OUT_DIR instead. See $(CHANGES_URL)#OUT)
$(KATI_obsolete_var ANDROID_HOST_OUT,Use HOST_OUT instead. See $(CHANGES_URL)#ANDROID_HOST_OUT)
$(KATI_obsolete_var ANDROID_PRODUCT_OUT,Use PRODUCT_OUT instead. See $(CHANGES_URL)#ANDROID_PRODUCT_OUT)
$(KATI_obsolete_var ANDROID_HOST_OUT_TESTCASES,Use HOST_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_HOST_OUT_TESTCASES)
$(KATI_obsolete_var ANDROID_TARGET_OUT_TESTCASES,Use TARGET_OUT_TESTCASES instead. See $(CHANGES_URL)#ANDROID_TARGET_OUT_TESTCASES)
$(KATI_obsolete_var ANDROID_BUILD_TOP,Use '.' instead. See $(CHANGES_URL)#ANDROID_BUILD_TOP)
$(KATI_obsolete_var \
ANDROID_TOOLCHAIN \
ANDROID_TOOLCHAIN_2ND_ARCH \
ANDROID_DEV_SCRIPTS \
ANDROID_EMULATOR_PREBUILTS \
ANDROID_PRE_BUILD_PATHS \
,See $(CHANGES_URL)#other_envsetup_variables)
$(KATI_obsolete_var PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE,Set FCM Version in device manifest instead. See $(CHANGES_URL)#PRODUCT_COMPATIBILITY_MATRIX_LEVEL_OVERRIDE)
$(KATI_obsolete_var USE_CLANG_PLATFORM_BUILD,Clang is the only supported Android compiler. See $(CHANGES_URL)#USE_CLANG_PLATFORM_BUILD)
$(KATI_obsolete_var BUILD_DROIDDOC,Droiddoc is only supported in Soong. See details on build/soong/java/droiddoc.go)
$(KATI_obsolete_var BUILD_APIDIFF,Apidiff is only supported in Soong. See details on build/soong/java/droiddoc.go)
$(KATI_obsolete_var \
DEFAULT_GCC_CPP_STD_VERSION \
HOST_GLOBAL_CFLAGS 2ND_HOST_GLOBAL_CFLAGS \
HOST_GLOBAL_CONLYFLAGS 2ND_HOST_GLOBAL_CONLYFLAGS \
HOST_GLOBAL_CPPFLAGS 2ND_HOST_GLOBAL_CPPFLAGS \
HOST_GLOBAL_LDFLAGS 2ND_HOST_GLOBAL_LDFLAGS \
HOST_GLOBAL_LLDFLAGS 2ND_HOST_GLOBAL_LLDFLAGS \
HOST_CLANG_SUPPORTED 2ND_HOST_CLANG_SUPPORTED \
HOST_CC 2ND_HOST_CC \
HOST_CXX 2ND_HOST_CXX \
HOST_CROSS_GLOBAL_CFLAGS 2ND_HOST_CROSS_GLOBAL_CFLAGS \
HOST_CROSS_GLOBAL_CONLYFLAGS 2ND_HOST_CROSS_GLOBAL_CONLYFLAGS \
HOST_CROSS_GLOBAL_CPPFLAGS 2ND_HOST_CROSS_GLOBAL_CPPFLAGS \
HOST_CROSS_GLOBAL_LDFLAGS 2ND_HOST_CROSS_GLOBAL_LDFLAGS \
HOST_CROSS_GLOBAL_LLDFLAGS 2ND_HOST_CROSS_GLOBAL_LLDFLAGS \
HOST_CROSS_CLANG_SUPPORTED 2ND_HOST_CROSS_CLANG_SUPPORTED \
HOST_CROSS_CC 2ND_HOST_CROSS_CC \
HOST_CROSS_CXX 2ND_HOST_CROSS_CXX \
TARGET_GLOBAL_CFLAGS 2ND_TARGET_GLOBAL_CFLAGS \
TARGET_GLOBAL_CONLYFLAGS 2ND_TARGET_GLOBAL_CONLYFLAGS \
TARGET_GLOBAL_CPPFLAGS 2ND_TARGET_GLOBAL_CPPFLAGS \
TARGET_GLOBAL_LDFLAGS 2ND_TARGET_GLOBAL_LDFLAGS \
TARGET_GLOBAL_LLDFLAGS 2ND_TARGET_GLOBAL_LLDFLAGS \
TARGET_CLANG_SUPPORTED 2ND_TARGET_CLANG_SUPPORTED \
TARGET_CC 2ND_TARGET_CC \
TARGET_CXX 2ND_TARGET_CXX \
TARGET_TOOLCHAIN_ROOT 2ND_TARGET_TOOLCHAIN_ROOT \
HOST_TOOLCHAIN_ROOT 2ND_HOST_TOOLCHAIN_ROOT \
HOST_CROSS_TOOLCHAIN_ROOT 2ND_HOST_CROSS_TOOLCHAIN_ROOT \
HOST_TOOLS_PREFIX 2ND_HOST_TOOLS_PREFIX \
HOST_CROSS_TOOLS_PREFIX 2ND_HOST_CROSS_TOOLS_PREFIX \
HOST_GCC_VERSION 2ND_HOST_GCC_VERSION \
HOST_CROSS_GCC_VERSION 2ND_HOST_CROSS_GCC_VERSION \
TARGET_NDK_GCC_VERSION 2ND_TARGET_NDK_GCC_VERSION \
GLOBAL_CFLAGS_NO_OVERRIDE GLOBAL_CPPFLAGS_NO_OVERRIDE \
,GCC support has been removed. Use Clang instead)
$(KATI_obsolete_var DIST_DIR dist_goal,Use dist-for-goals instead. See $(CHANGES_URL)#dist)
$(KATI_obsolete_var TARGET_ANDROID_FILESYSTEM_CONFIG_H,Use TARGET_FS_CONFIG_GEN instead)
$(KATI_deprecated_var USER,Use BUILD_USERNAME instead. See $(CHANGES_URL)#USER)
$(KATI_obsolete_var TARGET_ROOT_OUT_SBIN,/sbin has been removed, use /system/bin instead)
$(KATI_obsolete_var TARGET_ROOT_OUT_SBIN_UNSTRIPPED,/sbin has been removed, use /system/bin instead)
$(KATI_obsolete_var BUILD_BROKEN_PHONY_TARGETS)
$(KATI_obsolete_var BUILD_BROKEN_DUP_COPY_HEADERS)
$(KATI_obsolete_var BUILD_BROKEN_ENG_DEBUG_TAGS)
$(KATI_obsolete_export It is a global setting. See $(CHANGES_URL)#export_keyword)
$(KATI_obsolete_var BUILD_BROKEN_ANDROIDMK_EXPORTS)
$(KATI_obsolete_var PRODUCT_NOTICE_SPLIT_OVERRIDE,Stop using this, keep calm, and carry on.)
$(KATI_obsolete_var PRODUCT_STATIC_BOOT_CONTROL_HAL,Use shared library module instead. See $(CHANGES_URL)#PRODUCT_STATIC_BOOT_CONTROL_HAL)
$(KATI_obsolete_var \
ARCH_ARM_HAVE_ARMV7A \
ARCH_DSP_REV \
ARCH_HAVE_ALIGNED_DOUBLES \
ARCH_MIPS_HAS_DSP \
ARCH_MIPS_HAS_FPU \
ARCH_MIPS_REV6 \
ARCH_X86_HAVE_AES_NI \
ARCH_X86_HAVE_AVX \
ARCH_X86_HAVE_AVX2 \
ARCH_X86_HAVE_AVX512 \
ARCH_X86_HAVE_MOVBE \
ARCH_X86_HAVE_POPCNT \
ARCH_X86_HAVE_SSE4 \
ARCH_X86_HAVE_SSE4_2 \
ARCH_X86_HAVE_SSSE3 \
)
$(KATI_obsolete_var PRODUCT_IOT)
$(KATI_obsolete_var MD5SUM)
$(KATI_obsolete_var BOARD_HAL_STATIC_LIBRARIES, See $(CHANGES_URL)#BOARD_HAL_STATIC_LIBRARIES)
$(KATI_obsolete_var LOCAL_HAL_STATIC_LIBRARIES, See $(CHANGES_URL)#BOARD_HAL_STATIC_LIBRARIES)
$(KATI_obsolete_var \
TARGET_AUX_OS_VARIANT_LIST \
LOCAL_AUX_ARCH \
LOCAL_AUX_CPU \
LOCAL_AUX_OS \
LOCAL_AUX_OS_VARIANT \
LOCAL_AUX_SUBARCH \
LOCAL_AUX_TOOLCHAIN \
LOCAL_CUSTOM_BUILD_STEP_INPUT \
LOCAL_CUSTOM_BUILD_STEP_OUTPUT \
LOCAL_IS_AUX_MODULE \
,AUX support has been removed)
$(KATI_obsolete_var HOST_OUT_TEST_CONFIG TARGET_OUT_TEST_CONFIG LOCAL_TEST_CONFIG_OPTIONS)
$(KATI_obsolete_var \
TARGET_PROJECT_INCLUDES \
2ND_TARGET_PROJECT_INCLUDES \
TARGET_PROJECT_SYSTEM_INCLUDES \
2ND_TARGET_PROJECT_SYSTEM_INCLUDES \
,Project include variables have been removed)
$(KATI_obsolete_var TARGET_PREFER_32_BIT TARGET_PREFER_32_BIT_APPS TARGET_PREFER_32_BIT_EXECUTABLES)
$(KATI_obsolete_var PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_WHITELIST,Use PRODUCT_ARTIFACT_SYSTEM_CERTIFICATE_REQUIREMENT_ALLOW_LIST)
$(KATI_obsolete_var PRODUCT_ARTIFACT_PATH_REQUIREMENT_WHITELIST,Use PRODUCT_ARTIFACT_PATH_REQUIREMENT_ALLOWED_LIST)
$(KATI_obsolete_var COVERAGE_PATHS,Use NATIVE_COVERAGE_PATHS instead)
$(KATI_obsolete_var COVERAGE_EXCLUDE_PATHS,Use NATIVE_COVERAGE_EXCLUDE_PATHS instead)
$(KATI_obsolete_var BOARD_VNDK_RUNTIME_DISABLE,VNDK-Lite is no longer supported)
$(KATI_obsolete_var LOCAL_SANITIZE_BLACKLIST,Use LOCAL_SANITIZE_BLOCKLIST instead)
$(KATI_obsolete_var BOARD_PLAT_PUBLIC_SEPOLICY_DIR,Use SYSTEM_EXT_PUBLIC_SEPOLICY_DIRS instead)
$(KATI_obsolete_var BOARD_PLAT_PRIVATE_SEPOLICY_DIR,Use SYSTEM_EXT_PRIVATE_SEPOLICY_DIRS instead)
$(KATI_obsolete_var TARGET_NO_VENDOR_BOOT,Use PRODUCT_BUILD_VENDOR_BOOT_IMAGE instead)
$(KATI_obsolete_var PRODUCT_CHECK_ELF_FILES,Use BUILD_BROKEN_PREBUILT_ELF_FILES instead)
$(KATI_obsolete_var ALL_GENERATED_SOURCES,ALL_GENERATED_SOURCES is no longer used)
$(KATI_obsolete_var ALL_ORIGINAL_DYNAMIC_BINARIES,ALL_ORIGINAL_DYNAMIC_BINARIES is no longer used)
$(KATI_obsolete_var PRODUCT_SUPPORTS_VERITY,VB 1.0 and related variables are no longer supported)
$(KATI_obsolete_var PRODUCT_SUPPORTS_VERITY_FEC,VB 1.0 and related variables are no longer supported)
$(KATI_obsolete_var PRODUCT_SUPPORTS_BOOT_SIGNER,VB 1.0 and related variables are no longer supported)
$(KATI_obsolete_var PRODUCT_VERITY_SIGNING_KEY,VB 1.0 and related variables are no longer supported)
$(KATI_obsolete_var BOARD_PREBUILT_PVMFWIMAGE,pvmfw.bin is now built in AOSP and custom versions are no longer supported)
$(KATI_obsolete_var BUILDING_PVMFW_IMAGE,BUILDING_PVMFW_IMAGE is no longer used)
$(KATI_obsolete_var BOARD_BUILD_SYSTEM_ROOT_IMAGE)
$(KATI_obsolete_var FS_GET_STATS)
$(KATI_obsolete_var BUILD_BROKEN_USES_SOONG_PYTHON2_MODULES)
# Used to force goals to build. Only use for conditionally defined goals.
.PHONY: FORCE
FORCE:
ORIGINAL_MAKECMDGOALS := $(MAKECMDGOALS)
UNAME := $(shell uname -sm)
SRC_TARGET_DIR := $(TOPDIR)build/make/target
# Some specific paths to tools
SRC_DROIDDOC_DIR := $(TOPDIR)build/make/tools/droiddoc
# Mark some inputs as readonly
ifdef TARGET_DEVICE_DIR
.KATI_READONLY := TARGET_DEVICE_DIR
endif
ONE_SHOT_MAKEFILE :=
.KATI_READONLY := ONE_SHOT_MAKEFILE
# Set up efficient math functions which are used in make.
# Here since this file is included by envsetup as well as during build.
include $(BUILD_SYSTEM_COMMON)/math.mk
include $(BUILD_SYSTEM_COMMON)/strings.mk
include $(BUILD_SYSTEM_COMMON)/json.mk
# Various mappings to avoid hard-coding paths all over the place
include $(BUILD_SYSTEM)/pathmap.mk
# Allow projects to define their own globally-available variables
include $(BUILD_SYSTEM)/project_definitions.mk
# ###############################################################
# Build system internal files
# ###############################################################
BUILD_COMBOS :=$= $(BUILD_SYSTEM)/combo
CLEAR_VARS :=$= $(BUILD_SYSTEM)/clear_vars.mk
BUILD_HOST_STATIC_LIBRARY :=$= $(BUILD_SYSTEM)/host_static_library.mk
BUILD_HOST_SHARED_LIBRARY :=$= $(BUILD_SYSTEM)/host_shared_library.mk
BUILD_STATIC_LIBRARY :=$= $(BUILD_SYSTEM)/static_library.mk
BUILD_HEADER_LIBRARY :=$= $(BUILD_SYSTEM)/header_library.mk
BUILD_SHARED_LIBRARY :=$= $(BUILD_SYSTEM)/shared_library.mk
BUILD_EXECUTABLE :=$= $(BUILD_SYSTEM)/executable.mk
BUILD_HOST_EXECUTABLE :=$= $(BUILD_SYSTEM)/host_executable.mk
BUILD_PACKAGE :=$= $(BUILD_SYSTEM)/package.mk
BUILD_PHONY_PACKAGE :=$= $(BUILD_SYSTEM)/phony_package.mk
BUILD_RRO_PACKAGE :=$= $(BUILD_SYSTEM)/build_rro_package.mk
BUILD_HOST_PREBUILT :=$= $(BUILD_SYSTEM)/host_prebuilt.mk
BUILD_PREBUILT :=$= $(BUILD_SYSTEM)/prebuilt.mk
BUILD_MULTI_PREBUILT :=$= $(BUILD_SYSTEM)/multi_prebuilt.mk
BUILD_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/java_library.mk
BUILD_STATIC_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/static_java_library.mk
BUILD_HOST_JAVA_LIBRARY :=$= $(BUILD_SYSTEM)/host_java_library.mk
BUILD_COPY_HEADERS :=$= $(BUILD_SYSTEM)/copy_headers.mk
BUILD_NATIVE_TEST :=$= $(BUILD_SYSTEM)/native_test.mk
BUILD_FUZZ_TEST :=$= $(BUILD_SYSTEM)/fuzz_test.mk
BUILD_NOTICE_FILE :=$= $(BUILD_SYSTEM)/notice_files.mk
BUILD_SBOM_GEN :=$= $(BUILD_SYSTEM)/sbom.mk
include $(BUILD_SYSTEM)/deprecation.mk
# ###############################################################
# Parse out any modifier targets.
# ###############################################################
hide := @
################################################################
# Tools needed in product configuration makefiles.
################################################################
NORMALIZE_PATH := build/make/tools/normalize_path.py
# $(1): the paths to be normalized
define normalize-paths
$(if $(1),$(shell $(NORMALIZE_PATH) $(1)))
endef
# ###############################################################
# Set common values
# ###############################################################
# Initialize SOONG_CONFIG_NAMESPACES so that it isn't recursive.
SOONG_CONFIG_NAMESPACES :=
# TODO(asmundak): remove add_soong_config_namespace, add_soong_config_var,
# and add_soong_config_var_value once all their usages are replaced with
# soong_config_set/soong_config_append.
# The add_soong_config_namespace function adds a namespace and initializes it
# to be empty.
# $1 is the namespace.
# Ex: $(call add_soong_config_namespace,acme)
define add_soong_config_namespace
$(eval SOONG_CONFIG_NAMESPACES += $(strip $1)) \
$(eval SOONG_CONFIG_$(strip $1) :=)
endef
# The add_soong_config_var function adds a a list of soong config variables to
# SOONG_CONFIG_*. The variables and their values are then available to a
# soong_config_module_type in an Android.bp file.
# $1 is the namespace. $2 is the list of variables.
# Ex: $(call add_soong_config_var,acme,COOL_FEATURE_A COOL_FEATURE_B)
define add_soong_config_var
$(eval SOONG_CONFIG_$(strip $1) += $(strip $2)) \
$(foreach v,$(strip $2),$(eval SOONG_CONFIG_$(strip $1)_$v := $(strip $($v))))
endef
# The add_soong_config_var_value function defines a make variable and also adds
# the variable to SOONG_CONFIG_*.
# $1 is the namespace. $2 is the variable name. $3 is the variable value.
# Ex: $(call add_soong_config_var_value,acme,COOL_FEATURE,true)
define add_soong_config_var_value
$(eval $(strip $2) := $(strip $3)) \
$(call add_soong_config_var,$1,$2)
endef
# Soong config namespace variables manipulation.
#
# internal utility to define a namespace and a variable in it.
define soong_config_define_internal
$(if $(filter $1,$(SOONG_CONFIG_NAMESPACES)),,$(eval SOONG_CONFIG_NAMESPACES:=$(SOONG_CONFIG_NAMESPACES) $(strip $1))) \
$(if $(filter $2,$(SOONG_CONFIG_$(strip $1))),,$(eval SOONG_CONFIG_$(strip $1):=$(SOONG_CONFIG_$(strip $1)) $(strip $2)))
endef
# soong_config_set defines the variable in the given Soong config namespace
# and sets its value. If the namespace does not exist, it will be defined.
# $1 is the namespace. $2 is the variable name. $3 is the variable value.
# Ex: $(call soong_config_set,acme,COOL_FEATURE,true)
define soong_config_set
$(call soong_config_define_internal,$1,$2) \
$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(strip $3))
endef
# soong_config_set_bool is the same as soong_config_set, but it will
# also type the variable as a bool, so that when using select() expressions
# in blueprint files they can use boolean values instead of strings.
# It will only accept "true" for its value, any other value will be
# treated as false.
# $1 is the namespace. $2 is the variable name. $3 is the variable value.
# Ex: $(call soong_config_set_bool,acme,COOL_FEATURE,true)
define soong_config_set_bool
$(call soong_config_define_internal,$1,$2) \
$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(filter true,$3))
$(eval SOONG_CONFIG_TYPE_$(strip $1)_$(strip $2):=bool)
endef
# soong_config_set_int is the same as soong_config_set, but it will
# also type the variable as an integer, so that when using select() expressions
# in blueprint files they can use integer values instead of strings.
# It will error out if a non-integer is supplied
# $1 is the namespace. $2 is the variable name. $3 is the variable value.
# Ex: $(call soong_config_set_bool,acme,COOL_FEATURE,34)
define soong_config_set_int
$(call soong_config_define_internal,$1,$2) \
$(if $(call math_is_int,$3),,$(error soong_config_set_int called with non-integer value $(3)))
$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(strip $3))
$(eval SOONG_CONFIG_TYPE_$(strip $1)_$(strip $2):=int)
endef
# soong_config_set_string_list is the same as soong_config_set, but it will
# also type the variable as a list of strings, so that when using select() expressions
# in blueprint files they can use list values instead of strings.
# The values of the list must be space-separated.
# $1 is the namespace. $2 is the variable name. $3 is the variable value.
# Ex: $(call soong_config_set_string_list,acme,COOL_LIBS,a b)
define soong_config_set_string_list
$(call soong_config_define_internal,$1,$2) \
$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(strip $3))
$(eval SOONG_CONFIG_TYPE_$(strip $1)_$(strip $2):=string_list)
endef
# soong_config_append appends to the value of the variable in the given Soong
# config namespace. If the variable does not exist, it will be defined. If the
# namespace does not exist, it will be defined.
# $1 is the namespace, $2 is the variable name, $3 is the value
define soong_config_append
$(call soong_config_define_internal,$1,$2) \
$(eval SOONG_CONFIG_$(strip $1)_$(strip $2):=$(SOONG_CONFIG_$(strip $1)_$(strip $2)) $(strip $3))
endef
# soong_config_append gets to the value of the variable in the given Soong
# config namespace. If the namespace or variables does not exist, an
# empty string will be returned.
# $1 is the namespace, $2 is the variable name
define soong_config_get
$(SOONG_CONFIG_$(strip $1)_$(strip $2))
endef
# Set the extensions used for various packages
COMMON_PACKAGE_SUFFIX := .zip
COMMON_JAVA_PACKAGE_SUFFIX := .jar
COMMON_ANDROID_PACKAGE_SUFFIX := .apk
ifdef TMPDIR
JAVA_TMPDIR_ARG := -Djava.io.tmpdir=$(TMPDIR)
else
JAVA_TMPDIR_ARG :=
endif
# These build broken variables are intended to be set in a buildspec file,
# while other build broken flags are expected to be set in a board config.
# These are build broken variables that are expected to apply across board
# configs, generally for cross-cutting features.
# Build broken variables that should be treated as booleans
_build_broken_bool_vars :=
# Build broken variables that should be treated as lists
_build_broken_list_vars := \
BUILD_BROKEN_PLUGIN_VALIDATION \
_build_broken_var_names := $(_build_broken_bool_vars)
_build_broken_var_names += $(_build_broken_list_vars)
$(foreach v,$(_build_broken_var_names),$(eval $(v) :=))
# ###############################################################
# Include sub-configuration files
# ###############################################################
# ---------------------------------------------------------------
# Try to include buildspec.mk, which will try to set stuff up.
# If this file doesn't exist, the environment variables will
# be used, and if that doesn't work, then the default is an
# arm build
ifndef ANDROID_BUILDSPEC
ANDROID_BUILDSPEC := $(TOPDIR)buildspec.mk
endif
-include $(ANDROID_BUILDSPEC)
# ---------------------------------------------------------------
# Define most of the global variables. These are the ones that
# are specific to the user's build configuration.
include $(BUILD_SYSTEM)/envsetup.mk
$(foreach var,$(_build_broken_bool_vars), \
$(if $(filter-out true false,$($(var))), \
$(error Valid values of $(var) are "true", "false", and "". Not "$($(var))")))
.KATI_READONLY := $(_build_broken_var_names)
# Returns true if it is a low memory device, otherwise it returns false.
define is-low-mem-device
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_PROPERTY_OVERRIDES)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_DEFAULT_PROPERTY_OVERRIDES)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_COMPATIBLE_PROPERTY)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_SYSTEM_DEFAULT_PROPERTIES)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_SYSTEM_EXT_PROPERTIES)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_PRODUCT_PROPERTIES)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_VENDOR_PROPERTIES)),true,\
$(if $(findstring ro.config.low_ram=true,$(PRODUCT_ODM_PROPERTIES)),true,false)))))))))
endef
# Set TARGET_MAX_PAGE_SIZE_SUPPORTED.
# TARGET_MAX_PAGE_SIZE_SUPPORTED indicates the alignment of the ELF segments.
ifdef PRODUCT_MAX_PAGE_SIZE_SUPPORTED
TARGET_MAX_PAGE_SIZE_SUPPORTED := $(PRODUCT_MAX_PAGE_SIZE_SUPPORTED)
else ifeq ($(strip $(call is-low-mem-device)),true)
# Low memory device will have 4096 binary alignment.
TARGET_MAX_PAGE_SIZE_SUPPORTED := 4096
else ifeq ($(call math_lt,$(VSR_VENDOR_API_LEVEL),34),true)
TARGET_MAX_PAGE_SIZE_SUPPORTED := 4096
else ifeq (,$(filter arm64 x86_64,$(TARGET_ARCH)))
# TARGET_MAX_PAGE_SIZE_SUPPORTED > 4096 is only supported in arm64 and
# x86_64 targets.
TARGET_MAX_PAGE_SIZE_SUPPORTED := 4096
else
# The default binary alignment for userspace is 16384.
TARGET_MAX_PAGE_SIZE_SUPPORTED := 16384
endif
.KATI_READONLY := TARGET_MAX_PAGE_SIZE_SUPPORTED
# Boolean variable determining if AOSP relies on bionic's PAGE_SIZE macro.
ifdef PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO
TARGET_NO_BIONIC_PAGE_SIZE_MACRO := $(PRODUCT_NO_BIONIC_PAGE_SIZE_MACRO)
else ifeq ($(call math_lt,$(VSR_VENDOR_API_LEVEL),35),true)
TARGET_NO_BIONIC_PAGE_SIZE_MACRO := false
else
TARGET_NO_BIONIC_PAGE_SIZE_MACRO := true
endif
.KATI_READONLY := TARGET_NO_BIONIC_PAGE_SIZE_MACRO
# Pruned directory options used when using findleaves.py
# See envsetup.mk for a description of SCAN_EXCLUDE_DIRS
FIND_LEAVES_EXCLUDES := $(addprefix --prune=, $(SCAN_EXCLUDE_DIRS) .repo .git)
# The build system exposes several variables for where to find the kernel
# headers:
# TARGET_DEVICE_KERNEL_HEADERS is automatically created for the current
# device being built. It is set as $(TARGET_DEVICE_DIR)/kernel-headers,
# e.g. device/samsung/tuna/kernel-headers. This directory is not
# explicitly set by anyone, the build system always adds this subdir.
#
# TARGET_BOARD_KERNEL_HEADERS is specified by the BoardConfig.mk file
# to allow other directories to be included. This is useful if there's
# some common place where a few headers are being kept for a group
# of devices. For example, device//common/kernel-headers could
# contain some headers for several of 's devices.
#
# TARGET_PRODUCT_KERNEL_HEADERS is generated by the product inheritance
# graph. This allows architecture products to provide headers for the
# devices using that architecture. For example,
# hardware/ti/omap4xxx/omap4.mk will specify
# PRODUCT_VENDOR_KERNEL_HEADERS variable that specify where the omap4
# specific headers are, e.g. hardware/ti/omap4xxx/kernel-headers.
# The build system then combines all the values specified by all the
# PRODUCT_VENDOR_KERNEL_HEADERS directives in the product inheritance
# tree and then exports a TARGET_PRODUCT_KERNEL_HEADERS variable.
#
# The layout of subdirs in any of the kernel-headers dir should mirror the
# layout of the kernel include/ directory. For example,
# device/samsung/tuna/kernel-headers/linux/,
# hardware/ti/omap4xxx/kernel-headers/media/,
# etc.
#
# NOTE: These directories MUST contain post-processed headers using the
# bionic/libc/kernel/tools/clean_header.py tool. Additionally, the original
# kernel headers must also be checked in, but in a different subdirectory. By
# convention, the originals should be checked into original-kernel-headers
# directory of the same parent dir. For example,
# device/samsung/tuna/kernel-headers <----- post-processed
# device/samsung/tuna/original-kernel-headers <----- originals
#
TARGET_DEVICE_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_DEVICE_DIR)/kernel-headers))
define validate-kernel-headers
$(if $(firstword $(foreach hdr_dir,$(1),\
$(filter-out kernel-headers,$(notdir $(hdr_dir))))),\
$(error Kernel header dirs must be end in kernel-headers: $(1)))
endef
# also allow the board config to provide additional directories since
# there could be device/oem/base_hw and device/oem/derived_hw
# that both are valid devices but derived_hw needs to use kernel headers
# from base_hw.
TARGET_BOARD_KERNEL_HEADERS := $(strip $(wildcard $(TARGET_BOARD_KERNEL_HEADERS)))
TARGET_BOARD_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_BOARD_KERNEL_HEADERS))
$(call validate-kernel-headers,$(TARGET_BOARD_KERNEL_HEADERS))
# then add product-inherited includes, to allow for
# hardware/sivendor/chip/chip.mk to include their own headers
TARGET_PRODUCT_KERNEL_HEADERS := $(strip $(wildcard $(PRODUCT_VENDOR_KERNEL_HEADERS)))
TARGET_PRODUCT_KERNEL_HEADERS := $(patsubst %/,%,$(TARGET_PRODUCT_KERNEL_HEADERS))
$(call validate-kernel-headers,$(TARGET_PRODUCT_KERNEL_HEADERS))
.KATI_READONLY := TARGET_DEVICE_KERNEL_HEADERS TARGET_BOARD_KERNEL_HEADERS TARGET_PRODUCT_KERNEL_HEADERS
# Commands to generate .toc file common to ELF .so files.
define _gen_toc_command_for_elf
$(hide) ($($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) -d $(1) | grep SONAME || echo "No SONAME for $1") > $(2)
$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)READELF) --dyn-syms $(1) | awk '{$$2=""; $$3=""; print}' >> $(2)
endef
# Commands to generate .toc file from Darwin dynamic library.
define _gen_toc_command_for_macho
$(hide) $(HOST_OTOOL) -l $(1) | grep LC_ID_DYLIB -A 5 > $(2)
$(hide) $(HOST_NM) -gP $(1) | cut -f1-2 -d" " | (grep -v U$$ >> $(2) || true)
endef
# Pick a Java compiler.
include $(BUILD_SYSTEM)/combo/javac.mk
ifeq ($(CALLED_FROM_SETUP),true)
include $(BUILD_SYSTEM)/ccache.mk
include $(BUILD_SYSTEM)/rbe.mk
endif
# GCC version selection
TARGET_GCC_VERSION := 4.9
ifdef TARGET_2ND_ARCH
2ND_TARGET_GCC_VERSION := 4.9
endif
# Normalize WITH_STATIC_ANALYZER
ifeq ($(strip $(WITH_STATIC_ANALYZER)),0)
WITH_STATIC_ANALYZER :=
endif
# Unset WITH_TIDY_ONLY if global WITH_TIDY_ONLY is not true nor 1.
ifeq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
WITH_TIDY_ONLY :=
endif
# ---------------------------------------------------------------
# Check that the configuration is current. We check that
# BUILD_ENV_SEQUENCE_NUMBER is current against this value.
# Don't fail if we're called from envsetup, so they have a
# chance to update their environment.
ifeq (,$(strip $(CALLED_FROM_SETUP)))
ifneq (,$(strip $(BUILD_ENV_SEQUENCE_NUMBER)))
ifneq ($(BUILD_ENV_SEQUENCE_NUMBER),$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER))
$(warning BUILD_ENV_SEQUENCE_NUMBER is set incorrectly.)
$(info *** If you use envsetup/lunch/choosecombo:)
$(info *** - Re-execute envsetup (". envsetup.sh"))
$(info *** - Re-run lunch or choosecombo)
$(info *** If you use buildspec.mk:)
$(info *** - Look at buildspec.mk.default to see what has changed)
$(info *** - Update BUILD_ENV_SEQUENCE_NUMBER to "$(CORRECT_BUILD_ENV_SEQUENCE_NUMBER)")
$(error bailing..)
endif
endif
endif
# ---------------------------------------------------------------
# Whether we can expect a full build graph
ALLOW_MISSING_DEPENDENCIES := $(filter true,$(ALLOW_MISSING_DEPENDENCIES))
ifneq ($(TARGET_BUILD_APPS),)
ALLOW_MISSING_DEPENDENCIES := true
endif
ifeq ($(TARGET_BUILD_UNBUNDLED_IMAGE),true)
ALLOW_MISSING_DEPENDENCIES := true
endif
ifneq ($(filter true,$(SOONG_ALLOW_MISSING_DEPENDENCIES)),)
ALLOW_MISSING_DEPENDENCIES := true
endif
# Mac builds default to ALLOW_MISSING_DEPENDENCIES, at least until the host
# tools aren't enabled by default for Mac.
ifeq ($(HOST_OS),darwin)
ALLOW_MISSING_DEPENDENCIES := true
endif
.KATI_READONLY := ALLOW_MISSING_DEPENDENCIES
TARGET_BUILD_USE_PREBUILT_SDKS :=
DISABLE_PREOPT :=
DISABLE_PREOPT_BOOT_IMAGES :=
ifneq (,$(TARGET_BUILD_APPS)$(TARGET_BUILD_UNBUNDLED_IMAGE))
DISABLE_PREOPT := true
DISABLE_PREOPT_BOOT_IMAGES := true
endif
ifeq (true,$(TARGET_BUILD_UNBUNDLED))
ifneq (true,$(UNBUNDLED_BUILD_SDKS_FROM_SOURCE))
TARGET_BUILD_USE_PREBUILT_SDKS := true
endif
endif
.KATI_READONLY := \
TARGET_BUILD_USE_PREBUILT_SDKS \
DISABLE_PREOPT \
DISABLE_PREOPT_BOOT_IMAGES \
prebuilt_sdk_tools := prebuilts/sdk/tools
prebuilt_sdk_tools_bin := $(prebuilt_sdk_tools)/$(HOST_OS)/bin
prebuilt_build_tools := prebuilts/build-tools
prebuilt_build_tools_wrappers := prebuilts/build-tools/common/bin
prebuilt_build_tools_jars := prebuilts/build-tools/common/framework
prebuilt_build_tools_bin_noasan := $(prebuilt_build_tools)/$(HOST_PREBUILT_TAG)/bin
ifeq ($(filter address,$(SANITIZE_HOST)),)
prebuilt_build_tools_bin := $(prebuilt_build_tools_bin_noasan)
else
prebuilt_build_tools_bin := $(prebuilt_build_tools)/$(HOST_PREBUILT_TAG)/asan/bin
endif
# Work around for b/68406220
# This should match the soong version.
USE_D8 := true
.KATI_READONLY := USE_D8
#
# Tools that are prebuilts for TARGET_BUILD_USE_PREBUILT_SDKS
#
ifeq (,$(TARGET_BUILD_USE_PREBUILT_SDKS))
AAPT := $(HOST_OUT_EXECUTABLES)/aapt
else # TARGET_BUILD_USE_PREBUILT_SDKS
AAPT := $(prebuilt_sdk_tools_bin)/aapt
endif # TARGET_BUILD_USE_PREBUILT_SDKS
ifeq (,$(TARGET_BUILD_USE_PREBUILT_SDKS))
# Use RenderScript prebuilts for unbundled builds
LLVM_RS_CC := $(HOST_OUT_EXECUTABLES)/llvm-rs-cc
BCC_COMPAT := $(HOST_OUT_EXECUTABLES)/bcc_compat
else
LLVM_RS_CC := $(prebuilt_sdk_tools_bin)/llvm-rs-cc
BCC_COMPAT := $(prebuilt_sdk_tools_bin)/bcc_compat
endif
prebuilt_sdk_tools :=
prebuilt_sdk_tools_bin :=
ACP := $(prebuilt_build_tools_bin)/acp
CKATI := $(prebuilt_build_tools_bin)/ckati
DEPMOD := $(HOST_OUT_EXECUTABLES)/depmod
FILESLIST := $(HOST_OUT_EXECUTABLES)/fileslist
FILESLIST_UTIL :=$= build/make/tools/fileslist_util.py
HOST_INIT_VERIFIER := $(HOST_OUT_EXECUTABLES)/host_init_verifier
XMLLINT := $(HOST_OUT_EXECUTABLES)/xmllint
ACONFIG := $(HOST_OUT_EXECUTABLES)/aconfig
# SOONG_ZIP is exported by Soong, but needs to be defined early for
# $OUT/dexpreopt.global. It will be verified against the Soong version.
SOONG_ZIP := $(HOST_OUT_EXECUTABLES)/soong_zip
# ---------------------------------------------------------------
# Generic tools.
# These dependencies are now handled via dependencies on prebuilt_build_tool
BISON_DATA :=$=
YASM := prebuilts/misc/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/yasm/yasm
DOXYGEN:= doxygen
ifeq ($(HOST_OS),linux)
BREAKPAD_DUMP_SYMS := $(HOST_OUT_EXECUTABLES)/dump_syms
else
# For non-supported hosts, do not generate breakpad symbols.
BREAKPAD_GENERATE_SYMBOLS := false
endif
GZIP := prebuilts/build-tools/path/$(BUILD_OS)-$(HOST_PREBUILT_ARCH)/gzip
PROTOC := $(HOST_OUT_EXECUTABLES)/aprotoc$(HOST_EXECUTABLE_SUFFIX)
NANOPB_SRCS := $(HOST_OUT_EXECUTABLES)/protoc-gen-nanopb
MKBOOTFS := $(HOST_OUT_EXECUTABLES)/mkbootfs$(HOST_EXECUTABLE_SUFFIX)
MINIGZIP := $(GZIP)
LZ4 := $(HOST_OUT_EXECUTABLES)/lz4$(HOST_EXECUTABLE_SUFFIX)
ifeq (,$(strip $(BOARD_CUSTOM_MKBOOTIMG)))
MKBOOTIMG := $(HOST_OUT_EXECUTABLES)/mkbootimg$(HOST_EXECUTABLE_SUFFIX)
else
MKBOOTIMG := $(BOARD_CUSTOM_MKBOOTIMG)
endif
ifeq (,$(strip $(BOARD_CUSTOM_AVBTOOL)))
AVBTOOL := $(HOST_OUT_EXECUTABLES)/avbtool$(HOST_EXECUTABLE_SUFFIX)
else
AVBTOOL := $(BOARD_CUSTOM_AVBTOOL)
endif
APICHECK := $(HOST_OUT_JAVA_LIBRARIES)/metalava$(COMMON_JAVA_PACKAGE_SUFFIX)
MKEXTUSERIMG := $(HOST_OUT_EXECUTABLES)/mkuserimg_mke2fs
MKE2FS_CONF := system/extras/ext4_utils/mke2fs.conf
MKEROFS := $(HOST_OUT_EXECUTABLES)/mkfs.erofs
MKSQUASHFSUSERIMG := $(HOST_OUT_EXECUTABLES)/mksquashfsimage
MKF2FSUSERIMG := $(HOST_OUT_EXECUTABLES)/mkf2fsuserimg
SIMG2IMG := $(HOST_OUT_EXECUTABLES)/simg2img$(HOST_EXECUTABLE_SUFFIX)
E2FSCK := $(HOST_OUT_EXECUTABLES)/e2fsck$(HOST_EXECUTABLE_SUFFIX)
TUNE2FS := $(HOST_OUT_EXECUTABLES)/tune2fs$(HOST_EXECUTABLE_SUFFIX)
JARJAR := $(HOST_OUT_JAVA_LIBRARIES)/jarjar.jar
DATA_BINDING_COMPILER := $(HOST_OUT_JAVA_LIBRARIES)/databinding-compiler.jar
FAT16COPY := build/make/tools/fat16copy.py
CHECK_ELF_FILE := $(HOST_OUT_EXECUTABLES)/check_elf_file$(HOST_EXECUTABLE_SUFFIX)
LPMAKE := $(HOST_OUT_EXECUTABLES)/lpmake$(HOST_EXECUTABLE_SUFFIX)
ADD_IMG_TO_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/add_img_to_target_files$(HOST_EXECUTABLE_SUFFIX)
BUILD_IMAGE := $(HOST_OUT_EXECUTABLES)/build_image$(HOST_EXECUTABLE_SUFFIX)
ifeq (,$(strip $(BOARD_CUSTOM_BUILD_SUPER_IMAGE)))
BUILD_SUPER_IMAGE := $(HOST_OUT_EXECUTABLES)/build_super_image$(HOST_EXECUTABLE_SUFFIX)
else
BUILD_SUPER_IMAGE := $(BOARD_CUSTOM_BUILD_SUPER_IMAGE)
endif
IMG_FROM_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/img_from_target_files$(HOST_EXECUTABLE_SUFFIX)
UNPACK_BOOTIMG := $(HOST_OUT_EXECUTABLES)/unpack_bootimg
MAKE_RECOVERY_PATCH := $(HOST_OUT_EXECUTABLES)/make_recovery_patch$(HOST_EXECUTABLE_SUFFIX)
OTA_FROM_TARGET_FILES := $(HOST_OUT_EXECUTABLES)/ota_from_target_files$(HOST_EXECUTABLE_SUFFIX)
OTA_FROM_RAW_IMG := $(HOST_OUT_EXECUTABLES)/ota_from_raw_img$(HOST_EXECUTABLE_SUFFIX)
SPARSE_IMG := $(HOST_OUT_EXECUTABLES)/sparse_img$(HOST_EXECUTABLE_SUFFIX)
CHECK_PARTITION_SIZES := $(HOST_OUT_EXECUTABLES)/check_partition_sizes$(HOST_EXECUTABLE_SUFFIX)
SYMBOLS_MAP := $(HOST_OUT_EXECUTABLES)/symbols_map
PROGUARD_HOME := external/proguard
PROGUARD := $(PROGUARD_HOME)/bin/proguard.sh
PROGUARD_DEPS := $(PROGUARD) $(PROGUARD_HOME)/lib/proguard.jar
JAVATAGS := $(HOST_OUT_EXECUTABLES)/java-event-log-tags
MERGETAGS := $(HOST_OUT_EXECUTABLES)/merge-event-log-tags
APPEND2SIMG := $(HOST_OUT_EXECUTABLES)/append2simg
VERITY_SIGNER := $(HOST_OUT_EXECUTABLES)/verity_signer
BUILD_VERITY_METADATA := $(HOST_OUT_EXECUTABLES)/build_verity_metadata
BUILD_VERITY_TREE := $(HOST_OUT_EXECUTABLES)/build_verity_tree
DEXDUMP := $(HOST_OUT_EXECUTABLES)/dexdump$(BUILD_EXECUTABLE_SUFFIX)
PROFMAN := $(HOST_OUT_EXECUTABLES)/profman
GEN_SBOM := $(HOST_OUT_EXECUTABLES)/generate-sbom
FINDBUGS_DIR := external/owasp/sanitizer/tools/findbugs/bin
FINDBUGS := $(FINDBUGS_DIR)/findbugs
JETIFIER := prebuilts/sdk/tools/jetifier/jetifier-standalone/bin/jetifier-standalone
EXTRACT_KERNEL := build/make/tools/extract_kernel.py
# Path to tools.jar
HOST_JDK_TOOLS_JAR := $(ANDROID_JAVA8_HOME)/lib/tools.jar
APICHECK_COMMAND := $(JAVA) -Xmx4g -jar $(APICHECK)
# Boolean variable determining if the allow list for compatible properties is enabled
PRODUCT_COMPATIBLE_PROPERTY := true
ifeq ($(PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE),false)
$(error PRODUCT_COMPATIBLE_PROPERTY_OVERRIDE is obsolete)
endif
.KATI_READONLY := \
PRODUCT_COMPATIBLE_PROPERTY
# TODO: remove all code referencing these, and remove override variables
PRODUCT_FULL_TREBLE := true
PRODUCT_TREBLE_LINKER_NAMESPACES := true
PRODUCT_ENFORCE_VINTF_MANIFEST := true
# TODO(b/114488870): disallow PRODUCT_FULL_TREBLE_OVERRIDE from being used.
.KATI_READONLY := \
PRODUCT_FULL_TREBLE \
PRODUCT_TREBLE_LINKER_NAMESPACES \
PRODUCT_ENFORCE_VINTF_MANIFEST \
# TODO(b/114488870): remove all sets of these everwhere, and disallow them to be used
$(KATI_obsolete_var PRODUCT_TREBLE_LINKER_NAMESPACES_OVERRIDE,Deprecated.)
$(KATI_obsolete_var PRODUCT_ENFORCE_VINTF_MANIFEST_OVERRIDE,Deprecated.)
$(KATI_obsolete_var PRODUCT_FULL_TREBLE_OVERRIDE,Deprecated.)
# BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED can be true only if early-mount of
# partitions is supported. But the early-mount must be supported for full
# treble products, and so BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED should be set
# by default for full treble products.
ifeq ($(PRODUCT_FULL_TREBLE),true)
BOARD_PROPERTY_OVERRIDES_SPLIT_ENABLED ?= true
endif
ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),36),)
ifneq ($(NEED_AIDL_NDK_PLATFORM_BACKEND),)
$(error Must not set NEED_AIDL_NDK_PLATFORM_BACKEND, but it is set to: $(NEED_AIDL_NDK_PLATFORM_BACKEND). Support will be removed.)
endif
endif
ifdef PRODUCT_CHECK_PREBUILT_MAX_PAGE_SIZE
TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE := $(PRODUCT_CHECK_PREBUILT_MAX_PAGE_SIZE)
else ifeq (true,$(TARGET_BUILD_UNBUNDLED))
# unbundled builds may not have updated build sources
TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE := false
else ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),36),)
TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE := true
else
TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE := false
endif
.KATI_READONLY := TARGET_CHECK_PREBUILT_MAX_PAGE_SIZE
# Set BOARD_SYSTEMSDK_VERSIONS to the latest SystemSDK version starting from P-launching
# devices if unset.
ifndef BOARD_SYSTEMSDK_VERSIONS
ifeq (REL,$(PLATFORM_VERSION_CODENAME))
BOARD_SYSTEMSDK_VERSIONS := $(PLATFORM_SDK_VERSION)
else
BOARD_SYSTEMSDK_VERSIONS := $(PLATFORM_VERSION_CODENAME)
endif
endif
ifndef BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES
BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES := current
else
ifdef PRODUCT_SHIPPING_API_LEVEL
ifneq ($(call math_lt,$(BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES),$(PRODUCT_SHIPPING_API_LEVEL)),)
$(error BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES ($(BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES)) must be greater than or equal to PRODUCT_SHIPPING_API_LEVEL ($(PRODUCT_SHIPPING_API_LEVEL)))
endif
endif
endif
.KATI_READONLY := BOARD_CURRENT_API_LEVEL_FOR_VENDOR_MODULES
ifdef PRODUCT_SHIPPING_API_LEVEL
ifneq ($(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29),)
ifneq ($(BOARD_OTA_FRAMEWORK_VBMETA_VERSION_OVERRIDE),)
$(error When PRODUCT_SHIPPING_API_LEVEL >= 29, BOARD_OTA_FRAMEWORK_VBMETA_VERSION_OVERRIDE cannot be set)
endif
endif
endif
# The default key if not set as LOCAL_CERTIFICATE
ifdef PRODUCT_DEFAULT_DEV_CERTIFICATE
DEFAULT_SYSTEM_DEV_CERTIFICATE := $(PRODUCT_DEFAULT_DEV_CERTIFICATE)
else
DEFAULT_SYSTEM_DEV_CERTIFICATE := build/make/target/product/security/testkey
endif
.KATI_READONLY := DEFAULT_SYSTEM_DEV_CERTIFICATE
# Certificate for the NetworkStack sepolicy context
ifdef PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES
MAINLINE_SEPOLICY_DEV_CERTIFICATES := $(PRODUCT_MAINLINE_SEPOLICY_DEV_CERTIFICATES)
else
MAINLINE_SEPOLICY_DEV_CERTIFICATES := $(dir $(DEFAULT_SYSTEM_DEV_CERTIFICATE))
endif
.KATI_READONLY := MAINLINE_SEPOLICY_DEV_CERTIFICATES
BUILD_NUMBER_FROM_FILE := $$(cat $(SOONG_OUT_DIR)/build_number.txt)
BUILD_HOSTNAME_FROM_FILE := $$(cat $(SOONG_OUT_DIR)/build_hostname.txt)
BUILD_DATETIME_FROM_FILE := $$(cat $(BUILD_DATETIME_FILE))
# SEPolicy versions
# PLATFORM_SEPOLICY_VERSION is a number of the form "YYYYMM" with "YYYYMM"
# mapping to vFRC version.
PLATFORM_SEPOLICY_VERSION := $(BOARD_API_LEVEL)
BOARD_SEPOLICY_VERS := $(PLATFORM_SEPOLICY_VERSION)
.KATI_READONLY := PLATFORM_SEPOLICY_VERSION BOARD_SEPOLICY_VERS
# A list of SEPolicy versions, besides PLATFORM_SEPOLICY_VERSION, that the framework supports.
PLATFORM_SEPOLICY_COMPAT_VERSIONS := \
29.0 \
30.0 \
31.0 \
32.0 \
33.0 \
34.0 \
PLATFORM_SEPOLICY_COMPAT_VERSIONS += $(foreach ver,\
202404 \
202504 \
,$(if $(filter true,$(call math_gt,$(PLATFORM_SEPOLICY_VERSION),$(ver))),$(ver)))
.KATI_READONLY := \
PLATFORM_SEPOLICY_COMPAT_VERSIONS \
PLATFORM_SEPOLICY_VERSION \
BOARD_GENFS_LABELS_VERSION ?= $(BOARD_API_LEVEL)
ifeq ($(call math_gt,$(BOARD_API_LEVEL),$(BOARD_GENFS_LABELS_VERSION)),true)
$(error BOARD_GENFS_LABELS_VERSION ($(BOARD_GENFS_LABELS_VERSION)) must be greater than or equal to BOARD_API_LEVEL ($(BOARD_API_LEVEL)))
endif
ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
ifneq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
$(error PRODUCT_USE_DYNAMIC_PARTITIONS must be true when PRODUCT_RETROFIT_DYNAMIC_PARTITIONS \
is set)
endif
ifdef PRODUCT_SHIPPING_API_LEVEL
ifeq (true,$(call math_gt_or_eq,$(PRODUCT_SHIPPING_API_LEVEL),29))
$(error Devices with shipping API level $(PRODUCT_SHIPPING_API_LEVEL) must not set \
PRODUCT_RETROFIT_DYNAMIC_PARTITIONS)
endif
endif
endif
ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
ifneq ($(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),true)
$(error PRODUCT_USE_DYNAMIC_PARTITION_SIZE must be true for devices with dynamic partitions)
endif
endif
ifeq ($(PRODUCT_BUILD_SUPER_PARTITION),true)
ifneq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
$(error Can only build super partition for devices with dynamic partitions)
endif
endif
ifeq ($(PRODUCT_USE_DYNAMIC_PARTITION_SIZE),true)
ifneq ($(BOARD_SYSTEMIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_SYSTEMIMAGE_PARTITION_SIZE and \
BOARD_SYSTEMIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_VENDORIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_VENDORIMAGE_PARTITION_SIZE and \
BOARD_VENDORIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_ODMIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_ODMIMAGE_PARTITION_SIZE and \
BOARD_ODMIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_VENDOR_DLKMIMAGE_PARTITION_SIZE and \
BOARD_VENDOR_DLKMIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_ODM_DLKMIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_ODM_DLKMIMAGE_PARTITION_SIZE and \
BOARD_ODM_DLKMIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_SYSTEM_DLKMIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_SYSTEM_DLKMIMAGE_PARTITION_SIZE and \
BOARD_SYSTEM_DLKMIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_PRODUCTIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_PRODUCTIMAGE_PARTITION_SIZE and \
BOARD_PRODUCTIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
ifneq ($(BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE),)
ifneq ($(BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE),)
$(error Should not define BOARD_SYSTEM_EXTIMAGE_PARTITION_SIZE and \
BOARD_SYSTEM_EXTIMAGE_PARTITION_RESERVED_SIZE together)
endif
endif
endif # PRODUCT_USE_DYNAMIC_PARTITION_SIZE
ifeq ($(PRODUCT_USE_DYNAMIC_PARTITIONS),true)
# BOARD_SUPER_PARTITION_GROUPS defines a list of "updatable groups". Each updatable group is a
# group of partitions that share the same pool of free spaces.
# For each group in BOARD_SUPER_PARTITION_GROUPS, a BOARD_{GROUP}_SIZE and
# BOARD_{GROUP}_PARTITION_PARTITION_LIST may be defined.
# - BOARD_{GROUP}_SIZE: The maximum sum of sizes of all partitions in the group.
# Must not be empty.
# - BOARD_{GROUP}_PARTITION_PARTITION_LIST: the list of partitions that belongs to this group.
# If empty, no partitions belong to this group, and the sum of sizes is effectively 0.
$(foreach group,$(call to-upper,$(BOARD_SUPER_PARTITION_GROUPS)), \
$(eval BOARD_$(group)_SIZE := $(strip $(BOARD_$(group)_SIZE))) \
$(if $(BOARD_$(group)_SIZE),,$(error BOARD_$(group)_SIZE must not be empty)) \
$(eval .KATI_READONLY := BOARD_$(group)_SIZE) \
$(eval BOARD_$(group)_PARTITION_LIST ?=) \
$(eval .KATI_READONLY := BOARD_$(group)_PARTITION_LIST) \
)
# Define BOARD_SUPER_PARTITION_PARTITION_LIST, the sum of all BOARD_*_PARTITION_LIST
ifdef BOARD_SUPER_PARTITION_PARTITION_LIST
$(error BOARD_SUPER_PARTITION_PARTITION_LIST should not be defined, but computed from \
BOARD_SUPER_PARTITION_GROUPS and BOARD_*_PARTITION_LIST)
endif
BOARD_SUPER_PARTITION_PARTITION_LIST := \
$(foreach group,$(call to-upper,$(BOARD_SUPER_PARTITION_GROUPS)),$(BOARD_$(group)_PARTITION_LIST))
.KATI_READONLY := BOARD_SUPER_PARTITION_PARTITION_LIST
ifneq ($(BOARD_SUPER_PARTITION_SIZE),)
ifeq ($(PRODUCT_RETROFIT_DYNAMIC_PARTITIONS),true)
# The metadata device must be specified manually for retrofitting.
ifeq ($(BOARD_SUPER_PARTITION_METADATA_DEVICE),)
$(error Must specify BOARD_SUPER_PARTITION_METADATA_DEVICE if PRODUCT_RETROFIT_DYNAMIC_PARTITIONS=true.)
endif
# The super partition block device list must be specified manually for retrofitting.
ifeq ($(BOARD_SUPER_PARTITION_BLOCK_DEVICES),)
$(error Must specify BOARD_SUPER_PARTITION_BLOCK_DEVICES if PRODUCT_RETROFIT_DYNAMIC_PARTITIONS=true.)
endif
# The metadata device must be included in the super partition block device list.
ifeq (,$(filter $(BOARD_SUPER_PARTITION_METADATA_DEVICE),$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)))
$(error BOARD_SUPER_PARTITION_METADATA_DEVICE is not listed in BOARD_SUPER_PARTITION_BLOCK_DEVICES.)
endif
# The metadata device must be supplied to init via the kernel command-line.
INTERNAL_KERNEL_CMDLINE += androidboot.super_partition=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)
BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE := true
# If "vendor" is listed as one of the dynamic partitions but without its image available (e.g. an
# AOSP target built without vendor image), don't build the retrofit full OTA package. Because we
# won't be able to build meaningful super_* images for retrofitting purpose.
ifneq (,$(filter vendor,$(BOARD_SUPER_PARTITION_PARTITION_LIST)))
ifndef BUILDING_VENDOR_IMAGE
ifndef BOARD_PREBUILT_VENDORIMAGE
BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE :=
endif # BOARD_PREBUILT_VENDORIMAGE
endif # BUILDING_VENDOR_IMAGE
endif # BOARD_SUPER_PARTITION_PARTITION_LIST
else # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
# For normal devices, we populate BOARD_SUPER_PARTITION_BLOCK_DEVICES so the
# build can handle both cases consistently.
ifeq ($(BOARD_SUPER_PARTITION_METADATA_DEVICE),)
BOARD_SUPER_PARTITION_METADATA_DEVICE := super
endif
ifeq ($(BOARD_SUPER_PARTITION_BLOCK_DEVICES),)
BOARD_SUPER_PARTITION_BLOCK_DEVICES := $(BOARD_SUPER_PARTITION_METADATA_DEVICE)
endif
# If only one super block device, default to super partition size.
ifeq ($(word 2,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)),)
BOARD_SUPER_PARTITION_$(call to-upper,$(strip $(BOARD_SUPER_PARTITION_BLOCK_DEVICES)))_DEVICE_SIZE ?= \
$(BOARD_SUPER_PARTITION_SIZE)
endif
ifneq ($(BOARD_SUPER_PARTITION_METADATA_DEVICE),super)
INTERNAL_KERNEL_CMDLINE += androidboot.super_partition=$(BOARD_SUPER_PARTITION_METADATA_DEVICE)
endif
BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE :=
endif # PRODUCT_RETROFIT_DYNAMIC_PARTITIONS
endif # BOARD_SUPER_PARTITION_SIZE
BOARD_SUPER_PARTITION_BLOCK_DEVICES ?=
.KATI_READONLY := BOARD_SUPER_PARTITION_BLOCK_DEVICES
BOARD_SUPER_PARTITION_METADATA_DEVICE ?=
.KATI_READONLY := BOARD_SUPER_PARTITION_METADATA_DEVICE
BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE ?=
.KATI_READONLY := BOARD_BUILD_RETROFIT_DYNAMIC_PARTITIONS_OTA_PACKAGE
$(foreach device,$(call to-upper,$(BOARD_SUPER_PARTITION_BLOCK_DEVICES)), \
$(eval BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE := $(strip $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE))) \
$(if $(BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE),, \
$(error BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE must not be empty)) \
$(eval .KATI_READONLY := BOARD_SUPER_PARTITION_$(device)_DEVICE_SIZE))
endif # PRODUCT_USE_DYNAMIC_PARTITIONS
# By default, we build the hidden API csv files from source. You can use
# prebuilt hiddenapi files by setting BOARD_PREBUILT_HIDDENAPI_DIR to the name
# of a directory containing both prebuilt hiddenapi-flags.csv and
# hiddenapi-index.csv.
BOARD_PREBUILT_HIDDENAPI_DIR ?=
.KATI_READONLY := BOARD_PREBUILT_HIDDENAPI_DIR
# ###############################################################
# Set up final options.
# ###############################################################
# We run gcc/clang with PWD=/proc/self/cwd to remove the $TOP
# from the debug output. That way two builds in two different
# directories will create the same output.
# /proc doesn't exist on Darwin.
ifeq ($(HOST_OS),linux)
RELATIVE_PWD := PWD=/proc/self/cwd
else
RELATIVE_PWD :=
endif
# Flags for DEX2OAT
first_non_empty_of_three = $(if $(1),$(1),$(if $(2),$(2),$(3)))
DEX2OAT_TARGET_ARCH := $(TARGET_ARCH)
DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT),$(TARGET_ARCH_VARIANT),default)
DEX2OAT_TARGET_CPU_VARIANT_RUNTIME := $(call first_non_empty_of_three,$(TARGET_CPU_VARIANT_RUNTIME),$(TARGET_ARCH_VARIANT),default)
DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
ifdef TARGET_2ND_ARCH
$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_ARCH := $(TARGET_2ND_ARCH)
$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT),$(TARGET_2ND_ARCH_VARIANT),default)
$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_CPU_VARIANT_RUNTIME := $(call first_non_empty_of_three,$(TARGET_2ND_CPU_VARIANT_RUNTIME),$(TARGET_2ND_ARCH_VARIANT),default)
$(TARGET_2ND_ARCH_VAR_PREFIX)DEX2OAT_TARGET_INSTRUCTION_SET_FEATURES := default
endif
# ###############################################################
# Collect a list of the SDK versions that we could compile against
# For use with the LOCAL_SDK_VERSION variable for include $(BUILD_PACKAGE)
# ###############################################################
HISTORICAL_SDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/sdk
HISTORICAL_NDK_VERSIONS_ROOT := $(TOPDIR)prebuilts/ndk
# The path where app can reference the support library resources.
ifdef TARGET_BUILD_USE_PREBUILT_SDKS
SUPPORT_LIBRARY_ROOT := $(HISTORICAL_SDK_VERSIONS_ROOT)/current/support
else
SUPPORT_LIBRARY_ROOT := frameworks/support
endif
get-sdk-version = $(if $(findstring _,$(1)),$(subst core_,,$(subst system_,,$(subst test_,,$(1)))),$(1))
get-sdk-api = $(if $(findstring _,$(1)),$(patsubst %_$(call get-sdk-version,$(1)),%,$(1)),public)
get-prebuilt-sdk-dir = $(HISTORICAL_SDK_VERSIONS_ROOT)/$(call get-sdk-version,$(1))/$(call get-sdk-api,$(1))
# Resolve LOCAL_SDK_VERSION to prebuilt module name, e.g.:
# 23 -> sdk_public_23_android
# system_current -> sdk_system_current_android
# $(1): An sdk version (LOCAL_SDK_VERSION)
# $(2): optional library name (default: android)
define resolve-prebuilt-sdk-module
$(if $(findstring _,$(1)),\
sdk_$(1)_$(or $(2),android),\
sdk_public_$(1)_$(or $(2),android))
endef
# Resolve LOCAL_SDK_VERSION to prebuilt android.jar
# $(1): LOCAL_SDK_VERSION
resolve-prebuilt-sdk-jar-path = $(call get-prebuilt-sdk-dir,$(1))/android.jar
# Resolve LOCAL_SDK_VERSION to prebuilt framework.aidl
# $(1): An sdk version (LOCAL_SDK_VERSION)
resolve-prebuilt-sdk-aidl-path = $(call get-prebuilt-sdk-dir,$(call get-sdk-version,$(1)))/framework.aidl
# Historical SDK version N is stored in $(HISTORICAL_SDK_VERSIONS_ROOT)/N.
# The 'current' version is whatever this source tree is.
#
# sgrax is the opposite of xargs. It takes the list of args and puts them
# on each line for sort to process.
# sort -g is a numeric sort, so 1 2 3 10 instead of 1 10 2 3.
# Numerically sort a list of numbers
# $(1): the list of numbers to be sorted
define numerically_sort
$(shell function sgrax() { \
while [ -n "$$1" ] ; do echo $$1 ; shift ; done \
} ; \
( sgrax $(1) | sort -g ) )
endef
# This produces a list like "current/core current/public current/system 4/public"
TARGET_AVAILABLE_SDK_VERSIONS := $(wildcard $(HISTORICAL_SDK_VERSIONS_ROOT)/*/*/android.jar)
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst $(HISTORICAL_SDK_VERSIONS_ROOT)/%/android.jar,%,$(TARGET_AVAILABLE_SDK_VERSIONS))
# Strips and reorganizes the "public", "core", "system" and "test" subdirs.
TARGET_AVAILABLE_SDK_VERSIONS := $(subst /public,,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/core,core_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/system,system_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAILABLE_SDK_VERSIONS := $(patsubst %/test,test_%,$(TARGET_AVAILABLE_SDK_VERSIONS))
# module-lib and system-server are not supported in Make.
TARGET_AVAILABLE_SDK_VERSIONS := $(filter-out %/module-lib %/system-server,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_AVAIALBLE_SDK_VERSIONS := $(call numerically_sort,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_SDK_VERSIONS_WITHOUT_JAVA_1_9_SUPPORT := $(call numbers_less_than,30,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_SDK_VERSIONS_WITHOUT_JAVA_11_SUPPORT := $(call numbers_less_than,32,$(TARGET_AVAILABLE_SDK_VERSIONS))
TARGET_SDK_VERSIONS_WITHOUT_JAVA_17_SUPPORT := $(call numbers_less_than,34,$(TARGET_AVAILABLE_SDK_VERSIONS))
JAVA_LANGUAGE_VERSIONS_WITHOUT_SYSTEM_MODULES := 1.7 1.8
# This is the standard way to name a directory containing prebuilt target
# objects. E.g., prebuilt/$(TARGET_PREBUILT_TAG)/libc.so
TARGET_PREBUILT_TAG := android-$(TARGET_ARCH)
ifdef TARGET_2ND_ARCH
TARGET_2ND_PREBUILT_TAG := android-$(TARGET_2ND_ARCH)
endif
# Set up RS prebuilt variables for compatibility library
RS_PREBUILT_CLCORE := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/librsrt_$(TARGET_ARCH).bc
RS_PREBUILT_COMPILER_RT := prebuilts/sdk/renderscript/lib/$(TARGET_ARCH)/libcompiler_rt.a
# API Level lists for Renderscript Compat lib.
RSCOMPAT_32BIT_ONLY_API_LEVELS := 8 9 10 11 12 13 14 15 16 17 18 19 20
RSCOMPAT_NO_USAGEIO_API_LEVELS := 8 9 10 11 12 13
APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)
# Add BUILD_NUMBER to apps if PRODUCT_BUILD_APPS_WITH_BUILD_NUMBER is defined.
ifeq ($(PRODUCT_BUILD_APPS_WITH_BUILD_NUMBER),true)
APPS_DEFAULT_VERSION_NAME := $(PLATFORM_VERSION)-$(BUILD_NUMBER_FROM_FILE)
endif
# ANDROID_WARNING_ALLOWED_PROJECTS is generated by build/soong.
define find_warning_allowed_projects
$(filter $(ANDROID_WARNING_ALLOWED_PROJECTS),$(1)/)
endef
GOMA_POOL :=
RBE_POOL :=
GOMA_OR_RBE_POOL :=
# When goma or RBE are enabled, kati will be passed --default_pool=local_pool to put
# most rules into the local pool. Explicitly set the pool to "none" for rules that
# should be run outside the local pool, i.e. with -j500.
ifneq (,$(filter-out false,$(USE_GOMA)))
GOMA_POOL := none
GOMA_OR_RBE_POOL := none
else ifneq (,$(filter-out false,$(USE_RBE)))
RBE_POOL := none
GOMA_OR_RBE_POOL := none
endif
.KATI_READONLY := GOMA_POOL RBE_POOL GOMA_OR_RBE_POOL
JAVAC_NINJA_POOL :=
R8_NINJA_POOL :=
D8_NINJA_POOL :=
ifneq ($(filter-out false,$(USE_RBE)),)
ifdef RBE_JAVAC
JAVAC_NINJA_POOL := $(RBE_POOL)
endif
ifdef RBE_R8
R8_NINJA_POOL := $(RBE_POOL)
endif
ifdef RBE_D8
D8_NINJA_POOL := $(RBE_POOL)
endif
endif
.KATI_READONLY := JAVAC_NINJA_POOL R8_NINJA_POOL D8_NINJA_POOL
# Soong modules that are known to have broken optional_uses_libs dependencies.
BUILD_WARNING_BAD_OPTIONAL_USES_LIBS_ALLOWLIST := LegacyCamera Gallery2
# These goals don't need to collect and include Android.mks/CleanSpec.mks
# in the source tree.
dont_bother_goals := out product-graph
ifeq ($(TARGET_SYSTEM_PROP),)
TARGET_SYSTEM_PROP := $(wildcard $(TARGET_DEVICE_DIR)/system.prop)
endif
ifeq ($(TARGET_SYSTEM_EXT_PROP),)
TARGET_SYSTEM_EXT_PROP := $(wildcard $(TARGET_DEVICE_DIR)/system_ext.prop)
endif
ifeq ($(TARGET_PRODUCT_PROP),)
TARGET_PRODUCT_PROP := $(wildcard $(TARGET_DEVICE_DIR)/product.prop)
endif
ifeq ($(TARGET_ODM_PROP),)
TARGET_ODM_PROP := $(wildcard $(TARGET_DEVICE_DIR)/odm.prop)
endif
.KATI_READONLY := \
TARGET_SYSTEM_PROP \
TARGET_SYSTEM_EXT_PROP \
TARGET_PRODUCT_PROP \
TARGET_ODM_PROP \
include $(BUILD_SYSTEM)/sysprop_config.mk
# Make ANDROID Soong config variables visible to Android.mk files, for
# consistency with those defined in BoardConfig.mk files.
include $(BUILD_SYSTEM)/android_soong_config_vars.mk
# EMMA_INSTRUMENT is set to true when coverage is enabled. Creates a suffix to
# differeciate the coverage version of ninja files. This will save 5 minutes of
# build time used to regenerate ninja.
ifeq (true,$(EMMA_INSTRUMENT))
COVERAGE_SUFFIX := .coverage
endif
SOONG_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).variables
SOONG_EXTRA_VARIABLES := $(SOONG_OUT_DIR)/soong.$(TARGET_PRODUCT)$(COVERAGE_SUFFIX).extra.variables
ifeq ($(CALLED_FROM_SETUP),true)
include $(BUILD_SYSTEM)/ninja_config.mk
include $(BUILD_SYSTEM)/soong_config.mk
endif
SOONG_VARIABLES :=
SOONG_EXTRA_VARIABLES :=
include $(BUILD_SYSTEM)/dumpvar.mk
ifdef BOARD_VNDK_VERSION
BOARD_VNDK_VERSION=
endif
ifdef PLATFORM_VNDK_VERSION
PLATFORM_VNDK_VERSION=
endif
ifeq (true,$(FULL_SYSTEM_OPTIMIZE_JAVA))
ifeq (false,$(SYSTEM_OPTIMIZE_JAVA))
$(error SYSTEM_OPTIMIZE_JAVA must be enabled when FULL_SYSTEM_OPTIMIZE_JAVA is enabled)
endif
endif
# -----------------------------------------------------------------
# Define fingerprint, thumbprint, and version tags for the current build
#
# BUILD_VERSION_TAGS is a comma-separated list of tags chosen by the device
# implementer that further distinguishes the build. It's basically defined
# by the device implementer. Here, we are adding a mandatory tag that
# identifies the signing config of the build.
BUILD_VERSION_TAGS := $(BUILD_VERSION_TAGS)
ifeq ($(TARGET_BUILD_TYPE),debug)
BUILD_VERSION_TAGS += debug
endif
# The "test-keys" tag marks builds signed with the old test keys,
# which are available in the SDK. "dev-keys" marks builds signed with
# non-default dev keys (usually private keys from a vendor directory).
# Both of these tags will be removed and replaced with "release-keys"
# when the target-files is signed in a post-build step.
ifeq ($(DEFAULT_SYSTEM_DEV_CERTIFICATE),build/make/target/product/security/testkey)
BUILD_KEYS := test-keys
else
BUILD_KEYS := dev-keys
endif
BUILD_VERSION_TAGS += $(BUILD_KEYS)
BUILD_VERSION_TAGS := $(subst $(space),$(comma),$(sort $(BUILD_VERSION_TAGS)))
# BUILD_FINGERPRINT is used used to uniquely identify the combined build and
# product; used by the OTA server.
ifeq (,$(strip $(BUILD_FINGERPRINT)))
BUILD_FINGERPRINT := $(PRODUCT_BRAND)/$(TARGET_PRODUCT)/$(TARGET_DEVICE):$(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
endif
BUILD_FINGERPRINT_FILE := $(PRODUCT_OUT)/build_fingerprint.txt
ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_FINGERPRINT) >$(BUILD_FINGERPRINT_FILE).tmp && (if ! cmp -s $(BUILD_FINGERPRINT_FILE).tmp $(BUILD_FINGERPRINT_FILE); then mv $(BUILD_FINGERPRINT_FILE).tmp $(BUILD_FINGERPRINT_FILE); else rm $(BUILD_FINGERPRINT_FILE).tmp; fi) && grep " " $(BUILD_FINGERPRINT_FILE)))
$(error BUILD_FINGERPRINT cannot contain spaces: "$(file <$(BUILD_FINGERPRINT_FILE))")
endif
BUILD_FINGERPRINT_FROM_FILE := $$(cat $(BUILD_FINGERPRINT_FILE))
# unset it for safety.
BUILD_FINGERPRINT :=
# BUILD_THUMBPRINT is used to uniquely identify the system build; used by the
# OTA server. This purposefully excludes any product-specific variables.
ifeq (,$(strip $(BUILD_THUMBPRINT)))
BUILD_THUMBPRINT := $(PLATFORM_VERSION)/$(BUILD_ID)/$(BUILD_NUMBER_FROM_FILE):$(TARGET_BUILD_VARIANT)/$(BUILD_VERSION_TAGS)
endif
BUILD_THUMBPRINT_FILE := $(PRODUCT_OUT)/build_thumbprint.txt
ifeq ($(strip $(HAS_BUILD_NUMBER)),true)
$(BUILD_THUMBPRINT_FILE): $(BUILD_NUMBER_FILE)
endif
ifneq (,$(shell mkdir -p $(PRODUCT_OUT) && echo $(BUILD_THUMBPRINT) >$(BUILD_THUMBPRINT_FILE) && grep " " $(BUILD_THUMBPRINT_FILE)))
$(error BUILD_THUMBPRINT cannot contain spaces: "$(file <$(BUILD_THUMBPRINT_FILE))")
endif
# unset it for safety.
BUILD_THUMBPRINT_FILE :=
BUILD_THUMBPRINT :=
================================================
FILE: core/config_sanitizers.mk
================================================
##############################################
## Perform configuration steps for sanitizers.
##############################################
my_sanitize := $(strip $(LOCAL_SANITIZE))
my_sanitize_diag := $(strip $(LOCAL_SANITIZE_DIAG))
my_global_sanitize :=
my_global_sanitize_diag :=
ifdef LOCAL_IS_HOST_MODULE
ifneq ($($(my_prefix)OS),windows)
my_global_sanitize := $(strip $(SANITIZE_HOST))
# SANITIZE_HOST=true is a deprecated way to say SANITIZE_HOST=address.
my_global_sanitize := $(subst true,address,$(my_global_sanitize))
endif
else
my_global_sanitize := $(strip $(SANITIZE_TARGET))
my_global_sanitize_diag := $(strip $(SANITIZE_TARGET_DIAG))
endif
# Disable global integer_overflow in excluded paths.
ifneq ($(filter integer_overflow, $(my_global_sanitize)),)
combined_exclude_paths := $(INTEGER_OVERFLOW_EXCLUDE_PATHS) \
$(PRODUCT_INTEGER_OVERFLOW_EXCLUDE_PATHS)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_global_sanitize := $(filter-out integer_overflow,$(my_global_sanitize))
my_global_sanitize_diag := $(filter-out integer_overflow,$(my_global_sanitize_diag))
endif
endif
# Global integer sanitization doesn't support static modules.
ifeq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
my_global_sanitize := $(filter-out integer_overflow,$(my_global_sanitize))
my_global_sanitize_diag := $(filter-out integer_overflow,$(my_global_sanitize_diag))
endif
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_global_sanitize := $(filter-out integer_overflow,$(my_global_sanitize))
my_global_sanitize_diag := $(filter-out integer_overflow,$(my_global_sanitize_diag))
endif
# Disable global CFI in excluded paths
ifneq ($(filter cfi, $(my_global_sanitize)),)
combined_exclude_paths := $(CFI_EXCLUDE_PATHS) \
$(PRODUCT_CFI_EXCLUDE_PATHS)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_global_sanitize := $(filter-out cfi,$(my_global_sanitize))
my_global_sanitize_diag := $(filter-out cfi,$(my_global_sanitize_diag))
endif
endif
# Disable global memtag_heap in excluded paths
ifneq ($(filter memtag_heap, $(my_global_sanitize)),)
combined_exclude_paths := $(MEMTAG_HEAP_EXCLUDE_PATHS) \
$(PRODUCT_MEMTAG_HEAP_EXCLUDE_PATHS)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_global_sanitize := $(filter-out memtag_heap,$(my_global_sanitize))
my_global_sanitize_diag := $(filter-out memtag_heap,$(my_global_sanitize_diag))
endif
endif
# Disable global HWASan in excluded paths
ifneq ($(filter hwaddress, $(my_global_sanitize)),)
combined_exclude_paths := $(HWASAN_EXCLUDE_PATHS) \
$(PRODUCT_HWASAN_EXCLUDE_PATHS)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_global_sanitize := $(filter-out hwaddress,$(my_global_sanitize))
my_global_sanitize_diag := $(filter-out hwaddress,$(my_global_sanitize_diag))
endif
endif
ifneq ($(my_global_sanitize),)
my_sanitize := $(my_global_sanitize) $(my_sanitize)
endif
ifneq ($(my_global_sanitize_diag),)
my_sanitize_diag := $(my_global_sanitize_diag) $(my_sanitize_diag)
endif
# The sanitizer specified in the product configuration wins over the previous.
ifneq ($(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG),)
my_sanitize := $(SANITIZER.$(TARGET_PRODUCT).$(LOCAL_MODULE).CONFIG)
ifeq ($(my_sanitize),never)
my_sanitize :=
my_sanitize_diag :=
endif
endif
ifndef LOCAL_IS_HOST_MODULE
# Add a filter point for 32-bit vs 64-bit sanitization (to lighten the burden)
SANITIZE_TARGET_ARCH ?= $(TARGET_ARCH) $(TARGET_2ND_ARCH)
ifeq ($(filter $(SANITIZE_TARGET_ARCH),$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
my_sanitize :=
my_sanitize_diag :=
endif
endif
# Add a filter point based on module owner (to lighten the burden). The format is a space- or
# colon-separated list of owner names.
ifneq (,$(SANITIZE_NEVER_BY_OWNER))
ifneq (,$(LOCAL_MODULE_OWNER))
ifneq (,$(filter $(LOCAL_MODULE_OWNER),$(subst :, ,$(SANITIZE_NEVER_BY_OWNER))))
$(warning Not sanitizing $(LOCAL_MODULE) based on module owner.)
my_sanitize :=
my_sanitize_diag :=
endif
endif
endif
# Don't apply sanitizers to NDK code.
ifdef LOCAL_SDK_VERSION
my_sanitize :=
my_global_sanitize :=
my_sanitize_diag :=
endif
# Never always wins.
ifeq ($(LOCAL_SANITIZE),never)
my_sanitize :=
my_sanitize_diag :=
endif
# Enable CFI in included paths.
ifeq ($(filter cfi, $(my_sanitize)),)
combined_include_paths := $(CFI_INCLUDE_PATHS) \
$(PRODUCT_CFI_INCLUDE_PATHS)
combined_exclude_paths := $(CFI_EXCLUDE_PATHS) \
$(PRODUCT_CFI_EXCLUDE_PATHS)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
ifeq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_sanitize := cfi $(my_sanitize)
endif
endif
endif
# Enable memtag_heap in included paths (for Arm64 only).
ifeq ($(filter memtag_heap, $(my_sanitize)),)
ifneq ($(filter arm64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
combined_sync_include_paths := $(MEMTAG_HEAP_SYNC_INCLUDE_PATHS) \
$(PRODUCT_MEMTAG_HEAP_SYNC_INCLUDE_PATHS)
combined_async_include_paths := $(MEMTAG_HEAP_ASYNC_INCLUDE_PATHS) \
$(PRODUCT_MEMTAG_HEAP_ASYNC_INCLUDE_PATHS)
combined_exclude_paths := $(MEMTAG_HEAP_EXCLUDE_PATHS) \
$(PRODUCT_MEMTAG_HEAP_EXCLUDE_PATHS)
ifneq ($(PRODUCT_MEMTAG_HEAP_SKIP_DEFAULT_PATHS),true)
combined_sync_include_paths += $(PRODUCT_MEMTAG_HEAP_SYNC_DEFAULT_INCLUDE_PATHS)
combined_async_include_paths += $(PRODUCT_MEMTAG_HEAP_ASYNC_DEFAULT_INCLUDE_PATHS)
endif
ifeq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_exclude_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_sync_include_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_sanitize := memtag_heap $(my_sanitize)
my_sanitize_diag := memtag_heap $(my_sanitize_diag)
else ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_async_include_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_sanitize := memtag_heap $(my_sanitize)
endif
endif
endif
endif
# Enable HWASan in included paths.
ifeq ($(filter hwaddress, $(my_sanitize)),)
combined_include_paths := $(HWASAN_INCLUDE_PATHS) \
$(PRODUCT_HWASAN_INCLUDE_PATHS)
ifneq ($(strip $(foreach dir,$(subst $(comma),$(space),$(combined_include_paths)),\
$(filter $(dir)%,$(LOCAL_PATH)))),)
my_sanitize := hwaddress $(my_sanitize)
endif
endif
# If CFI is disabled globally, remove it from my_sanitize.
ifeq ($(strip $(ENABLE_CFI)),false)
my_sanitize := $(filter-out cfi,$(my_sanitize))
my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif
# Also disable CFI and MTE if ASAN is enabled.
ifneq ($(filter address,$(my_sanitize)),)
my_sanitize := $(filter-out cfi,$(my_sanitize))
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
endif
# Disable memtag for host targets. Host executables in AndroidMk files are
# deprecated, but some partners still have them floating around.
ifdef LOCAL_IS_HOST_MODULE
my_sanitize := $(filter-out memtag_heap memtag_stack memtag_globals,$(my_sanitize))
my_sanitize_diag := $(filter-out memtag_heap memtag_stack memtag_globals,$(my_sanitize_diag))
endif
# Disable sanitizers which need the UBSan runtime for host targets.
ifdef LOCAL_IS_HOST_MODULE
my_sanitize := $(filter-out cfi,$(my_sanitize))
my_sanitize_diag := $(filter-out cfi,$(my_sanitize_diag))
my_sanitize := $(filter-out signed-integer-overflow unsigned-integer-overflow integer_overflow,$(my_sanitize))
my_sanitize_diag := $(filter-out signed-integer-overflow unsigned-integer-overflow integer_overflow,$(my_sanitize_diag))
endif
# Support for local sanitize blacklist paths.
ifneq ($(my_sanitize)$(my_global_sanitize),)
ifneq ($(LOCAL_SANITIZE_BLOCKLIST),)
my_cflags += -fsanitize-blacklist=$(LOCAL_PATH)/$(LOCAL_SANITIZE_BLOCKLIST)
endif
endif
# Disable integer_overflow if LOCAL_NOSANITIZE=integer.
ifneq ($(filter integer_overflow, $(my_global_sanitize) $(my_sanitize)),)
ifneq ($(filter integer, $(strip $(LOCAL_NOSANITIZE))),)
my_sanitize := $(filter-out integer_overflow,$(my_sanitize))
my_sanitize_diag := $(filter-out integer_overflow,$(my_sanitize_diag))
endif
endif
my_nosanitize = $(strip $(LOCAL_NOSANITIZE))
ifneq ($(my_nosanitize),)
my_sanitize := $(filter-out $(my_nosanitize),$(my_sanitize))
endif
ifneq ($(filter arm x86 x86_64,$(TARGET_$(LOCAL_2ND_ARCH_VAR_PREFIX)ARCH)),)
my_sanitize := $(filter-out hwaddress,$(my_sanitize))
my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
endif
ifneq ($(filter hwaddress,$(my_sanitize)),)
my_sanitize := $(filter-out address,$(my_sanitize))
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
my_sanitize := $(filter-out thread,$(my_sanitize))
my_sanitize := $(filter-out cfi,$(my_sanitize))
endif
ifneq ($(filter hwaddress,$(my_sanitize)),)
my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)HWADDRESS_SANITIZER_RUNTIME_LIBRARY)
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_static_libraries := $(my_static_libraries) \
$($(LOCAL_2ND_ARCH_VAR_PREFIX)HWADDRESS_SANITIZER_STATIC_LIBRARY) \
libdl
endif
endif
endif
ifneq ($(filter memtag_heap memtag_stack memtag_globals,$(my_sanitize)),)
ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
my_ldflags += -fsanitize-memtag-mode=sync
my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag))
else
my_ldflags += -fsanitize-memtag-mode=async
endif
endif
# Ignore SANITIZE_TARGET_DIAG=memtag_heap without SANITIZE_TARGET=memtag_heap
# This can happen if a condition above filters out memtag_heap from
# my_sanitize. It is easier to handle all of these cases here centrally.
ifneq ($(filter memtag_heap,$(my_sanitize_diag)),)
my_sanitize_diag := $(filter-out memtag_heap,$(my_sanitize_diag))
endif
ifneq ($(filter memtag_heap,$(my_sanitize)),)
my_cflags += -fsanitize=memtag-heap
my_ldflags += -fsanitize=memtag-heap
my_sanitize := $(filter-out memtag_heap,$(my_sanitize))
endif
ifneq ($(filter memtag_stack,$(my_sanitize)),)
my_cflags += -fsanitize=memtag-stack
my_ldflags += -fsanitize=memtag-stack
my_cflags += -Xclang -target-feature -Xclang +mte
my_ldflags += -Xclang -target-feature -Xclang +mte
my_asflags += -Xclang -target-feature -Xclang +mte
my_sanitize := $(filter-out memtag_stack,$(my_sanitize))
endif
ifneq ($(filter memtag_globals,$(my_sanitize)),)
my_cflags += -fsanitize=memtag-globals
my_ldflags += -fsanitize=memtag-globals
# TODO(mitchp): For now, enable memtag-heap with memtag-globals because the
# linker isn't new enough
# (https://reviews.llvm.org/differential/changeset/?ref=4243566).
my_sanitize := $(filter-out memtag_globals,$(my_sanitize))
endif
# TSAN is not supported on 32-bit architectures. For non-multilib cases, make
# its use an error. For multilib cases, don't use it for the 32-bit case.
ifneq ($(filter thread,$(my_sanitize)),)
ifeq ($(my_32_64_bit_suffix),32)
ifeq ($(my_module_multilib),both)
my_sanitize := $(filter-out thread,$(my_sanitize))
else
$(error $(LOCAL_PATH): $(LOCAL_MODULE): TSAN cannot be used for 32-bit modules.)
endif
else
my_shared_libraries += $(TSAN_RUNTIME_LIBRARY)
endif
endif
ifneq ($(filter safe-stack,$(my_sanitize)),)
ifeq ($(my_32_64_bit_suffix),32)
my_sanitize := $(filter-out safe-stack,$(my_sanitize))
endif
endif
# Disable Scudo if ASan or TSan is enabled.
ifneq ($(filter address thread hwaddress,$(my_sanitize)),)
my_sanitize := $(filter-out scudo,$(my_sanitize))
endif
# Or if disabled globally.
ifeq ($(PRODUCT_DISABLE_SCUDO),true)
my_sanitize := $(filter-out scudo,$(my_sanitize))
endif
# Undefined symbols can occur if a non-sanitized library links
# sanitized static libraries. That's OK, because the executable
# always depends on the ASan runtime library, which defines these
# symbols.
ifneq ($(filter address thread,$(strip $(SANITIZE_TARGET))),)
ifndef LOCAL_IS_HOST_MODULE
ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
ifeq ($(my_sanitize),)
my_allow_undefined_symbols := true
endif
endif
endif
endif
ifneq ($(filter default-ub,$(my_sanitize)),)
my_sanitize := $(CLANG_DEFAULT_UB_CHECKS)
endif
ifneq ($(filter fuzzer,$(my_sanitize)),)
# SANITIZE_TARGET='fuzzer' actually means to create the fuzzer coverage
# information, not to link against the fuzzer main().
my_sanitize := $(filter-out fuzzer,$(my_sanitize))
my_sanitize += fuzzer-no-link
# TODO(b/131771163): Disable LTO for fuzzer builds. Note that Cfi causes
# dependency on LTO.
my_sanitize := $(filter-out cfi,$(my_sanitize))
my_cflags += -fno-lto
my_ldflags += -fno-lto
# TODO(b/142430592): Upstream linker scripts for sanitizer runtime libraries
# discard the sancov_lowest_stack symbol, because it's emulated TLS (and thus
# doesn't match the linker script due to the "__emutls_v." prefix).
my_cflags += -fno-sanitize-coverage=stack-depth
my_ldflags += -fno-sanitize-coverage=stack-depth
endif
ifneq ($(filter integer_overflow,$(my_sanitize)),)
# Respect LOCAL_NOSANITIZE for integer-overflow flags.
ifeq ($(filter signed-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
my_sanitize += signed-integer-overflow
endif
ifeq ($(filter unsigned-integer-overflow, $(strip $(LOCAL_NOSANITIZE))),)
my_sanitize += unsigned-integer-overflow
endif
my_cflags += $(INTEGER_OVERFLOW_EXTRA_CFLAGS)
# Check for diagnostics mode.
ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
ifneq ($(filter SHARED_LIBRARIES EXECUTABLES,$(LOCAL_MODULE_CLASS)),)
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_sanitize_diag += signed-integer-overflow
my_sanitize_diag += unsigned-integer-overflow
else
$(call pretty-error,Make cannot apply integer overflow diagnostics to static binary.)
endif
else
$(call pretty-error,Make cannot apply integer overflow diagnostics to static library.)
endif
endif
my_sanitize := $(filter-out integer_overflow,$(my_sanitize))
endif
# Makes sure integer_overflow diagnostics is removed from the diagnostics list
# even if integer_overflow is not set for some reason.
ifneq ($(filter integer_overflow,$(my_sanitize_diag)),)
my_sanitize_diag := $(filter-out integer_overflow,$(my_sanitize_diag))
endif
ifneq ($(my_sanitize),)
fsanitize_arg := $(subst $(space),$(comma),$(my_sanitize))
my_cflags += -fsanitize=$(fsanitize_arg)
my_asflags += -fsanitize=$(fsanitize_arg)
# When fuzzing, we wish to crash with diagnostics on any bug.
ifneq ($(filter fuzzer-no-link,$(my_sanitize)),)
my_cflags += -fno-sanitize-trap=all
my_cflags += -fno-sanitize-recover=all
my_ldflags += -fsanitize=fuzzer-no-link
else ifdef LOCAL_IS_HOST_MODULE
my_cflags += -fno-sanitize-recover=all
my_ldflags += -fsanitize=$(fsanitize_arg)
else
my_cflags += -fsanitize-trap=all
ifneq ($(filter address thread,$(my_sanitize)),)
my_cflags += -fno-sanitize-trap=address,thread
my_shared_libraries += libdl
endif
endif
endif
ifneq ($(filter cfi,$(my_sanitize)),)
# __cfi_check needs to be built as Thumb (see the code in linker_cfi.cpp).
# LLVM is not set up to do this on a function basis, so force Thumb on the
# entire module.
LOCAL_ARM_MODE := thumb
my_cflags += $(CFI_EXTRA_CFLAGS)
my_asflags += $(CFI_EXTRA_ASFLAGS)
# Only append the default visibility flag if -fvisibility has not already been
# set to hidden.
ifeq ($(filter -fvisibility=hidden,$(LOCAL_CFLAGS)),)
my_cflags += -fvisibility=default
endif
my_ldflags += $(CFI_EXTRA_LDFLAGS)
ifeq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_ldflags := $(filter-out -fsanitize-cfi-cross-dso,$(my_ldflags))
my_cflags := $(filter-out -fsanitize-cfi-cross-dso,$(my_cflags))
else
# Apply the version script to non-static executables
my_ldflags += -Wl,--version-script,build/soong/cc/config/cfi_exports.map
LOCAL_ADDITIONAL_DEPENDENCIES += build/soong/cc/config/cfi_exports.map
endif
endif
# If local or global modules need ASAN, add linker flags.
ifneq ($(filter address,$(my_global_sanitize) $(my_sanitize)),)
my_ldflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_LDFLAGS)
ifdef LOCAL_IS_HOST_MODULE
# -nodefaultlibs (provided with libc++) prevents the driver from linking
# libraries needed with -fsanitize=address. http://b/18650275 (WAI)
my_ldflags += -Wl,--no-as-needed
else
# Add asan libraries unless LOCAL_MODULE is the asan library.
# ASan runtime library must be the first in the link order.
ifeq (,$(filter $(LOCAL_MODULE),$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY)))
my_shared_libraries := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_RUNTIME_LIBRARY) \
$(my_shared_libraries)
endif
# Do not add unnecessary dependency in shared libraries.
ifeq ($(LOCAL_MODULE_CLASS),SHARED_LIBRARIES)
my_ldflags += -Wl,--as-needed
endif
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_linker := $($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER)
# Make sure linker_asan get installed.
$(LOCAL_INSTALLED_MODULE) : | $(PRODUCT_OUT)$($(LOCAL_2ND_ARCH_VAR_PREFIX)ADDRESS_SANITIZER_LINKER_FILE)
endif
endif
endif
endif
# If local module needs ASAN, add compiler flags.
ifneq ($(filter address,$(my_sanitize)),)
# Frame pointer based unwinder in ASan requires ARM frame setup.
LOCAL_ARM_MODE := arm
my_cflags += $(ADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
ifndef LOCAL_IS_HOST_MODULE
my_cflags += -mllvm -asan-globals=0
endif
endif
# If local module needs HWASAN, add compiler flags.
ifneq ($(filter hwaddress,$(my_sanitize)),)
my_cflags += $(HWADDRESS_SANITIZER_CONFIG_EXTRA_CFLAGS)
ifneq ($(filter EXECUTABLES NATIVE_TESTS,$(LOCAL_MODULE_CLASS)),)
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
my_linker := /system/bin/linker_hwasan64
endif
endif
endif
# Use minimal diagnostics when integer overflow is enabled; never do it for HOST modules
ifeq ($(LOCAL_IS_HOST_MODULE),)
# Pre-emptively add UBSAN minimal runtime incase a static library dependency requires it
ifeq ($(filter STATIC_LIBRARIES,$(LOCAL_MODULE_CLASS)),)
ifndef LOCAL_SDK_VERSION
my_static_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_MINIMAL_RUNTIME_LIBRARY)
my_ldflags += -Wl,--exclude-libs,$($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_MINIMAL_RUNTIME_LIBRARY).a
endif
endif
ifneq ($(filter unsigned-integer-overflow signed-integer-overflow integer,$(my_sanitize)),)
ifeq ($(filter unsigned-integer-overflow signed-integer-overflow integer,$(my_sanitize_diag)),)
ifeq ($(filter cfi,$(my_sanitize_diag)),)
ifeq ($(filter address hwaddress fuzzer-no-link,$(my_sanitize)),)
my_cflags += -fsanitize-minimal-runtime
my_cflags += -fno-sanitize-trap=integer
my_cflags += -fno-sanitize-recover=integer
endif
endif
endif
endif
endif
# For Scudo, we opt for the minimal runtime, unless some diagnostics are enabled.
ifneq ($(filter scudo,$(my_sanitize)),)
ifeq ($(filter unsigned-integer-overflow signed-integer-overflow integer cfi,$(my_sanitize_diag)),)
my_cflags += -fsanitize-minimal-runtime
endif
ifneq ($(filter -fsanitize-minimal-runtime,$(my_cflags)),)
my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)SCUDO_MINIMAL_RUNTIME_LIBRARY)
else
my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)SCUDO_RUNTIME_LIBRARY)
endif
endif
ifneq ($(strip $(LOCAL_SANITIZE_RECOVER)),)
recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_RECOVER)),
my_cflags += -fsanitize-recover=$(recover_arg)
endif
ifneq ($(strip $(LOCAL_SANITIZE_NO_RECOVER)),)
no_recover_arg := $(subst $(space),$(comma),$(LOCAL_SANITIZE_NO_RECOVER)),
my_cflags += -fno-sanitize-recover=$(no_recover_arg)
endif
ifneq ($(my_sanitize_diag),)
# TODO(vishwath): Add diagnostic support for static executables once
# we switch to clang-4393122 (which adds the static ubsan runtime
# that this depends on)
ifneq ($(LOCAL_FORCE_STATIC_EXECUTABLE),true)
notrap_arg := $(subst $(space),$(comma),$(my_sanitize_diag)),
my_cflags += -fno-sanitize-trap=$(notrap_arg)
# Diagnostic requires a runtime library, unless ASan or TSan are also enabled.
ifeq ($(filter address thread scudo hwaddress,$(my_sanitize)),)
# Does not have to be the first DT_NEEDED unlike ASan.
my_shared_libraries += $($(LOCAL_2ND_ARCH_VAR_PREFIX)UBSAN_RUNTIME_LIBRARY)
endif
endif
endif
# http://b/119329758, Android core does not boot up with this sanitizer yet.
# Previously sanitized modules might not pass new implicit-integer-sign-change check.
# Disable this check unless it has been explicitly specified.
ifneq ($(findstring fsanitize,$(my_cflags)),)
ifneq ($(findstring integer,$(my_cflags)),)
ifeq ($(findstring sanitize=implicit-integer-sign-change,$(my_cflags)),)
my_cflags += -fno-sanitize=implicit-integer-sign-change
endif
endif
endif
# http://b/177566116, libc++ may crash with this sanitizer.
# Disable this check unless it has been explicitly specified.
ifneq ($(findstring fsanitize,$(my_cflags)),)
ifneq ($(findstring integer,$(my_cflags)),)
ifeq ($(findstring sanitize=unsigned-shift-base,$(my_cflags)),)
my_cflags += -fno-sanitize=unsigned-shift-base
endif
endif
endif
================================================
FILE: core/configure_module_stem.mk
================================================
my_multilib_stem := $(LOCAL_MODULE_STEM_$(if $($(LOCAL_2ND_ARCH_VAR_PREFIX)$(my_prefix)IS_64_BIT),64,32))
ifdef my_multilib_stem
my_module_stem := $(my_multilib_stem)
$(call verify-module-stem,my_multilib_stem)
else ifdef LOCAL_MODULE_STEM
my_module_stem := $(LOCAL_MODULE_STEM)
$(call verify-module-stem,LOCAL_MODULE_STEM)
else
my_module_stem := $(LOCAL_MODULE)
endif
ifdef LOCAL_BUILT_MODULE_STEM
my_built_module_stem := $(LOCAL_BUILT_MODULE_STEM)
$(call verify-module-stem,LOCAL_BUILT_MODULE_STEM)
else
my_built_module_stem := $(my_module_stem)$(LOCAL_MODULE_SUFFIX)
$(call verify-module-stem,LOCAL_MODULE_SUFFIX)
endif
ifdef LOCAL_INSTALLED_MODULE_STEM
my_installed_module_stem := $(LOCAL_INSTALLED_MODULE_STEM)
$(call verify-module-stem,LOCAL_INSTALLED_MODULE_STEM)
else
my_installed_module_stem := $(my_module_stem)$(LOCAL_MODULE_SUFFIX)
$(call verify-module-stem,LOCAL_MODULE_SUFFIX)
endif
================================================
FILE: core/copy_headers.mk
================================================
ifneq (,$(strip $(LOCAL_COPY_HEADERS)))
###########################################################
## Copy headers to the install tree
###########################################################
$(call record-module-type,COPY_HEADERS)
ifneq ($(strip $(LOCAL_IS_HOST_MODULE)),)
$(call pretty-error,LOCAL_COPY_HEADERS may not be used with host modules)
endif
# Modules linking against the SDK do not have the include path to use
# COPY_HEADERS, so prevent them from exporting any either.
ifdef LOCAL_SDK_VERSION
$(call pretty-error,Modules using LOCAL_SDK_VERSION may not use LOCAL_COPY_HEADERS)
endif
include $(BUILD_SYSTEM)/local_vendor_product.mk
# Modules in vendor or product may use LOCAL_COPY_HEADERS.
# Platform libraries will not have the include path present.
ifeq ($(call module-in-vendor-or-product),)
$(call pretty-error,Only modules in vendor or product may use LOCAL_COPY_HEADERS)
endif
# Clean up LOCAL_COPY_HEADERS_TO, since soong_ui will be comparing cleaned
# paths to figure out which headers are obsolete and should be removed.
LOCAL_COPY_HEADERS_TO := $(call clean-path,$(LOCAL_COPY_HEADERS_TO))
ifneq ($(filter /% .. ../%,$(LOCAL_COPY_HEADERS_TO)),)
$(call pretty-error,LOCAL_COPY_HEADERS_TO may not start with / or ../ : $(LOCAL_COPY_HEADERS_TO))
endif
ifeq ($(LOCAL_COPY_HEADERS_TO),.)
LOCAL_COPY_HEADERS_TO :=
endif
# Create a rule to copy each header, and make the
# all_copied_headers phony target depend on each
# destination header. copy-one-header defines the
# actual rule.
#
$(foreach header,$(LOCAL_COPY_HEADERS), \
$(eval _chFrom := $(LOCAL_PATH)/$(header)) \
$(eval _chTo := \
$(if $(LOCAL_COPY_HEADERS_TO),\
$(TARGET_OUT_HEADERS)/$(LOCAL_COPY_HEADERS_TO)/$(notdir $(header)),\
$(TARGET_OUT_HEADERS)/$(notdir $(header)))) \
$(eval ALL_COPIED_HEADERS.$(_chTo).MAKEFILE += $(LOCAL_MODULE_MAKEFILE)) \
$(eval ALL_COPIED_HEADERS.$(_chTo).SRC += $(_chFrom)) \
$(if $(filter $(_chTo),$(ALL_COPIED_HEADERS)),, \
$(eval ALL_COPIED_HEADERS += $(_chTo))) \
)
_chFrom :=
_chTo :=
$(if $(my_register_name),$(eval ALL_MODULES.$(my_register_name).MAKE_MODULE_TYPE:=COPY_HEADERS))
endif # LOCAL_COPY_HEADERS
================================================
FILE: core/cxx_stl_setup.mk
================================================
#############################################################
## Set up flags based on LOCAL_CXX_STL.
## Input variables: LOCAL_CXX_STL, my_prefix
## Output variables: My_cflags, my_c_includes, my_shared_libraries, etc.
#############################################################
# Select the appropriate C++ STL
ifeq ($(strip $(LOCAL_CXX_STL)),default)
ifndef LOCAL_SDK_VERSION
# Platform code. Select the appropriate STL.
my_cxx_stl := libc++
ifdef LOCAL_IS_HOST_MODULE
ifneq (,$(BUILD_HOST_static))
my_cxx_stl := libc++_static
endif
endif
else
my_cxx_stl := ndk
endif
else
my_cxx_stl := $(strip $(LOCAL_CXX_STL))
ifdef LOCAL_SDK_VERSION
# The NDK has historically used LOCAL_NDK_STL_VARIANT to specify the
# STL. An Android.mk that specifies both LOCAL_CXX_STL and
# LOCAL_SDK_VERSION will incorrectly try (and most likely fail) to use
# the platform STL in an NDK binary. Emit an error to direct the user
# toward the correct option.
#
# Note that we could also accept LOCAL_CXX_STL as an alias for
# LOCAL_NDK_STL_VARIANT (and in fact soong does use the same name), but
# the two options use different names for the STLs.
$(error $(LOCAL_PATH): $(LOCAL_MODULE): Must use LOCAL_NDK_STL_VARIANT rather than LOCAL_CXX_STL for NDK binaries)
endif
endif
my_link_type := dynamic
ifdef LOCAL_IS_HOST_MODULE
ifneq (,$(BUILD_HOST_static))
my_link_type := static
endif
ifeq (-static,$(filter -static,$(my_ldflags)))
my_link_type := static
endif
else
ifeq (true,$(LOCAL_FORCE_STATIC_EXECUTABLE))
my_link_type := static
endif
endif
my_cxx_ldlibs :=
ifneq ($(filter $(my_cxx_stl),libc++ libc++_static),)
ifeq ($($(my_prefix)OS),darwin)
# libc++'s headers are annotated with availability macros that indicate
# which version of Mac OS was the first to ship with a libc++ feature
# available in its *system's* libc++.dylib. We do not use the system's
# library, but rather ship our own. As such, these availability
# attributes are meaningless for us but cause build breaks when we try
# to use code that would not be available in the system's dylib.
my_cppflags += -D_LIBCPP_DISABLE_AVAILABILITY
endif
# Note that the structure of this means that LOCAL_CXX_STL := libc++ will
# use the static libc++ for static executables.
ifeq ($(my_link_type),dynamic)
ifeq ($(my_cxx_stl),libc++)
my_shared_libraries += libc++
else
my_static_libraries += libc++_static
endif
else
my_static_libraries += libc++_static
endif
ifdef LOCAL_IS_HOST_MODULE
my_cppflags += -nostdinc++
my_ldflags += -nostdlib++
else
my_static_libraries += libc++demangle
ifeq ($(my_link_type),static)
my_static_libraries += libm libc libunwind libstatic_rustlibs_for_make
endif
endif
else ifeq ($(my_cxx_stl),ndk)
# Using an NDK STL. Handled in binary.mk.
else ifeq ($(my_cxx_stl),libstdc++)
$(error $(LOCAL_PATH): $(LOCAL_MODULE): libstdc++ is not supported)
else ifeq ($(my_cxx_stl),none)
ifdef LOCAL_IS_HOST_MODULE
my_cppflags += -nostdinc++
my_ldflags += -nostdlib++
endif
else
$(error $(LOCAL_PATH): $(LOCAL_MODULE): $(my_cxx_stl) is not a supported STL.)
endif
================================================
FILE: core/definitions.mk
================================================
#
# Copyright (C) 2008 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.
#
##
## Common build system definitions. Mostly standard
## commands for building various types of targets, which
## are used by others to construct the final targets.
##
# These are variables we use to collect overall lists
# of things being processed.
# Full paths to all of the documentation
ALL_DOCS:=
# The short names of all of the targets in the system.
# For each element of ALL_MODULES, two other variables
# are defined:
# $(ALL_MODULES.$(target)).BUILT
# $(ALL_MODULES.$(target)).INSTALLED
# The BUILT variable contains LOCAL_BUILT_MODULE for that
# target, and the INSTALLED variable contains the LOCAL_INSTALLED_MODULE.
# Some targets may have multiple files listed in the BUILT and INSTALLED
# sub-variables.
ALL_MODULES:=
ALL_MAKE_MODULE_INFO_JSON_MODULES:=
# The relative paths of the non-module targets in the system.
ALL_NON_MODULES:=
NON_MODULES_WITHOUT_LICENSE_METADATA:=
# List of copied targets that need license metadata copied.
ALL_COPIED_TARGETS:=
# Full paths to targets that should be added to the "make droid"
# set of installed targets.
ALL_DEFAULT_INSTALLED_MODULES:=
# Full path to all asm, C, C++, lex and yacc generated C files.
# These all have an order-only dependency on the copied headers
ALL_C_CPP_ETC_OBJECTS:=
# These files go into the SDK
ALL_SDK_FILES:=
# Files for dalvik. This is often build without building the rest of the OS.
INTERNAL_DALVIK_MODULES:=
# All findbugs xml files
ALL_FINDBUGS_FILES:=
# Packages with certificate violation
CERTIFICATE_VIOLATION_MODULES :=
# Target and host installed module's dependencies on shared libraries.
# They are list of "::lib1,lib2...".
TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
$(TARGET_2ND_ARCH_VAR_PREFIX)TARGET_DEPENDENCIES_ON_SHARED_LIBRARIES :=
HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
$(HOST_2ND_ARCH_VAR_PREFIX)HOST_DEPENDENCIES_ON_SHARED_LIBRARIES :=
HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
$(HOST_CROSS_2ND_ARCH_VAR_PREFIX)HOST_CROSS_DEPENDENCIES_ON_SHARED_LIBRARIES :=
# Generated class file names for Android resource.
# They are escaped and quoted so can be passed safely to a bash command.
ANDROID_RESOURCE_GENERATED_CLASSES := 'R.class' 'R$$*.class' 'Manifest.class' 'Manifest$$*.class'
# Display names for various build targets
TARGET_DISPLAY := target
HOST_DISPLAY := host
HOST_CROSS_DISPLAY := host cross
# All installed initrc files
ALL_INIT_RC_INSTALLED_PAIRS :=
# All installed vintf manifest fragments for a partition at
ALL_VINTF_MANIFEST_FRAGMENTS_LIST:=
# All compatibility suites mentioned in LOCAL_COMPATIBILITY_SUITE
ALL_COMPATIBILITY_SUITES :=
# All compatibility suite files to dist.
ALL_COMPATIBILITY_DIST_FILES :=
# All LINK_TYPE entries
ALL_LINK_TYPES :=
# All exported/imported include entries
EXPORTS_LIST :=
# All modules already converted to Soong
SOONG_ALREADY_CONV :=
###########################################################
## Debugging; prints a variable list to stdout
###########################################################
# $(1): variable name list, not variable values
define print-vars
$(foreach var,$(1), \
$(info $(var):) \
$(foreach word,$($(var)), \
$(info $(space)$(space)$(word)) \
) \
)
endef
###########################################################
## Evaluates to true if the string contains the word true,
## and empty otherwise
## $(1): a var to test
###########################################################
define true-or-empty
$(filter true, $(1))
endef
define boolean-not
$(if $(filter true,$(1)),,true)
endef
###########################################################
## Rule for touching GCNO files.
###########################################################
define gcno-touch-rule
$(2): $(1)
touch -c $$@
endef
###########################################################
###########################################################
## Retrieve the directory of the current makefile
## Must be called before including any other makefile!!
###########################################################
# Figure out where we are.
define my-dir
$(strip \
$(eval LOCAL_MODULE_MAKEFILE := $$(lastword $$(MAKEFILE_LIST))) \
$(if $(filter $(BUILD_SYSTEM)/% $(OUT_DIR)/%,$(LOCAL_MODULE_MAKEFILE)), \
$(error my-dir must be called before including any other makefile.) \
, \
$(patsubst %/,%,$(dir $(LOCAL_MODULE_MAKEFILE))) \
) \
)
endef
###########################################################
## Retrieve a list of all makefiles immediately below some directory
###########################################################
define all-makefiles-under
$(wildcard $(1)/*/Android.mk)
endef
###########################################################
## Look under a directory for makefiles that don't have parent
## makefiles.
###########################################################
# $(1): directory to search under
# Ignores $(1)/Android.mk
define first-makefiles-under
$(shell build/make/tools/findleaves.py $(FIND_LEAVES_EXCLUDES) \
--mindepth=2 $(addprefix --dir=,$(1)) Android.mk)
endef
###########################################################
## Retrieve a list of all makefiles immediately below your directory
## Must be called before including any other makefile!!
###########################################################
define all-subdir-makefiles
$(call all-makefiles-under,$(call my-dir))
endef
###########################################################
## Look in the named list of directories for makefiles,
## relative to the current directory.
## Must be called before including any other makefile!!
###########################################################
# $(1): List of directories to look for under this directory
define all-named-subdir-makefiles
$(wildcard $(addsuffix /Android.mk, $(addprefix $(call my-dir)/,$(1))))
endef
###########################################################
## Find all of the directories under the named directories with
## the specified name.
## Meant to be used like:
## INC_DIRS := $(call all-named-dirs-under,inc,.)
###########################################################
define all-named-dirs-under
$(call find-subdir-files,$(2) -type d -name "$(1)")
endef
###########################################################
## Find all the directories under the current directory that
## haves name that match $(1)
###########################################################
define all-subdir-named-dirs
$(call all-named-dirs-under,$(1),.)
endef
###########################################################
## Find all of the files under the named directories with
## the specified name.
## Meant to be used like:
## SRC_FILES := $(call all-named-files-under,*.h,src tests)
###########################################################
define all-named-files-under
$(call find-files-in-subdirs,$(LOCAL_PATH),"$(1)",$(2))
endef
###########################################################
## Find all of the files under the current directory with
## the specified name.
###########################################################
define all-subdir-named-files
$(call all-named-files-under,$(1),.)
endef
###########################################################
## Find all of the java files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-java-files-under,src tests)
###########################################################
define all-java-files-under
$(call all-named-files-under,*.java,$(1))
endef
###########################################################
## Find all of the java files from here. Meant to be used like:
## SRC_FILES := $(call all-subdir-java-files)
###########################################################
define all-subdir-java-files
$(call all-java-files-under,.)
endef
###########################################################
## Find all of the c files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-c-files-under,src tests)
###########################################################
define all-c-files-under
$(call all-named-files-under,*.c,$(1))
endef
###########################################################
## Find all of the c files from here. Meant to be used like:
## SRC_FILES := $(call all-subdir-c-files)
###########################################################
define all-subdir-c-files
$(call all-c-files-under,.)
endef
###########################################################
## Find all of the cpp files under the named directories.
## LOCAL_CPP_EXTENSION is respected if set.
## Meant to be used like:
## SRC_FILES := $(call all-cpp-files-under,src tests)
###########################################################
define all-cpp-files-under
$(sort $(patsubst ./%,%, \
$(shell cd $(LOCAL_PATH) ; \
find -L $(1) -name "*$(or $(LOCAL_CPP_EXTENSION),.cpp)" -and -not -name ".*") \
))
endef
###########################################################
## Find all of the cpp files from here. Meant to be used like:
## SRC_FILES := $(call all-subdir-cpp-files)
###########################################################
define all-subdir-cpp-files
$(call all-cpp-files-under,.)
endef
###########################################################
## Find all files named "I*.aidl" under the named directories,
## which must be relative to $(LOCAL_PATH). The returned list
## is relative to $(LOCAL_PATH).
###########################################################
define all-Iaidl-files-under
$(call all-named-files-under,I*.aidl,$(1))
endef
###########################################################
## Find all of the "I*.aidl" files under $(LOCAL_PATH).
###########################################################
define all-subdir-Iaidl-files
$(call all-Iaidl-files-under,.)
endef
###########################################################
## Find all files named "*.vts" under the named directories,
## which must be relative to $(LOCAL_PATH). The returned list
## is relative to $(LOCAL_PATH).
###########################################################
define all-vts-files-under
$(call all-named-files-under,*.vts,$(1))
endef
###########################################################
## Find all of the "*.vts" files under $(LOCAL_PATH).
###########################################################
define all-subdir-vts-files
$(call all-vts-files-under,.)
endef
###########################################################
## Find all of the logtags files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-logtags-files-under,src)
###########################################################
define all-logtags-files-under
$(call all-named-files-under,*.logtags,$(1))
endef
###########################################################
## Find all of the .proto files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-proto-files-under,src)
###########################################################
define all-proto-files-under
$(call all-named-files-under,*.proto,$(1))
endef
###########################################################
## Find all of the RenderScript files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-renderscript-files-under,src)
###########################################################
define all-renderscript-files-under
$(call find-subdir-files,$(1) \( -name "*.rscript" -or -name "*.fs" \) -and -not -name ".*")
endef
###########################################################
## Find all of the S files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-c-files-under,src tests)
###########################################################
define all-S-files-under
$(call all-named-files-under,*.S,$(1))
endef
###########################################################
## Find all of the html files under the named directories.
## Meant to be used like:
## SRC_FILES := $(call all-html-files-under,src tests)
###########################################################
define all-html-files-under
$(call all-named-files-under,*.html,$(1))
endef
###########################################################
## Find all of the html files from here. Meant to be used like:
## SRC_FILES := $(call all-subdir-html-files)
###########################################################
define all-subdir-html-files
$(call all-html-files-under,.)
endef
###########################################################
## Find all of the files matching pattern
## SRC_FILES := $(call find-subdir-files, )
###########################################################
define find-subdir-files
$(sort $(patsubst ./%,%,$(shell cd $(LOCAL_PATH) ; find -L $(1))))
endef
###########################################################
# find the files in the subdirectory $1 of LOCAL_DIR
# matching pattern $2, filtering out files $3
# e.g.
# SRC_FILES += $(call find-subdir-subdir-files, \
# css, *.cpp, DontWantThis.cpp)
###########################################################
define find-subdir-subdir-files
$(sort $(filter-out $(patsubst %,$(1)/%,$(3)),$(patsubst ./%,%,$(shell cd \
$(LOCAL_PATH) ; find -L $(1) -maxdepth 1 -name $(2)))))
endef
###########################################################
## Find all of the files matching pattern
## SRC_FILES := $(call all-subdir-java-files)
###########################################################
define find-subdir-assets
$(sort $(if $(1),$(patsubst ./%,%, \
$(shell if [ -d $(1) ] ; then cd $(1) ; find -L ./ -not -name '.*' -and -type f ; fi)), \
$(warning Empty argument supplied to find-subdir-assets in $(LOCAL_PATH)) \
))
endef
###########################################################
## Find various file types in a list of directories relative to $(LOCAL_PATH)
###########################################################
define find-other-java-files
$(call all-java-files-under,$(1))
endef
define find-other-html-files
$(call all-html-files-under,$(1))
endef
###########################################################
# Use utility find to find given files in the given subdirs.
# This function uses $(1), instead of LOCAL_PATH as the base.
# $(1): the base dir, relative to the root of the source tree.
# $(2): the file name pattern to be passed to find as "-name".
# $(3): a list of subdirs of the base dir.
# Returns: a list of paths relative to the base dir.
###########################################################
define find-files-in-subdirs
$(sort $(patsubst ./%,%, \
$(shell cd $(1) ; \
find -L $(3) -name $(2) -and -not -name ".*") \
))
endef
###########################################################
## Scan through each directory of $(1) looking for files
## that match $(2) using $(wildcard). Useful for seeing if
## a given directory or one of its parents contains
## a particular file. Returns the first match found,
## starting furthest from the root.
###########################################################
define find-parent-file
$(strip \
$(eval _fpf := $(sort $(wildcard $(foreach f, $(2), $(strip $(1))/$(f))))) \
$(if $(_fpf),$(_fpf), \
$(if $(filter-out ./ .,$(1)), \
$(call find-parent-file,$(patsubst %/,%,$(dir $(1))),$(2)) \
) \
) \
)
endef
###########################################################
## Find test data in a form required by LOCAL_TEST_DATA
## $(1): the base dir, relative to the root of the source tree.
## $(2): the file name pattern to be passed to find as "-name"
## $(3): a list of subdirs of the base dir
###########################################################
define find-test-data-in-subdirs
$(foreach f,$(sort $(patsubst ./%,%, \
$(shell cd $(1) ; \
find -L $(3) -type f -and -name $(2) -and -not -name ".*") \
)),$(1):$(f))
endef
###########################################################
## Function we can evaluate to introduce a dynamic dependency
###########################################################
define add-dependency
$(1): $(2)
endef
###########################################################
## Reverse order of a list
###########################################################
define reverse-list
$(if $(1),$(call reverse-list,$(wordlist 2,$(words $(1)),$(1)))) $(firstword $(1))
endef
###########################################################
## Sometimes a notice dependency will reference an unadorned
## module name that only appears in ALL_MODULES adorned with
## an ARCH suffix or a `host_cross_` prefix.
##
## After all of the modules are processed in base_rules.mk,
## replace all such dependencies with every matching adorned
## module name.
###########################################################
define fix-notice-deps
$(strip \
$(eval _all_module_refs := \
$(sort \
$(foreach m,$(sort $(ALL_MODULES)), \
$(call word-colon,1,$(ALL_MODULES.$(m).NOTICE_DEPS)) \
) \
) \
) \
$(foreach m, $(_all_module_refs), \
$(eval _lookup.$(m) := \
$(sort \
$(if $(strip $(ALL_MODULES.$(m).PATH)), \
$(m), \
$(filter $(m)_32 $(m)_64 host_cross_$(m) host_cross_$(m)_32 host_cross_$(m)_64, $(ALL_MODULES)) \
) \
) \
) \
) \
$(foreach m, $(ALL_MODULES), \
$(eval ALL_MODULES.$(m).NOTICE_DEPS := \
$(sort \
$(foreach d,$(sort $(ALL_MODULES.$(m).NOTICE_DEPS)), \
$(foreach n,$(_lookup.$(call word-colon,1,$(d))),$(n):$(call wordlist-colon,2,9999,$(d))) \
) \
) \
) \
) \
)
endef
###########################################################
## Target directory for license metadata files.
###########################################################
define license-metadata-dir
$(call generated-sources-dir-for,META,lic,$(filter-out $(PRODUCT_OUT)%,$(1)))
endef
TARGETS_MISSING_LICENSE_METADATA:=
###########################################################
# License metadata targets corresponding to targets in $(1)
###########################################################
define corresponding-license-metadata
$(strip $(filter-out 0p,$(foreach target, $(sort $(1)), \
$(if $(strip $(ALL_MODULES.$(target).META_LIC)), \
$(ALL_MODULES.$(target).META_LIC), \
$(if $(strip $(ALL_TARGETS.$(target).META_LIC)), \
$(ALL_TARGETS.$(target).META_LIC), \
$(eval TARGETS_MISSING_LICENSE_METADATA += $(target)) \
) \
) \
)))
endef
###########################################################
## Record a target $(1) copied from another target(s) $(2) that will need
## license metadata.
###########################################################
define declare-copy-target-license-metadata
$(strip $(if $(filter $(OUT_DIR)%,$(2)),\
$(eval _tgt:=$(strip $(1)))\
$(eval ALL_COPIED_TARGETS.$(_tgt).SOURCES := $(sort $(ALL_COPIED_TARGETS.$(_tgt).SOURCES) $(filter $(OUT_DIR)%,$(2))))\
$(eval ALL_COPIED_TARGETS += $(_tgt))))
endef
###########################################################
## License metadata build rule for my_register_name $(1)
###########################################################
define license-metadata-rule
$(foreach meta_lic, $(ALL_MODULES.$(1).DELAYED_META_LIC),$(call _license-metadata-rule,$(1),$(meta_lic)))
endef
$(KATI_obsolete_var notice-rule, This function has been removed)
define _license-metadata-rule
$(strip $(eval _srcs := $(strip $(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS),$(if $(strip $(ALL_MODULES.$(call word-colon,1,$(d)).INSTALLED)), $(ALL_MODULES.$(call word-colon,1,$(d)).INSTALLED),$(if $(strip $(ALL_MODULES.$(call word-colon,1,$(d)).BUILT)), $(ALL_MODULES.$(call word-colon,1,$(d)).BUILT), $(call word-colon,1,$d)))))))
$(strip $(eval _deps := $(sort $(filter-out $(2)%,\
$(foreach d,$(ALL_MODULES.$(1).NOTICE_DEPS),\
$(addsuffix :$(call wordlist-colon,2,9999,$(d)), \
$(foreach dt,$(ALL_MODULES.$(d).BUILT) $(ALL_MODULES.$(d).INSTALLED),\
$(ALL_TARGETS.$(dt).META_LIC))))))))
$(strip $(eval _notices := $(sort $(ALL_MODULES.$(1).NOTICES))))
$(strip $(eval _tgts := $(sort $(ALL_MODULES.$(1).BUILT))))
$(strip $(eval _inst := $(sort $(ALL_MODULES.$(1).INSTALLED))))
$(strip $(eval _path := $(sort $(ALL_MODULES.$(1).PATH))))
$(strip $(eval _map := $(strip $(foreach _m,$(sort $(ALL_MODULES.$(1).LICENSE_INSTALL_MAP)), \
$(eval _s := $(call word-colon,1,$(_m))) \
$(eval _d := $(call word-colon,2,$(_m))) \
$(eval _ns := $(if $(strip $(ALL_MODULES.$(_s).INSTALLED)),$(ALL_MODULES.$(_s).INSTALLED),$(if $(strip $(ALL_MODULES.$(_s).BUILT)),$(ALL_MODULES.$(_s).BUILT),$(_s)))) \
$(foreach ns,$(_ns),$(ns):$(_d) ) \
))))
$(2): PRIVATE_KINDS := $(sort $(ALL_MODULES.$(1).LICENSE_KINDS))
$(2): PRIVATE_CONDITIONS := $(sort $(ALL_MODULES.$(1).LICENSE_CONDITIONS))
$(2): PRIVATE_NOTICES := $(_notices)
$(2): PRIVATE_NOTICE_DEPS := $(_deps)
$(2): PRIVATE_SOURCES := $(_srcs)
$(2): PRIVATE_TARGETS := $(_tgts)
$(2): PRIVATE_INSTALLED := $(_inst)
$(2): PRIVATE_PATH := $(_path)
$(2): PRIVATE_IS_CONTAINER := $(ALL_MODULES.$(1).IS_CONTAINER)
$(2): PRIVATE_PACKAGE_NAME := $(strip $(ALL_MODULES.$(1).LICENSE_PACKAGE_NAME))
$(2): PRIVATE_INSTALL_MAP := $(_map)
$(2): PRIVATE_MODULE_NAME := $(1)
$(2): PRIVATE_MODULE_TYPE := $(ALL_MODULES.$(1).MODULE_TYPE)
$(2): PRIVATE_MODULE_CLASS := $(ALL_MODULES.$(1).MODULE_CLASS)
$(2): PRIVATE_INSTALL_MAP := $(_map)
$(2): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,notice)/$(2)/arguments
$(2): $(BUILD_LICENSE_METADATA)
$(2) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
rm -f $$@
mkdir -p $$(dir $$@)
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
$$(call dump-words-to-file,\
$$(addprefix -mn ,$$(PRIVATE_MODULE_NAME))\
$$(addprefix -mt ,$$(PRIVATE_MODULE_TYPE))\
$$(addprefix -mc ,$$(PRIVATE_MODULE_CLASS))\
$$(addprefix -k ,$$(PRIVATE_KINDS))\
$$(addprefix -c ,$$(PRIVATE_CONDITIONS))\
$$(addprefix -n ,$$(PRIVATE_NOTICES))\
$$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS))\
$$(addprefix -s ,$$(PRIVATE_SOURCES))\
$$(addprefix -m ,$$(PRIVATE_INSTALL_MAP))\
$$(addprefix -t ,$$(PRIVATE_TARGETS))\
$$(addprefix -i ,$$(PRIVATE_INSTALLED))\
$$(addprefix -r ,$$(PRIVATE_PATH)),\
$$(PRIVATE_ARGUMENT_FILE))
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
-p '$$(PRIVATE_PACKAGE_NAME)' \
@$$(PRIVATE_ARGUMENT_FILE) \
-o $$@
endef
###########################################################
## License metadata build rule for non-module target $(1)
###########################################################
define non-module-license-metadata-rule
$(strip $(eval _dir := $(call license-metadata-dir,$(1))))
$(strip $(eval _tgt := $(strip $(1))))
$(strip $(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(_tgt).meta_lic))))
$(strip $(eval _deps := $(sort $(filter-out 0p: :,$(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)),$(ALL_TARGETS.$(call word-colon,1,$(d)).META_LIC):$(call wordlist-colon,2,9999,$(d)))))))
$(strip $(eval _notices := $(sort $(ALL_NON_MODULES.$(_tgt).NOTICES))))
$(strip $(eval _path := $(sort $(ALL_NON_MODULES.$(_tgt).PATH))))
$(strip $(eval _install_map := $(ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS)))
$(_meta): PRIVATE_KINDS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_KINDS))
$(_meta): PRIVATE_CONDITIONS := $(sort $(ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS))
$(_meta): PRIVATE_NOTICES := $(_notices)
$(_meta): PRIVATE_NOTICE_DEPS := $(_deps)
$(_meta): PRIVATE_SOURCES := $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)
$(_meta): PRIVATE_TARGETS := $(_tgt)
$(_meta): PRIVATE_PATH := $(_path)
$(_meta): PRIVATE_IS_CONTAINER := $(ALL_NON_MODULES.$(_tgt).IS_CONTAINER)
$(_meta): PRIVATE_PACKAGE_NAME := $(strip $(ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME))
$(_meta): PRIVATE_INSTALL_MAP := $(strip $(_install_map))
$(_meta): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,notice)/$(_meta)/arguments
$(_meta): $(BUILD_LICENSE_METADATA)
$(_meta) : $(foreach d,$(_deps),$(call word-colon,1,$(d))) $(foreach n,$(_notices),$(call word-colon,1,$(n)) )
rm -f $$@
mkdir -p $$(dir $$@)
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
$$(call dump-words-to-file,\
$$(addprefix -k ,$$(PRIVATE_KINDS))\
$$(addprefix -c ,$$(PRIVATE_CONDITIONS))\
$$(addprefix -n ,$$(PRIVATE_NOTICES))\
$$(addprefix -d ,$$(PRIVATE_NOTICE_DEPS))\
$$(addprefix -s ,$$(PRIVATE_SOURCES))\
$$(addprefix -m ,$$(PRIVATE_INSTALL_MAP))\
$$(addprefix -t ,$$(PRIVATE_TARGETS))\
$$(addprefix -r ,$$(PRIVATE_PATH)),\
$$(PRIVATE_ARGUMENT_FILE))
OUT_DIR=$(OUT_DIR) $(BUILD_LICENSE_METADATA) \
-mt raw -mc unknown \
$$(if $$(PRIVATE_IS_CONTAINER),-is_container) \
$$(addprefix -r ,$$(PRIVATE_PATH)) \
@$$(PRIVATE_ARGUMENT_FILE) \
-o $$@
endef
###########################################################
## Record missing dependencies for non-module target $(1)
###########################################################
define record-missing-non-module-dependencies
$(strip $(eval _tgt := $(strip $(1))))
$(strip $(foreach d,$(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES)), \
$(if $(strip $(ALL_TARGETS.$(d).META_LIC)), \
, \
$(eval NON_MODULES_WITHOUT_LICENSE_METADATA += $(d))) \
))
endef
###########################################################
## License metadata build rule for copied target $(1)
###########################################################
define copied-target-license-metadata-rule
$(if $(strip $(ALL_TARGETS.$(1).META_LIC)),,$(call _copied-target-license-metadata-rule,$(1)))
endef
define _copied-target-license-metadata-rule
$(strip $(eval _dir := $(call license-metadata-dir,$(1))))
$(strip $(eval _meta := $(call append-path,$(_dir),$(patsubst $(OUT_DIR)%,out%,$(1).meta_lic))))
$(strip $(eval ALL_TARGETS.$(1).META_LIC:=$(_meta)))
$(strip $(eval _dep:=))
$(strip $(foreach s,$(ALL_COPIED_TARGETS.$(1).SOURCES),\
$(eval _dmeta:=$(ALL_TARGETS.$(s).META_LIC))\
$(if $(filter-out 0p,$(_dep)),\
$(if $(filter-out $(_dep),$(_dmeta)),$(error cannot copy target from multiple modules: $(1) from $(_dep) and $(_dmeta))),\
$(eval _dep:=$(_dmeta)))))
$(if $(filter 0p,$(_dep)),$(eval ALL_TARGETS.$(1).META_LIC:=0p))
$(strip $(if $(strip $(_dep)),,$(error cannot copy target from unknown module: $(1) from $(ALL_COPIED_TARGETS.$(1).SOURCES))))
ifneq (0p,$(ALL_TARGETS.$(1).META_LIC))
$(_meta): PRIVATE_DEST_TARGET := $(1)
$(_meta): PRIVATE_SOURCE_TARGETS := $(ALL_COPIED_TARGETS.$(1).SOURCES)
$(_meta): PRIVATE_SOURCE_METADATA := $(_dep)
$(_meta): PRIVATE_ARGUMENT_FILE := $(call intermediates-dir-for,PACKAGING,copynotice)/$(_meta)/arguments
$(_meta) : $(_dep) $(COPY_LICENSE_METADATA)
rm -f $$@
mkdir -p $$(dir $$@)
mkdir -p $$(dir $$(PRIVATE_ARGUMENT_FILE))
$$(call dump-words-to-file,\
$$(addprefix -i ,$$(PRIVATE_DEST_TARGET))\
$$(addprefix -s ,$$(PRIVATE_SOURCE_TARGETS))\
$$(addprefix -d ,$$(PRIVATE_SOURCE_METADATA)),\
$$(PRIVATE_ARGUMENT_FILE))
OUT_DIR=$(OUT_DIR) $(COPY_LICENSE_METADATA) \
@$$(PRIVATE_ARGUMENT_FILE) \
-o $$@
endif
$(eval _dep:=)
$(eval _dmeta:=)
$(eval _meta:=)
$(eval _dir:=)
endef
###########################################################
## Declare the license metadata for non-module target $(1).
##
## $(2) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
## $(3) -- license conditions e.g. notice by_exception_only
## $(4) -- license text filenames (notices)
## $(5) -- package name
## $(6) -- project path
###########################################################
define declare-license-metadata
$(strip \
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
$(eval ALL_NON_MODULES += $(_tgt)) \
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
$(eval ALL_NON_MODULES.$(_tgt).NOTICES := $(strip $(4))) \
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME := $(strip $(5))) \
$(eval ALL_NON_MODULES.$(_tgt).PATH := $(strip $(6))) \
)
endef
###########################################################
## Declare that non-module targets copied from project $(1) and
## optionally ending in $(2) have the following license
## metadata:
##
## $(3) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
## $(4) -- license conditions e.g. notice by_exception_only
## $(5) -- license text filenames (notices)
## $(6) -- package name
###########################################################
define declare-copy-files-license-metadata
$(strip \
$(foreach _pair,$(filter $(1)%$(2),$(PRODUCT_COPY_FILES)),$(eval $(call declare-license-metadata,$(PRODUCT_OUT)/$(call word-colon,2,$(_pair)),$(3),$(4),$(5),$(6),$(1)))) \
)
endef
###########################################################
## Declare the license metadata for non-module container-type target $(1).
##
## Container-type targets are targets like .zip files that
## merely aggregate other files.
##
## $(2) -- license kinds e.g. SPDX-license-identifier-Apache-2.0
## $(3) -- license conditions e.g. notice by_exception_only
## $(4) -- license text filenames (notices)
## $(5) -- package name
## $(6) -- project path
###########################################################
define declare-container-license-metadata
$(strip \
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
$(eval ALL_NON_MODULES += $(_tgt)) \
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_KINDS := $(strip $(2))) \
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_CONDITIONS := $(strip $(3))) \
$(eval ALL_NON_MODULES.$(_tgt).NOTICES := $(strip $(4))) \
$(eval ALL_NON_MODULES.$(_tgt).LICENSE_PACKAGE_NAME := $(strip $(5))) \
$(eval ALL_NON_MODULES.$(_tgt).PATH := $(strip $(6))) \
$(eval ALL_NON_MODULES.$(_tgt).IS_CONTAINER := true) \
)
endef
###########################################################
## Declare that non-module target $(1) is a non-copyrightable file.
##
## e.g. an information-only file merely listing other files.
###########################################################
define declare-0p-target
$(strip \
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
$(eval ALL_0P_TARGETS += $(_tgt)) \
)
endef
###########################################################
## Declare non-module target $(1) to have a first-party license
## (Android Apache 2.0)
##
## $(2) -- project path
###########################################################
define declare-1p-target
$(call declare-license-metadata,$(1),SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,Android,$(2))
endef
###########################################################
## Declare that non-module targets copied from project $(1) and
## optionally ending in $(2) are first-party licensed
## (Android Apache 2.0)
###########################################################
define declare-1p-copy-files
$(foreach _pair,$(filter $(1)%$(2),$(PRODUCT_COPY_FILES)),$(call declare-1p-target,$(PRODUCT_OUT)/$(call word-colon,2,$(_pair)),$(1)))
endef
###########################################################
## Declare non-module container-type target $(1) to have a
## first-party license (Android Apache 2.0).
##
## Container-type targets are targets like .zip files that
## merely aggregate other files.
##
## $92) -- project path
###########################################################
define declare-1p-container
$(call declare-container-license-metadata,$(1),SPDX-license-identifier-Apache-2.0,notice,build/soong/licenses/LICENSE,Android,$(2))
endef
###########################################################
## Declare license dependencies $(2) with optional colon-separated
## annotations for non-module target $(1)
###########################################################
define declare-license-deps
$(strip \
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
$(eval ALL_NON_MODULES += $(_tgt)) \
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
$(eval ALL_NON_MODULES.$(_tgt).DEPENDENCIES := $(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES) $(2))) \
)
endef
###########################################################
## Declare license dependencies $(2) with optional colon-separated
## annotations for non-module container-type target $(1)
##
## Container-type targets are targets like .zip files that
## merely aggregate other files.
##
## $(3) -- root mappings space-separated source:target
###########################################################
define declare-container-license-deps
$(strip \
$(eval _tgt := $(subst //,/,$(strip $(1)))) \
$(eval ALL_NON_MODULES += $(_tgt)) \
$(eval ALL_TARGETS.$(_tgt).META_LIC := $(call license-metadata-dir,$(1))/$(patsubst $(OUT_DIR)%,out%,$(_tgt)).meta_lic) \
$(eval ALL_NON_MODULES.$(_tgt).DEPENDENCIES := $(strip $(ALL_NON_MODULES.$(_tgt).DEPENDENCIES) $(2))) \
$(eval ALL_NON_MODULES.$(_tgt).IS_CONTAINER := true) \
$(eval ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS := $(strip $(ALL_NON_MODULES.$(_tgt).ROOT_MAPPINGS) $(3))) \
)
endef
###########################################################
## Declares the rule to report targets with no license metadata.
###########################################################
define report-missing-licenses-rule
.PHONY: reportmissinglicenses
reportmissinglicenses: PRIVATE_NON_MODULES:=$(sort $(NON_MODULES_WITHOUT_LICENSE_METADATA) $(TARGETS_MISSING_LICENSE_METADATA))
reportmissinglicenses: PRIVATE_COPIED_FILES:=$(sort $(filter $(NON_MODULES_WITHOUT_LICENSE_METADATA) $(TARGETS_MISSING_LICENSE_METADATA),\
$(foreach _pair,$(PRODUCT_COPY_FILES), $(PRODUCT_OUT)/$(call word-colon,2,$(_pair)))))
reportmissinglicenses:
@echo Reporting $$(words $$(PRIVATE_NON_MODULES)) targets without license metadata
$$(foreach t,$$(PRIVATE_NON_MODULES),if ! [ -h $$(t) ]; then echo No license metadata for $$(t) >&2; fi;)
$$(foreach t,$$(PRIVATE_COPIED_FILES),if ! [ -h $$(t) ]; then echo No license metadata for copied file $$(t) >&2; fi;)
echo $$(words $$(PRIVATE_NON_MODULES)) targets missing license metadata >&2
endef
###########################################################
# Returns the unique list of built license metadata files.
###########################################################
define all-license-metadata
$(sort \
$(foreach t,$(ALL_NON_MODULES),$(if $(filter 0p,$(ALL_TARGETS.$(t).META_LIC)),, $(ALL_TARGETS.$(t).META_LIC))) \
$(foreach m,$(ALL_MODULES), $(ALL_MODULES.$(m).META_LIC)) \
)
endef
###########################################################
# Declares the rule to report all library names used in any notice files.
###########################################################
define report-all-notice-library-names-rule
$(strip $(eval _all := $(call all-license-metadata)))
.PHONY: reportallnoticelibrarynames
reportallnoticelibrarynames: PRIVATE_LIST_FILE := $(call license-metadata-dir,COMMON)/filelist
reportallnoticelibrarynames: | $(COMPLIANCENOTICE_SHIPPEDLIBS)
reportallnoticelibrarynames: $(_all)
@echo Reporting notice library names for at least $$(words $(_all)) license metadata files
$(hide) rm -f $$(PRIVATE_LIST_FILE)
$(hide) mkdir -p $$(dir $$(PRIVATE_LIST_FILE))
$(hide) find out -name '*meta_lic' -type f -printf '"%p"\n' >$$(PRIVATE_LIST_FILE)
OUT_DIR=$(OUT_DIR) $(COMPLIANCENOTICE_SHIPPEDLIBS) @$$(PRIVATE_LIST_FILE)
endef
###########################################################
# Declares the rule to build all license metadata.
###########################################################
define build-all-license-metadata-rule
$(strip $(eval _all := $(call all-license-metadata)))
.PHONY: alllicensemetadata
alllicensemetadata: $(_all)
@echo Building all $(words $(_all)) license metadata files
endef
###########################################################
## Declares a license metadata build rule for ALL_MODULES
###########################################################
define build-license-metadata
$(strip \
$(foreach t,$(sort $(ALL_0P_TARGETS)), \
$(eval ALL_TARGETS.$(t).META_LIC := 0p) \
) \
$(foreach t,$(sort $(ALL_COPIED_TARGETS)),$(eval $(call copied-target-license-metadata-rule,$(t)))) \
$(foreach t,$(sort $(ALL_NON_MODULES)),$(eval $(call non-module-license-metadata-rule,$(t)))) \
$(foreach m,$(sort $(ALL_MODULES)),$(eval $(call license-metadata-rule,$(m)))) \
$(eval $(call build-all-license-metadata-rule)))
endef
###########################################################
## Returns correct _idfPrefix from the list:
## { HOST, HOST_CROSS, TARGET }
###########################################################
# the following rules checked in order:
# ($1 is in {HOST_CROSS} => $1;
# ($1 is empty) => TARGET;
# ($2 is not empty) => HOST_CROSS;
# => HOST;
define find-idf-prefix
$(strip \
$(eval _idf_pfx_:=$(strip $(filter HOST_CROSS,$(1)))) \
$(eval _idf_pfx_:=$(if $(strip $(1)),$(if $(_idf_pfx_),$(_idf_pfx_),$(if $(strip $(2)),HOST_CROSS,HOST)),TARGET)) \
$(_idf_pfx_)
)
endef
###########################################################
## The intermediates directory. Where object files go for
## a given target. We could technically get away without
## the "_intermediates" suffix on the directory, but it's
## nice to be able to grep for that string to find out if
## anyone's abusing the system.
###########################################################
# $(1): target class, like "APPS"
# $(2): target name, like "NotePad"
# $(3): { HOST, HOST_CROSS, , }
# $(4): if non-empty, force the intermediates to be COMMON
# $(5): if non-empty, force the intermediates to be for the 2nd arch
# $(6): if non-empty, force the intermediates to be for the host cross os
define intermediates-dir-for
$(strip \
$(eval _idfClass := $(strip $(1))) \
$(if $(_idfClass),, \
$(error $(LOCAL_PATH): Class not defined in call to intermediates-dir-for)) \
$(eval _idfName := $(strip $(2))) \
$(if $(_idfName),, \
$(error $(LOCAL_PATH): Name not defined in call to intermediates-dir-for)) \
$(eval _idfPrefix := $(call find-idf-prefix,$(3),$(6))) \
$(eval _idf2ndArchPrefix := $(if $(strip $(5)),$(TARGET_2ND_ARCH_VAR_PREFIX))) \
$(if $(filter $(_idfPrefix)_$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_INTERMEDIATES)) \
,$(if $(filter $(_idfClass),$(PER_ARCH_MODULE_CLASSES)),\
$(eval _idfIntBase := $($(_idf2ndArchPrefix)$(_idfPrefix)_OUT_INTERMEDIATES)) \
,$(eval _idfIntBase := $($(_idfPrefix)_OUT_INTERMEDIATES)) \
) \
) \
$(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
)
endef
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
# to determine the intermediates directory.
#
# $(1): if non-empty, force the intermediates to be COMMON
# $(2): if non-empty, force the intermediates to be for the 2nd arch
# $(3): if non-empty, force the intermediates to be for the host cross os
define local-intermediates-dir
$(strip \
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-intermediates-dir)) \
$(if $(strip $(LOCAL_MODULE)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-intermediates-dir)) \
$(call intermediates-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST),$(1),$(2),$(3)) \
)
endef
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
# to determine the intermediates directory.
#
# $(1): if non-empty, force the intermediates to be COMMON
# $(2): if non-empty, force the intermediates to be for the 2nd arch
# $(3): if non-empty, force the intermediates to be for the host cross os
define local-meta-intermediates-dir
$(strip \
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-meta-intermediates-dir)) \
$(if $(strip $(LOCAL_MODULE)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-meta-intermediates-dir)) \
$(call intermediates-dir-for,META$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST),$(1),$(2),$(3)) \
)
endef
###########################################################
## The generated sources directory. Placing generated
## source files directly in the intermediates directory
## causes problems for multiarch builds, where there are
## two intermediates directories for a single target. Put
## them in a separate directory, and they will be copied to
## each intermediates directory automatically.
###########################################################
# $(1): target class, like "APPS"
# $(2): target name, like "NotePad"
# $(3): { HOST, HOST_CROSS, , }
# $(4): if non-empty, force the generated sources to be COMMON
define generated-sources-dir-for
$(strip \
$(eval _idfClass := $(strip $(1))) \
$(if $(_idfClass),, \
$(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
$(eval _idfName := $(strip $(2))) \
$(if $(_idfName),, \
$(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
$(eval _idfPrefix := $(call find-idf-prefix,$(3),)) \
$(if $(filter $(_idfPrefix)_$(_idfClass),$(COMMON_MODULE_CLASSES))$(4), \
$(eval _idfIntBase := $($(_idfPrefix)_OUT_COMMON_GEN)) \
, \
$(eval _idfIntBase := $($(_idfPrefix)_OUT_GEN)) \
) \
$(_idfIntBase)/$(_idfClass)/$(_idfName)_intermediates \
)
endef
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
# to determine the generated sources directory.
#
# $(1): if non-empty, force the intermediates to be COMMON
define local-generated-sources-dir
$(strip \
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
$(if $(strip $(LOCAL_MODULE)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
$(call generated-sources-dir-for,$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST),$(1)) \
)
endef
###########################################################
## The packaging directory for a module. Similar to intermedates, but
## in a location that will be wiped by an m installclean.
###########################################################
# $(1): subdir in PACKAGING
# $(2): target class, like "APPS"
# $(3): target name, like "NotePad"
# $(4): { HOST, HOST_CROSS, , }
define packaging-dir-for
$(strip \
$(eval _pdfClass := $(strip $(2))) \
$(if $(_pdfClass),, \
$(error $(LOCAL_PATH): Class not defined in call to generated-sources-dir-for)) \
$(eval _pdfName := $(strip $(3))) \
$(if $(_pdfName),, \
$(error $(LOCAL_PATH): Name not defined in call to generated-sources-dir-for)) \
$(call intermediates-dir-for,PACKAGING,$(1),$(4))/$(_pdfClass)/$(_pdfName)_intermediates \
)
endef
# Uses LOCAL_MODULE_CLASS, LOCAL_MODULE, and LOCAL_IS_HOST_MODULE
# to determine the packaging directory.
#
# $(1): subdir in PACKAGING
define local-packaging-dir
$(strip \
$(if $(strip $(LOCAL_MODULE_CLASS)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE_CLASS not defined before call to local-generated-sources-dir)) \
$(if $(strip $(LOCAL_MODULE)),, \
$(error $(LOCAL_PATH): LOCAL_MODULE not defined before call to local-generated-sources-dir)) \
$(call packaging-dir-for,$(1),$(LOCAL_MODULE_CLASS),$(LOCAL_MODULE),$(if $(strip $(LOCAL_IS_HOST_MODULE)),HOST)) \
)
endef
###########################################################
## Convert a list of short module names (e.g., "framework", "Browser")
## into the list of files that are built for those modules.
## NOTE: this won't return reliable results until after all
## sub-makefiles have been included.
## $(1): target list
###########################################################
define module-built-files
$(foreach module,$(1),$(ALL_MODULES.$(module).BUILT))
endef
###########################################################
## Convert a list of short modules names (e.g., "framework", "Browser")
## into the list of files that are installed for those modules.
## NOTE: this won't return reliable results until after all
## sub-makefiles have been included.
## $(1): target list
###########################################################
define module-installed-files
$(foreach module,$(1),$(ALL_MODULES.$(module).INSTALLED))
endef
###########################################################
## Convert a list of short modules names (e.g., "framework", "Browser")
## into the list of files that are built *for the target* for those modules.
## NOTE: this won't return reliable results until after all
## sub-makefiles have been included.
## $(1): target list
###########################################################
define module-target-built-files
$(foreach module,$(1),$(ALL_MODULES.$(module).TARGET_BUILT))
endef
###########################################################
## Convert a list of short modules names (e.g., "framework", "Browser")
## into the list of files that should be used when linking
## against that module as a public API.
## TODO: Allow this for more than JAVA_LIBRARIES modules
## NOTE: this won't return reliable results until after all
## sub-makefiles have been included.
## $(1): target list
###########################################################
define module-stubs-files
$(foreach module,$(1),$(if $(filter $(module),$(JAVA_SDK_LIBRARIES)),\
$(call java-lib-files,$(module).stubs),$(ALL_MODULES.$(module).STUBS)))
endef
###########################################################
## Evaluates to the timestamp file for a doc module, which
## is the dependency that should be used.
## $(1): doc module
###########################################################
define doc-timestamp-for
$(OUT_DOCS)/$(strip $(1))-timestamp
endef
###########################################################
## Convert "core ext framework" to "out/.../javalib.jar ..."
## $(1): library list
## $(2): Non-empty if IS_HOST_MODULE
###########################################################
# Get the jar files (you can pass to "javac -classpath") of static or shared
# Java libraries that you want to link against.
# $(1): library name list
# $(2): Non-empty if IS_HOST_MODULE
define java-lib-files
$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes.jar)
endef
# Get the header jar files (you can pass to "javac -classpath") of static or shared
# Java libraries that you want to link against.
# $(1): library name list
# $(2): Non-empty if IS_HOST_MODULE
ifneq ($(TURBINE_ENABLED),false)
define java-lib-header-files
$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),$(2),COMMON)/classes-header.jar)
endef
else
define java-lib-header-files
$(call java-lib-files,$(1),$(2))
endef
endif
# Get the dependency files (you can put on the right side of "|" of a build rule)
# of the Java libraries.
# $(1): library name list
# $(2): Non-empty if IS_HOST_MODULE
# Historically for target Java libraries we used a different file (javalib.jar)
# as the dependency.
# Now we can use classes.jar as dependency, so java-lib-deps is the same
# as java-lib-files.
define java-lib-deps
$(call java-lib-files,$(1),$(2))
endef
# Get the jar files (you can pass to "javac -classpath") of static or shared
# APK libraries that you want to link against.
# $(1): library name list
define app-lib-files
$(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes.jar)
endef
# Get the header jar files (you can pass to "javac -classpath") of static or shared
# APK libraries that you want to link against.
# $(1): library name list
ifneq ($(TURBINE_ENABLED),false)
define app-lib-header-files
$(foreach lib,$(1),$(call intermediates-dir-for,APPS,$(lib),,COMMON)/classes-header.jar)
endef
else
define app-lib-header-files
$(call app-lib-files,$(1))
endef
endif
# Get the exported-sdk-libs files which collectively give you the list of exported java sdk
# lib names that are (transitively) exported from the given set of java libs
# $(1): library name list
define exported-sdk-libs-files
$(foreach lib,$(1),$(call intermediates-dir-for,JAVA_LIBRARIES,$(lib),,COMMON)/exported-sdk-libs)
endef
###########################################################
## Append a leaf to a base path. Properly deals with
## base paths ending in /.
##
## $(1): base path
## $(2): leaf path
###########################################################
define append-path
$(subst //,/,$(1)/$(2))
endef
###########################################################
## Color-coded warnings and errors
## Use echo-(warning|error) in a build rule
## Use pretty-(warning|error) instead of $(warning)/$(error)
###########################################################
ESC_BOLD := \033[1m
ESC_WARNING := \033[35m
ESC_ERROR := \033[31m
ESC_RESET := \033[0m
# $(1): path (and optionally line) information
# $(2): message to print
define echo-warning
echo -e "$(ESC_BOLD)$(1): $(ESC_WARNING)warning:$(ESC_RESET)$(ESC_BOLD)" '$(subst ','\'',$(2))' "$(ESC_RESET)" >&2
endef
# $(1): path (and optionally line) information
# $(2): message to print
define echo-error
echo -e "$(ESC_BOLD)$(1): $(ESC_ERROR)error:$(ESC_RESET)$(ESC_BOLD)" '$(subst ','\'',$(2))' "$(ESC_RESET)" >&2
endef
###########################################################
## Legacy showcommands compatibility
###########################################################
define pretty
@echo $1
endef
###########################################################
## Commands for including the dependency files the compiler generates
###########################################################
# $(1): the .P file
# $(2): the main build target
define include-depfile
$(eval $(2) : .KATI_DEPFILE := $1)
endef
# $(1): object files
define include-depfiles-for-objs
$(foreach obj, $(1), $(call include-depfile, $(obj:%.o=%.d), $(obj)))
endef
###########################################################
## Track source files compiled to objects
###########################################################
# $(1): list of sources
# $(2): list of matching objects
define track-src-file-obj
$(eval $(call _track-src-file-obj,$(1)))
endef
define _track-src-file-obj
i := w
$(foreach s,$(1),
my_tracked_src_files += $(s)
my_src_file_obj_$(s) := $$(word $$(words $$(i)),$$(2))
i += w)
endef
# $(1): list of sources
# $(2): list of matching generated sources
define track-src-file-gen
$(eval $(call _track-src-file-gen,$(2)))
endef
define _track-src-file-gen
i := w
$(foreach s,$(1),
my_tracked_gen_files += $(s)
my_src_file_gen_$(s) := $$(word $$(words $$(i)),$$(1))
i += w)
endef
# $(1): list of generated sources
# $(2): list of matching objects
define track-gen-file-obj
$(call track-src-file-obj,$(foreach f,$(1),\
$(or $(my_src_file_gen_$(f)),$(f))),$(2))
endef
###########################################################
## Commands for running lex
###########################################################
define transform-l-to-c-or-cpp
@echo "Lex: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
M4=$(M4) $(LEX) -o$@ $<
endef
###########################################################
## Commands for running yacc
##
###########################################################
define transform-y-to-c-or-cpp
@echo "Yacc: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
M4=$(M4) $(YACC) $(PRIVATE_YACCFLAGS) \
--defines=$(basename $@).h \
-o $@ $<
endef
###########################################################
## Commands to compile RenderScript to Java
###########################################################
## Merge multiple .d files generated by llvm-rs-cc. This is necessary
## because ninja can handle only a single depfile per build target.
## .d files generated by llvm-rs-cc define .stamp, .bc, and optionally
## .java as build targets. However, there's no way to let ninja know
## dependencies to .bc files and .java files, so we give up build
## targets for them. As we write the .stamp file as the target by
## ourselves, the awk script removes the first lines before the colon
## and append a backslash to the last line to concatenate contents of
## multiple files.
# $(1): .d files to be merged
# $(2): merged .d file
define _merge-renderscript-d
$(hide) echo '$@: $(backslash)' > $2
$(foreach d,$1, \
$(hide) awk 'start { sub(/( \\)?$$/, " \\"); print } /:/ { start=1 }' < $d >> $2$(newline))
$(hide) echo >> $2
endef
# b/37755219
RS_CC_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0:detect_container_overflow=0
define transform-renderscripts-to-java-and-bc
@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/res/raw
$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/src
$(hide) $(RS_CC_ASAN_OPTIONS) $(PRIVATE_RS_CC) \
-o $(PRIVATE_RS_OUTPUT_DIR)/res/raw \
-p $(PRIVATE_RS_OUTPUT_DIR)/src \
-d $(PRIVATE_RS_OUTPUT_DIR) \
-a $@ -MD \
$(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
$(PRIVATE_RS_FLAGS) \
$(foreach inc,$(PRIVATE_RS_INCLUDES),$(addprefix -I , $(inc))) \
$(PRIVATE_RS_SOURCE_FILES)
$(SOONG_ZIP) -o $@ -C $(PRIVATE_RS_OUTPUT_DIR)/src -D $(PRIVATE_RS_OUTPUT_DIR)/src
$(SOONG_ZIP) -o $(PRIVATE_RS_OUTPUT_RES_ZIP) -C $(PRIVATE_RS_OUTPUT_DIR)/res -D $(PRIVATE_RS_OUTPUT_DIR)/res
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
endef
define transform-bc-to-so
@echo "Renderscript compatibility: $(notdir $@) <= $(notdir $<)"
$(hide) mkdir -p $(dir $@)
$(hide) $(BCC_COMPAT) -O3 -o $(dir $@)/$(notdir $(<:.bc=.o)) -fPIC -shared \
-rt-path $(RS_PREBUILT_CLCORE) -mtriple $(RS_COMPAT_TRIPLE) $<
$(hide) $(PRIVATE_CXX_LINK) -fuse-ld=lld -target $(CLANG_TARGET_TRIPLE) -shared -Wl,-soname,$(notdir $@) -nostdlib \
-Wl,-rpath,\$$ORIGIN/../lib \
$(dir $@)/$(notdir $(<:.bc=.o)) \
$(RS_PREBUILT_COMPILER_RT) \
-o $@ $(CLANG_TARGET_GLOBAL_LLDFLAGS) -Wl,--hash-style=sysv \
-L $(SOONG_OUT_DIR)/ndk/platforms/android-$(PRIVATE_SDK_VERSION)/arch-$(TARGET_ARCH)/usr/lib64 \
-L $(SOONG_OUT_DIR)/ndk/platforms/android-$(PRIVATE_SDK_VERSION)/arch-$(TARGET_ARCH)/usr/lib \
$(call intermediates-dir-for,SHARED_LIBRARIES,libRSSupport)/libRSSupport.so \
-lm -lc
endef
###########################################################
## Commands to compile RenderScript to C++
###########################################################
define transform-renderscripts-to-cpp-and-bc
@echo "RenderScript: $(PRIVATE_MODULE) <= $(PRIVATE_RS_SOURCE_FILES)"
$(hide) rm -rf $(PRIVATE_RS_OUTPUT_DIR)
$(hide) mkdir -p $(PRIVATE_RS_OUTPUT_DIR)/
$(hide) $(RS_CC_ASAN_OPTIONS) $(PRIVATE_RS_CC) \
-o $(PRIVATE_RS_OUTPUT_DIR)/ \
-d $(PRIVATE_RS_OUTPUT_DIR) \
-a $@ -MD \
-reflect-c++ \
$(addprefix -target-api , $(PRIVATE_RS_TARGET_API)) \
$(PRIVATE_RS_FLAGS) \
$(addprefix -I , $(PRIVATE_RS_INCLUDES)) \
$(PRIVATE_RS_SOURCE_FILES)
$(call _merge-renderscript-d,$(PRIVATE_DEP_FILES),$@.d)
$(hide) mkdir -p $(dir $@)
$(hide) touch $@
endef
###########################################################
## Commands for running aidl
###########################################################
define transform-aidl-to-java
@mkdir -p $(dir $@)
@echo "Aidl: $(PRIVATE_MODULE) <= $<"
$(hide) $(AIDL) -d$(patsubst %.java,%.P,$@) $(PRIVATE_AIDL_FLAGS) $< $@
endef
#$(AIDL) $(PRIVATE_AIDL_FLAGS) $< - | indent -nut -br -npcs -l1000 > $@
define transform-aidl-to-cpp
@mkdir -p $(dir $@)
@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
@echo "Generating C++ from AIDL: $(PRIVATE_MODULE) <= $<"
$(hide) $(AIDL_CPP) -d$(basename $@).aidl.d --ninja $(PRIVATE_AIDL_FLAGS) \
$< $(PRIVATE_HEADER_OUTPUT_DIR) $@
endef
## Given a .aidl file path, generate the rule to compile it a .java file
# $(1): a .aidl source file
# $(2): a directory to place the generated .java files in
# $(3): name of a variable to add the path to the generated source file to
#
# You must call this with $(eval).
define define-aidl-java-rule
define_aidl_java_rule_src := $(patsubst %.aidl,%.java,$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
$$(define_aidl_java_rule_src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL)
$$(transform-aidl-to-java)
$(3) += $$(define_aidl_java_rule_src)
endef
## Given a .aidl file path generate the rule to compile it a .cpp file.
# $(1): a .aidl source file
# $(2): a directory to place the generated .cpp files in
# $(3): name of a variable to add the path to the generated source file to
#
# You must call this with $(eval).
define define-aidl-cpp-rule
define_aidl_cpp_rule_src := $(patsubst %.aidl,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
$$(define_aidl_cpp_rule_src) : $(call clean-path,$(LOCAL_PATH)/$(1)) $(AIDL_CPP)
$$(transform-aidl-to-cpp)
$(3) += $$(define_aidl_cpp_rule_src)
endef
###########################################################
## Commands for running vts
###########################################################
define transform-vts-to-cpp
@mkdir -p $(dir $@)
@mkdir -p $(PRIVATE_HEADER_OUTPUT_DIR)
@echo "Generating C++ from VTS: $(PRIVATE_MODULE) <= $<"
$(hide) $(VTSC) -TODO_b/120496070 $(PRIVATE_VTS_FLAGS) \
$< $(PRIVATE_HEADER_OUTPUT_DIR) $@
endef
## Given a .vts file path generate the rule to compile it a .cpp file.
# $(1): a .vts source file
# $(2): a directory to place the generated .cpp files in
# $(3): name of a variable to add the path to the generated source file to
#
# You must call this with $(eval).
define define-vts-cpp-rule
define_vts_cpp_rule_src := $(patsubst %.vts,%$(LOCAL_CPP_EXTENSION),$(subst ../,dotdot/,$(addprefix $(2)/,$(1))))
$$(define_vts_cpp_rule_src) : $(LOCAL_PATH)/$(1) $(VTSC)
$$(transform-vts-to-cpp)
$(3) += $$(define_vts_cpp_rule_src)
endef
###########################################################
## Commands for running java-event-log-tags.py
###########################################################
define transform-logtags-to-java
@mkdir -p $(dir $@)
@echo "logtags: $@ <= $<"
$(hide) $(JAVATAGS) -o $@ $<
endef
###########################################################
## Commands for running protoc to compile .proto into .java
###########################################################
define transform-proto-to-java
@mkdir -p $(dir $@)
@echo "Protoc: $@ <= $(PRIVATE_PROTO_SRC_FILES)"
@rm -rf $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
@mkdir -p $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
$(hide) for f in $(PRIVATE_PROTO_SRC_FILES); do \
$(PROTOC) \
$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
$(PRIVATE_PROTO_JAVA_OUTPUT_OPTION)="$(PRIVATE_PROTO_JAVA_OUTPUT_PARAMS):$(PRIVATE_PROTO_JAVA_OUTPUT_DIR)" \
$(PRIVATE_PROTOC_FLAGS) \
$$f || exit 33; \
done
$(SOONG_ZIP) -o $@ -C $(PRIVATE_PROTO_JAVA_OUTPUT_DIR) -D $(PRIVATE_PROTO_JAVA_OUTPUT_DIR)
endef
######################################################################
## Commands for running protoc to compile .proto into .pb.cc (or.pb.c) and .pb.h
######################################################################
define transform-proto-to-cc
@echo "Protoc: $@ <= $<"
@mkdir -p $(dir $@)
$(hide) \
$(PROTOC) \
$(addprefix --proto_path=, $(PRIVATE_PROTO_INCLUDES)) \
$(PRIVATE_PROTOC_FLAGS) \
$<
@# aprotoc outputs only .cc. Rename it to .cpp if necessary.
$(if $(PRIVATE_RENAME_CPP_EXT),\
$(hide) mv $(basename $@).cc $@)
endef
###########################################################
## Helper to set include paths form transform-*-to-o
###########################################################
define c-includes
$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
$(foreach i,$(PRIVATE_IMPORTED_INCLUDES),$(EXPORTS.$(i)))\
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),,\
$(addprefix -I ,\
$(filter-out $(PRIVATE_C_INCLUDES), \
$(PRIVATE_GLOBAL_C_INCLUDES))) \
$(addprefix -isystem ,\
$(filter-out $(PRIVATE_C_INCLUDES), \
$(PRIVATE_GLOBAL_C_SYSTEM_INCLUDES))))
endef
###########################################################
## Commands for running gcc to compile a C++ file
###########################################################
define transform-cpp-to-o-compiler-args
$(c-includes) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
$(PRIVATE_TARGET_GLOBAL_CPPFLAGS) \
$(PRIVATE_ARM_CFLAGS) \
) \
$(PRIVATE_RTTI_FLAG) \
$(PRIVATE_CFLAGS) \
$(PRIVATE_CPPFLAGS) \
$(PRIVATE_DEBUG_CFLAGS) \
$(PRIVATE_CFLAGS_NO_OVERRIDE) \
$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
endef
# PATH_TO_CLANG_TIDY is defined in build/soong
define call-clang-tidy
$(PATH_TO_CLANG_TIDY) \
$(PRIVATE_TIDY_FLAGS) \
-checks=$(PRIVATE_TIDY_CHECKS)
endef
define clang-tidy-cpp
$(hide) $(call-clang-tidy) $< -- $(transform-cpp-to-o-compiler-args)
endef
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
define transform-cpp-to-o
$(if $(PRIVATE_TIDY_CHECKS),
@echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C++: $<"
$(clang-tidy-cpp))
endef
else
define transform-cpp-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C++: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-cpp))
$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
$(transform-cpp-to-o-compiler-args) \
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
endef
endif
###########################################################
## Commands for running gcc to compile a C file
###########################################################
# $(1): extra flags
define transform-c-or-s-to-o-compiler-args
$(c-includes) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_TARGET_GLOBAL_CFLAGS) \
$(PRIVATE_TARGET_GLOBAL_CONLYFLAGS) \
$(PRIVATE_ARM_CFLAGS) \
) \
$(1)
endef
define transform-c-to-o-compiler-args
$(call transform-c-or-s-to-o-compiler-args, \
$(PRIVATE_CFLAGS) \
$(PRIVATE_CONLYFLAGS) \
$(PRIVATE_DEBUG_CFLAGS) \
$(PRIVATE_CFLAGS_NO_OVERRIDE))
endef
define clang-tidy-c
$(hide) $(call-clang-tidy) $< -- $(transform-c-to-o-compiler-args)
endef
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
define transform-c-to-o
$(if $(PRIVATE_TIDY_CHECKS),
@echo "$($(PRIVATE_PREFIX)DISPLAY) tidy $(PRIVATE_ARM_MODE) C: $<"
$(clang-tidy-c))
endef
else
define transform-c-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) $(PRIVATE_ARM_MODE) C: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-c))
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
$(transform-c-to-o-compiler-args) \
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
endef
endif
define transform-s-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(RELATIVE_PWD) $(PRIVATE_CC) \
$(call transform-c-or-s-to-o-compiler-args, $(PRIVATE_ASFLAGS)) \
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
endef
# YASM compilation
define transform-asm-to-o
@mkdir -p $(dir $@)
$(hide) $(YASM) \
$(addprefix -I , $(PRIVATE_C_INCLUDES)) \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_YASM_FLAGS) \
$(PRIVATE_ASFLAGS) \
-o $@ $<
endef
###########################################################
## Commands for running gcc to compile an Objective-C file
## This should never happen for target builds but this
## will error at build time.
###########################################################
define transform-m-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
$(call transform-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS))
endef
###########################################################
## Commands for running gcc to compile a host C++ file
###########################################################
define transform-host-cpp-to-o-compiler-args
$(c-includes) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
$(PRIVATE_HOST_GLOBAL_CPPFLAGS) \
) \
$(PRIVATE_CFLAGS) \
$(PRIVATE_CPPFLAGS) \
$(PRIVATE_DEBUG_CFLAGS) \
$(PRIVATE_CFLAGS_NO_OVERRIDE) \
$(PRIVATE_CPPFLAGS_NO_OVERRIDE)
endef
define clang-tidy-host-cpp
$(hide) $(call-clang-tidy) $< -- $(transform-host-cpp-to-o-compiler-args)
endef
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
define transform-host-cpp-to-o
$(if $(PRIVATE_TIDY_CHECKS),
@echo "tidy $($(PRIVATE_PREFIX)DISPLAY) C++: $<"
$(clang-tidy-host-cpp))
endef
else
define transform-host-cpp-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) C++: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(if $(PRIVATE_TIDY_CHECKS),$(clang-tidy-host-cpp))
$(hide) $(RELATIVE_PWD) $(PRIVATE_CXX) \
$(transform-host-cpp-to-o-compiler-args) \
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
endef
endif
###########################################################
## Commands for running gcc to compile a host C file
###########################################################
define transform-host-c-or-s-to-o-common-args
$(c-includes) \
-c \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_HOST_GLOBAL_CFLAGS) \
$(PRIVATE_HOST_GLOBAL_CONLYFLAGS) \
)
endef
# $(1): extra flags
define transform-host-c-or-s-to-o
@mkdir -p $(dir $@)
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
$(transform-host-c-or-s-to-o-common-args) \
$(1) \
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
endef
define transform-host-c-to-o-compiler-args
$(transform-host-c-or-s-to-o-common-args) \
$(PRIVATE_CFLAGS) $(PRIVATE_CONLYFLAGS) \
$(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE)
endef
define clang-tidy-host-c
$(hide) $(call-clang-tidy) $< -- $(transform-host-c-to-o-compiler-args)
endef
ifneq (,$(filter 1 true,$(WITH_TIDY_ONLY)))
define transform-host-c-to-o
$(if $(PRIVATE_TIDY_CHECKS),
@echo "tidy $($(PRIVATE_PREFIX)DISPLAY) C: $<"
$(clang-tidy-host-c))
endef
else
define transform-host-c-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) C: $(PRIVATE_MODULE) <= $<"
@mkdir -p $(dir $@)
$(if $(PRIVATE_TIDY_CHECKS), $(clang-tidy-host-c))
$(hide) $(RELATIVE_PWD) $(PRIVATE_CC) \
$(transform-host-c-to-o-compiler-args) \
-MD -MF $(patsubst %.o,%.d,$@) -o $@ $<
endef
endif
define transform-host-s-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) asm: $(PRIVATE_MODULE) <= $<"
$(call transform-host-c-or-s-to-o, $(PRIVATE_ASFLAGS))
endef
###########################################################
## Commands for running gcc to compile a host Objective-C file
###########################################################
define transform-host-m-to-o
@echo "$($(PRIVATE_PREFIX)DISPLAY) ObjC: $(PRIVATE_MODULE) <= $<"
$(call transform-host-c-or-s-to-o, $(PRIVATE_CFLAGS) $(PRIVATE_DEBUG_CFLAGS) $(PRIVATE_CFLAGS_NO_OVERRIDE))
endef
###########################################################
## Commands for running gcc to compile a host Objective-C++ file
###########################################################
define transform-host-mm-to-o
$(transform-host-cpp-to-o)
endef
###########################################################
## Rules to compile a single C/C++ source with ../ in the path
###########################################################
# Replace "../" in object paths with $(DOTDOT_REPLACEMENT).
DOTDOT_REPLACEMENT := dotdot/
## Rule to compile a C++ source file with ../ in the path.
## Must be called with $(eval).
# $(1): the C++ source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
# $(4): the ninja pool to use for the rule
define compile-dotdot-cpp-file
o := $(intermediates)/$(patsubst %$(LOCAL_CPP_EXTENSION),%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG_CXX)
$$(transform-$$(PRIVATE_HOST)cpp-to-o)
$$(call include-depfiles-for-objs, $$(o))
$(3) += $$(o)
endef
## Rule to compile a C source file with ../ in the path.
## Must be called with $(eval).
# $(1): the C source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
# $(4): the ninja pool to use for the rule
define compile-dotdot-c-file
o := $(intermediates)/$(patsubst %.c,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
$$(transform-$$(PRIVATE_HOST)c-to-o)
$$(call include-depfiles-for-objs, $$(o))
$(3) += $$(o)
endef
## Rule to compile a .S source file with ../ in the path.
## Must be called with $(eval).
# $(1): the .S source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
# $(4): the ninja pool to use for the rule
define compile-dotdot-s-file
o := $(intermediates)/$(patsubst %.S,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
$$(transform-$$(PRIVATE_HOST)s-to-o)
$$(call include-depfiles-for-objs, $$(o))
$(3) += $$(o)
endef
## Rule to compile a .s source file with ../ in the path.
## Must be called with $(eval).
# $(1): the .s source file in LOCAL_SRC_FILES.
# $(2): the additional dependencies.
# $(3): the variable name to collect the output object file.
# $(4): the ninja pool to use for the rule
define compile-dotdot-s-file-no-deps
o := $(intermediates)/$(patsubst %.s,%.o,$(subst ../,$(DOTDOT_REPLACEMENT),$(1)))
$$(o) : .KATI_NINJA_POOL := $(4)
$$(o) : $(TOPDIR)$(LOCAL_PATH)/$(1) $(2) $(CLANG)
$$(transform-$$(PRIVATE_HOST)s-to-o)
$(3) += $$(o)
endef
###########################################################
## Commands for running ar
###########################################################
define _concat-if-arg2-not-empty
$(if $(2),$(hide) $(1) $(2))
endef
# Split long argument list into smaller groups and call the command repeatedly
# Call the command at least once even if there are no arguments, as otherwise
# the output file won't be created.
#
# $(1): the command without arguments
# $(2): the arguments
define split-long-arguments
$(hide) $(1) $(wordlist 1,500,$(2))
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 501,1000,$(2)))
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1001,1500,$(2)))
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 1501,2000,$(2)))
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2001,2500,$(2)))
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 2501,3000,$(2)))
$(call _concat-if-arg2-not-empty,$(1),$(wordlist 3001,99999,$(2)))
endef
# $(1): the full path of the source static library.
# $(2): the full path of the destination static library.
define _extract-and-include-single-target-whole-static-lib
$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
rm -rf $$ldir; \
mkdir -p $$ldir; \
cp $(1) $$ldir; \
lib_to_include=$$ldir/$(notdir $(1)); \
filelist=; \
subdir=0; \
for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) t $(1)`; do \
if [ -e $$ldir/$$f ]; then \
mkdir $$ldir/$$subdir; \
ext=$$subdir/; \
subdir=$$((subdir+1)); \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) m $$lib_to_include $$f; \
else \
ext=; \
fi; \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
filelist="$$filelist $$ldir/$$ext$$f"; \
done ; \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
$(PRIVATE_ARFLAGS) $(2) $$filelist
endef
# $(1): the full path of the source static library.
# $(2): the full path of the destination static library.
define extract-and-include-whole-static-libs-first
$(if $(strip $(1)),
$(hide) cp $(1) $(2))
endef
# $(1): the full path of the destination static library.
define extract-and-include-target-whole-static-libs
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
$(call _extract-and-include-single-target-whole-static-lib, $(lib), $(1)))
endef
# Explicitly delete the archive first so that ar doesn't
# try to add to an existing archive.
define transform-o-to-static-lib
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
@rm -f $@ $@.tmp
$(call extract-and-include-target-whole-static-libs,$@.tmp)
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_AR) \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)TARGET_GLOBAL_ARFLAGS) \
$(PRIVATE_ARFLAGS) \
$@.tmp,$(PRIVATE_ALL_OBJECTS))
$(hide) mv -f $@.tmp $@
endef
###########################################################
## Commands for running host ar
###########################################################
# $(1): the full path of the source static library.
# $(2): the full path of the destination static library.
define _extract-and-include-single-host-whole-static-lib
$(hide) ldir=$(PRIVATE_INTERMEDIATES_DIR)/WHOLE/$(basename $(notdir $(1)))_objs;\
rm -rf $$ldir; \
mkdir -p $$ldir; \
cp $(1) $$ldir; \
lib_to_include=$$ldir/$(notdir $(1)); \
filelist=; \
subdir=0; \
for f in `$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) t $(1) | \grep '\.o$$'`; do \
if [ -e $$ldir/$$f ]; then \
mkdir $$ldir/$$subdir; \
ext=$$subdir/; \
subdir=$$((subdir+1)); \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) m $$lib_to_include $$f; \
else \
ext=; \
fi; \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) p $$lib_to_include $$f > $$ldir/$$ext$$f; \
filelist="$$filelist $$ldir/$$ext$$f"; \
done ; \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) \
$(2) $$filelist
endef
define extract-and-include-host-whole-static-libs
$(call extract-and-include-whole-static-libs-first, $(firstword $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)),$(1))
$(foreach lib,$(wordlist 2,999,$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES)), \
$(call _extract-and-include-single-host-whole-static-lib, $(lib),$(1)))
endef
ifeq ($(HOST_OS),darwin)
# On Darwin the host ar fails if there is nothing to add to .a at all.
# We work around by adding a dummy.o and then deleting it.
define create-dummy.o-if-no-objs
$(if $(PRIVATE_ALL_OBJECTS),,$(hide) touch $(dir $(1))dummy.o)
endef
define get-dummy.o-if-no-objs
$(if $(PRIVATE_ALL_OBJECTS),,$(dir $(1))dummy.o)
endef
define delete-dummy.o-if-no-objs
$(if $(PRIVATE_ALL_OBJECTS),,$(hide) $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) d $(1) $(dir $(1))dummy.o \
&& rm -f $(dir $(1))dummy.o)
endef
else
create-dummy.o-if-no-objs =
get-dummy.o-if-no-objs =
delete-dummy.o-if-no-objs =
endif # HOST_OS is darwin
# Explicitly delete the archive first so that ar doesn't
# try to add to an existing archive.
define transform-host-o-to-static-lib
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticLib: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
@rm -f $@ $@.tmp
$(call extract-and-include-host-whole-static-libs,$@.tmp)
$(call create-dummy.o-if-no-objs,$@.tmp)
$(call split-long-arguments,$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)AR) \
$($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)GLOBAL_ARFLAGS) $@.tmp,\
$(PRIVATE_ALL_OBJECTS) $(call get-dummy.o-if-no-objs,$@.tmp))
$(call delete-dummy.o-if-no-objs,$@.tmp)
$(hide) mv -f $@.tmp $@
endef
###########################################################
## Commands for running gcc to link a shared library or package
###########################################################
# ld just seems to be so finicky with command order that we allow
# it to be overriden en-masse see combo/linux-arm.make for an example.
ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
define transform-host-o-to-shared-lib-inner
$(hide) $(PRIVATE_CXX_LINK) \
-Wl,-rpath,\$$ORIGIN/../$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
-Wl,-rpath,\$$ORIGIN/$(notdir $($(PRIVATE_2ND_ARCH_VAR_PREFIX)$(PRIVATE_PREFIX)OUT_SHARED_LIBRARIES)) \
-shared -Wl,-soname,$(notdir $@) \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_CRTBEGIN) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
$(PRIVATE_LIBCRT_BUILTINS) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
-o $@ \
$(PRIVATE_CRTEND) \
$(PRIVATE_LDLIBS)
endef
endif
define transform-host-o-to-shared-lib
@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-host-o-to-shared-lib-inner)
endef
define transform-host-o-to-package
@echo "$($(PRIVATE_PREFIX)DISPLAY) Package: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-host-o-to-shared-lib-inner)
endef
###########################################################
## Commands for running gcc to link a shared library or package
###########################################################
define transform-o-to-shared-lib-inner
$(hide) $(PRIVATE_CXX_LINK) \
-nostdlib -Wl,-soname,$(notdir $@) \
-Wl,--gc-sections \
-shared \
$(PRIVATE_TARGET_CRTBEGIN_SO_O) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
-o $@ \
$(PRIVATE_TARGET_CRTEND_SO_O) \
$(PRIVATE_LDLIBS)
endef
define transform-o-to-shared-lib
@echo "$($(PRIVATE_PREFIX)DISPLAY) SharedLib: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-o-to-shared-lib-inner)
endef
###########################################################
## Commands for running gcc to link an executable
###########################################################
define transform-o-to-executable-inner
$(hide) $(PRIVATE_CXX_LINK) -pie \
-nostdlib -Bdynamic \
-Wl,-dynamic-linker,$(PRIVATE_LINKER) \
-Wl,--gc-sections \
-Wl,-z,nocopyreloc \
$(PRIVATE_TARGET_CRTBEGIN_DYNAMIC_O) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
-o $@ \
$(PRIVATE_TARGET_CRTEND_O) \
$(PRIVATE_LDLIBS)
endef
define transform-o-to-executable
@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-o-to-executable-inner)
endef
###########################################################
## Commands for linking a static executable. In practice,
## we only use this on arm, so the other platforms don't
## have transform-o-to-static-executable defined.
## Clang driver needs -static to create static executable.
## However, bionic/linker uses -shared to overwrite.
## Linker for x86 targets does not allow coexistance of -static and -shared,
## so we add -static only if -shared is not used.
###########################################################
define transform-o-to-static-executable-inner
$(hide) $(PRIVATE_CXX_LINK) \
-nostdlib -Bstatic \
$(if $(filter $(PRIVATE_LDFLAGS),-shared),,-static) \
-Wl,--gc-sections \
-o $@ \
$(PRIVATE_TARGET_CRTBEGIN_STATIC_O) \
$(PRIVATE_TARGET_GLOBAL_LDFLAGS) \
$(PRIVATE_LDFLAGS) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
$(filter-out %libcompiler_rt.hwasan.a %libc_nomalloc.hwasan.a %libc.hwasan.a %libcompiler_rt.a %libc_nomalloc.a %libc.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
-Wl,--start-group \
$(filter %libc.a %libc.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(filter %libc_nomalloc.a %libc_nomalloc.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_TARGET_COVERAGE_LIB)) \
$(filter %libcompiler_rt.a %libcompiler_rt.hwasan.a,$(PRIVATE_ALL_STATIC_LIBRARIES)) \
$(PRIVATE_TARGET_LIBCRT_BUILTINS) \
-Wl,--end-group \
$(PRIVATE_TARGET_CRTEND_O)
endef
define transform-o-to-static-executable
@echo "$($(PRIVATE_PREFIX)DISPLAY) StaticExecutable: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-o-to-static-executable-inner)
endef
###########################################################
## Commands for running gcc to link a host executable
###########################################################
ifneq ($(HOST_CUSTOM_LD_COMMAND),true)
define transform-host-o-to-executable-inner
$(hide) $(PRIVATE_CXX_LINK) \
$(PRIVATE_CRTBEGIN) \
$(PRIVATE_ALL_OBJECTS) \
-Wl,--whole-archive \
$(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES) \
-Wl,--no-whole-archive \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--start-group) \
$(PRIVATE_ALL_STATIC_LIBRARIES) \
$(if $(PRIVATE_GROUP_STATIC_LIBRARIES),-Wl$(comma)--end-group) \
$(if $(filter true,$(NATIVE_COVERAGE)),$(PRIVATE_HOST_LIBPROFILE_RT)) \
$(PRIVATE_LIBCRT_BUILTINS) \
$(PRIVATE_ALL_SHARED_LIBRARIES) \
$(foreach path,$(PRIVATE_RPATHS), \
-Wl,-rpath,\$$ORIGIN/$(path)) \
$(if $(PRIVATE_NO_DEFAULT_COMPILER_FLAGS),, \
$(PRIVATE_HOST_GLOBAL_LDFLAGS) \
) \
$(PRIVATE_LDFLAGS) \
-o $@ \
$(PRIVATE_CRTEND) \
$(PRIVATE_LDLIBS)
endef
endif
define transform-host-o-to-executable
@echo "$($(PRIVATE_PREFIX)DISPLAY) Executable: $(PRIVATE_MODULE) ($@)"
@mkdir -p $(dir $@)
$(transform-host-o-to-executable-inner)
endef
###########################################################
## Commands for packaging native coverage files
###########################################################
define package-coverage-files
@rm -f $@ $@.lst $@.premerged
@touch $@.lst
$(foreach obj,$(strip $(PRIVATE_ALL_OBJECTS)), $(hide) echo $(obj) >> $@.lst$(newline))
$(hide) $(SOONG_ZIP) -o $@.premerged -C $(OUT_DIR) -l $@.lst
$(hide) $(MERGE_ZIPS) -ignore-duplicates $@ $@.premerged $(strip $(PRIVATE_ALL_WHOLE_STATIC_LIBRARIES))
endef
###########################################################
## Commands for running javac to make .class files
###########################################################
# b/37750224
AAPT_ASAN_OPTIONS := ASAN_OPTIONS=detect_leaks=0
# Search for generated R.java in $1, copy the found R.java as $2.
define find-generated-R.java
$(hide) for GENERATED_R_FILE in `find $(1) \
-name R.java 2> /dev/null`; do \
cp $$GENERATED_R_FILE $(2) || exit 32; \
done;
@# Ensure that the target file is always created, i.e. also in case we did not
@# enter the GENERATED_R_FILE-loop above. This avoids unnecessary rebuilding.
$(hide) touch $(2)
endef
###########################################################
# AAPT2 compilation and link
###########################################################
define aapt2-compile-one-resource-file
@mkdir -p $(dir $@)
$(hide) $(AAPT2) compile -o $(dir $@) $(PRIVATE_AAPT2_CFLAGS) $<
endef
define aapt2-compile-resource-dirs
@mkdir -p $(dir $@)
$(hide) $(AAPT2) compile -o $@ $(addprefix --dir ,$(PRIVATE_SOURCE_RES_DIRS)) \
$(PRIVATE_AAPT2_CFLAGS)
endef
# TODO(b/74574557): use aapt2 compile --zip if it gets implemented
define aapt2-compile-resource-zips
@mkdir -p $(dir $@)
$(ZIPSYNC) -d $@.contents -l $@.list $(PRIVATE_SOURCE_RES_ZIPS)
$(hide) $(AAPT2) compile -o $@ --dir $@.contents $(PRIVATE_AAPT2_CFLAGS)
endef
# Set up rule to compile one resource file with aapt2.
# Must be called with $(eval).
# $(1): the source file
# $(2): the output file
define aapt2-compile-one-resource-file-rule
$(2) : $(1) $(AAPT2)
@echo "AAPT2 compile $$@ <- $$<"
$$(call aapt2-compile-one-resource-file)
endef
# Convert input resource file path to output file path.
# values-[config]/.xml -> values-[config]_.arsc.flat;
# For other resource file, just replace the last "/" with "_" and
# add .flat extension.
#
# $(1): the input resource file path
# $(2): the base dir of the output file path
# Returns: the compiled output file path
define aapt2-compiled-resource-out-file
$(strip \
$(eval _p_w := $(strip $(subst /,$(space),$(dir $(call clean-path,$(1))))))
$(2)/$(subst $(space),/,$(_p_w))_$(if $(filter values%,$(lastword $(_p_w))),$(patsubst %.xml,%.arsc,$(notdir $(1))),$(notdir $(1))).flat)
endef
define aapt2-link
@mkdir -p $(dir $@)
rm -rf $(PRIVATE_JAVA_GEN_DIR)
mkdir -p $(PRIVATE_JAVA_GEN_DIR)
$(call dump-words-to-file,$(PRIVATE_RES_FLAT),$(dir $@)aapt2-flat-list)
$(call dump-words-to-file,$(PRIVATE_OVERLAY_FLAT),$(dir $@)aapt2-flat-overlay-list)
cat $(PRIVATE_STATIC_LIBRARY_TRANSITIVE_RES_PACKAGES_LISTS) | sort -u | tr '\n' ' ' > $(dir $@)aapt2-transitive-overlay-list
$(hide) $(AAPT2) link -o $@ \
$(PRIVATE_AAPT_FLAGS) \
$(if $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES),$$(cat $(PRIVATE_STATIC_LIBRARY_EXTRA_PACKAGES))) \
$(addprefix --manifest ,$(PRIVATE_ANDROID_MANIFEST)) \
$(addprefix -I ,$(PRIVATE_AAPT_INCLUDES)) \
$(addprefix -I ,$(PRIVATE_SHARED_ANDROID_LIBRARIES)) \
$(addprefix -A ,$(foreach d,$(PRIVATE_ASSET_DIR),$(call clean-path,$(d)))) \
$(addprefix --java ,$(PRIVATE_JAVA_GEN_DIR)) \
$(addprefix --proguard ,$(PRIVATE_PROGUARD_OPTIONS_FILE)) \
$(addprefix --min-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
$(addprefix --target-sdk-version ,$(PRIVATE_DEFAULT_APP_TARGET_SDK)) \
$(if $(filter --product,$(PRIVATE_AAPT_FLAGS)),,$(addprefix --product ,$(PRIVATE_TARGET_AAPT_CHARACTERISTICS))) \
$(addprefix -c ,$(PRIVATE_PRODUCT_AAPT_CONFIG)) \
$(addprefix --preferred-density ,$(PRIVATE_PRODUCT_AAPT_PREF_CONFIG)) \
$(if $(filter --version-code,$(PRIVATE_AAPT_FLAGS)),,--version-code $(PLATFORM_SDK_VERSION)) \
$(if $(filter --version-name,$(PRIVATE_AAPT_FLAGS)),,--version-name $(APPS_DEFAULT_VERSION_NAME)) \
$(addprefix --rename-manifest-package ,$(PRIVATE_MANIFEST_PACKAGE_NAME)) \
$(addprefix --rename-instrumentation-target-package ,$(PRIVATE_MANIFEST_INSTRUMENTATION_FOR)) \
-R \@$(dir $@)aapt2-flat-overlay-list \
-R \@$(dir $@)aapt2-transitive-overlay-list \
\@$(dir $@)aapt2-flat-list
$(SOONG_ZIP) -o $(PRIVATE_SRCJAR) -C $(PRIVATE_JAVA_GEN_DIR) -D $(PRIVATE_JAVA_GEN_DIR)
$(EXTRACT_JAR_PACKAGES) -i $(PRIVATE_SRCJAR) -o $(PRIVATE_AAPT_EXTRA_PACKAGES) --prefix '--extra-packages '
endef
define _create-default-manifest-file
$(1):
rm -f $1
(echo '' && \
echo ' ' && \
echo '' ) > $1
endef
define create-default-manifest-file
$(eval $(call _create-default-manifest-file,$(1),$(2)))
endef
###########################################################
xlint_unchecked := -Xlint:unchecked
# emit-line, ,