File tree Expand file tree Collapse file tree 4 files changed +19
-4
lines changed
docs/api/rules_python/python/config_settings Expand file tree Collapse file tree 4 files changed +19
-4
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ except for the case of `force_enabled` and `forced_disabled`.
36
36
37
37
Values:
38
38
39
- * ` auto ` : Automatically decide the effective value based on environment,
39
+ * ` auto ` : (default) Automatically decide the effective value based on environment,
40
40
target platform, etc.
41
41
* ` enabled ` : Compile Python source files at build time. Note that
42
42
{bzl: obj }` --precompile_add_to_runfiles ` affects how the compiled files are included into
@@ -65,12 +65,18 @@ attribute.
65
65
66
66
Values:
67
67
68
+ * ` auto ` : (default) Automatically decide the effective value based on environment,
69
+ target platform, etc.
68
70
* ` keep_source ` : Include the original Python source.
69
71
* ` omit_source ` : Don't include the orignal py source.
70
72
* ` omit_if_generated_source ` : Keep the original source if it's a regular source
71
73
file, but omit it if it's a generated file.
74
+
72
75
:::{versionadded} 0.33.0
73
76
:::
77
+ :::{versionadded} 0.36.0
78
+ The ` auto ` value
79
+ :::
74
80
::::
75
81
76
82
::::{bzl: flag } precompile_add_to_runfiles
Original file line number Diff line number Diff line change @@ -58,7 +58,7 @@ string_flag(
58
58
59
59
string_flag (
60
60
name = "precompile_source_retention" ,
61
- build_setting_default = PrecompileSourceRetentionFlag .KEEP_SOURCE ,
61
+ build_setting_default = PrecompileSourceRetentionFlag .AUTO ,
62
62
values = sorted (PrecompileSourceRetentionFlag .__members__ .values ()),
63
63
# NOTE: Only public because it's an implicit dependency
64
64
visibility = ["//visibility:public" ],
Original file line number Diff line number Diff line change 16
16
load ("@bazel_skylib//rules:common_settings.bzl" , "BuildSettingInfo" )
17
17
load ("@rules_cc//cc:defs.bzl" , "CcInfo" )
18
18
load ("//python/private:enum.bzl" , "enum" )
19
- load ("//python/private:flags.bzl" , "PrecompileFlag" )
19
+ load ("//python/private:flags.bzl" , "PrecompileFlag" , "PrecompileSourceRetentionFlag" )
20
20
load ("//python/private:reexports.bzl" , "BuiltinPyInfo" )
21
21
load (":common.bzl" , "union_attrs" )
22
22
load (":providers.bzl" , "PyInfo" )
@@ -85,7 +85,7 @@ PrecompileInvalidationModeAttr = enum(
85
85
def _precompile_source_retention_get_effective_value (ctx ):
86
86
attr_value = ctx .attr .precompile_source_retention
87
87
if attr_value == PrecompileSourceRetentionAttr .INHERIT :
88
- attr_value = ctx . attr . _precompile_source_retention_flag [ BuildSettingInfo ]. value
88
+ attr_value = PrecompileSourceRetentionFlag . get_effective_value ( ctx )
89
89
90
90
if attr_value not in (
91
91
PrecompileSourceRetentionAttr .KEEP_SOURCE ,
Original file line number Diff line number Diff line change @@ -74,17 +74,26 @@ PrecompileFlag = enum(
74
74
get_effective_value = _precompile_flag_get_effective_value ,
75
75
)
76
76
77
+ def _precompile_source_retention_flag_get_effective_value (ctx ):
78
+ value = ctx .attr ._precompile_source_retention_flag [BuildSettingInfo ].value
79
+ if value == PrecompileSourceRetentionFlag .AUTO :
80
+ value = PrecompileSourceRetentionFlag .KEEP_SOURCE
81
+ return value
82
+
77
83
# Determines if, when a source file is compiled, if the source file is kept
78
84
# in the resulting output or not.
79
85
# buildifier: disable=name-conventions
80
86
PrecompileSourceRetentionFlag = enum (
87
+ # Automatically decide the effective value based on environment, etc.
88
+ AUTO = "auto" ,
81
89
# Include the original py source in the output.
82
90
KEEP_SOURCE = "keep_source" ,
83
91
# Don't include the original py source.
84
92
OMIT_SOURCE = "omit_source" ,
85
93
# Keep the original py source if it's a regular source file, but omit it
86
94
# if it's a generated file.
87
95
OMIT_IF_GENERATED_SOURCE = "omit_if_generated_source" ,
96
+ get_effective_value = _precompile_source_retention_flag_get_effective_value ,
88
97
)
89
98
90
99
# Determines if a target adds its compiled files to its runfiles. When a target
You can’t perform that action at this time.
0 commit comments