2021-01-25 21:42:14 +00:00
|
|
|
"""A module for defining WORKSPACE dependencies required for rules_foreign_cc"""
|
|
|
|
|
2018-08-30 16:08:44 +00:00
|
|
|
load("//for_workspace:repositories.bzl", "repositories")
|
2019-01-18 17:06:10 +00:00
|
|
|
load(
|
|
|
|
"//tools/build_defs/shell_toolchain/toolchains:ws_defs.bzl",
|
|
|
|
shell_toolchain_workspace_initalization = "workspace_part",
|
|
|
|
)
|
2018-08-22 12:31:01 +00:00
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
# buildifier: disable=unnamed-macro
|
2019-01-31 14:11:28 +00:00
|
|
|
def rules_foreign_cc_dependencies(
|
|
|
|
native_tools_toolchains = [],
|
|
|
|
register_default_tools = True,
|
|
|
|
additonal_shell_toolchain_mappings = [],
|
2020-05-04 17:50:45 +00:00
|
|
|
additonal_shell_toolchain_package = None):
|
2021-01-22 14:25:49 +00:00
|
|
|
"""Call this function from the WORKSPACE file to initialize rules_foreign_cc \
|
|
|
|
dependencies and let neccesary code generation happen \
|
|
|
|
(Code generation is needed to support different variants of the C++ Starlark API.).
|
2019-01-08 11:25:16 +00:00
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
Args:
|
2019-01-08 11:25:16 +00:00
|
|
|
native_tools_toolchains: pass the toolchains for toolchain types
|
2021-01-22 14:25:49 +00:00
|
|
|
'@rules_foreign_cc//tools/build_defs:cmake_toolchain' and
|
|
|
|
'@rules_foreign_cc//tools/build_defs:ninja_toolchain' with the needed platform constraints.
|
|
|
|
If you do not pass anything, registered default toolchains will be selected (see below).
|
2019-01-08 11:25:16 +00:00
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
register_default_tools: If True, the cmake and ninja toolchains, calling corresponding
|
|
|
|
preinstalled binaries by name (cmake, ninja) will be registered after
|
|
|
|
'native_tools_toolchains' without any platform constraints. The default is True.
|
2019-01-31 14:11:28 +00:00
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
additonal_shell_toolchain_mappings: Mappings of the shell toolchain functions to
|
|
|
|
execution and target platforms constraints. Similar to what defined in
|
|
|
|
@rules_foreign_cc//tools/build_defs/shell_toolchain/toolchains:toolchain_mappings.bzl
|
|
|
|
in the TOOLCHAIN_MAPPINGS list. Please refer to example in @rules_foreign_cc//toolchain_examples.
|
2019-01-31 14:11:28 +00:00
|
|
|
|
2021-01-22 14:25:49 +00:00
|
|
|
additonal_shell_toolchain_package: A package under which additional toolchains, referencing
|
|
|
|
the generated data for the passed additonal_shell_toolchain_mappings, will be defined.
|
|
|
|
This value is needed since register_toolchains() is called for these toolchains.
|
|
|
|
Please refer to example in @rules_foreign_cc//toolchain_examples.
|
2019-01-08 11:25:16 +00:00
|
|
|
"""
|
2018-08-27 12:56:16 +00:00
|
|
|
repositories()
|
2019-01-18 17:06:10 +00:00
|
|
|
|
2019-01-31 14:11:28 +00:00
|
|
|
shell_toolchain_workspace_initalization(
|
|
|
|
additonal_shell_toolchain_mappings,
|
|
|
|
additonal_shell_toolchain_package,
|
|
|
|
)
|
2019-01-08 11:25:16 +00:00
|
|
|
|
|
|
|
native.register_toolchains(*native_tools_toolchains)
|
|
|
|
if register_default_tools:
|
|
|
|
native.register_toolchains(
|
|
|
|
"@rules_foreign_cc//tools/build_defs:preinstalled_cmake_toolchain",
|
|
|
|
"@rules_foreign_cc//tools/build_defs:preinstalled_ninja_toolchain",
|
2020-09-07 08:48:26 +00:00
|
|
|
"@rules_foreign_cc//tools/build_defs:preinstalled_make_toolchain",
|
2019-01-08 11:25:16 +00:00
|
|
|
)
|