File tree 2 files changed +47
-3
lines changed
2 files changed +47
-3
lines changed Original file line number Diff line number Diff line change 11
11
"PrecompileSourceRetentionFlag" ,
12
12
"VenvsSitePackages" ,
13
13
"VenvsUseDeclareSymlinkFlag" ,
14
+ rp_string_flag = "string_flag" ,
14
15
)
15
16
load (
16
17
"//python/private/pypi:flags.bzl" ,
@@ -87,14 +88,27 @@ string_flag(
87
88
visibility = ["//visibility:public" ],
88
89
)
89
90
90
- string_flag (
91
+ rp_string_flag (
91
92
name = "bootstrap_impl" ,
92
- build_setting_default = BootstrapImplFlag .SYSTEM_PYTHON ,
93
+ build_setting_default = BootstrapImplFlag .SCRIPT ,
94
+ override = select ({
95
+ # Windows doesn't yet support bootstrap=script, so force disable it
96
+ ":_is_windows" : BootstrapImplFlag .SYSTEM_PYTHON ,
97
+ "//conditions:default" : "" ,
98
+ }),
93
99
values = sorted (BootstrapImplFlag .__members__ .values ()),
94
100
# NOTE: Only public because it's an implicit dependency
95
101
visibility = ["//visibility:public" ],
96
102
)
97
103
104
+ # For some reason, @platforms//os:windows can't be directly used
105
+ # in the select() for the flag. But it can be used when put behind
106
+ # a config_setting().
107
+ config_setting (
108
+ name = "_is_windows" ,
109
+ constraint_values = ["@platforms//os:windows" ],
110
+ )
111
+
98
112
# This is used for pip and hermetic toolchain resolution.
99
113
string_flag (
100
114
name = "py_linux_libc" ,
Original file line number Diff line number Diff line change @@ -35,8 +35,38 @@ AddSrcsToRunfilesFlag = FlagEnum(
35
35
is_enabled = _AddSrcsToRunfilesFlag_is_enabled ,
36
36
)
37
37
38
+ def _string_flag_impl (ctx ):
39
+ if ctx .attr .override :
40
+ value = ctx .attr .override
41
+ else :
42
+ value = ctx .build_setting_value
43
+
44
+ if value not in ctx .attr .values :
45
+ fail ((
46
+ "Invalid value for {name}: got {value}, must " +
47
+ "be one of {allowed}"
48
+ ).format (
49
+ name = ctx .label ,
50
+ value = value ,
51
+ allowed = ctx .attr .values ,
52
+ ))
53
+
54
+ return [
55
+ BuildSettingInfo (value = value ),
56
+ config_common .FeatureFlagInfo (value = value ),
57
+ ]
58
+
59
+ string_flag = rule (
60
+ implementation = _string_flag_impl ,
61
+ build_setting = config .string (flag = True ),
62
+ attrs = {
63
+ "override" : attr .string (),
64
+ "values" : attr .string_list (),
65
+ },
66
+ )
67
+
38
68
def _bootstrap_impl_flag_get_value (ctx ):
39
- return ctx .attr ._bootstrap_impl_flag [BuildSettingInfo ].value
69
+ return ctx .attr ._bootstrap_impl_flag [config_common . FeatureFlagInfo ].value
40
70
41
71
# buildifier: disable=name-conventions
42
72
BootstrapImplFlag = enum (
You can’t perform that action at this time.
0 commit comments