prebuilt_cxx_library_group
A prebuilt_cxx_library_group()
rule represents a group of native libraries which should be handled together in a single rule, perhaps using special link-line construction.
Function Signature
def prebuilt_cxx_library_group(
*,
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] = {},
_create_third_party_build_root: str = "prelude//third-party/tools:create_build",
_cxx_toolchain: str = "gh_facebook_buck2_shims_meta//:cxx",
contacts: list[str] = [],
default_host_platform: None | str = None,
deps: list[str] = [],
exported_deps: list[str] = [],
exported_platform_deps: list[(str, list[str])] = [],
exported_preprocessor_flags: list[str] = [],
import_libs: dict[str, str] = {},
include_dirs: list[str] = [],
include_in_android_merge_map_output: bool = True,
labels: list[str] = [],
licenses: list[str] = [],
provided_shared_libs: dict[str, str] = {},
shared_libs: dict[str, str] = {},
shared_link: list[str] = [],
static_libs: list[str] = [],
static_link: list[str] = [],
static_pic_libs: list[str] = [],
static_pic_link: list[str] = [],
supported_platforms_regex: None | str = None,
supports_shared_library_interface: bool = True,
version: None | str = 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
-
exported_deps
: (defaults to:[]
)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_platform_deps
: (defaults to:[]
)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. Seeexported_deps
for more information. -
provided_shared_libs
: (defaults to:{}
)The map of system-provided shared library names to paths used when using the shared link style. The
shared_link
parameter should refer to these libs using their library name. -
shared_libs
: (defaults to:{}
)The map of shared library names to paths used when using the shared link style. The
shared_link
parameter should refer to these libs using their library name. -
shared_link
: (defaults to:[]
)The arguments to use when linking this library group using the shared link style. The actual paths to libraries should be listed in the
shared_libs
parameter, and referenced via the the$(lib [name])
macro (or the$(rel-lib [name])
macro, when the shared library should be linked using the-L[dir] -l[name]
style) in these args. -
static_libs
: (defaults to:[]
)The paths to the libraries used when using the static link style. The
static_link
parameter should refer to these libs using their index number. -
static_link
: (defaults to:[]
)The arguments to use when linking this library group using the static link style. The actual paths to libraries should be listed in the
static_libs
parameter, and referenced via the the$(lib [index])
macro in these args. -
static_pic_libs
: (defaults to:[]
)The paths to the libraries used when using the static link style. The
static_pic_link
parameter should refer to these libs using their index number. -
static_pic_link
: (defaults to:[]
)The arguments to use when linking this library group using the static-pic link style. The actual paths to libraries should be listed in the
static_pic_libs
parameter, and referenced via the the$(lib [index])
macro in these args. -
supported_platforms_regex
: (defaults to:None
)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.
-
version
: (defaults to:None
)A string denoting a meaningful version of this rule that is optionally passed to the linker as extra metadata.
Examples
A prebuilt library group wrapping two libraries that must be linked together.
prebuilt_cxx_library_group(
name = 'util',
static_link = [
'-Wl,--start-group',
'$(lib 0)',
'$(lib 1)',
'-Wl,--end-group',
],
static_libs = [
'lib/liba.a',
'lib/libb.a',
],
static_pic_link = [
'-Wl,--start-group',
'$(lib 0)',
'$(lib 1)',
'-Wl,--end-group',
],
static_libs = [
'lib/liba_pic.a',
'lib/libb_pic.a',
],
shared_link = [
'$(rel-lib liba.so)',
'$(rel-lib libb.so)',
],
shared_libs = {
'liba.so': 'lib/liba.so',
},
provided_shared_libs = {
'libb.so': 'lib/libb.so',
},
)