Skip to content

Latest commit

 

History

History
executable file
·
57 lines (44 loc) · 7.1 KB

cc_archive_docs.md

File metadata and controls

executable file
·
57 lines (44 loc) · 7.1 KB

Module providing means of creating archive files which use mapping metadata.

cc_archive

cc_archive(name, additional_linker_inputs, copts, defines, deps, hdrs_map, include_prefix, includes,
           linkopts, linkstatic, local_defines, private_hdrs, public_hdrs, srcs, strip_include_prefix)

This rule allows for creating archive objects, which can utilize the headers map and propagate them futher down the dependency chain.

Example:

cc_archive(
    name = "foo",
    hdrs_map = {
        "**/*.hpp": ["bar/{filename}"],
    },
    deps = [
        ":foo_hdrs",
    ],
    srcs = [
        "foo.cpp",
    ],
)

ATTRIBUTES

Name Description Type Mandatory Default
name A unique name for this target. Name required
additional_linker_inputs Pass these files to the C++ linker command.

For example, compiled Windows .res files can be provided here to be embedded in the binary target.
List of labels optional []
copts Add these options to the C++ compilation command. Subject to "Make variable" substitution and Bourne shell tokenization. Each string in this attribute is added in the given order to COPTS before compiling the binary target. The flags take effect only for compiling this target, not its dependencies, so be careful about header files included elsewhere. All paths should be relative to the workspace, not to the current package.

If the package declares the feature no_copts_tokenization, Bourne shell tokenization applies only to strings that consist of a single "Make" variable.
List of strings optional []
defines List of defines to add to the compile line. Subject to "Make" variable substitution and Bourne shell tokenization. Each string, which must consist of a single Bourne shell token, is prepended with -D and added to the compile command line to this target, as well as to every rule that depends on it. Be very careful, since this may have far-reaching effects. When in doubt, add define values to local_defines instead. List of strings optional []
deps The list of dependencies of current target List of labels optional []
hdrs_map Dictionary describing paths under which header files should be avaiable as.

Keys are simple glob pathnames, used to match agains all header files avaiable in the rule. Values are list of paths to which matching header files should be mapped.

'{filename}' is special token used to signify to matching file name.

For example: '"**/*o.hpp": ["a/{filename}"]' - will ensure all hpp files with names ending with '0' will be also avaible as if they were placed in a subdirectory.
Dictionary: String -> List of strings optional {}
include_prefix The prefix to add to the paths of the headers of this rule. When set, the headers in the hdrs attribute of this rule are accessible at is the value of this attribute prepended to their repository-relative path.

The prefix in the strip_include_prefix attribute is removed before this prefix is added.
String optional ""
includes List of include dirs to be added to the compile line. Subject to "Make variable" substitution. Each string is prepended with -isystem and added to COPTS. Unlike COPTS, these flags are added for this rule and every rule that depends on it. (Note: not the rules it depends upon!) Be very careful, since this may have far-reaching effects. When in doubt, add "-I" flags to COPTS instead.

Headers must be added to srcs or hdrs, otherwise they will not be available to dependent rules when compilation is sandboxed (the default).
List of strings optional []
linkopts Add these flags to the C++ linker command. Subject to "Make" variable substitution, Bourne shell tokenization and label expansion. Each string in this attribute is added to LINKOPTS before linking the binary target. Each element of this list that does not start with $ or - is assumed to be the label of a target in deps. The list of files generated by that target is appended to the linker options. An error is reported if the label is invalid, or is not declared in deps. List of strings optional []
linkstatic Link the binary in static mode. Boolean optional True
local_defines List of defines to add to the compile line. Subject to "Make" variable substitution and Bourne shell tokenization. Each string, which must consist of a single Bourne shell token, is prepended with -D and added to the compile command line for this target, but not to its dependents. List of strings optional []
private_hdrs List of headers that CANNOT be included by dependent rules. Notice: the cutoff happens during compilation. List of labels optional []
public_hdrs List of headers that may be included by dependent rules transitively. Notice: the cutoff happens during compilation. List of labels optional []
srcs The list of source files. List of labels required
strip_include_prefix The prefix to strip from the paths of the headers of this rule. When set, the headers in the hdrs attribute of this rule are accessible at their path with this prefix cut off.

If it's a relative path, it's taken as a package-relative one. If it's an absolute one, it's understood as a repository-relative path.

The prefix in the include_prefix attribute is added after this prefix is stripped.
String optional ""