@@ -65,14 +65,7 @@ def maybe_precompile(ctx, srcs):
65
65
* `py_to_pyc_map`: dict of src File input to pyc File output. If a source
66
66
file wasn't precompiled, it won't be in the dict.
67
67
"""
68
-
69
- # The exec tools toolchain and precompiler are optional. Rather than
70
- # fail, just skip precompiling, as its mostly just an optimization.
71
- exec_tools_toolchain = ctx .toolchains [EXEC_TOOLS_TOOLCHAIN_TYPE ]
72
- if exec_tools_toolchain == None or exec_tools_toolchain .exec_tools .precompiler == None :
73
- precompile = PrecompileAttr .DISABLED
74
- else :
75
- precompile = PrecompileAttr .get_effective_value (ctx )
68
+ precompile = PrecompileAttr .get_effective_value (ctx )
76
69
77
70
source_retention = PrecompileSourceRetentionAttr .get_effective_value (ctx )
78
71
@@ -98,6 +91,12 @@ def maybe_precompile(ctx, srcs):
98
91
(source_retention == PrecompileSourceRetentionAttr .OMIT_IF_GENERATED_SOURCE and not is_generated_source )
99
92
)
100
93
if should_precompile :
94
+ # The exec tools toolchain and precompiler are optional. Rather than
95
+ # fail, just skip precompiling, as its mostly just an optimization.
96
+ exec_tools_toolchain = ctx .toolchains [EXEC_TOOLS_TOOLCHAIN_TYPE ]
97
+ if exec_tools_toolchain == None or exec_tools_toolchain .exec_tools .precompiler == None :
98
+ precompile = PrecompileAttr .DISABLED
99
+ break
101
100
pyc = _precompile (ctx , src , use_pycache = keep_source )
102
101
result .pyc_files .append (pyc )
103
102
result .py_to_pyc_map [src ] = pyc
0 commit comments