成员
- action_is_enabled
- CcToolchainInfo
- 编译
- configure_features
- create_cc_toolchain_config_info
- create_compilation_context
- create_compilation_outputs
- create_compile_variables
- create_library_to_link
- create_link_variables
- create_linker_input
- create_linking_context
- create_linking_context_from_compilation_outputs
- do_not_use_tools_cpp_compiler_present
- get_environment_variables
- get_execution_requirements
- get_memory_inefficient_command_line
- get_tool_for_action
- is_enabled
- 链接
- merge_cc_infos
- merge_compilation_contexts
- merge_compilation_outputs
action_is_enabled
bool cc_common.action_is_enabled(feature_configuration, action_name)
参数
| 参数 | 说明 | 
|---|---|
| feature_configuration | 必需 要查询的功能配置。 | 
| action_name | 必需 action_config 的名称。 | 
CcToolchainInfo
Provider cc_common.CcToolchainInfo
compile
tuple cc_common.compile(actions, feature_configuration, cc_toolchain, srcs=[], public_hdrs=[], private_hdrs=[], includes=[], quote_includes=[], system_includes=[], framework_includes=[], defines=[], local_defines=[], include_prefix='', strip_include_prefix='', user_compile_flags=[], compilation_contexts=[], name, disallow_pic_outputs=False, disallow_nopic_outputs=False, additional_inputs=[], grep_includes=None)
CompilationContext, CcCompilationOutputs) 的元组。
          
      参数
| 参数 | 说明 | 
|---|---|
| actions | 必需 actions对象。 | 
| feature_configuration | 必需 要查询的值为 feature_configuration。 | 
| cc_toolchain | 必需 要使用的 CcToolchainInfo提供方。 | 
| srcs | 默认值 = [] 要编译的源文件列表。 | 
| public_hdrs | 默认值 = [] 编译 src 所需的头文件的列表,可能会以传递方式包含在从属规则中。 | 
| private_hdrs | 默认值 = [] 编译 src 所需的头文件的列表,这些头文件不包含在从属规则中。 | 
| includes | 默认值 = [] 搜索由尖括号和引号引用的标头文件的路径。传递时通常使用 -I。以传递方式传播到从属项。 | 
| quote_includes | 默认值 = [] 搜索通过引号引用的标头文件的路径,例如#include "foo/bar/header.h"。它们可以是相对于执行根的相对路径,也可以是绝对根。通常使用 -iquote 传递。以传递方式传播到从属项。 | 
| system_includes | 默认值 = [] 搜索以尖括号引用的标头文件的路径,例如#include <foo/bar/header.h>。它们可以是相对于执行根的相对路径,也可以是绝对根。通常使用 -isystem 进行传递。以传递方式传播到从属项。 | 
| framework_includes | 默认值 = [] 搜索 Apple 框架中的头文件的路径。它们可以是相对于执行根的相对路径,也可以是绝对根。传递时通常与 -F 一起传递。以传递方式传播到从属项。 | 
| defines | 默认值 = [] 编译此目标所需的一组定义。每个定义都是一个字符串。以传递方式传播到从属项。 | 
| local_defines | 默认值 = [] 编译此目标所需的一组定义。每个定义都是一个字符串。不会以传递方式传播到从属项。 | 
| include_prefix | 默认值 = '' 要添加到此规则标头的路径中的前缀。设置后,此规则的 hdrs 属性中的标头可通过位于其代码库相对路径前面的该属性值访问。在添加此前缀之前,系统会先移除 trip_include_prefix 属性中的前缀。 | 
| strip_include_prefix | 默认值 = '' 要从此规则的标头的路径中删除的前缀。设置后,此规则的 hdrs 属性中的标头可通过其路径访问,并且此前缀被截断。如果是相对路径,则会被当作软件包相对路径。如果它是绝对路径,则会被理解为代码库相对路径。该前缀删除之后,才添加 include_prefix 属性中的前缀。 | 
| user_compile_flags | 默认值 = [] 编译选项的其他列表。 | 
| compilation_contexts | 默认值 = [] 用于编译的依赖项的头文件。 | 
| name | 必需 此属性用于为该方法创建的操作命名的输出工件。另请参阅“main_output”参数。 | 
| disallow_pic_outputs | 默认值 = False 是否应创建 PIC 输出。 | 
| disallow_nopic_outputs | 默认值 = False 是否应创建 NOPIC 输出。 | 
| additional_inputs | 默认值 = [] 编译 srcs 所需的其他文件的列表 | 
| grep_includes | File; or None;
                                     默认 = 无 | 
configure_features
FeatureConfiguration cc_common.configure_features(ctx=None, cc_toolchain, language=None, requested_features=[], unsupported_features=[])
参数
| 参数 | 说明 | 
|---|---|
| ctx | ctx; or None;
                                     默认 = 无规则上下文。 | 
| cc_toolchain | 必需 我们为其配置功能的 cc_toolchain。 | 
| language | string; or None;
                                     默认 = 无配置语言:c++ 或 objc(默认 c++) | 
| requested_features | 默认值 = [] 要启用的功能的列表。 | 
| unsupported_features | 默认值 = [] 当前规则不支持的功能的列表。 | 
create_cc_toolchain_config_info
CcToolchainConfigInfo cc_common.create_cc_toolchain_config_info(ctx, features=[], action_configs=[], artifact_name_patterns=[], cxx_builtin_include_directories=[], toolchain_identifier, host_system_name=None, target_system_name, target_cpu, target_libc, compiler, abi_version=None, abi_libc_version=None, tool_paths=[], make_variables=[], builtin_sysroot=None, cc_target_os=None)
CcToolchainConfigInfo 提供方
          
      参数
| 参数 | 说明 | 
|---|---|
| ctx | 必需 规则上下文。 | 
| features | 默认值 = [] 特征列表。 | 
| action_configs | 默认值 = [] action_configs 列表。 | 
| artifact_name_patterns | 默认值 = [] artifact_name_patterns 列表。 | 
| cxx_builtin_include_directories | 默认值 = [] 用于 C++ 编译的内置 include 目录。这些路径应该是编译器使用的确切路径,并且通常相对于 exec 根。 编译器使用的路径可以由“gcc -E -xc++ - -v”确定。 我们目前还使用 C++ 路径进行 C 编译,只要 C++ 和 C 头文件之间没有名称冲突,这种做法是安全的。 相对路径是相对于配置文件目录进行解析的。 如果编译器支持 --sysroot,则这些路径应使用 %sysroot% 而不是 include 路径,并指定 sysroot 属性,以便为 blaze 提供执行正确替换所需的信息。 | 
| toolchain_identifier | 必需 交叉工具版本中工具链的唯一标识符。必须能够将其用作路径中的目录名。 它必须与以下正则表达式匹配:[a-zA-Z_][\.\- \w]* | 
| host_system_name | string; or None;
                                     默认 = 无已忽略。 | 
| target_system_name | 必需 GNU 系统名称。 | 
| target_cpu | 必需 目标架构字符串。 | 
| target_libc | 必需 libc 版本字符串(例如“glibc-2.2.2”)。 | 
| compiler | 必需 编译器版本字符串(例如“gcc-4.1.1”)。 | 
| abi_version | string; or None;
                                     默认 = 无使用的 abi,是一个 gcc 版本。例如:“gcc-3.4” | 
| abi_libc_version | string; or None;
                                     默认 = 无我们正在使用的 abi 使用的 glibc 版本。 | 
| tool_paths | 默认值 = [] tool_paths 的列表。 | 
| make_variables | 默认值 = [] make_variables 的列表。 | 
| builtin_sysroot | string; or None;
                                     默认 = 无内置的 sysroot。如果此属性不存在,则 Bazel 不允许使用其他 sysroot,即不允许通过 --grte_top 选项使用。 | 
| cc_target_os | string; or None;
                                     默认 = 无仅供内部使用,请勿使用。 | 
create_compilation_context
CompilationContext cc_common.create_compilation_context(headers=unbound, system_includes=unbound, includes=unbound, quote_includes=unbound, framework_includes=unbound, defines=unbound, local_defines=unbound)
CompilationContext。
          
      参数
| 参数 | 说明 | 
|---|---|
| headers | 默认值 = 未绑定 编译此目标所需的一组头文件 | 
| system_includes | 默认值 = 未绑定 用尖括号引用的标头文件(即 #include <foo/bar/header.h>)的一组搜索路径。它们可以是相对于执行根的相对路径,也可以是绝对根。通常使用 -isystem 传递 | 
| includes | 默认值 = 未绑定 由尖括号和引号引用的头文件的搜索路径集。通常使用 -I 进行传递 | 
| quote_includes | 默认值 = 未绑定 使用引号引用的标头文件的一组搜索路径,即 #include "foo/bar/header.h"。它们可以是相对于执行根的相对路径,也可以是绝对根。通常使用 -iquote 传递 | 
| framework_includes | 默认值 = 未绑定 头文件的框架搜索路径集(仅限 Apple 平台) | 
| defines | 默认值 = 未绑定 编译此目标所需的一组定义。每个定义都是一个字符串。以传递方式传播到从属项。 | 
| local_defines | 默认值 = 未绑定 编译此目标所需的一组定义。每个定义都是一个字符串。不会传递至从属项。 | 
create_compilation_outputs
CcCompilationOutputs cc_common.create_compilation_outputs(objects=None, pic_objects=None)
参数
| 参数 | 说明 | 
|---|---|
| objects | depset; or None;
                                     默认 = 无对象文件列表。 | 
| pic_objects | depset; or None;
                                     默认 = 无pic 对象文件列表。 | 
create_compile_variables
Variables cc_common.create_compile_variables(cc_toolchain, feature_configuration, source_file=None, output_file=None, user_compile_flags=None, include_directories=None, quote_include_directories=None, system_include_directories=None, framework_include_directories=None, preprocessor_defines=None, thinlto_index=None, thinlto_input_bitcode_file=None, thinlto_output_object_file=None, use_pic=False, add_legacy_cxx_options=False, variables_extension=unbound)
参数
| 参数 | 说明 | 
|---|---|
| cc_toolchain | 必需 cc_toolchain。 | 
| feature_configuration | 必需 要查询的功能配置。 | 
| source_file | 默认值 = 无 用于编译的可选源文件。请在此处传递 source_file(而非将其附加到从 cc_common.get_memory_inefficient_command_line 生成的命令行的末尾),因为工具链作者的作用是正确指定和定位编译器标记。 | 
| output_file | 默认值 = 无 编译的可选输出文件。请在此处传递 output_file,而不是将其附加到通过 cc_common.get_memory_inefficient_command_line 生成的命令行的末尾,因为这样就可以由工具链作者正确指定和定位编译器标记。 | 
| user_compile_flags | sequence of strings; or None;
                                     默认 = 无其他编译标志 (copts) 的列表。 | 
| include_directories | depset; or None;
                                     默认 = 无移除 include 目录。 | 
| quote_include_directories | depset; or None;
                                     默认 = 无取消引号包含目录。 | 
| system_include_directories | depset; or None;
                                     默认 = 无移除系统包含目录。 | 
| framework_include_directories | depset; or None;
                                     默认 = 无框架包含目录的弃用。 | 
| preprocessor_defines | depset; or None;
                                     默认 = 无预处理器定义的设置。 | 
| thinlto_index | string; or None;
                                     默认 = 无LTO 索引文件路径。 | 
| thinlto_input_bitcode_file | string; or None;
                                     默认 = 无输入到 LTO 后端的位码文件。 | 
| thinlto_output_object_file | string; or None;
                                     默认 = 无LTO 后端输出的对象文件。 | 
| use_pic | 默认值 = False 如果为 true,编译将生成与位置无关的代码。 | 
| add_legacy_cxx_options | 默认值 = False 未使用。 | 
| variables_extension | dict;
                                     默认 = 未绑定编译操作使用的其他变量的字典。 | 
create_library_to_link
LibraryToLink cc_common.create_library_to_link(actions, feature_configuration=None, cc_toolchain=None, static_library=None, pic_static_library=None, dynamic_library=None, interface_library=None, pic_objects=unbound, objects=unbound, alwayslink=False, dynamic_library_symlink_path='', interface_library_symlink_path='')
LibraryToLink
          
      参数
| 参数 | 说明 | 
|---|---|
| actions | 必需 actions对象。 | 
| feature_configuration | 默认值 = 无 要查询的值为 feature_configuration。 | 
| cc_toolchain | 默认值 = 无 要使用的 CcToolchainInfo提供方。 | 
| static_library | File; or None;
                                     默认 = 无要链接的静态库的 File。 | 
| pic_static_library | File; or None;
                                     默认 = 无要关联的图片静态库的 File。 | 
| dynamic_library | File; or None;
                                     默认 = 无要关联的动态库的 File。始终用于运行时;如果未传递interface_library,则用于链接。 | 
| interface_library | File; or None;
                                     默认 = 无要关联的接口库的 File。 | 
| pic_objects | sequence of Files;
                                     默认 = 未绑定实验性功能,请勿使用 | 
| objects | sequence of Files;
                                     默认 = 未绑定实验性功能,请勿使用 | 
| alwayslink | 默认值 = False 是否关联 --whole_archive 块中的静态库/对象。 | 
| dynamic_library_symlink_path | string;
                                     默认值 = ''替换 solib 目录中动态库链接的默认路径。空字符串以使用默认值。 | 
| interface_library_symlink_path | 默认值 = '' 替换 solib 目录中接口库链接的默认路径。空字符串以使用默认值。 | 
create_link_variables
Variables cc_common.create_link_variables(cc_toolchain, feature_configuration, library_search_directories=None, runtime_library_search_directories=None, user_link_flags=None, output_file=None, param_file=None, def_file=None, is_using_linker=True, is_linking_dynamic_library=False, must_keep_debug=True, use_test_only_flags=False, is_static_linking_mode=True)
参数
| 参数 | 说明 | 
|---|---|
| cc_toolchain | 必需 cc_toolchain。 | 
| feature_configuration | 必需 要查询的功能配置。 | 
| library_search_directories | None; or depset;
                                     默认 = 无表示链接器在链接时在其中查找库的目录。 | 
| runtime_library_search_directories | None; or depset;
                                     默认 = 无移除了加载器将在运行时查找库的目录。 | 
| user_link_flags | None; or sequence;
                                     默认 = 无其他链接标志 (linkopts) 列表。 | 
| output_file | 默认值 = 无 可选的输出文件路径。 | 
| param_file | 默认值 = 无 可选参数文件路径。 | 
| def_file | 默认值 = 无 .def 文件路径(可选)。 | 
| is_using_linker | 默认值 = True 使用链接器时为 true,使用归档程序时为 false。调用方负责使此操作与所使用的操作名称保持同步(如果链接可执行文件或动态库,is_using_linker = True;如果归档静态库,则 is_using_linker = False)。 | 
| is_linking_dynamic_library | 默认值 = False 创建动态库时为 true,可执行库或静态库时为 false。调用方负责使此操作与所使用的操作名称保持同步。修复 b/65151735 后,此字段将被移除。 | 
| must_keep_debug | 默认值 = True 如果设置为 True,bazel 将公开“strip_debug_symbols”变量,该变量通常用于链接器从输出文件中剥离调试符号。 | 
| use_test_only_flags | 默认值 = False 当设置为 true 时,“is_cc_test”变量。 | 
| is_static_linking_mode | 默认值 = True 未使用。 | 
create_linker_input
LinkerInput cc_common.create_linker_input(owner, libraries=None, user_link_flags=None, additional_inputs=None)
LinkerInput。
          
      参数
| 参数 | 说明 | 
|---|---|
| owner | 必需 生成此输入中使用的所有文件的目标的标签。 | 
| libraries | None; or depset;
                                     默认 = 无LibraryToLink的列表。 | 
| user_link_flags | None; or depset of strings; or sequence of strings;
                                     默认 = 无以字符串形式传递的用户链接标志。接受 [String]、[[String]] 或 depset(String)。不建议采用后一种方法,因为它只是出于兼容性目的而保留,其设置是扁平化的。如果您想通过不扁平的 depsets() 传播 user_link_flag,请将它们封装在 LinkerInput 中,使其在结束前不会被展平。 | 
| additional_inputs | None; or depset;
                                     默认 = 无对于关联操作的其他输入,例如关联脚本。 | 
create_linking_context
LinkingContext cc_common.create_linking_context(linker_inputs=None, libraries_to_link=None, user_link_flags=None, additional_inputs=None)
LinkingContext。
          
      参数
| 参数 | 说明 | 
|---|---|
| linker_inputs | None; or depset;
                                     默认 = 无LinkerInput已起飞。 | 
| libraries_to_link | None; or sequence;
                                     默认 = 无已弃用。此参数已被弃用,很快就会被移除。请勿依赖它。此选项已通过 --+incompatible_require_linker_input_cc_api停用。使用此标记验证您的代码与其即将移除的兼容性兼容。LibraryToLink的列表。 | 
| user_link_flags | None; or sequence;
                                     默认 = 无已弃用。此参数已被弃用,很快就会被移除。请勿依赖它。此选项已通过 --+incompatible_require_linker_input_cc_api停用。使用此标记验证您的代码与其即将移除的兼容性兼容。以字符串形式传递的用户链接标志列表。 | 
| additional_inputs | None; or sequence;
                                     默认 = 无已弃用。此参数已被弃用,很快就会被移除。请勿依赖它。此选项已通过 --+incompatible_require_linker_input_cc_api停用。使用此标记验证您的代码与其即将移除的兼容性兼容。对于关联操作的其他输入,例如关联脚本。 | 
create_linking_context_from_compilation_outputs
tuple cc_common.create_linking_context_from_compilation_outputs(actions, feature_configuration, cc_toolchain, compilation_outputs, user_link_flags=[], linking_contexts=[], name, language='c++', alwayslink=False, additional_inputs=[], disallow_static_libraries=False, disallow_dynamic_library=False, grep_includes=None)
CcLinkingContext, CcLinkingOutputs) 的元组。
          
      参数
| 参数 | 说明 | 
|---|---|
| actions | 必需 actions对象。 | 
| feature_configuration | 必需 要查询的值为 feature_configuration。 | 
| cc_toolchain | 必需 要使用的 CcToolchainInfo提供方。 | 
| compilation_outputs | 必需 包含要链接的对象文件的编译输出。 | 
| user_link_flags | 默认值 = [] 其他关联选项列表。 | 
| linking_contexts | 默认值 = [] 来自依赖项的库。这些库会关联到 link() 调用的输出工件中,无论是二进制文件还是库。 | 
| name | 必需 此属性用于为该方法创建的操作命名的输出工件。 | 
| language | 默认值 = 'c++' 目前仅支持 C++。请勿使用此参数。 | 
| alwayslink | 默认值 = False 是否应始终链接此库。 | 
| additional_inputs | 默认值 = [] 对于关联操作的其他输入,例如关联脚本。 | 
| disallow_static_libraries | 默认值 = False 是否应创建静态库。 | 
| disallow_dynamic_library | 默认值 = False 是否应创建动态库。 | 
| grep_includes | File; or None;
                                     默认 = 无 | 
do_not_use_tools_cpp_compiler_present
None cc_common.do_not_use_tools_cpp_compiler_present
get_environment_variables
dict cc_common.get_environment_variables(feature_configuration, action_name, variables)
参数
| 参数 | 说明 | 
|---|---|
| feature_configuration | 必需 要查询的功能配置。 | 
| action_name | 必需 操作的名称。必须是 @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) 中的某个名称 | 
| variables | 必需 用于模板展开的构建变量。 | 
get_execution_requirements
sequence cc_common.get_execution_requirements(feature_configuration, action_name)
参数
| 参数 | 说明 | 
|---|---|
| feature_configuration | 必需 要查询的功能配置。 | 
| action_name | 必需 操作的名称。必须是 @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) 中的某个名称 | 
get_memory_inefficient_command_line
sequence cc_common.get_memory_inefficient_command_line(feature_configuration, action_name, variables)
参数
| 参数 | 说明 | 
|---|---|
| feature_configuration | 必需 要查询的功能配置。 | 
| action_name | 必需 操作的名称。必须是 @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) 中的某个名称 | 
| variables | 必需 用于模板展开的构建变量。 | 
get_tool_for_action
string cc_common.get_tool_for_action(feature_configuration, action_name)
参数
| 参数 | 说明 | 
|---|---|
| feature_configuration | 必需 要查询的功能配置。 | 
| action_name | 必需 操作的名称。必须是 @bazel_tools//tools/build_defs/cc:action_names.bzl (https://github.com/bazelbuild/bazel/blob/master/tools/build_defs/cc/action_names.bzl) 中的某个名称 | 
is_enabled
bool cc_common.is_enabled(feature_configuration, feature_name)
参数
| 参数 | 说明 | 
|---|---|
| feature_configuration | 必需 要查询的功能配置。 | 
| feature_name | 必需 地图项的名称。 | 
链接
CcLinkingOutputs cc_common.link(actions, feature_configuration, cc_toolchain, compilation_outputs=None, user_link_flags=[], linking_contexts=[], name, language='c++', output_type='executable', link_deps_statically=True, stamp=0, additional_inputs=[], grep_includes=None, additional_outputs=unbound)
参数
| 参数 | 说明 | 
|---|---|
| actions | 必需 actions对象。 | 
| feature_configuration | 必需 要查询的值为 feature_configuration。 | 
| cc_toolchain | 必需 要使用的 CcToolchainInfo提供方。 | 
| compilation_outputs | CcCompilationOutputs; or None;
                                     默认 = 无包含要链接的对象文件的编译输出。 | 
| user_link_flags | 默认值 = [] 链接器选项的其他列表。 | 
| linking_contexts | 默认值 = [] 关联依赖项中要关联到由此规则生成的关联上下文中的上下文。 | 
| name | 必需 此属性用于为该方法创建的操作命名的输出工件。 | 
| language | 默认值 = 'c++' 目前仅支持 C++。请勿使用此参数。 | 
| output_type | 默认值 = 'executable' 可以是“executable”或“dynamic_library” | 
| link_deps_statically | 默认值 = True 如果为 True,则以静态方式关联依赖项;如果要以动态方式关联,则为 False。 | 
| stamp | 默认值 = 0 如果 output_type 为“executable”,则是否在链接的可执行文件中包含 build 信息。如果为 1,则始终包含 build 信息。如果为 0(始终排除默认 build 信息,如果为 -1,则使用默认行为,该行为可能会被 --[no]stamp 标志替换。在为测试规则生成可执行输出时,应取消设置(或将其设置为 0)。 | 
| additional_inputs | sequence; or depset;
                                     默认值 = []对于关联操作的其他输入,例如关联脚本。 | 
| grep_includes | File; or None;
                                     默认 = 无 | 
| additional_outputs | sequence;
                                     默认 = 未绑定对于关联操作的其他输出,例如地图文件。 | 
merge_cc_infos
CcInfo cc_common.merge_cc_infos(direct_cc_infos=[], cc_infos=[])
CcInfo 合并为一个。
          
      参数
| 参数 | 说明 | 
|---|---|
| direct_cc_infos | 默认值 = [] 要合并的 CcInfo的列表,其标头将由返回的提供程序中的直接字段导出。 | 
| cc_infos | 默认值 = [] 要合并的 CcInfo的列表,其标头不会由返回的提供程序中的直接字段导出。 | 
merge_compilation_contexts
CompilationContext cc_common.merge_compilation_contexts(compilation_contexts=[])
CompilationContexts 合并为一个。
          
      参数
| 参数 | 说明 | 
|---|---|
| compilation_contexts | 默认值 = [] 要合并的 CompilationContexts的列表。每个上下文的标头将由返回的提供程序中的直接字段导出。 | 
merge_compilation_outputs
CcCompilationOutputs cc_common.merge_compilation_outputs(compilation_outputs=[])
参数
| 参数 | 说明 | 
|---|---|
| compilation_outputs | 默认值 = [] |