ndk_library
An ndk_library() is used to define a set of C/C++ files, an Android.mk and an Application.mk file that are used by the NDK's ndk-build tool to generate one or more shared objects.
Details
Additional notes:
An android_binary() that includes this library will
aggregate all of the native shared objects into a directory in the
root of the APK named lib/ or assets/lib/.
Unlike the default invocation of ndk-build,
buck will put all intermediate files and build output
into a subdirectory under buck-out/gen.
Function Signature
def ndk_library(
*,
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] = {},
contacts: list[str] = [],
default_host_platform: None | str = None,
deps: list[str] = [],
flags: list[str] = [],
is_asset: bool = False,
labels: list[str] = [],
licenses: list[str] = [],
srcs: list[str] = [],
) -> 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
-
contacts: (defaults to:[])A list of organizational contacts for this rule. These could be individuals who you would contact in the event of a failure or other issue with the rule.
contacts = [ 'Joe Sixpack', 'Erika Mustermann' ] -
deps: (defaults to:[])List of build targets to build before this rule.
-
flags: (defaults to:[])Array of strings passed verbatim to
ndk-build. Normally this is not needed, but in some cases you may want to put something here. For example, this can be used to build the libraries in debug mode (NDK_DEBUG=1) or set the number of jobs spawned byndk-build(by default, the same as the number of cores). -
is_asset: (defaults to:False)Normally native shared objects end up in a directory in the root of the APK named
lib/. If this parameter is set toTrue, then these objects are placed inassets/lib/. Placing shared objects in a non-standard location prevents Android from extracting them to the device's internal storage. -
labels: (defaults to:[])Set of arbitrary strings which allow you to annotate a build rule with tags that can be searched for over an entire dependency tree using
buck query(). -
licenses: (defaults to:[])Set of license files for this library. To get the list of license files for a given build rule and all of its dependencies, you can use buck query
-
srcs: (defaults to:[])The set of files to compile for this rule. If not provided,
buckassumes that all files with the following extensions are part of the build:c, cpp, cc, cxx, h, hpp, mk.