windows_resource
A windows_resource() rule specifies a set of Window's Resource File (.rc) that are compiled into object files.
Details
The files are compiled into .res files using rc.exe and then compiled into object files using cvtres.exe. They are not part of cxx_library because Microsoft's linker ignores the resources unless they are specified as an object file, meaning including them in a possibly static library is unintuitive.
Function Signature
def windows_resource(
*,
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",
deps: list[str] = [],
header_namespace: None | str = None,
headers: list[str] | dict[str, str] = [],
include_directories: list[str] = [],
labels: list[str] = [],
platform_headers: list[(str, list[str] | dict[str, str])] = [],
raw_headers: list[str] = [],
srcs: list[str | (str, 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
-
header_namespace: (defaults to:None)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. Seeheadersfor more information. -
headers: (defaults to:[])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 name can contain forward slashes (
/). The headers can be included with#include "$HEADER_NAMESPACE/$HEADER_NAME"or#include <$HEADER_NAMESPACE/$HEADER_NAME>, where$HEADER_NAMESPACEis the value of the target'sheader_namespaceattribute, and$HEADER_NAMEis the header name if specified, and the filename of the header file otherwise. Seeheader_namespacefor more information. -
include_directories: (defaults to:[])A list of include directories (with
raw_headers) to be added to the compile command for compiling this target (via-I). An include directory is relative to the current package. -
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(). -
platform_headers: (defaults to:[])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 if the platform matches the regex. See
headersfor more information. -
raw_headers: (defaults to:[])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_directoriesandpublic_include_directoriesare the recommended way to add raw headers to the search path (they will be added via-I).compiler_flags,preprocessor_flagsandexported_preprocessor_flagscan also be used to add such raw headers to the search path if inclusion via-isystemor-iquoteis needed.raw_headerscannot be used together withheadersorexported_headersin the same target. -
srcs: (defaults to:[])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).
Examples
# A rule that includes a single .rc file and compiles it into an object file.
windows_resource(
name = "resources",
srcs = [
"resources.rc",
],
)
# A rule that links against the above windows_resource rule.
cxx_binary(
name = "app",
srcs = [
"main.cpp",
],
deps = [
":resources"
],
)