-
-
Notifications
You must be signed in to change notification settings - Fork 696
Expand file tree
/
Copy pathconfig.bzl
More file actions
53 lines (44 loc) · 1.64 KB
/
Copy pathconfig.bzl
File metadata and controls
53 lines (44 loc) · 1.64 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
"""Extension for configuring global settings of rules_python."""
load("//python/private:internal_config_repo.bzl", "internal_config_repo")
load("//python/private/pypi:deps.bzl", "pypi_deps")
_add_transition_setting = tag_class(
doc = """
Specify a build setting that terminal rules transition on by default.
Terminal rules are rules such as py_binary, py_test, py_wheel, or similar
rules that represent some deployable unit. Settings added here can
then be used a keys with the {obj}`config_settings` attribute.
:::{note}
This adds the label as a dependency of the Python rules. Take care to not refer
to repositories that are expensive to create or invalidate frequently.
:::
""",
attrs = {
"setting": attr.label(doc = "The build setting to add."),
},
)
def _config_impl(mctx):
transition_setting_generators = {}
transition_settings = []
for mod in mctx.modules:
for tag in mod.tags.add_transition_setting:
setting = str(tag.setting)
if setting not in transition_setting_generators:
transition_setting_generators[setting] = []
transition_settings.append(setting)
transition_setting_generators[setting].append(mod.name)
internal_config_repo(
name = "rules_python_internal",
transition_setting_generators = transition_setting_generators,
transition_settings = transition_settings,
)
pypi_deps()
config = module_extension(
doc = """Global settings for rules_python.
:::{versionadded} 1.7.0
:::
""",
implementation = _config_impl,
tag_classes = {
"add_transition_setting": _add_transition_setting,
},
)