Rules
These rules are available as standard in Buck2.
alias
def alias(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
actual: str,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
) -> None
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
android_aar
def android_aar(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_cxx_toolchain: str = ...,
_is_building_android_binary: bool = ...,
_is_force_single_cpu: bool = ...,
_is_force_single_default_cpu: bool = ...,
_java_toolchain: str = ...,
abi_generation_mode: None | str = ...,
annotation_processing_tool: None | str = ...,
annotation_processor_deps: list[str] = ...,
annotation_processor_params: list[str] = ...,
annotation_processors: list[str] = ...,
build_config_values: list[str] = ...,
build_config_values_file: None | str = ...,
compress_asset_libraries: bool = ...,
contacts: list[str] = ...,
cpu_filters: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
enable_relinker: bool = ...,
excluded_java_deps: list[str] = ...,
extra_arguments: list[str] = ...,
extra_kotlinc_arguments: list[str] = ...,
friend_paths: list[str] = ...,
include_build_config_class: bool = ...,
java_version: None | str = ...,
javac: None | str = ...,
labels: list[str] = ...,
language: None | str = ...,
licenses: list[str] = ...,
manifest: None | str = ...,
manifest_entries: dict[str, typing.Any] = ...,
manifest_file: None | str = ...,
manifest_skeleton: str,
maven_coords: None | str = ...,
min_sdk_version: None | int = ...,
native_library_merge_code_generator: None | str = ...,
native_library_merge_glue: None | str = ...,
native_library_merge_linker_args: None | dict[str, list[str]] = ...,
native_library_merge_map: None | dict[str, list[str]] = ...,
native_library_merge_non_asset_libs: bool = ...,
native_library_merge_sequence: None | list = ...,
native_library_merge_sequence_blocklist: None | list[str] = ...,
never_mark_as_unused_dependency: None | bool = ...,
on_unused_dependencies: None | str = ...,
package_asset_libraries: bool = ...,
package_resources: bool = ...,
plugins: list[str | (str, list[str])] = ...,
proguard_config: None | str = ...,
relinker_extra_deps: list[str] = ...,
relinker_whitelist: list[str] = ...,
remove_classes: list[str] = ...,
required_for_source_only_abi: bool = ...,
resource_union_package: None | str = ...,
resources: list[str] = ...,
resources_root: None | str = ...,
runtime_deps: list[str] = ...,
source: None | str = ...,
source_abi_verification_mode: None | str = ...,
source_only_abi_deps: list[str] = ...,
srcs: list[str] = ...,
strip_libraries: bool = ...,
target: None | str = ...,
use_jvm_abi_gen: None | bool = ...,
) -> None
An android_aar()
rule is used to generate an Android AAR.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this targetbuild_config_values
: See the documentation on the values argument forandroid_build_config()
.include_build_config_class
: Whether to include theBuildConfig
class files in the final .aar file. Needs to be set toTrue
if any build_config_values are specified. This is normally only needed if the build tool that is consuming the .aar file does not generateBuildConfig
classes. Note: the AAR format does not specify a way to pass defaults that should be injected into the finalBuildConfig
class, therefore that information might need to be replicated manually in the build that's consuming the .aar file.javac
: Specifies the Java compiler program to use for this rule. The value is a source path or an execution dep (e.g., //foo/bar:bar). Overrides the value in "javac" in the "tools" section of.buckconfig
.manifest_skeleton
: The skeleton manifest file used to generate the finalAndroidManifest.xml
. May either be a file or anandroid_manifest()
target.remove_classes
: List of classes to remove from the output aar. It removes classes from the target's own sources, and its dependencies.
Details
See the official Android documentation for details about the .aar
format.
Examples:
android_resource(
name = 'res',
res = 'res',
assets = 'assets',
package = 'com.example',
)
android_library(
name = 'lib',
srcs = glob(['**/*.java']),
)
android_aar(
name = 'app',
manifest_skeleton = 'AndroidManifestSkeleton.xml',
deps = [
':res',
':lib',
],
)
android_app_modularity
def android_app_modularity(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_build_only_native_code: bool = ...,
application_module_blocklist: None | list[str] = ...,
application_module_configs: dict[str, list[str]] = ...,
application_module_dependencies: None | dict[str, list[str]] = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
no_dx: list[str] = ...,
should_include_classes: bool = ...,
should_include_libraries: bool = ...,
) -> None
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
android_binary
def android_binary(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_cxx_toolchain: str = ...,
_dex_toolchain: str = ...,
_exec_os_type: str = ...,
_is_building_android_binary: bool = ...,
_is_force_single_cpu: bool = ...,
_is_force_single_default_cpu: bool = ...,
_java_toolchain: str = ...,
aapt2_keep_raw_values: bool = ...,
aapt2_locale_filtering: bool = ...,
aapt2_preferred_density: None | str = ...,
additional_aapt_params: list[str] = ...,
allow_r_dot_java_in_secondary_dex: bool = ...,
allowed_duplicate_resource_types: list[str] = ...,
android_sdk_proguard_config: None | str = ...,
application_module_blocklist: None | list[str] = ...,
application_module_configs: dict[str, list[str]] = ...,
application_module_dependencies: None | dict[str, list[str]] = ...,
asset_compression_algorithm: None | str = ...,
banned_duplicate_resource_types: list[str] = ...,
build_config_values: list[str] = ...,
build_config_values_file: None | str = ...,
build_string_source_map: bool = ...,
compress_asset_libraries: bool = ...,
constraint_overrides: list[str] = ...,
contacts: list[str] = ...,
cpu_filters: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
dex_compression: None | str = ...,
dex_group_lib_limit: int = ...,
disable_pre_dex: bool = ...,
duplicate_resource_behavior: str = ...,
duplicate_resource_whitelist: None | str = ...,
enable_bootstrap_dexes: bool = ...,
enable_relinker: bool = ...,
exopackage_modes: list[str] = ...,
extra_filtered_resources: list[str] = ...,
extra_no_compress_asset_extensions: list[str] = ...,
field_ref_count_buffer_space: int = ...,
ignore_aapt_proguard_config: bool = ...,
includes_vector_drawables: bool = ...,
is_cacheable: bool = ...,
is_voltron_language_pack_enabled: bool = ...,
keystore: str,
labels: list[str] = ...,
licenses: list[str] = ...,
linear_alloc_hard_limit: int = ...,
locales: list[str] = ...,
manifest: None | str = ...,
manifest_entries: dict[str, typing.Any] = ...,
manifest_skeleton: None | str = ...,
method_ref_count_buffer_space: int = ...,
min_sdk_version: None | int = ...,
minimize_primary_dex_size: bool = ...,
module_manifest_skeleton: None | str = ...,
native_library_merge_code_generator: None | str = ...,
native_library_merge_glue: None | str = ...,
native_library_merge_linker_args: None | dict[str, list[str]] = ...,
native_library_merge_map: None | dict[str, list[str]] = ...,
native_library_merge_non_asset_libs: bool = ...,
native_library_merge_sequence: None | list = ...,
native_library_merge_sequence_blocklist: None | list[str] = ...,
no_auto_add_overlay_resources: bool = ...,
no_auto_version_resources: bool = ...,
no_dx: list[str] = ...,
no_version_transitions_resources: bool = ...,
optimization_passes: int = ...,
package_asset_libraries: bool = ...,
package_type: str = ...,
packaged_locales: list[str] = ...,
packaging_options: dict[str, list[str]] = ...,
platform_override: None | str = ...,
post_filter_resources_cmd: None | str = ...,
preprocess_java_classes_bash: None | str = ...,
preprocess_java_classes_cmd: None | str = ...,
preprocess_java_classes_deps: list[str] = ...,
primary_dex_patterns: list[str] = ...,
proguard_config: None | str = ...,
proguard_jvm_args: list[str] = ...,
relinker_extra_deps: list[str] = ...,
relinker_whitelist: list[str] = ...,
resource_compression: str = ...,
resource_filter: list[str] = ...,
resource_stable_ids: None | str = ...,
resource_union_package: None | str = ...,
secondary_dex_weight_limit: None | int = ...,
skip_crunch_pngs: None | bool = ...,
skip_proguard: bool = ...,
strip_libraries: bool = ...,
trim_resource_ids: bool = ...,
use_split_dex: bool = ...,
validation_deps: list[str] = ...,
xz_compression_level: int = ...,
) -> None
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
android_build_config
def android_build_config(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_build_only_native_code: bool = ...,
_is_building_android_binary: bool = ...,
_java_toolchain: str = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
package: str = ...,
values: list[str] = ...,
values_file: None | str = ...,
) -> None
An android_build_config()
rule is used to generate a BuildConfig
class with global configuration variables that other android_library()
rules can compile against. Currently, the only variable exposed by BuildConfig
is a global boolean
named DEBUG
, much like the BuildConfig.java
generated by the official Android build tools based on Gradle.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
package
: Name of the Java package to use in the generatedBuildConfig.java
file. Most developers set this to the application id declared in the manifest via<manifest package="APP_ID">
. Example:com.facebook.orca
. -
values
: List of strings that defines additional fields (and values) that should be declared in the generatedBuildConfig.java
file. LikeDEBUG
, the values will be non-constant-expressions that evaluate to the value specified in the file at compilation time. To override the values in an APK, specify build_config_values or build_config_values_file inandroid_binary()
. -
values_file
: Optional path to a file that defines additional fields (and values) that should be declared in the generatedBuildConfig.java
file. LikeDEBUG
, the values will be non-constant-expressions that evaluate to the value specified in the file at compilation time. To override the values in an APK, specify build_config_values or build_config_values_file inandroid_binary()
.Note that values_file can be a generated file, as can build_config_values_file as demonstrated in the example below.
Details
The fields in the generated BuildConfig
class will
be non-constant-expressions (see JLS 15.28).
However, if BuildConfig
is packaged into an APK, it will
be replaced with a new version where:
- The fields will be set to literal values (i.e., constant expressions).
- The
boolean BuildConfig.DEBUG
field will correspond to that of thepackage_type
argument to theandroid_binary()
rule that is packaging it.
This transformation is done before ProGuard is applied (if applicable), so
that it can propagate constants from BuildConfig
and eliminate
dead code.
Examples:
Here is an example of an android_build_config()
rule that
is transitively included by both debug and release versions
of an android_binary()
rule. The value
of com.example.pkg.BuildConfig.DEBUG
will be different in each APK
even though they both transitively depend on the same :build_config
rule.
android_build_config(
name = 'build_config',
package = 'com.example.pkg',
values = [
'String COMMIT_ID = "0000000000000000000000000000000000000000"',
],
)
# The .java files in this library may contain references to the boolean
# com.example.pkg.BuildConfig.DEBUG because :build_config is in the deps.
# It could also reference BuildConfig.COMMIT_ID.
android_library(
name = 'mylib',
srcs = glob(['src/**/*.java']),
deps = [
':build_config',
],
)
android_binary(
name = 'debug',
package_type = 'DEBUG',
keystore = '//keystores:debug',
manifest = 'AndroidManifest.xml',
target = 'Google Inc.:Google APIs:19',
deps = [
':mylib',
],
)
# The contents of the file generated by this rule might be:
#
# String COMMIT_ID = "7bf804bdf71fdbfc99cce3b155b3643f022c6fa4"
#
# Note that the output of :build_config_release_values will be cached by Buck.
# Assuming that generate_release_build_config.py depends on state that is not
# expressed by its deps (which violates a fundamental invariant in Buck!), a
# workaround is to ensure that the inputs to :build_config_release_values are
# changed in some way before :release is built to ensure that the output from
# :build_config_release_values is not pulled from cache. For example:
#
# $ buck build :release
# $ uuidgen > dummy_state_file.txt
# $ buck build :release
#
# This makes sure that generate_release_build_config.py is re-run before
# :release is rebuilt. This is much cheaper than deleting your build cache
# before rebuilding.
genrule(
name = 'build_config_release_values',
srcs = [ 'generate_release_build_config.py', 'dummy_state_file.txt' ],
bash = 'generate_release_build_config.py $OUT',
out = 'build_config_release_values.txt',
)
android_binary(
name = 'release',
package_type = 'RELEASE',
keystore = '//keystores:release',
manifest = 'AndroidManifest.xml',
target = 'Google Inc.:Google APIs:19',
build_config_values_file = ':build_config_release_values',
deps = [
':mylib',
],
)
android_bundle
def android_bundle(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_cxx_toolchain: str = ...,
_dex_toolchain: str = ...,
_exec_os_type: str = ...,
_is_building_android_binary: bool = ...,
_is_force_single_cpu: bool = ...,
_is_force_single_default_cpu: bool = ...,
_java_toolchain: str = ...,
aapt2_keep_raw_values: bool = ...,
aapt2_locale_filtering: bool = ...,
aapt2_preferred_density: None | str = ...,
additional_aapt_params: list[str] = ...,
allow_r_dot_java_in_secondary_dex: bool = ...,
allowed_duplicate_resource_types: list[str] = ...,
android_sdk_proguard_config: None | str = ...,
application_module_blocklist: None | list[str] = ...,
application_module_configs: dict[str, list[str]] = ...,
application_module_dependencies: None | dict[str, list[str]] = ...,
asset_compression_algorithm: None | str = ...,
banned_duplicate_resource_types: list[str] = ...,
build_config_values: list[str] = ...,
build_config_values_file: None | str = ...,
build_string_source_map: bool = ...,
bundle_config_file: None | str = ...,
compress_asset_libraries: bool = ...,
contacts: list[str] = ...,
cpu_filters: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
dex_compression: None | str = ...,
dex_group_lib_limit: int = ...,
disable_pre_dex: bool = ...,
duplicate_resource_behavior: str = ...,
duplicate_resource_whitelist: None | str = ...,
enable_bootstrap_dexes: bool = ...,
enable_relinker: bool = ...,
exopackage_modes: list[str] = ...,
extra_filtered_resources: list[str] = ...,
extra_no_compress_asset_extensions: list[str] = ...,
field_ref_count_buffer_space: int = ...,
ignore_aapt_proguard_config: bool = ...,
includes_vector_drawables: bool = ...,
is_cacheable: bool = ...,
is_voltron_language_pack_enabled: bool = ...,
keystore: str,
labels: list[str] = ...,
licenses: list[str] = ...,
linear_alloc_hard_limit: int = ...,
locales: list[str] = ...,
manifest: None | str = ...,
manifest_entries: dict[str, typing.Any] = ...,
manifest_skeleton: None | str = ...,
method_ref_count_buffer_space: int = ...,
min_sdk_version: None | int = ...,
minimize_primary_dex_size: bool = ...,
module_manifest_skeleton: None | str = ...,
native_library_merge_code_generator: None | str = ...,
native_library_merge_glue: None | str = ...,
native_library_merge_linker_args: None | dict[str, list[str]] = ...,
native_library_merge_map: None | dict[str, list[str]] = ...,
native_library_merge_non_asset_libs: bool = ...,
native_library_merge_sequence: None | list = ...,
native_library_merge_sequence_blocklist: None | list[str] = ...,
no_auto_add_overlay_resources: bool = ...,
no_auto_version_resources: bool = ...,
no_dx: list[str] = ...,
no_version_transitions_resources: bool = ...,
optimization_passes: int = ...,
package_asset_libraries: bool = ...,
package_type: str = ...,
packaged_locales: list[str] = ...,
packaging_options: dict[str, list[str]] = ...,
post_filter_resources_cmd: None | str = ...,
preprocess_java_classes_bash: None | str = ...,
preprocess_java_classes_cmd: None | str = ...,
preprocess_java_classes_deps: list[str] = ...,
primary_dex_patterns: list[str] = ...,
proguard_config: None | str = ...,
proguard_jvm_args: list[str] = ...,
relinker_extra_deps: list[str] = ...,
relinker_whitelist: list[str] = ...,
resource_compression: str = ...,
resource_filter: list[str] = ...,
resource_stable_ids: None | str = ...,
resource_union_package: None | str = ...,
secondary_dex_weight_limit: None | int = ...,
skip_crunch_pngs: None | bool = ...,
skip_proguard: bool = ...,
trim_resource_ids: bool = ...,
use_derived_apk: bool = ...,
use_split_dex: bool = ...,
validation_deps: list[str] = ...,
xz_compression_level: int = ...,
) -> None
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
android_instrumentation_apk
def android_instrumentation_apk(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_dex_toolchain: str = ...,
_exec_os_type: str = ...,
_is_building_android_binary: bool = ...,
_is_force_single_cpu: bool = ...,
_is_force_single_default_cpu: bool = ...,
_java_toolchain: str = ...,
apk: str,
contacts: list[str] = ...,
cpu_filters: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
disable_pre_dex: bool = ...,
enable_bootstrap_dexes: bool = ...,
includes_vector_drawables: bool = ...,
is_self_instrumenting: bool = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
manifest: None | str = ...,
manifest_skeleton: None | str = ...,
min_sdk_version: None | int = ...,
native_library_merge_map: None | dict[str, list[str]] = ...,
native_library_merge_sequence: None | list = ...,
preprocess_java_classes_bash: None | str = ...,
preprocess_java_classes_cmd: None | str = ...,
preprocess_java_classes_deps: list[str] = ...,
primary_dex_patterns: list[str] = ...,
use_split_dex: None | bool = ...,
) -> None
An android_instrumentation_apk()
rule is used to generate an Android Instrumentation APK.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
Details
Android's Testing Fundamentals documentation includes a diagram that shows the relationship between an "application package" and a "test package" when running a test. This rule corresponds to a test package. Note that a test package has an interesting quirk where it is compiled against an application package, but must not include the resources or Java classes of the application package. Therefore, this class takes responsibility for making sure the appropriate bits are excluded. Failing to do so will generate mysterious runtime errors when running the test.
Examples:
Here is an example of an android_instrumentation_apk()
rule that tests an android_binary()
, and depends on a test
package.
android_library(
name = 'test',
srcs = glob(['test/**/*.java']),
)
android_binary(
name = 'messenger',
manifest = 'AndroidManifest.xml',
keystore = '//keystores:prod',
package_type = 'release',
proguard_config = 'proguard.cfg',
deps = [
...
],
)
# Building this rule will produce a file named messenger_test.apk
android_instrumentation_apk(
name = 'messenger_test',
manifest = 'AndroidInstrumentationManifest.xml',
apk = ':messenger',
deps = [
':test',
],
)
android_instrumentation_test
def android_instrumentation_test(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_emulators: None | str = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_exec_os_type: str = ...,
_inject_test_env: str = ...,
_java_test_toolchain: str = ...,
_java_toolchain: str = ...,
_test_toolchain: str = ...,
apk: str,
clear_package_data: bool = ...,
collect_tombstones: bool = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
disable_animations: bool = ...,
env: dict[str, str] = ...,
extra_instrumentation_args: None | dict[str, str] = ...,
instrumentation_test_listener: None | str = ...,
instrumentation_test_listener_class: None | str = ...,
is_self_instrumenting: bool = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
log_extractors: dict[str, str] = ...,
re_caps: None | dict[str, dict[str, str]] = ...,
re_use_case: None | dict[str, str] = ...,
record_video: bool = ...,
test_rule_timeout_ms: None | int = ...,
) -> None
An android_instrumentation_test()
rule is used to define apks that should be used to run Android instrumentation tests.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target_android_emulators
: If provided, local resource of "android_emulators" type will be required to run this test locally and this target will be used to manage it. If omitted, local resource of "android_emulators" type will be ignored even if requested by the test runner.apk
: The APK containing the tests. Can be anandroid_binary()
, anapk_genrule()
or anandroid_instrumentation_apk()
.clear_package_data
: Runspm clear
on the app and test packages before the test run if set to True.collect_tombstones
: Checks whether the test generated any tombstones, and downloads them from the emulator if true.disable_animations
: Disables animations on the emulator if set to True.labels
: A list of labels to be applied to these tests. These labels are arbitrary text strings and have no meaning within buck itself. They can, however, have meaning for you as a test author (e.g.,smoke
orfast
). A label can be used to filter or include a specific test rule when executingbuck test
record_video
: Record video of test run and collect it as TRAtest_rule_timeout_ms
: If set specifies the maximum amount of time (in milliseconds) in which all of the tests in this rule should complete. This overrides the defaultrule_timeout
if any has been specified in.buckconfig
.
Details
Examples:
Here is an example of an android_instrumentation_test()
rule that tests an android_binary()
.
android_binary(
name = 'messenger',
manifest = 'AndroidManifest.xml',
keystore = '//keystores:prod',
package_type = 'release',
proguard_config = 'proguard.cfg',
deps = [
...
],
)
android_instrumentation_apk(
name = 'messenger_test',
manifest = 'AndroidInstrumentationManifest.xml',
apk = ':messenger',
deps = [
...
],
)
android_instrumentation_test(
name = 'messenger_instrumentation_test',
apk = ':messenger_test',
)
android_library
def android_library(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_build_only_native_code: bool = ...,
_compose_stability_config: None | str = ...,
_dex_min_sdk_version: None | int = ...,
_dex_toolchain: str = ...,
_exec_os_type: str = ...,
_is_building_android_binary: bool = ...,
_java_toolchain: str = ...,
_kotlin_toolchain: str = ...,
abi_generation_mode: None | str = ...,
android_optional_jars: None | list[str] = ...,
annotation_processing_tool: None | str = ...,
annotation_processor_deps: list[str] = ...,
annotation_processor_params: list[str] = ...,
annotation_processors: list[str] = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
enable_used_classes: bool = ...,
exported_deps: list[str] = ...,
exported_provided_deps: list[str] = ...,
extra_arguments: list[str] = ...,
extra_kotlinc_arguments: list[str] = ...,
friend_paths: list[str] = ...,
incremental: bool = ...,
jar_postprocessor: None | str = ...,
java_version: None | str = ...,
javac: None | str = ...,
k2: bool = ...,
kotlin_compiler_plugins: dict[str, dict[str, str]] = ...,
labels: list[str] = ...,
language: None | str = ...,
licenses: list[str] = ...,
manifest: None | str = ...,
manifest_file: None | str = ...,
maven_coords: None | str = ...,
never_mark_as_unused_dependency: None | bool = ...,
on_unused_dependencies: None | str = ...,
plugins: list[str | (str, list[str])] = ...,
proguard_config: None | str = ...,
provided_deps: list[str] = ...,
provided_deps_query: None | str = ...,
remove_classes: list[str] = ...,
required_for_source_only_abi: bool = ...,
resource_union_package: None | str = ...,
resources: list[str] = ...,
resources_root: None | str = ...,
runtime_deps: list[str] = ...,
source: None | str = ...,
source_abi_verification_mode: None | str = ...,
source_only_abi_deps: list[str] = ...,
srcs: list[str] = ...,
target: None | str = ...,
use_jvm_abi_gen: None | bool = ...,
validation_deps: list[str] = ...,
) -> None
An android_library()
rule is used to define a set of Java files that can be compiled together against the Android SDK. The main output of an android_library()
rule is a single JAR file containing all of the compiled class files and resources.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
annotation_processing_tool
: Specifies the tool to use for annotation processing. Possible values: "kapt" or "javac". "kapt" allows running Java annotation processors against Kotlin sources while backporting it for Java sources too. "javac" works only against Java sources, Kotlin sources won't have access to generated classes at compile time. -
deps
: Rules (usually otherandroid_library
rules) that are used to generate the classpath required to compile thisandroid_library
. -
enable_used_classes
: Deprecated: for an experiment only, will be removed -
exported_deps
: Other rules that depend on this rule will also include itsexported_deps
in their classpaths. This is useful when the public API of a rule has return types or checked exceptions that are defined in another rule, which would otherwise require callers to add an extra dependency. It's also useful for exposing e.g. a collection ofprebuilt_jar
rules as a single target for callers to depend on. Targets inexported_deps
are implicitly included in thedeps
of this rule, so they don't need to be repeated there. -
exported_provided_deps
: This is a combination ofprovided_deps
andexported_deps
. Rules listed in this parameter will be added to classpath of rules that depend on this rule, but they will not be included in a binary if binary depends on a such target. -
extra_arguments
: List of additional arguments to pass into the Java compiler. These arguments follow the ones specified in.buckconfig
. -
extra_kotlinc_arguments
: List of additional arguments to pass into the Kotlin compiler. -
incremental
: Enables Kotlin incremental compilation. -
javac
: Specifies the Java compiler program to use for this rule. The value is a source path or an execution dep (e.g., //foo/bar:bar). Overrides the value in "javac" in the "tools" section of.buckconfig
. -
k2
: Enables the Kotlin K2 compiler. -
kotlin_compiler_plugins
: Use this to specify Kotlin compiler plugins to use when compiling this library. This takes a map, with each entry specify one plugin. Entry's key is plugin source path, and value is a map of plugin option key value pair. Unlikeextra_kotlinc_arguments
, these can be source paths, not just strings.A special option value is
__codegen_dir__
, in which case Buck will provide a default codegen folder's path as option value instead. E.g.fbcode/buck2/prelude/decls/jvm_common.bzl
kotlin_compiler_plugins = {
"somePluginSourcePath": {
"plugin:somePluginId:somePluginOptionKey": "somePluginOptionValue",
"plugin:somePluginId:someDirectoryRelatedOptionKey": "__codegen_dir__",
},
},Each plugin source path will be prefixed with
-Xplugin=
and passed as extra arguments to the compiler. Plugin options will be appended after its plugin with-P
.A specific example is, if you want to use kotlinx.serialization with
kotlin_library()
, you need to specifykotlinx-serialization-compiler-plugin.jar
underkotlin_compiler_plugins
andkotlinx-serialization-runtime.jar
(which you may have to fetch from Maven) in yourdeps
:
kotlin_library(
name = "example",
srcs = glob(["*.kt"]),
deps = [
":kotlinx-serialization-runtime",
],
kotlin_compiler_plugins = {
# Likely copied from your $KOTLIN_HOME directory.
"kotlinx-serialization-compiler-plugin.jar": {},
},
)
prebuilt_jar(
name = "kotlinx-serialization-runtime",
binary_jar = ":kotlinx-serialization-runtime-0.10.0",
)
# Note you probably want to set
# maven_repo=http://jcenter.bintray.com/ in your .buckconfig until
# https://github.com/Kotlin/kotlinx.serialization/issues/64
# is closed.
remote_file(
name = "kotlinx-serialization-runtime-0.10.0",
out = "kotlinx-serialization-runtime-0.10.0.jar",
url = "mvn:org.jetbrains.kotlinx:kotlinx-serialization-runtime:jar:0.10.0",
sha1 = "23d777a5282c1957c7ce35946374fff0adab114c"
) -
manifest
: An optional Android Manifest for the to declare any permissions or intents it may need or want to handle. May either be a file or anandroid_manifest()
target. -
provided_deps
: These represent dependencies that are known to be provided at run time, but are required in order for the code to compile. Examples ofprovided_deps
include the JEE servlet APIs. When this rule is included in a , theprovided_deps
will not be packaged into the output. -
provided_deps_query
: Status: experimental/unstable. The provided deps query functions in the same way as the deps query, but the referenced deps using$declared
are the provided deps of the target, and the results of the query are appended to the declared provided deps. -
remove_classes
: List of classes to remove from the output jar. It only removes classes from the target's own sources, not from any of its dependencies. -
required_for_source_only_abi
: Indicates that this rule must be present on the classpath duringsource-only ABI generation
of any rule that depends on it. Typically this is done when a rule contains annotations, enums, constants, or interfaces.Having rules present on the classpath during source-only ABI generation prevents Buck from completely flattening the build graph, thus reducing the performance win from source-only ABI generation. These rules should be kept small (ideally just containing annotations, constants, enums, and interfaces) and with minimal dependencies of their own.
-
resources
: Static files to include among the compiled.class
files. These files can be loaded via Class.getResource().Note: Buck uses the
src_roots
property in.buckconfig
to help determine where resources should be placed within the generated JAR file. -
source
: Specifies the version of Java (as a string) to interpret source files as. Overrides the value in "source_level" in the "java" section of.buckconfig
. -
source_only_abi_deps
: These are dependencies that must be present duringsource-only ABI generation
. Typically such dependencies are added when some property of the code in this rule prevents source-only ABI generation from being correct without these dependencies being present.Having
source_only_abi_deps
prevents Buck from completely flattening the build graph, thus reducing the performance win from source-only ABI generation. They should be avoided when possible. Often only a small code change is needed to avoid them. For more information on such code changes, read aboutsource-only ABI generation
. -
srcs
: The set of.java
files to compile for this rule. -
target
: Specifies the version of Java (as a string) for which to generate code. Overrides the value in "target_level" in the "java" section of.buckconfig
.
Details
Examples:
An android_library
rule used in concert with an
android_resource()
rule.
This would be a common arrangement for a standard Android Library project
as defined by
http://developer.android.com/tools/projects/index.html
android_resource(
name = 'res',
res = 'res',
package = 'com.example',
)
android_library(
name = 'my_library',
srcs = glob(['src/**/*.java']),
deps = [
':res',
],
)
android_manifest
def android_manifest(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
skeleton: str,
) -> None
An android_manifest()
rule is used to generate an Android Manifest to be used by android_binary()
and android_aar()
rules. This rule takes a skeleton manifest, and merges it with manifests found in any deps.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this targetdeps
: A collection of dependencies that includes android_library rules. The manifest files of theandroid_library()
rules will be filtered out to become dependent source files for the manifest.skeleton
: Either abuild target
or a path to a file representing the manifest that will be merged with any manifests associated with this rule'sdeps
.
Details
Examples:
Here's an example of an android_manifest()
that has no deps.
android_manifest(
name = 'my-manifest',
skeleton = 'AndroidManifestSkeleton.xml',
)
This is what AndroidManifestSkeleton.xml
looks like.
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk targetSdkVersion="19" minSdkVersion="17"/>
<application
android:label="@string/app_name"
android:icon="@drawable/ic_launcher">
<activity
android:name="MyActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
</application>
</manifest>
You could also use a genrule()
to generate the manifest file and reference the
build target
in the skeleton
argument.
android_platform
def android_platform(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
base_platform: str,
native_platforms: dict[str, str] = ...,
) -> None
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
android_prebuilt_aar
def android_prebuilt_aar(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_build_only_native_code: bool = ...,
_dex_min_sdk_version: None | int = ...,
_dex_toolchain: str = ...,
_exec_os_type: str = ...,
_java_toolchain: str = ...,
aar: str,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
desugar_deps: list[str] = ...,
for_primary_apk: bool = ...,
javadoc_url: None | str = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
maven_coords: None | str = ...,
required_for_source_only_abi: bool = ...,
source_jar: None | str = ...,
use_system_library_loader: bool = ...,
) -> None
An android_prebuilt_aar()
rule takes an .aar
file and makes it available as an Android dependency. As expected, an android_binary()
that transitively depends on an android_prebuilt_aar()
will include its contents in the generated APK.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this targetaar
: Path to the.aar
file. This may also be a build target to a rule (such as agenrule()
) whose output is an.aar
file.javadoc_url
: URL to the Javadoc for the.class
files in theaar
.source_jar
: Path to a JAR file that contains the.java
files to create the.class
in theaar
. This is frequently provided for debugging purposes.use_system_library_loader
: If this.aar
file contains native prebuilt.so
libraries and the Java code uses these libraries via a call toSystem.loadLibrary()
, then many optimizations—such as exopackage, compression, or asset packaging—may not be compatible with these prebuilt libs. Setting this parameter toTrue
causes all of these optimizations to skip the prebuilt.so
files originating from this.aar
file. The.so
files will always be packaged directly into the main.apk
.
Details
See the official Android documentation for details about the .aar
format.
Examples:
android_prebuilt_aar(
name = 'play-services',
aar = 'play-services-4.0.30.aar',
source_jar = 'play-services-4.0.30-sources.jar',
javadoc_url = 'file:///opt/android-sdk/extras/google/google_play_services/docs/reference',
)
android_library(
name = 'lib',
# This Java code can compile against Play services and reference its resources.
srcs = glob(['*.java']),
deps = [ ':play-services' ],
)
android_resource
def android_resource(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_build_only_native_code: bool = ...,
_java_toolchain: str = ...,
allowlisted_locales: None | list[str] = ...,
assets: None | str | dict[str, str] = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
deps: list[str] = ...,
has_whitelisted_strings: bool = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
manifest: None | str = ...,
package: None | str = ...,
project_assets: None | str = ...,
project_res: None | str = ...,
res: None | str | dict[str, str] = ...,
resource_union: bool = ...,
) -> None
An android_resource()
rule is used to bundle Android resources that are traditionally stored in res
and assets
directories.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this targetdeps
: Otherandroid_resource
rules to include via-S
when runningaapt
.manifest
: An optional Android Manifest for the to declare any permissions or intents it may need or want to handle. May either be a file or anandroid_manifest()
target.package
: Java package for theR.java
file that will be generated for these resources.
Details
The output of an android_resource()
is an R.txt
file
generated via aapt --output-text-symbols
.
Examples:
Most of the time, an android_resource
rule defines only name
, res
, and package
. By convention,
such simple rules are often named res
:
android_resource(
name = 'res',
res = subdir_glob([('res', '**')]),
package = 'com.example',
)
apk_genrule
def apk_genrule(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_android_toolchain: str = ...,
_apple_platforms: dict[str, str] = ...,
_build_only_native_code: bool = ...,
_exec_os_type: str = ...,
_genrule_toolchain: str = ...,
_java_toolchain: str = ...,
aab: None | str = ...,
always_print_stderr: bool = ...,
apk: None | str = ...,
bash: None | str = ...,
cacheable: None | bool = ...,
cmd: None | str = ...,
cmd_exe: None | str = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
default_outs: None | list[str] = ...,
enable_sandbox: None | bool = ...,
environment_expansion_separator: None | str = ...,
is_cacheable: bool = ...,
keystore: None | str = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
metadata_env_var: None | str = ...,
metadata_path: None | str = ...,
need_android_tools: bool = ...,
no_outputs_cleanup: bool = ...,
out: None | str = ...,
outs: None | dict[str, list[str]] = ...,
remote: None | bool = ...,
remote_execution_dependencies: list[dict[str, str]] = ...,
srcs: list[str] | dict[str, str] = ...,
type: str = ...,
use_derived_apk: bool = ...,
weight: None | int = ...,
) -> None
An apk_genrule()
rule is used to post-process an APK. What separates an apk_genrule from a genrule is apk_genrules are known by BUCK to produce APKs, so commands like buck install
or buck uninstall
still work. Additionally, apk_genrule()
rules can be inputs to other apk_genrule()
rules.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
aab
: The inputandroid_binary()
rule. The path to the AAB can be accessed with the$AAB
shell variable. Only one ofapk
oraab
can be provided. -
apk
: The inputandroid_binary()
rule. The path to the APK can be accessed with the$APK
shell variable. Only one ofapk
oraab
can be provided. -
bash
: A platform-specific version of the shell command parametercmd
. It runs on Linux and UNIX systems—including OSX—on whichbash
is installed. It has a higher priority thancmd
. Thebash
argument is run with/usr/bin/env bash -c
. It has access to the same set of macros and variables as thecmd
argument. -
cmd
: The shell command to run to generate the output file. It is the fallback forbash
andcmd_exe
arguments. The following environment variables are populated by Buck and available to the shell command. They are accessed using the syntax:${<variable>}
Example:
${SRCS}
${SRCS}
A string expansion of the
srcs
argument delimited by theenvironment_expansion_separator
argument where each element ofsrcs
will be translated into a relative path.${SRCDIR}
The relative path to a directory to which sources are copied prior to running the command.
${OUT}
The output file or directory for the
genrule()
. This variable will have whatever value is specified by theout
argument if not using named outputs. If using named outputs, this variable will be the output directory.The value should be a valid filepath. The semantics of the shell command determine whether this filepath is treated as a file or a directory. If the filepath is a directory, then the shell command needs to create it if not using named outputs. Otherwise, it will be automatically created. All outputs (directories and files) must be readable, writable, and (in the case of directories) executable by the current user.
The file or directory specified by this variable must always be written by this command. If not, the execution of this rule will be considered a failure, halting the build process.
${TMP}
A temporary directory which can be used for intermediate results and will not be bundled into the output.
-
cmd_exe
: A platform-specific version of the shell command parametercmd
. It runs on Windows and has a higher priority thancmd
. Thecmd_exe
argument is run withcmd.exe /v:off /c
. It has access to the same set of macros and variables as thecmd
argument. -
environment_expansion_separator
: The delimiter between paths in environment variables, such as SRCS, that can contain multiple paths. It can be useful to specify this parameter if the paths could contain spaces. -
out
: The name of the output file or directory. The complete path to this argument is provided to the shell command through theOUT
environment variable. Only one ofout
orouts
may be present.For an apk_genrule the output should be a '.apk' or '.aab' file.
-
srcs
: Either a list or a map of the source files which Buck makes available to the shell command at the path in theSRCDIR
environment variable. If you specify a list, the source files are the names in the list. If you specify a map, the source files are made available as the names in the keys of the map, where the values of the map are the original source file names. -
weight
: How many local slots these genrule should take when executing locally.
Details
Examples:
Here is an example of a couple apk_genrule()
open up an APK, do
some super signing, and then zipalign that APK again.
# Building this rule will produce a file named messenger.apk.
android_binary(
name = 'messenger',
manifest = 'AndroidManifest.xml',
target = 'Google Inc.:Google APIs:16',
keystore = '//keystores:prod',
package_type = 'release',
proguard_config = 'proguard.cfg',
deps = [
':res',
':src',
],
)
apk_genrule(
name = 'messenger_super_sign_unalign',
apk = ':messenger',
bash = '$(exe //java/com/facebook/sign:super_sign) --input $APK --output $OUT',
cmd_exe = '$(exe //java/com/facebook/sign:super_sign) --input %APK% --output %OUT%',
out = 'messenger_super_sign_unalign.apk',
)
apk_genrule(
name = 'messenger_super_sign',
apk = ':messenger_super_sign_unalign',
bash = '$ANDROID_HOME/tools/zipalign -f 4 $APK $OUT',
cmd_exe = '%ANDROID_HOME%\tools\zipalign -f 4 %APK% %OUT%',
out = 'messenger_super_sign.apk',
)
apple_asset_catalog
def apple_asset_catalog(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
app_icon: None | str = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
dirs: list[str] = ...,
labels: list[str] = ...,
launch_image: None | str = ...,
licenses: list[str] = ...,
skip_universal_resource_dedupe: bool = ...,
) -> None
An apple_asset_catalog()
rule contains resources stored in Apple asset catalog directories. This rule does not have any output on its own and can be built only as a dependency (either direct or transitive) of an apple_bundle()
rule, in which case all apple_asset_catalog()
rules that the bundle rule depends on are merged and placed into the final output bundle together.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this targetapp_icon
: An optional reference to a.appiconset
containing a image set representing an application icon. (The extension itself should not be included.) This parameter may be specified at most once in a givenapple_bundle
's transitive dependencies.launch_image
: An optional reference to a.launchimage
containing a image set representing an application launch image. (The extension itself should not be included.) This parameter may be specified at most once in a givenapple_bundle
's transitive dependencies.
Details
Examples:
apple_asset_catalog(
name = 'MyAssetCatalog',
dirs = [
'MyResources.xcassets',
],
)
# A asset catalog with a app icon and launch image
apple_asset_catalog(
name = 'AssetCatalog',
dirs = [ 'AssetCatalog.xcassets' ],
app_icon = 'Icon',
launch_image = 'LaunchImage',
)
apple_binary
def apple_binary(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
_apple_toolchain: str = ...,
_apple_tools: str = ...,
_apple_xctoolchain: str = ...,
_apple_xctoolchain_bundle_id: str = ...,
_dsymutil_extra_flags: list[str],
_dsymutil_verify_dwarf: str,
_enable_library_evolution: bool = ...,
_stripped_default: bool = ...,
_swift_enable_testing: bool = ...,
allow_cache_upload: None | bool = ...,
attrs_validators: None | list[str] = ...,
binary_linker_flags: list[str] = ...,
bridging_header: None | str = ...,
can_be_asset: None | bool = ...,
compiler_flags: list[str] = ...,
constraint_overrides: list[str] = ...,
contacts: list[str] = ...,
cxx_runtime_type: None | str = ...,
default_host_platform: None | str = ...,
default_platform: None | str = ...,
defaults: dict[str, str] = ...,
deps: list[str] = ...,
devirt_enabled: bool = ...,
diagnostics: dict[str, str] = ...,
dist_thin_lto_codegen_flags: list[str] = ...,
dsym_uses_parallel_linker: bool = ...,
enable_cxx_interop: bool = ...,
enable_distributed_thinlto: bool = ...,
enable_library_evolution: None | bool = ...,
entitlements_file: None | str = ...,
executable_name: None | str = ...,
exported_header_style: str = ...,
exported_headers: list[str] | dict[str, str] = ...,
exported_lang_platform_preprocessor_flags: dict[str, list[(str, list[str])]] = ...,
exported_lang_preprocessor_flags: dict[str, list[str]] = ...,
exported_linker_flags: list[str] = ...,
exported_platform_deps: list[(str, list[str])] = ...,
exported_platform_headers: list[(str, list[str] | dict[str, str])] = ...,
exported_platform_linker_flags: list[(str, list[str])] = ...,
exported_platform_preprocessor_flags: list[(str, list[str])] = ...,
exported_post_linker_flags: list[str] = ...,
exported_post_platform_linker_flags: list[(str, list[str])] = ...,
exported_preprocessor_flags: list[str] = ...,
extra_xcode_files: list[str] = ...,
extra_xcode_sources: list[str] = ...,
fat_lto: bool = ...,
focused_list_target: None | str = ...,
force_static: None | bool = ...,
frameworks: list[str] = ...,
header_namespace: None | str = ...,
header_path_prefix: None | str = ...,
headers: list[str] | dict[str, str] = ...,
headers_as_raw_headers_mode: None | str = ...,
include_directories: list[str] = ...,
info_plist: None | str = ...,
info_plist_substitutions: dict[str, str] = ...,
labels: list[str] = ...,
lang_compiler_flags: dict[str, list[str]] = ...,
lang_platform_compiler_flags: dict[str, list[(str, list[str])]] = ...,
lang_platform_preprocessor_flags: dict[str, list[(str, list[str])]] = ...,
lang_preprocessor_flags: dict[str, list[str]] = ...,
libraries: list[str] = ...,
licenses: list[str] = ...,
link_execution_preference: None | str = ...,
link_group: None | str = ...,
link_group_map: None | str | list[(str, list[(None | str | list[None | str], str, None | str | list[str], None | str)], None | dict[str, typing.Any])] = ...,
link_group_public_deps_label: None | str = ...,
link_ordering: None | str = ...,
link_style: None | str = ...,
link_whole: None | bool = ...,
linker_extra_outputs: list[str] = ...,
linker_flags: list[str] = ...,
modular: bool = ...,
module_name: None | str = ...,
module_requires_cxx: bool = ...,
platform_compiler_flags: list[(str, list[str])] = ...,
platform_deps: list[(str, list[str])] = ...,
platform_headers: list[(str, list[str] | dict[str, str])] = ...,
platform_linker_flags: list[(str, list[str])] = ...,
platform_override: None | str = ...,
platform_preprocessor_flags: list[(str, list[str])] = ...,
platform_srcs: list[(str, list[str | (str, list[str])])] = ...,
post_linker_flags: list[str] = ...,
post_platform_linker_flags: list[(str, list[str])] = ...,
precompiled_header: None | str = ...,
prefer_stripped_objects: bool = ...,
preferred_linkage: str = ...,
prefix_header: None | str = ...,
preprocessor_flags: list[str] = ...,
propagated_target_sdk_version: None | str = ...,
public_include_directories: list[str] = ...,
public_system_include_directories: list[str] = ...,
raw_headers: list[str] = ...,
reexport_all_header_dependencies: None | bool = ...,
sanitizer_runtime_enabled: None | bool = ...,
sdk_modules: list[str] = ...,
serialize_debugging_options: None | bool = ...,
soname: None | str = ...,
srcs: list[str | (str, list[str])] = ...,
static_library_basename: None | str = ...,
stripped: None | bool = ...,
supported_platforms_regex: None | str = ...,
supports_merged_linking: None | bool = ...,
swift_compilation_mode: str = ...,
swift_compiler_flags: list[str] = ...,
swift_interface_compilation_enabled: bool = ...,
swift_module_skip_function_bodies: bool = ...,
swift_package_name: None | str = ...,
swift_version: None | str = ...,
target_sdk_version: None | str = ...,
thin_lto: bool = ...,
use_submodules: bool = ...,
uses_cxx_explicit_modules: bool = ...,
uses_explicit_modules: bool = ...,
uses_modules: bool = ...,
validation_deps: list[str] = ...,
) -> None
An apple_binary()
rule builds a native executable - such as an iOS or OSX app - from the supplied set of Objective-C/C++ source files and dependencies. It is similar to a cxx_binary()
rule with which it shares many attributes. In addition to those common attributes, apple_binary()
has a some additional attributes that are specific to binaries intended to be built using the Apple toolchain. Note, however, that apple_binary()
and cxx_binary()
differ in the way that they import header files, in order to better accommodate existing conventions. See the sections for the headers
and exported_headers
attributes for more details.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
allow_cache_upload
: Whether to allow uploading the output of this rule to be uploaded to cache when the action is executed locally if the configuration allows (i.e. there is a cache configured and the client has permission to write to it). -
compiler_flags
: Flags to use when compiling any of the above sources (which require compilation). -
entitlements_file
: An optional name of a plist file to be embedded in the binary. Some platforms likeiphonesimulator
require this to run properly. -
exported_headers
: The set of header files that are made available for inclusion to the source files in this target and all targets that transitively depend on this one. These should be specified as either a list of header files or a dictionary of header names to header files. The header names can contain forward slashes (/
). If a list of header files is specified, the headers can be imported with#import "$HEADER_PATH_PREFIX/$HEADER_NAME"
or, if a header file that belongs to the same rule is being imported, with#import "$HEADER_NAME"
, where$HEADER_PATH_PREFIX
is the value of the target'sheader_path_prefix
attribute, and$HEADER_NAME
is the filename of the header file. If a dictionary is specified, each header can be imported with#import "$HEADER_NAME"
, where$HEADER_NAME
is the key corresponding to this file. In this case, theheader_path_prefix
attribute is ignored. In either case, quotes in the import statements can be replaced with angle brackets. -
exported_linker_flags
: Flags to add to the linker command line when the output from this rule, or the output from any rule that transitively depends on this rule, is used in a link operation. -
extra_xcode_files
: When the project is generated, this is the list of files that will added to the project. Those files won't be added to the build phase "Compile Sources". -
frameworks
: A list of system frameworks that the code in this target uses. Each entry should be a path starting with$SDKROOT
or$PLATFORM_DIR
to denote that the rest of the path is relative to the root of the SDK used for the build or to the platform toolchain directory. -
header_path_prefix
: A path prefix when including headers of this target. For example, headers from a library defined usingapple_library(
name = "Library",
headers = glob(["**/*.h"]),
header_path_prefix = "Lib",
)can be imported using following mapping
Library/SubDir/Header1.h -> Lib/Header1.h
Library/Header2.h -> Lib/Header2.hDefaults to the short name of the target. Can contain forward slashes (
/
), but cannot start with one. Seeheaders
for more information. -
headers
: The set of header files that are made available for inclusion to the source files in this target. These should be specified as either a list of header files or a dictionary of header names to header files. The header names can contain forward slashes (/
). If a list of header files is specified, the headers can be imported with#import "$HEADER_PATH_PREFIX/$HEADER_NAME"
or#import "$HEADER_NAME"
, where$HEADER_PATH_PREFIX
is the value of the target'sheader_path_prefix
attribute, and$HEADER_NAME
is the filename of the header file. If a dictionary is specified, each header can be imported with#import "$HEADER_NAME"
, where$HEADER_NAME
is the key corresponding to this file. In this case, theheader_path_prefix
attribute is ignored. In either case, quotes in the import statements can be replaced with angle brackets. -
link_execution_preference
: The execution preference for linking. Options are:- any : No preference is set, and the link action will be performed based on buck2's executor configuration.
- full_hybrid : The link action will execute both locally and remotely, regardless of buck2's executor configuration (if the executor is capable of hybrid execution). The use_limited_hybrid setting of the hybrid executor is ignored.
- local : The link action will execute locally if compatible on current host platform.
- local_only : The link action will execute locally, and error if the current platform is not compatible.
- remote : The link action will execute remotely if a compatible remote platform exists, otherwise locally.
The default is None, expressing that no preference has been set on the target itself.
-
link_group_public_deps_label
: Surface nodes with this label as "public" nodes in the main executable when linking with with link groups. -
link_style
: Determines whether to build and link this rule's dependencies statically or dynamically. Can be eitherstatic
,static_pic
orshared
. -
linker_extra_outputs
: Declares extra outputs that the linker emits. These identifiers can be used in$(output ...)
macros inlinker_flags
to interpolate the output path into the linker command line. Useful for custom linkers that emit extra output files. -
linker_flags
: Flags to add to the linker command line whenever the output from this rule is used in a link operation, such as linked into an executable or a shared library. -
platform_compiler_flags
: Platform specific compiler flags. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is a list of flags to use when compiling the target's sources. Seecompiler_flags
for more information. -
platform_linker_flags
: Platform-specific linker flags. This argument is specified as a list of pairs where the first element in each pair is an un-anchored regex against which the platform name is matched. The regex should usejava.util.regex.Pattern
syntax. The second element in each pair is a list of linker flags. If the regex matches the platform, these flags are added to the linker command line when the output from this rule is used in a link operation. -
platform_srcs
: Platform specific source files. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is either a list of source files or a list of tuples of source files and a list of compilation flags to be preprocessed, compiled and assembled if the platform matches the regex. Seesrcs
for more information. -
preprocessor_flags
: Flags to use when preprocessing any of the above sources (which require preprocessing). -
srcs
: The set of C, C++, Objective-C, Objective-C++, or assembly source files to be preprocessed, compiled, and assembled by this rule. We determine which stages to run on each input source based on its file extension. See the GCC documentation for more detail on how file extensions are interpreted. Each element can be either a string specifying a source file (e.g.''
) or a tuple of a string specifying a source file and a list of compilation flags (e.g.('', ['-Wall', '-Werror'])
). In the latter case the specified flags will be used in addition to the rule's other flags when preprocessing and compiling that file (if applicable). -
target_sdk_version
: The minimum OS version that the library target should support, overriding the minimum set in.buckconfig
. When set, Buck will automatically add flags to both Objective-C and Swift compilation that will allow the use of the new APIs without guarding code inside availability checks.
Details
Buck enables you to override components of the Apple toolchain with
alternate tools, either from the Xcode search paths or from directories
that you specify.
See .buckconfig
and .buckconfig
for more information.
Examples:
apple_binary(
name = 'MyBinary',
deps = [
':MyLibrary',
'//Libraries:AnotherLibrary',
],
preprocessor_flags = ['-fobjc-arc'],
headers = [
'MyHeader.h',
],
srcs = [
'MySource.m',
],
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
)
apple_bundle
def apple_bundle(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
_apple_toolchain: str = ...,
_apple_tools: str = ...,
_apple_xctoolchain: str = ...,
_apple_xctoolchain_bundle_id: str = ...,
_bundling_cache_buster: None | str = ...,
_bundling_log_file_enabled: bool = ...,
_bundling_log_file_level: None | str = ...,
_code_signing_configuration: None | str = ...,
_codesign_entitlements: None | str = ...,
_codesign_identities_command_override: None | str = ...,
_codesign_type: None | str = ...,
_compile_resources_locally_override: None | bool = ...,
_dsymutil_extra_flags: list[str],
_dsymutil_verify_dwarf: str,
_embed_provisioning_profile_when_adhoc_code_signing: None | bool = ...,
_fast_adhoc_signing_enabled_default: bool = ...,
_fast_provisioning_profile_parsing_enabled: bool = ...,
_incremental_bundling_enabled: bool = ...,
_info_plist_identify_build_system_default: bool = ...,
_profile_bundling_enabled: bool = ...,
_provisioning_profiles: str = ...,
_resource_bundle: None | str = ...,
_skip_adhoc_resigning_scrubbed_frameworks_default: bool = ...,
_skip_adhoc_resigning_scrubbed_frameworks_override: None | bool = ...,
_strict_provisioning_profile_search_default: bool = ...,
_use_entitlements_when_adhoc_code_signing: None | bool = ...,
asset_catalogs_compilation_options: dict[str, typing.Any] = ...,
binary: None | str = ...,
bundle_type: None | str = ...,
code_signing_configuration: None | str = ...,
codesign_flags: list[str] = ...,
codesign_identity: None | str = ...,
codesign_type: None | str = ...,
contacts: list[str] = ...,
copy_public_framework_headers: None | bool = ...,
debug_artifacts_validators: dict[str, (str, str)] = ...,
default_host_platform: None | str = ...,
default_platform: None | str = ...,
deps: list[str] = ...,
dsym_uses_parallel_linker: bool = ...,
embed_provisioning_profile_when_adhoc_code_signing: bool = ...,
embed_xctest_frameworks: bool = ...,
extension: str,
fast_adhoc_signing_enabled: None | bool = ...,
ibtool_flags: None | list[str] = ...,
ibtool_module_flag: None | bool = ...,
incremental_bundling_enabled: None | bool = ...,
info_plist: str,
info_plist_identify_build_system: None | bool = ...,
info_plist_substitutions: dict[str, str] = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
module_map: None | str = ...,
platform_binary: None | list[(str, str)] = ...,
privacy_manifest: None | str = ...,
product_name: None | str = ...,
product_name_from_module_name: bool = ...,
propagated_target_sdk_version: None | str = ...,
provisioning_profile_filter: None | str = ...,
resource_group: None | str = ...,
resource_group_map: None | str = ...,
selective_debugging: None | str = ...,
skip_adhoc_resigning_scrubbed_frameworks: None | bool = ...,
skip_copying_swift_stdlib: None | bool = ...,
split_arch_dsym: bool = ...,
strict_provisioning_profile_search: None | bool = ...,
try_skip_code_signing: None | bool = ...,
universal: None | bool = ...,
use_entitlements_when_adhoc_code_signing: bool = ...,
validation_deps: list[str] = ...,
versioned_macos_bundle: bool = ...,
xcode_product_type: None | str = ...,
xcode_scheme_settings: None | str = ...,
) -> None
An apple_bundle()
rule takes an Apple binary and all of the resources and asset catalogs in the rule's transitive dependencies and generates a bundle containing all of those files. Optionally the generated bundle can also be signed using specified provisioning profiles.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
asset_catalogs_compilation_options
: A dict holding parameters for asset catalogs compiler (actool). Its options include:notices
(defaults toTrue
)warnings
(defaults toTrue
)errors
(defaults toTrue
)compress_pngs
(defaults toTrue
)optimization
(defaults to'space'
)output_format
(defaults to'human-readable-text'
)extra_flags
(defaults to[]
)
-
deps
: A list of dependencies of this bundle as build targets. You can embed application extensions by specifying the extension's bundle target. To include a WatchKit app, append the flavor#watch
to the target specification. Buck will automatically substitute the appropriate platform flavor (eitherwatchsimulator
orwatchos
) based on the parent. -
extension
: The extension of the generated bundle. For example'app'
for an application bundle or'appex'
for an application extension bundle. -
ibtool_flags
: List of flags to be passed to ibtool during interface builder file compilation. -
info_plist
: A path to anInfo.plist
file that will be placed in the bundle. The specified file will be processed by substituting variable names with their values (seeinfo_plist_substitutions
for more information). -
info_plist_substitutions
: A dictionary that assigns variable names to their values. It is used for variable substitution when processing the file specified ininfo_plist
. For example if this argument is set to{'VAR': 'MyValue'}
, then each occurrence of$(VAR)
or${VAR}
in the file will be replaced byMyValue
. -
privacy_manifest
: A path to an.xcprivacy
file that will be placed in the bundle. -
product_name
: The name of the resulting bundle and binary. The setting behaves like PRODUCT_NAME Xcode build setting. For example, if your rule is named "MyApp" and extension is "app", by default buck will generate MyApp.app bundle. But if you will set product name to "SuperApp", bundle will get "SuperApp.app" name. -
xcode_scheme_settings
: Optional settings to set on schemes when this target is represented in Xcode.
Details
Code signing will embed entitlements pointed to by the entitlements_file
arg in
the bundle's apple_binary
. This is the preferred way to specify entitlements
when building with Buck.
If the entitlements file is not present, it falls back to the CODE_SIGN_ENTITLEMENTS
entry in
info_plist_substitutions
.
If after these checks, an entitlements file is still not specified, it will be derived based
on the entitlements of the selected provisioning profile. Provisioning profiles will be selected
from profiles pointed to by apple.provisioning_profile_search_path
, based on a
non-expired profile that matches the bundle id and entitlements.
Code signing will embed entitlements pointed to by the CODE_SIGN_ENTITLEMENTS
entry in
info_plist_substitutions
. If an entitlements file is omitted, it will be derived based
on the entitlements of the selected provisioning profile. Provisioning profiles will be selected
from profiles pointed to by apple.provisioning_profile_search_path
, based on a
non-expired profile that matches the bundle id and entitlements.
Examples:
apple_bundle(
name = 'AppBundle',
binary = ':MyBinary',
extension = 'app',
info_plist = 'Info.plist',
)
# iOS app with embedded WatchOS 2.0 app/extension
apple_bundle(
name = 'DemoWatchAppExtension',
binary = ':DemoWatchAppExtensionBinary',
extension = 'appex',
info_plist = 'WatchExtension/Resources/Info.plist',
)
apple_bundle(
name = 'DemoWatchApp',
binary = ':DemoWatchAppBinary',
deps = [':DemoWatchAppResources', ':DemoWatchAppExtension'],
extension = 'app',
info_plist = 'WatchApplication/Info.plist',
)
apple_bundle(
name = 'DemoApp',
binary = ':DemoAppBinary',
deps = [':DemoWatchApp#watch'],
extension = 'app',
info_plist = 'Info.plist',
)
# iOS app using safeAreaInsets delivering to iOS 9.x
apple_bundle(
name = 'DemoIBApp',
binary = ':DemoIBAppBinary',
deps = [':DemoIBAppResources'],
extension = 'app',
ibtool_flags = ["--minimum-deployment-target", "9.0"],
info_plist = 'Info.plist',
)
apple_library
def apple_library(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
_apple_toolchain: str = ...,
_apple_tools: str = ...,
_apple_xctoolchain: str = ...,
_apple_xctoolchain_bundle_id: str = ...,
_archive_objects_locally_override: None | bool = ...,
_dsymutil_extra_flags: list[str],
_dsymutil_verify_dwarf: str,
_enable_library_evolution: bool = ...,
_meta_apple_library_validation_enabled: bool = ...,
_stripped_default: bool = ...,
_swift_enable_testing: bool = ...,
allow_cache_upload: None | bool = ...,
attrs_validators: None | list[str] = ...,
bridging_header: None | str = ...,
can_be_asset: None | bool = ...,
compiler_flags: list[str] = ...,
contacts: list[str] = ...,
cxx_runtime_type: None | str = ...,
default_host_platform: None | str = ...,
default_platform: None | str = ...,
defaults: dict[str, str] = ...,
deps: list[str] = ...,
devirt_enabled: bool = ...,
diagnostics: dict[str, str] = ...,
dist_thin_lto_codegen_flags: list[str] = ...,
dsym_uses_parallel_linker: bool = ...,
enable_cxx_interop: bool = ...,
enable_distributed_thinlto: bool = ...,
enable_library_evolution: None | bool = ...,
enable_private_swift_module: bool = ...,
executable_name: None | str = ...,
exported_deps: list[str] = ...,
exported_header_style: str = ...,
exported_headers: list[str] | dict[str, str] = ...,
exported_lang_platform_preprocessor_flags: dict[str, list[(str, list[str])]] = ...,
exported_lang_preprocessor_flags: dict[str, list[str]] = ...,
exported_linker_flags: list[str] = ...,
exported_platform_deps: list[(str, list[str])] = ...,
exported_platform_headers: list[(str, list[str] | dict[str, str])] = ...,
exported_platform_linker_flags: list[(str, list[str])] = ...,
exported_platform_preprocessor_flags: list[(str, list[str])] = ...,
exported_post_linker_flags: list[str] = ...,
exported_post_platform_linker_flags: list[(str, list[str])] = ...,
exported_preprocessor_flags: list[str] = ...,
extra_xcode_files: list[str] = ...,
extra_xcode_sources: list[str] = ...,
fat_lto: bool = ...,
focused_list_target: None | str = ...,
force_static: None | bool = ...,
frameworks: list[str] = ...,
header_mode: None | str = ...,
header_namespace: None | str = ...,
header_path_prefix: None | str = ...,
headers: list[str] | dict[str, str] = ...,
headers_as_raw_headers_mode: None | str = ...,
include_directories: list[str] = ...,
info_plist: None | str = ...,
info_plist_substitutions: dict[str, str] = ...,
labels: list[str] = ...,
lang_compiler_flags: dict[str, list[str]] = ...,
lang_platform_compiler_flags: dict[str, list[(str, list[str])]] = ...,
lang_platform_preprocessor_flags: dict[str, list[(str, list[str])]] = ...,
lang_preprocessor_flags: dict[str, list[str]] = ...,
libraries: list[str] = ...,
licenses: list[str] = ...,
link_execution_preference: None | str = ...,
link_group: None | str = ...,
link_group_map: None | str | list[(str, list[(None | str | list[None | str], str, None | str | list[str], None | str)], None | dict[str, typing.Any])] = ...,
link_ordering: None | str = ...,
link_style: None | str = ...,
link_whole: None | bool = ...,
linker_extra_outputs: list[str] = ...,
linker_flags: list[str] = ...,
modular: bool = ...,
module_name: None | str = ...,
module_requires_cxx: bool = ...,
platform_compiler_flags: list[(str, list[str])] = ...,
platform_deps: list[(str, list[str])] = ...,
platform_headers: list[(str, list[str] | dict[str, str])] = ...,
platform_linker_flags: list[(str, list[str])] = ...,
platform_preprocessor_flags: list[(str, list[str])] = ...,
platform_srcs: list[(str, list[str | (str, list[str])])] = ...,
post_linker_flags: list[str] = ...,
post_platform_linker_flags: list[(str, list[str])] = ...,
precompiled_header: None | str = ...,
preferred_linkage: str = ...,
prefix_header: None | str = ...,
preprocessor_flags: list[str] = ...,
propagated_target_sdk_version: None | str = ...,
public_framework_headers: list[str] | dict[str, str] = ...,
public_include_directories: list[str] = ...,
public_system_include_directories: list[str] = ...,
raw_headers: list[str] = ...,
raw_headers_as_headers_mode: None | str = ...,
reexport_all_header_dependencies: None | bool = ...,
sdk_modules: list[str] = ...,
serialize_debugging_options: None | bool = ...,
shared_library_macho_file_type: str = ...,
soname: None | str = ...,
srcs: list[str | (str, list[str])] = ...,
static_library_basename: None | str = ...,
stripped: None | bool = ...,
supported_platforms_regex: None | str = ...,
supports_header_symlink_subtarget: bool = ...,
supports_merged_linking: None | bool = ...,
supports_shlib_interfaces: bool = ...,
swift_compilation_mode: str = ...,
swift_compiler_flags: list[str] = ...,
swift_interface_compilation_enabled: bool = ...,
swift_module_skip_function_bodies: bool = ...,
swift_package_name: None | str = ...,
swift_version: None | str = ...,
target_sdk_version: None | str = ...,
thin_lto: bool = ...,
use_archive: None | bool = ...,
use_submodules: bool = ...,
uses_cxx_explicit_modules: bool = ...,
uses_explicit_modules: bool = ...,
uses_modules: bool = ...,
validation_deps: list[str] = ...,
) -> None
An apple_library()
rule represents a set of Objective-C/C++/Swift source files and is similar to a cxx_library()
rule with which it shares many attributes. In addition to those common attributes, apple_library()
has a some additional attributes that are specific to binaries intended to be built using the Apple toolchain. Note, however, that apple_library()
and cxx_library()
differ in the way that they import header files, in order to better accommodate existing conventions. See the sections for the headers
and exported_headers
attributes for more details.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
allow_cache_upload
: Whether to allow uploading the output of this rule to be uploaded to cache when the action is executed locally if the configuration allows (i.e. there is a cache configured and the client has permission to write to it). -
compiler_flags
: Flags to use when compiling any of the above sources (which require compilation). -
exported_deps
: Dependencies that will also appear to belong to any rules that depend on this one. This has two effects: * Exported dependencies will also be included in the link line of dependents of this rules, but normal dependencies will not. * Whenreexport_all_header_dependencies = False
, only exported headers of the rules specified here are re-exported. -
exported_headers
: The set of header files that are made available for inclusion to the source files in this target and all targets that transitively depend on this one. These should be specified as either a list of header files or a dictionary of header names to header files. The header names can contain forward slashes (/
). If a list of header files is specified, the headers can be imported with#import "$HEADER_PATH_PREFIX/$HEADER_NAME"
or, if a header file that belongs to the same rule is being imported, with#import "$HEADER_NAME"
, where$HEADER_PATH_PREFIX
is the value of the target'sheader_path_prefix
attribute, and$HEADER_NAME
is the filename of the header file. If a dictionary is specified, each header can be imported with#import "$HEADER_NAME"
, where$HEADER_NAME
is the key corresponding to this file. In this case, theheader_path_prefix
attribute is ignored. In either case, quotes in the import statements can be replaced with angle brackets. -
exported_linker_flags
: Flags to add to the linker command line when the output from this rule, or the output from any rule that transitively depends on this rule, is used in a link operation. -
exported_platform_linker_flags
: Platform-specific linker flags for this rule and for all rules that transitively depend on this rule. This argument is specified as a list of pairs where the first element in each pair is an un-anchored regex against which the platform name is matched. The regex should usejava.util.regex.Pattern
syntax. The second element in each pair is a list of linker flags. If the regex matches the platform, these flags are added to the linker command line when the output from this rule, or the output from any rule that transitively depends on this rule, is used in a link operation. -
extra_xcode_files
: When the project is generated, this is the list of files that will added to the project. Those files won't be added to the build phase "Compile Sources". -
frameworks
: A list of system frameworks that the code in this target uses. Each entry should be a path starting with$SDKROOT
or$PLATFORM_DIR
to denote that the rest of the path is relative to the root of the SDK used for the build or to the platform toolchain directory. -
header_namespace
: A path prefix when including headers of this target. Defaults to the path from the root of the repository to the directory where this target is defined. Can contain forward slashes (/
), but cannot start with one. Seeheaders
for more information. -
header_path_prefix
: A path prefix when including headers of this target. For example, headers from a library defined usingapple_library(
name = "Library",
headers = glob(["**/*.h"]),
header_path_prefix = "Lib",
)can be imported using following mapping
Library/SubDir/Header1.h -> Lib/Header1.h
Library/Header2.h -> Lib/Header2.hDefaults to the short name of the target. Can contain forward slashes (
/
), but cannot start with one. Seeheaders
for more information. -
headers
: The set of header files that are made available for inclusion to the source files in this target. These should be specified as either a list of header files or a dictionary of header names to header files. The header names can contain forward slashes (/
). If a list of header files is specified, the headers can be imported with#import "$HEADER_PATH_PREFIX/$HEADER_NAME"
or#import "$HEADER_NAME"
, where$HEADER_PATH_PREFIX
is the value of the target'sheader_path_prefix
attribute, and$HEADER_NAME
is the filename of the header file. If a dictionary is specified, each header can be imported with#import "$HEADER_NAME"
, where$HEADER_NAME
is the key corresponding to this file. In this case, theheader_path_prefix
attribute is ignored. In either case, quotes in the import statements can be replaced with angle brackets. -
include_directories
: A list of include directories (withraw_headers
) to be added to the compile command for compiling this target (via-I
). An include directory is relative to the current package. -
link_execution_preference
: The execution preference for linking. Options are:- any : No preference is set, and the link action will be performed based on buck2's executor configuration.
- full_hybrid : The link action will execute both locally and remotely, regardless of buck2's executor configuration (if the executor is capable of hybrid execution). The use_limited_hybrid setting of the hybrid executor is ignored.
- local : The link action will execute locally if compatible on current host platform.
- local_only : The link action will execute locally, and error if the current platform is not compatible.
- remote : The link action will execute remotely if a compatible remote platform exists, otherwise locally.
The default is None, expressing that no preference has been set on the target itself.
-
link_style
: Determines whether to build and link this rule's dependencies statically or dynamically. Can be eitherstatic
,static_pic
orshared
. -
linker_extra_outputs
: Declares extra outputs that the linker emits. These identifiers can be used in$(output ...)
macros inlinker_flags
to interpolate the output path into the linker command line. Useful for custom linkers that emit extra output files. -
linker_flags
: Flags to add to the linker command line whenever the output from this rule is used in a link operation, such as linked into an executable or a shared library. -
platform_compiler_flags
: Platform specific compiler flags. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is a list of flags to use when compiling the target's sources. Seecompiler_flags
for more information. -
platform_srcs
: Platform specific source files. These should be specified as a list of pairs where the first element is an un-anchored regex (in java.util.regex.Pattern syntax) against which the platform name is matched, and the second element is either a list of source files or a list of tuples of source files and a list of compilation flags to be preprocessed, compiled and assembled if the platform matches the regex. Seesrcs
for more information. -
preprocessor_flags
: Flags to use when preprocessing any of the above sources (which require preprocessing). -
public_include_directories
: A list of include directories (withraw_headers
) to be added to the compile command for compiling this target and every target that depends on it (via-I
). An include directory is relative to the current package. -
public_system_include_directories
: A list of include directories (withraw_headers
) to be added to the compile command for compiling this target and every target that depends on it (via-isystem
if the compiler supports it of via-I
otherwise). An include directory is relative to the current package. -
raw_headers
: The set of header files that can be used for inclusion to the source files in the target and all targets that transitively depend on it. Buck doesn't add raw headers to the search path of a compiler/preprocessor automatically.include_directories
andpublic_include_directories
are the recommended way to add raw headers to the search path (they will be added via-I
).compiler_flags
,preprocessor_flags
andexported_preprocessor_flags
can also be used to add such raw headers to the search path if inclusion via-isystem
or-iquote
is needed.raw_headers
cannot be used together withheaders
orexported_headers
in the same target. -
raw_headers_as_headers_mode
: Controls whether raw_headers and *include_directories attributes should be automatically converted to headers and symlink trees and/or header maps via headers. Only has an effect if the cxx_toolchain has explicitly opted into supporting this behavior via a non-default value, even if the value is disabled. -
reexport_all_header_dependencies
: Whether to automatically re-export the exported headers of all dependencies.When this is set to false, only exported headers from
exported_deps
are re-exported. -
srcs
: The set of C, C++, Objective-C, Objective-C++, or assembly source files to be preprocessed, compiled, and assembled by this rule. We determine which stages to run on each input source based on its file extension. See the GCC documentation for more detail on how file extensions are interpreted. Each element can be either a string specifying a source file (e.g.''
) or a tuple of a string specifying a source file and a list of compilation flags (e.g.('', ['-Wall', '-Werror'])
). In the latter case the specified flags will be used in addition to the rule's other flags when preprocessing and compiling that file (if applicable). -
target_sdk_version
: The minimum OS version that the library target should support, overriding the minimum set in.buckconfig
. When set, Buck will automatically add flags to both Objective-C and Swift compilation that will allow the use of the new APIs without guarding code inside availability checks.
Details
Buck enables you to override components of the Apple toolchain with
alternate tools, either from the Xcode search paths or from directories
that you specify.
See .buckconfig
and .buckconfig
for more information.
Examples:
apple_library(
name = 'MyLibrary',
deps = [
':OtherLibrary',
'//Libraries:YetAnotherLibrary',
],
preprocessor_flags = ['-fobjc-arc'],
headers = [
'MyHeader.h',
],
srcs = [
'MySource.m',
'MySource.swift',
],
frameworks = [
'$SDKROOT/System/Library/Frameworks/UIKit.framework',
'$SDKROOT/System/Library/Frameworks/Foundation.framework',
],
)
apple_package
def apple_package(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
_apple_tools: str = ...,
_ipa_compression_level: str,
_ipa_package: str,
bundle: str,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
default_platform: None | str = ...,
ext: str = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
need_android_tools: bool = ...,
package_name: None | str = ...,
packager: None | str = ...,
packager_args: list[str] = ...,
prepackaged_validators: list[str | (str, list[str])] = ...,
) -> None
An apple_package()
rule takes the output of an apple_bundle()
rule and compresses it in an IPA (iOS App Store Package) file.
Parameters
name
: name of the targetdefault_target_platform
: specifies the default target platform, used when no platforms are specified on the command linetarget_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationcompatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configurationexec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platformvisibility
: a list of visibility patterns restricting what targets can depend on this onewithin_view
: a list of visibility patterns restricting what this target can depend onmetadata
: a key-value map of metadata associated with this targettests
: a list of targets that provide tests for this onemodifiers
: an array of modifiers associated with this target
Details
This rule can be customized using the config options .buckconfig
and .buckconfig
.
Examples:
apple_package(
name = 'AppPackage',
bundle = ':AppBundle',
)
apple_resource
def apple_resource(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,
compatible_with: list[str] = ...,
exec_compatible_with: list[str] = ...,
visibility: list[str] = ...,
within_view: list[str] = ...,
metadata: OpaqueMetadata = ...,
tests: list[str] = ...,
modifiers: OpaqueMetadata = ...,
_apple_platforms: dict[str, str] = ...,
codesign_entitlements: None | str = ...,
codesign_flags_override: None | list[str] = ...,
codesign_on_copy: bool = ...,
contacts: list[str] = ...,
content_dirs: list[str] = ...,
default_host_platform: None | str = ...,
destination: None | str = ...,
dirs: list[str] = ...,
files: list[str] = ...,
labels: list[str] = ...,
licenses: list[str] = ...,
named_variants: dict[str, list[str]] = ...,
resources_from_deps: list[str] = ...,
skip_universal_resource_dedupe: bool = ...,
variants: list[str] = ...,
) -> None
An apple_resource()
rule contains sets of resource directories, files and file variants that can be bundled in an application bundle. This rule does not have any output on its own and can be built only as a dependency (either direct or transitive) of an apple_bundle()
rule.
Parameters
-
name
: name of the target -
default_target_platform
: specifies the default target platform, used when no platforms are specified on the command line -
target_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with a configuration -
exec_compatible_with
: a list of constraints that are required to be satisfied for this target to be compatible with an execution platform -
visibility
: a list of visibility patterns restricting what targets can depend on this one -
within_view
: a list of visibility patterns restricting what this target can depend on -
metadata
: a key-value map of metadata associated with this target -
tests
: a list of targets that provide tests for this one -
modifiers
: an array of modifiers associated with this target -
destination
: Specifies the destination in the final application bundle where resource will be copied. Possible values: "resources", "frameworks", "executables", "plugins", "xpcservices". -
named_variants
: Mapping from a variant name to the list of resource file paths which should be placed in an application bundle. Those files will be placed in a directory with name equal to the corresponding key in this mapping. Keys should end with.lproj
suffix. (e.g.Base.lproj
,en.lproj
). -
resources_from_deps
: Set of build targets whose transitiveapple_resource
s should be considered as part of the current resource when collecting resources for bundles.Usually, an
apple_bundle
collects allapple_resource
rules transitively reachable through apple_library rules. This field allows for resources which are not reachable using the above traversal strategy to be considered for inclusion in the bundle. -
variants
: Set of paths of resource file variants that should be placed in an application bundle. The files mentioned here should be placed in a directory named$VARIANT_NAME.lproj
, where$VARIANT_NAME
is the name of the variant (e.g.Base
,en
). This argument makes it possible to use different resource files based on the active locale.
Details
Examples:
apple_resource(
name = 'Images',
files = glob([
'*.png',
]),
dirs = [
'PrettyImages',
],
)
apple_spm_package
def apple_spm_package(
*,
name: str,
default_target_platform: None | str = ...,
target_compatible_with: list[str] = ...,