-
Notifications
You must be signed in to change notification settings - Fork 248
/
repositories.bzl
110 lines (88 loc) · 5.27 KB
/
repositories.bzl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
"""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")
load("//foreign_cc/private/framework:toolchain.bzl", "register_framework_toolchains")
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,
cmake_version = "3.23.2",
make_version = "4.4.1",
ninja_version = "1.12.1",
meson_version = "1.5.1",
pkgconfig_version = "0.29.2",
register_preinstalled_tools = True,
register_built_tools = True,
register_toolchains = True,
register_built_pkgconfig_toolchain = True):
"""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`.
meson_version: The target version of the meson toolchain if `register_built_tools` is set to `True`.
pkgconfig_version: The target version of the pkg_config toolchain if `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
register_toolchains: If true, registers the toolchains via native.register_toolchains. Used by bzlmod
register_built_pkgconfig_toolchain: If true, the built pkgconfig toolchain will be registered. On Windows it may be preferrable to set this to False, as
this requires the --enable_runfiles bazel option. Also note that building pkgconfig from source under bazel results in paths that are more
than 256 characters long, which will not work on Windows unless the following options are added to the .bazelrc and symlinks are enabled in Windows.
startup --windows_enable_symlinks -> This is required to enable symlinking to avoid long runfile paths
build --action_env=MSYS=winsymlinks:nativestrict -> This is required to enable symlinking to avoid long runfile paths
startup --output_user_root=C:/b -> This is required to keep paths as short as possible
"""
register_framework_toolchains(register_toolchains = register_toolchains)
if register_toolchains:
native.register_toolchains(*native_tools_toolchains)
if register_default_tools:
prebuilt_toolchains(cmake_version, ninja_version, register_toolchains)
if register_built_tools:
built_toolchains(
cmake_version = cmake_version,
make_version = make_version,
ninja_version = ninja_version,
meson_version = meson_version,
pkgconfig_version = pkgconfig_version,
register_toolchains = register_toolchains,
register_built_pkgconfig_toolchain = register_built_pkgconfig_toolchain,
)
if register_preinstalled_tools:
preinstalled_toolchains()
maybe(
http_archive,
name = "bazel_features",
sha256 = "ba1282c1aa1d1fffdcf994ab32131d7c7551a9bc960fbf05f42d55a1b930cbfb",
strip_prefix = "bazel_features-1.15.0",
url = "https://github.com/bazel-contrib/bazel_features/releases/download/v1.15.0/bazel_features-v1.15.0.tar.gz",
)
maybe(
http_archive,
name = "bazel_skylib",
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
"https://github.com/bazelbuild/bazel-skylib/releases/download/1.2.1/bazel-skylib-1.2.1.tar.gz",
],
sha256 = "f7be3474d42aae265405a592bb7da8e171919d74c16f082a5457840f06054728",
)
maybe(
http_archive,
name = "rules_python",
sha256 = "84aec9e21cc56fbc7f1335035a71c850d1b9b5cc6ff497306f84cced9a769841",
strip_prefix = "rules_python-0.23.1",
url = "https://github.com/bazelbuild/rules_python/archive/refs/tags/0.23.1.tar.gz",
)