赞
踩
Android.bp是安卓系统,Soong构建系统使用的配置文件。具体描述可以查看官方描述;
关于Soong也可以看下这篇网上的文章;
这里关于Android.bp文件的说明谷歌官方给出参考,仅用于快速查看,没有进行翻译,详细可以查看对应的参考文档;
如下为android-13.0.0_r3中packages/apps/WallpaperPicker2/Android.bp的文件内容
// // Build rule for WallpaperPicker2 dependencies lib. // package { default_applicable_licenses: ["Android-Apache-2.0"], } android_library { name: "wallpaper-common-deps", static_libs: [ "androidx.appcompat_appcompat", "androidx.cardview_cardview", "androidx-constraintlayout_constraintlayout", "androidx.exifinterface_exifinterface", "androidx.lifecycle_lifecycle-runtime-ktx", "androidx.recyclerview_recyclerview", "androidx.slice_slice-view", "androidx.viewpager2_viewpager2", "com.google.android.material_material", "glide-prebuilt", "glide-gifdecoder-prebuilt", "glide-disklrucache-prebuilt", "kotlinx-coroutines-android", "kotlinx-coroutines-core", "libbackup", "SettingsLibCollapsingToolbarBaseActivity", "subsampling-scale-image-view", "SystemUISharedLib", "volley", "SettingsLibActivityEmbedding", ], resource_dirs: ["res"], optimize: { enabled: false, }, kotlincflags: ["-Xjvm-default=enable"], sdk_version: "current", manifest: "AndroidManifest-empty.xml", visibility: [ ":__subpackages__", "//packages/apps/ThemePicker", "//vendor:__subpackages__", ], } filegroup { name: "WallpaperPicker2_srcs", srcs: [ "src/**/*.java", "src/**/*.kt", ], } genrule { name: "WallpaperPicker2_res", tools: ["soong_zip"], srcs: [ "res/**/*" ], out: ["wallpaperpicker2_res.zip"], cmd: "INPUTS=($(in)) && " + "RES_DIR=$$(dirname $$(dirname $${INPUTS[0]})) && " + "$(location soong_zip) -o $(out) -C $$RES_DIR -D $$RES_DIR" } filegroup { name: "WallpaperPicker2_Manifest", srcs: [ "AndroidManifest.xml", ], } java_defaults { name: "WallpaperPicker2_defaults", static_libs: [ "renderscript_toolkit", "wallpaper-common-deps", ], jni_libs: [ "librenderscript-toolkit", ], srcs: [ ":WallpaperPicker2_srcs", "src_override/**/*.java", "src_override/**/*.kt", ], resource_zips: [":WallpaperPicker2_res"], certificate: "", optimize: { enabled: false, }, kotlincflags: ["-Xjvm-default=enable"], privileged: true, system_ext_specific: true, use_embedded_native_libs: true, manifest: "AndroidManifest.xml", } // // Build app code. // android_app { name: "WallpaperPicker2", defaults: ["WallpaperPicker2_defaults"], platform_apis: true, }
按照上面文件的描述,android_app表示会生成一个apk文件;
如下为Android.bp文件的一些配置项:
name, srcs, exclude_srcs, defaults, aapt_include_all_resources, aaptflags, additional_certificates, additional_manifests, aidl, apex_available, arch, asset_dirs, bazel_module, certificate, common_srcs, compile_dex, compile_multilib, debug_ramdisk, device_specific, dex_preopt, dist, dists, dont_merge_manifests, dxflags, embed_notices, enabled, enforce_default_target_sdk_version, enforce_uses_libs, errorprone, exclude_java_resource_dirs, exclude_java_resources, exclude_kotlinc_generated_files, exclude_static_libs, exclude_uses_libs, export_package_resources, exported_plugins, generated_srcjars, hidden_api, hiddenapi_additional_annotations, host_required, hostdex, include_srcs, init_rc, installable, jacoco, jarjar_rules, java_resource_dirs, java_resources, java_version, javac_shard_size, javacflags, jni_libs, jni_uses_platform_apis, jni_uses_sdk_apis, kotlincflags, libs, licenses, lineage, lint, logging_parent, main_dex_rules, manifest, max_sdk_version, min_sdk_version, multilib, native_bridge_supported, openjdk9, optimize, optional_uses_libs, overrides, owner, package_name, package_splits, patch_module, permitted_packages, platform_apis, plugins, privapp_allowlist, privileged, product_specific, product_variables.always_use_prebuilt_sdks, product_variables.arc, product_variables.build_from_text_stub, product_variables.debuggable, product_variables.eng, product_variables.malloc_not_svelte, product_variables.native_coverage, product_variables.pdk, product_variables.platform_sdk_version_or_codename, product_variables.unbundled_build, proprietary, proto, provides_uses_lib, ramdisk, recovery, rename_resources_package, replace_max_sdk_version_placeholder, required, resource_dirs, resource_zips, rotationMinSdkVersion, sdk_version, services, soc_specific, static_kotlin_stdlib, static_libs, stem, stl, system_ext_specific, system_modules, target, target.android, target.host, target.hostdex, target_required, target_sdk_version, uncompress_dex, updatable, use_embedded_dex, use_embedded_native_libs, use_tools_jar, uses_libs, v4_signature, vendor, vendor_ramdisk, vintf_fragments, visibility
如下为各个配置项的说明:
name string, The name of the module. Must be unique across all modules.
srcs list of string, list of source files used to compile the Java module. May be .java, .kt, .logtags, .proto, or .aidl files.
exclude_srcs list of string, list of source files that should not be used to build the Java module. This is most useful in the arch/multilib variants to remove non-common files
defaults list of string
aapt_include_all_resources bool, include all resource configurations, not just the product-configured ones.
aaptflags list of string, flags passed to aapt when creating the apk
additional_certificates list of string, Names of extra android_app_certificate modules to sign the apk with in the form “:module”.
additional_manifests list of string, paths to additional manifest files to merge with main manifest.
⊕aidl
apex_available list of string, Availability of this module in APEXes. Only the listed APEXes can contain this module. If the module has stubs then other APEXes and the platform may access it through them (subject to visibility). “//apex_available:anyapex” is a pseudo APEX name that matches to any APEX. “//apex_available:platform” refers to non-APEX partitions like “system.img”. “com.android.gki.*” matches any APEX module name with the prefix “com.android.gki.”. Default is [“//apex_available:platform”].
arch interface
asset_dirs list of string, list of directories relative to the Blueprints file containing assets. Defaults to [“assets”] if a directory called assets exists. Set to [] to disable the default.
⊕bazel_module BazelModuleProperties
certificate string, The name of a certificate in the default certificate directory, blank to use the default product certificate, or an android_app_certificate module name in the form “:module”.
common_srcs list of string, list Kotlin of source files containing Kotlin code that should be treated as common code in a codebase that supports Kotlin multiplatform. See https://kotlinlang.org/docs/reference/multiplatform.html. May be only be .kt files.
compile_dex bool, If set to true, compile dex regardless of installable. Defaults to false.
compile_multilib string, control whether this module compiles for 32-bit, 64-bit, or both. Possible values are “32” (compile for 32-bit only), “64” (compile for 64-bit only), “both” (compile for both architectures), or “first” (compile for 64-bit on a 64-bit platform, and 32-bit on a 32-bit platform).
debug_ramdisk bool, Whether this module is installed to debug ramdisk
device_specific bool, whether this module is specific to a device, not only for SoC, but also for off-chip peripherals. When set to true, it is installed into /odm (or /vendor/odm if odm partition does not exist, or /system/vendor/odm if both odm and vendor partitions do not exist). This implies soc_specific:true
.
⊕dex_preopt
⊕dist Dist
dists list of Dist, a list of configurations to distribute output files from this module to the distribution directory (default: $OUT/dist, configurable with $DIST_DIR)
dont_merge_manifests bool, do not include AndroidManifest from dependent libraries
dxflags list of string, list of module-specific flags that will be used for dex compiles
embed_notices bool, If set, find and merge all NOTICE files that this module and its dependencies have and store it in the APK as an asset.
enabled bool, emit build rules for this module Disabling a module should only be done for those modules that cannot be built in the current environment. Modules that can build in the current environment but are not usually required (e.g. superceded by a prebuilt) should not be disabled as that will prevent them from being built by the checkbuild target and so prevent early detection of changes that have broken those modules.
enforce_default_target_sdk_version bool, It can be set to test the behaviour of default target sdk version. Only required when updatable: false. It is an error if updatable: true and this is false.
enforce_uses_libs bool, If true, the list of uses_libs and optional_uses_libs modules must match the AndroidManifest.xml file. Defaults to true if either uses_libs or optional_uses_libs is set. Will unconditionally default to true in the future.
⊕errorprone
exclude_java_resource_dirs list of string, list of directories that should be excluded from java_resource_dirs
exclude_java_resources list of string, list of files that should be excluded from java_resources and java_resource_dirs
exclude_kotlinc_generated_files bool, Exclude kotlinc generate files: *.kotlin_module, *.kotlin_builtins. Defaults to false.
exclude_static_libs list of string, list of java libraries that should not be used to build this module
exclude_uses_libs list of string, A list of shared library names to exclude from the classpath of the APK. Adding a library here will prevent it from being used when precompiling the APK and prevent it from being implicitly added to the APK’s manifest’s elements. Care must be taken when using this as it could result in runtime errors if the APK actually uses classes provided by the library and which are not provided in any other way. This is primarily intended for use by various CTS tests that check the runtime handling of the android.test.base shared library (and related libraries) but which depend on some common libraries that depend on the android.test.base library. Without this those tests will end up with a in their manifest which would either render the tests worthless (as they would be testing the wrong behavior), or would break the test altogether by providing access to classes that the tests were not expecting. Those tests provide the android.test.base statically and use jarjar to rename them so they do not collide with the classes provided by the android.test.base library.
export_package_resources bool, If set, create package-export.apk, which other packages can use to get PRODUCT-agnostic resource data like IDs and type definitions.
exported_plugins list of string, List of modules to export to libraries that directly depend on this library as annotation processors. Note that if the plugins set generates_api: true this will disable the turbine optimization on modules that depend on this module, which will reduce parallelism and cause more recompilation.
generated_srcjars list of *ast.SelectorExpr, Additional srcJars tacked in by GeneratedJavaLibraryModule
⊕hidden_api
hiddenapi_additional_annotations list of string, A list of java_library instances that provide additional hiddenapi annotations for the library.
host_required list of string, names of other modules to install on host if this module is installed
hostdex bool, If true, export a copy of the module as a -hostdex module for host testing.
include_srcs bool, If set to true, include sources used to compile the module in to the final jar
init_rc list of string, init.rc files to be installed if this module is installed
installable bool, If set to true, allow this module to be dexed and installed on devices. Has no effect on host modules, which are always considered installable. Default: true
⊕jacoco
jarjar_rules string, if not blank, run jarjar using the specified rules file
java_resource_dirs list of string, list of directories containing Java resources
java_resources list of string, list of files to use as Java resources
java_version string, If not blank, set the java version passed to javac as -source and -target
javac_shard_size int64, The number of Java source entries each Javac instance can process
javacflags list of string, list of module-specific flags that will be used for javac compiles
jni_libs list of string, list of native libraries that will be provided in or alongside the resulting jar
jni_uses_platform_apis bool, if true, use JNI libraries that link against platform APIs even if this module sets sdk_version.
jni_uses_sdk_apis bool, if true, use JNI libraries that link against SDK APIs even if this module does not set sdk_version.
kotlincflags list of string, list of module-specific flags that will be used for kotlinc compiles
libs list of string, list of java libraries that will be in the classpath
licenses list of string, Describes the licenses applicable to this module. Must reference license modules.
lineage string, Name of the signing certificate lineage file or filegroup module.
⊕lint
logging_parent string, the logging parent of this app.
main_dex_rules list of string, A list of files containing rules that specify the classes to keep in the main dex file.
manifest string, manifest file to be included in resulting jar
max_sdk_version string, if not blank, set the maximum version of the sdk that the compiled artifacts will run against. Defaults to empty string “”. See sdk_version for possible values.
min_sdk_version string, if not blank, set the minimum version of the sdk that the compiled artifacts will run against. Defaults to sdk_version if not set. See sdk_version for possible values.
multilib interface
native_bridge_supported bool, Whether this module is built for non-native architectures (also known as native bridge binary)
⊕openjdk9
⊕optimize
optional_uses_libs list of string, A list of shared library modules that will be listed in uses-library tags in the AndroidManifest.xml file with required=false.
overrides list of string, Names of modules to be overridden. Listed modules can only be other binaries (in Make or Soong). This does not completely prevent installation of the overridden binaries, but if both binaries would be installed by default (in PRODUCT_PACKAGES) the other binary will be removed from PRODUCT_PACKAGES.
owner string, vendor who owns this module
package_name string, the package name of this app. The package name in the manifest file is used if one was not given.
package_splits list of string, list of resource labels to generate individual resource packages
patch_module string, When compiling language level 9+ .java code in packages that are part of a system module, patch_module names the module that your sources and dependencies should be patched into. The Android runtime currently 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.
permitted_packages list of string, If not empty, classes are restricted to the specified packages and their sub-packages. This restriction is checked after applying jarjar rules and including static libs.
platform_apis bool, Whether to compile against the platform APIs instead of an SDK. If true, then sdk_version must be empty. The value of this field is ignored when module’s type isn’t android_app, android_test, or android_test_helper_app.
plugins list of string, List of modules to use as annotation processors
privapp_allowlist string, Specifies the file that contains the allowlist for this app.
privileged bool, Specifies that this app should be installed to the priv-app directory, where the system will grant it additional privileges not available to normal apps.
product_specific bool, whether this module is specific to a software configuration of a product (e.g. country, network operator, etc). When set to true, it is installed into /product (or /system/product if product partition does not exist).
⊕product_variables.always_use_prebuilt_sdks
⊕product_variables.arc
⊕product_variables.build_from_text_stub
⊕product_variables.debuggable
⊕product_variables.eng
⊕product_variables.malloc_not_svelte
⊕product_variables.native_coverage
⊕product_variables.pdk
⊕product_variables.platform_sdk_version_or_codename
⊕product_variables.unbundled_build
proprietary bool, whether this is a proprietary vendor module, and should be installed into /vendor
⊕proto
provides_uses_lib string, Optional name of the provided by this module. This is needed for non-SDK libraries, because SDK ones are automatically picked up by Soong. The name normally is the same as the module name, but there are exceptions.
ramdisk bool, Whether this module is installed to ramdisk
recovery bool, Whether this module is installed to recovery partition
rename_resources_package bool, Whether to rename the package in resources to the override name rather than the base name. Defaults to true.
replace_max_sdk_version_placeholder string, if not blank, set the maxSdkVersion properties of permission and uses-permission tags. Defaults to empty string “”. See sdk_version for possible values.
required list of string, names of other modules to install if this module is installed
resource_dirs list of string, list of directories relative to the Blueprints file containing Android resources. Defaults to [“res”] if a directory called res exists. Set to [] to disable the default.
resource_zips list of string, list of zip files containing Android resources.
rotationMinSdkVersion string, For overriding the --rotation-min-sdk-version property of apksig
sdk_version string, If not blank, set to the version of the sdk to compile against. Defaults to an empty string, which compiles the module against the private platform APIs. Values are of one of the following forms: 1) numerical API level, “current”, “none”, or “core_platform” 2) An SDK kind with an API level: “_” See build/soong/android/sdk_version.go for the complete and up to date list of SDK kinds. If the SDK kind is empty, it will be set to public.
services list of string, List of files to include in the META-INF/services folder of the resulting jar.
soc_specific bool, whether this module is specific to an SoC (System-On-a-Chip). When set to true, it is installed into /vendor (or /system/vendor if vendor partition does not exist).
static_kotlin_stdlib bool, If true, package the kotlin stdlib into the jar. Defaults to true.
static_libs list of string, list of java libraries that will be compiled into the resulting jar
stem string, set the name of the output. If not set, name
is used. To override a module with this property set, overriding module might need to set this as well. Otherwise, both the overridden and the overriding modules will have the same output name, which can cause the duplicate output error.
stl string, STL library to use for JNI libraries.
system_ext_specific bool, whether this module extends system. When set to true, it is installed into /system_ext (or /system/system_ext if system_ext partition does not exist).
system_modules string, When targeting 1.9 and above, override the modules to use with --system, otherwise provides defaults libraries to add to the bootclasspath.
target interface
⊕target.android
⊕target.host
⊕target.hostdex
target_required list of string, names of other modules to install on target if this module is installed
target_sdk_version string, if not blank, set the targetSdkVersion in the AndroidManifest.xml. Defaults to sdk_version if not set. See sdk_version for possible values.
uncompress_dex bool, Keep the data uncompressed. We always need uncompressed dex for execution, so this might actually save space by avoiding storing the same data twice. This defaults to reasonable value based on module and should not be set. It exists only to support ART tests.
updatable bool, Whether this app is considered mainline updatable or not. When set to true, this will enforce additional rules to make sure an app can safely be updated. Default is false. Prefer using other specific properties if build behaviour must be changed; avoid using this flag for anything but neverallow rules (unless the behaviour change is invisible to owners).
use_embedded_dex bool, Store dex files uncompressed in the APK and set the android:useEmbeddedDex=“true” manifest attribute so that they are used from inside the APK at runtime.
use_embedded_native_libs bool, Store native libraries uncompressed in the APK and set the android:extractNativeLibs=“false” manifest flag so that they are used from inside the APK at runtime. Defaults to true for android_test modules unless sdk_version or min_sdk_version is set to a version that doesn’t support it (<23), defaults to true for android_app modules that are embedded to APEXes, defaults to false for other module types where the native libraries are generally preinstalled outside the APK.
use_tools_jar bool, Add host jdk tools.jar to bootclasspath
uses_libs list of string, A list of shared library modules that will be listed in uses-library tags in the AndroidManifest.xml file.
v4_signature bool, If true, generate the signature file of APK Signing Scheme V4, along side the signed APK file. Defaults to false.
vendor bool, whether this module is specific to an SoC (System-On-a-Chip). When set to true, it is installed into /vendor (or /system/vendor if vendor partition does not exist). Use soc_specific
instead for better meaning.
vendor_ramdisk bool, Whether this module is installed to vendor ramdisk
vintf_fragments list of string, VINTF manifest fragments to be installed if this module is installed
visibility list of string, Controls the visibility of this module to other modules. Allowable values are one or more of these formats:
[“//visibility:public”]: Anyone can use this module.
[“//visibility:private”]: Only rules in the module’s package (not its subpackages) can use
this module.
[“//visibility:override”]: Discards any rules inherited from defaults or a creating module.
Can only be used at the beginning of a list of visibility rules.
[“//some/package:pkg”, “//other/package:pkg”]: Only modules in some/package and
other/package (defined in some/package/.bp and other/package/.bp) have access to
this module. Note that sub-packages do not have access to the rule; for example,
//some/package/foo:bar or //other/package/testing:bla wouldn’t have access. pkg
is a special module and must be used verbatim. It represents all of the modules in the
package.
[“//project:subpackages”, “//other:subpackages”]: Only modules in packages project
or other or in one of their sub-packages have access to this module. For example,
//project:rule, //project/library:lib or //other/testing/internal:munge are allowed
to depend on this rule (but not //independent:evil)
[“//project”]: This is shorthand for [“//project:pkg”]
[“:subpackages”]: This is shorthand for [“//project:subpackages”] where
//project is the module’s package. e.g. using [“:subpackages”] in
packages/apps/Settings/Android.bp is equivalent to
//packages/apps/Settings:subpackages.
[“//visibility:legacy_public”]: The default visibility, behaves as //visibility:public
for now. It is an error if it is used in a module.
If a module does not specify the visibility
property then it uses the default_visibility
property of the package
module in the module’s package. If the default_visibility
property is not set for the module’s package then it will use the default_visibility
of its closest ancestor package for which a default_visibility
property is specified. If no default_visibility
property can be found then the module uses the global default of //visibility:legacy_public
. The visibility
property has no effect on a defaults module although it does apply to any non-defaults module that uses it. To set the visibility of a defaults module, use the defaults_visibility
property on the defaults module; not to be confused with the default_visibility
property on the package module. See https://android.googlesource.com/platform/build/soong/+/master/README.md#visibility for more details.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。