Skip to main content

prebuilt_cxx_library

name

def name(
*,
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] = ...,
_create_third_party_build_root: str = ...,
_cxx_toolchain: str = ...,
_target_os_type: str = ...,
allow_cache_upload: None | bool = ...,
can_be_asset: bool = ...,
contacts: list[str] = ...,
default_host_platform: None | str = ...,
deffile: None | str = ...,
deps: list[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] = ...,
extract_soname: bool = ...,
force_static: bool = ...,
frameworks: list[str] = ...,
header_dirs: None | list[str] = ...,
header_namespace: None | str = ...,
header_only: bool = ...,
import_lib: None | str = ...,
include_in_android_merge_map_output: bool = ...,
labels: list[str] = ...,
libraries: list[str] = ...,
licenses: list[str] = ...,
link_whole: bool = ...,
link_without_soname: bool = ...,
linker_flags: list[str] = ...,
local_linker_flags: list[str] = ...,
local_linker_script_flags: list[str] = ...,
platform_header_dirs: None | list[(str, list[str])] = ...,
platform_import_lib: None | list[(str, str)] = ...,
platform_shared_lib: None | list[(str, str)] = ...,
platform_static_lib: None | list[(str, str)] = ...,
platform_static_pic_lib: None | list[(str, str)] = ...,
post_linker_flags: list[str] = ...,
preferred_linkage: str = ...,
prestripped: bool = ...,
provided: bool = ...,
public_include_directories: list[str] = ...,
public_system_include_directories: list[str] = ...,
raw_headers: list[str] = ...,
shared_lib: None | str = ...,
soname: None | str = ...,
static_lib: None | str = ...,
static_pic_lib: None | str = ...,
stub: bool = ...,
supported_platforms_regex: None | str = ...,
supports_lto: bool = ...,
supports_merged_linking: None | bool = ...,
supports_python_dlopen: bool = ...,
supports_shared_library_interface: bool = ...,
version: None | str = ...,
versioned_exported_lang_platform_preprocessor_flags: list[(dict[str, str], dict[str, list[(str, list[str])]])] = ...,
versioned_exported_lang_preprocessor_flags: list[(dict[str, str], dict[str, list[str]])] = ...,
versioned_exported_platform_preprocessor_flags: list[(dict[str, str], list[(str, list[str])])] = ...,
versioned_exported_preprocessor_flags: list[(dict[str, str], list[str])] = ...,
versioned_header_dirs: None | list[(dict[str, str], list[str])] = ...,
versioned_import_lib: None | list[(dict[str, str], str)] = ...,
versioned_shared_lib: None | list[(dict[str, str], str)] = ...,
versioned_soname: None | list[(dict[str, str], str)] = ...,
versioned_static_lib: None | list[(dict[str, str], str)] = ...,
versioned_static_pic_lib: None | list[(dict[str, str], str)] = ...,
) -> None

A prebuilt_cxx_library() rule represents a set of native libraries and C/C++ header files and provides various flags to control how they are linked and exported.

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).
  • deffile: Specifies the *.def file used on windows to modify a dll's exports in place of explicit __declspec(dllexport) declarations. The default is to not use a defile.
  • 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. * When reexport_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 the target and all targets that transitively depend on it. These should be specified as either a list of header files or a dictionary of header names to header files. The headers can be included with #include "$HEADER_NAMESPACE/$HEADER_NAME" or #include <$HEADER_NAMESPACE/$HEADER_NAME>, where $HEADER_NAMESPACE is the value of the target's header_namespace attribute, and $HEADER_NAME is the header name if specified, and the filename of the header file otherwise. Note that the header name can contain forward slashes (/). See header_namespace for more information.
  • 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_deps: Platform specific dependencies that will also appear to belong to any rules that depend on this one. 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 external dependencies (same format as exported_deps) that are exported if the platform matches the regex. See exported_deps for more information.
  • exported_platform_headers: Platform specific header 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 header files or a dictionary of header names to header files that will be made available for inclusion to the source files in the target and all targets that transitively depend on it if the platform matches the regex. See headers for more information.
  • exported_platform_preprocessor_flags: Platform specific exported preprocessor 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 preprocessing the source files in the target and all targets that transitively depend on it if the platform matches the regex. See exported_preprocessor_flags for more information.
  • 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. See headers for more information.
  • header_only: Indicates if this library only consists of headers or not. If this is set to True, Buck will not link this library into any library that depends on it.
  • local_linker_flags: Flags to add to the linker command line whenever the output from this rule is used in a link operation driven by this rule (e.g. when this rule links a shared library, but not when the output is linked into a shared library by another rule's link group links).
  • local_linker_script_flags: Linker script lags to add to the linker command line whenever the output from this rule is used in a link operation driven by this rule. Used by rules that need to treat linker script flags different from normal linker flags.
  • platform_shared_lib: Platform specific shared library. 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 the path to the library. See shared_lib for more information.
  • platform_static_lib: Platform specific static library. 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 the path to the library. See static_lib for more information.
  • platform_static_pic_lib: Platform specific static PIC library. 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 the path to the library. See static_pic_lib for more information.
  • preferred_linkage: Determines what linkage is used when the library is depended on by another target. To control how the dependencies of this library are linked, use link_style instead.
  • prestripped: When set, skips running strip commands when building this library.
  • shared_lib: The path to the library to use when performing shared linking.
  • static_lib: The path to the library to use when performing static linking.
  • static_pic_lib: The path to the library to use when performing static PIC linking.
  • supported_platforms_regex: If present, an un-anchored regex (in java.util.regex.Pattern syntax) that matches all platforms that this library supports. It will not be built for other platforms.
  • supports_merged_linking: Whether this rule supports building with the merged linking strategy when building for non-native binaries (e.g. when using .buckconfig s merged setting).
  • version: A string denoting a meaningful version of this rule that is optionally passed to the linker as extra metadata.

Details

Examples:

A prebuilt library containing only headers that other libraries may need.


prebuilt_cxx_library(
name = 'stdutil',
header_only = True,
header_dirs = [
'include',
],
)

A prebuilt library with static and shared libs.


prebuilt_cxx_library(
name = 'mylib',
soname = 'libmylib.so',
static_lib = 'libmylib.a',
static_pic_lib = 'libmylib_pic.a',
shared_lib = 'libmylib.so',
exported_headers = [
'mylib.h',
],
)

A prebuilt library with multiple builds for multiple platforms.


prebuilt_cxx_library(
name = 'mylib',
soname = 'libmylib.so',
platform_shared_lib = [
('android-arm', 'android-arm/libmylib.so'),
('android-x86', 'android-x86/libmylib.so'),
('iphonesimulator-x86_64', 'iphonesimulator-x86_64/libmylib.so'),
],
platform_static_lib = [
('android-arm', 'android-arm/libmylib.a'),
('android-x86', 'android-x86/libmylib.a'),
('iphonesimulator-x86_64', 'iphonesimulator-x86_64/libmylib.a'),
],
exported_headers = [
'mylib.h',
],
)