cxx_universal_executable
A cxx_universal_executable() rule takes a target via its binary attribute, builds it for multiple architectures and combines the result into a single binary using lipo.
Details
The output of the rule is a universal binary:
- If
config//cpu/constraints:universal-enabledis present in the target platform. - If the
universalattribute is set toTrue.
If none of the conditions are met, then the rule acts as a nop alias().
The universal attribute, if present, takes precedence over constraint.
For example, if universal = False, then the presence of the constraint
would not affect the output.
Function Signature
def cxx_universal_executable(
*,
name: str,
default_target_platform: None | str = None,
target_compatible_with: list[str] = [],
compatible_with: list[str] = [],
exec_compatible_with: list[str] = [],
visibility: list[str] = [],
within_view: list[str] = ["PUBLIC"],
metadata: OpaqueMetadata = {},
tests: list[str] = [],
modifiers: OpaqueMetadata = [],
_apple_platforms: dict[str, str] = {},
_cxx_toolchain: str = "gh_facebook_buck2_shims_meta//:cxx",
executable: str,
executable_name: None | str = None,
labels: list[str] = [],
universal: None | bool = None,
) -> None
Parameters
-
name: (required)name of the target
-
default_target_platform: (defaults to:None)specifies the default target platform, used when no platforms are specified on the command line
-
target_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with a configuration
-
exec_compatible_with: (defaults to:[])a list of constraints that are required to be satisfied for this target to be compatible with an execution platform
-
visibility: (defaults to:[])a list of visibility patterns restricting what targets can depend on this one
-
within_view: (defaults to:["PUBLIC"])a list of visibility patterns restricting what this target can depend on
-
metadata: (defaults to:{})a key-value map of metadata associated with this target
-
tests: (defaults to:[])a list of targets that provide tests for this one
-
modifiers: (defaults to:[])an array of modifiers associated with this target
-
executable: (required)A build target identifying the binary which will be built for multiple architectures. The target will be transitioned into different configurations, with distinct architectures.
The target can be one of:
cxx_binary()[shared]subtargetcxx_library()cxx_library()which havepreferred_linkage = sharedattribute
-
executable_name: (defaults to:None)By default, the name of the universal executable is same as the name of the binary from the
binarytarget attribute. Setexecutable_nameto override the default. -
universal: (defaults to:None)Controls whether the output is universal binary. Any value overrides the presence of the
config//cpu/constraints:universal-enabledconstraint. Read the rule docs for more information on resolution.