-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathMODULE.bazel
More file actions
151 lines (124 loc) · 5.16 KB
/
MODULE.bazel
File metadata and controls
151 lines (124 loc) · 5.16 KB
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
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# *******************************************************************************
# Copyright (c) 2025 Contributors to the Eclipse Foundation
#
# See the NOTICE file(s) distributed with this work for additional
# information regarding copyright ownership.
#
# This program and the accompanying materials are made available under the
# terms of the Apache License Version 2.0 which is available at
# https://www.apache.org/licenses/LICENSE-2.0
#
# SPDX-License-Identifier: Apache-2.0
# *******************************************************************************
module(
name = "score_bazel_tools_cc",
version = "0.1.0",
compatibility_level = 0,
)
########################
# Direct dependencies. #
########################
bazel_dep(name = "toolchains_llvm", version = "1.4.0", dev_dependency = True)
llvm = use_extension("@toolchains_llvm//toolchain/extensions:llvm.bzl", "llvm", dev_dependency = True)
llvm.toolchain(
llvm_version = "15.0.2",
stdlib = {"linux-x86_64": "stdc++"},
)
use_repo(llvm, "llvm_toolchain")
register_toolchains(
"@llvm_toolchain//:all",
dev_dependency = True,
)
bazel_dep(name = "score_bazel_tools_python", version = "0.1.3", repo_name = "bazel_tools_python")
##########################
# Internal dependencies. #
##########################
bazel_dep(name = "rules_shell", version = "0.6.1")
bazel_dep(name = "rules_cc", version = "0.1.1")
bazel_dep(name = "platforms", version = "0.0.11", dev_dependency = True)
bazel_dep(name = "buildifier_prebuilt", version = "8.2.1", dev_dependency = True)
bazel_dep(name = "protobuf", version = "29.0", dev_dependency = True)
# Unfortunately bazel_skylib can not be dev_dependency because we use some of its libraries.
bazel_dep(name = "bazel_skylib", version = "1.7.1")
# Unfortunately rules_python can not be dev_dependency because we provide our pip hub using it.
bazel_dep(name = "rules_python", version = "1.4.1")
# We patch rules_python patch to python coverage files.
# This enable us to select our own .coveragerc file when issuing a bazel coverage command.
# Reference: https://github.com/bazelbuild/rules_python/blob/main/python/private/coverage.patch
single_version_override(
module_name = "rules_python",
patches = ["@score_bazel_tools_cc//third_party/rules_python:rules_python.patch"],
)
# score checker
bazel_dep(name = "score_tooling", version = "1.0.4", dev_dependency = True)
######################################
# Python toolchain and dependencies. #
######################################
PYTHON_VERSIONS = [
"3.8",
"3.9",
"3.10",
"3.11",
"3.12",
]
# By default, one can't add `dev_dependency = True` to `python` extension from
# `@rules_python//python/extensions:python.bzl` if python dependencies are
# provided to the end user. To circumvent that, we rely on a conditional
# statement by the mentioned extension, see:
# https://github.com/bazelbuild/rules_python/blob/89d850aab819eb2dea9d6340beab1ca810dbe18d/python/private/pypi/extension.bzl#L111
# The result is that `dev_dependency` can only be added to `python` extension
# if every `pip_parse` has `python_interpreter` set. We set `python_interpreter`
# to `python3` value because every hermetic toolchain has it as a symlink to
# the real executable.
# More info about this can be found at:
# https://github.com/bazelbuild/rules_python/issues/1818#issuecomment-2271227487
python = use_extension("@rules_python//python/extensions:python.bzl", "python")
[
python.toolchain(
configure_coverage_tool = True,
ignore_root_user_error = True,
is_default = False,
python_version = "{}".format(version),
)
for version in PYTHON_VERSIONS
]
# We can't use a loop for the following `use_repo` because we change the name of each toolchain.
# buildifier: leave-alone
use_repo(
python,
score_bazel_tools_cc_python_3_8 = "python_3_8",
score_bazel_tools_cc_python_3_9 = "python_3_9",
score_bazel_tools_cc_python_3_10 = "python_3_10",
score_bazel_tools_cc_python_3_11 = "python_3_11",
score_bazel_tools_cc_python_3_12 = "python_3_12",
)
[
register_toolchains(
"@score_bazel_tools_cc//bazel/toolchains/python:score_bazel_tools_cc_python_{}_toolchain".format(version.replace(".", "_")),
dev_dependency = True,
)
for version in PYTHON_VERSIONS
]
register_toolchains(
"@score_bazel_tools_cc//bazel/toolchains/python:py_undefined_trap",
dev_dependency = True,
)
register_toolchains(
"@score_bazel_tools_cc//bazel/toolchains/python:do_not_use_internal_toolchains_trap",
dev_dependency = True,
)
pip = use_extension("@rules_python//python/extensions:pip.bzl", "pip")
[
pip.parse(
hub_name = "score_bazel_tools_cc_pip_{}".format(version.replace(".", "_")),
python_version = "{}".format(version),
requirements_lock = "//third_party/pip:requirements_lock_{}.txt".format(version.replace(".", "_")),
)
for version in PYTHON_VERSIONS
]
[
use_repo(pip, "score_bazel_tools_cc_pip_{}".format(version.replace(".", "_")))
for version in PYTHON_VERSIONS
]
rules_python_pip_hub = use_extension("@score_bazel_tools_cc//third_party:extensions.bzl", "rules_python_pip_hub")
use_repo(rules_python_pip_hub, "score_bazel_tools_cc_pip_hub")