2021-03-12 17:08:13 +00:00
|
|
|
"""A module for defining WORKSPACE dependencies required for rules_foreign_cc"""
|
|
|
|
|
|
|
|
load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive")
|
|
|
|
load("@bazel_tools//tools/build_defs/repo:utils.bzl", "maybe")
|
2021-04-30 16:03:32 +00:00
|
|
|
load("//foreign_cc/private/framework:toolchain.bzl", "register_framework_toolchains")
|
2021-03-12 17:08:13 +00:00
|
|
|
load("//toolchains:toolchains.bzl", "built_toolchains", "prebuilt_toolchains", "preinstalled_toolchains")
|
|
|
|
|
|
|
|
# buildifier: disable=unnamed-macro
|
|
|
|
def rules_foreign_cc_dependencies(
|
|
|
|
native_tools_toolchains = [],
|
|
|
|
register_default_tools = True,
|
2021-06-16 11:46:23 +00:00
|
|
|
cmake_version = "3.20.4",
|
2021-03-12 17:08:13 +00:00
|
|
|
make_version = "4.3",
|
|
|
|
ninja_version = "1.10.2",
|
|
|
|
register_preinstalled_tools = True,
|
2021-04-30 16:03:32 +00:00
|
|
|
register_built_tools = True):
|
2021-03-12 17:08:13 +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.).
|
|
|
|
|
|
|
|
Args:
|
|
|
|
native_tools_toolchains: pass the toolchains for toolchain types
|
|
|
|
'@rules_foreign_cc//toolchains:cmake_toolchain' and
|
|
|
|
'@rules_foreign_cc//toolchains:ninja_toolchain' with the needed platform constraints.
|
|
|
|
If you do not pass anything, registered default toolchains will be selected (see below).
|
|
|
|
|
|
|
|
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.
|
|
|
|
|
|
|
|
cmake_version: The target version of the cmake toolchain if `register_default_tools`
|
|
|
|
or `register_built_tools` is set to `True`.
|
|
|
|
|
|
|
|
make_version: The target version of the default make toolchain if `register_built_tools`
|
|
|
|
is set to `True`.
|
|
|
|
|
|
|
|
ninja_version: The target version of the ninja toolchain if `register_default_tools`
|
|
|
|
or `register_built_tools` is set to `True`.
|
|
|
|
|
|
|
|
register_preinstalled_tools: If true, toolchains will be registered for the native built tools
|
|
|
|
installed on the exec host
|
|
|
|
|
|
|
|
register_built_tools: If true, toolchains that build the tools from source are registered
|
|
|
|
"""
|
|
|
|
|
2021-04-30 16:03:32 +00:00
|
|
|
register_framework_toolchains()
|
2021-03-12 17:08:13 +00:00
|
|
|
|
|
|
|
native.register_toolchains(*native_tools_toolchains)
|
|
|
|
|
|
|
|
if register_default_tools:
|
|
|
|
prebuilt_toolchains(cmake_version, ninja_version)
|
|
|
|
|
|
|
|
if register_built_tools:
|
|
|
|
built_toolchains(
|
|
|
|
cmake_version = cmake_version,
|
|
|
|
make_version = make_version,
|
|
|
|
ninja_version = ninja_version,
|
|
|
|
)
|
|
|
|
|
|
|
|
if register_preinstalled_tools:
|
|
|
|
preinstalled_toolchains()
|
|
|
|
|
|
|
|
maybe(
|
|
|
|
http_archive,
|
|
|
|
name = "bazel_skylib",
|
|
|
|
sha256 = "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c",
|
|
|
|
urls = [
|
|
|
|
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
|
|
|
|
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.0.3/bazel-skylib-1.0.3.tar.gz",
|
|
|
|
],
|
|
|
|
)
|