@@ -71,7 +71,19 @@ def build(self, elaboratable, name="top",
71
71
build_dir = "build" , do_build = True ,
72
72
program_opts = None , do_program = False ,
73
73
** kwargs ):
74
- if self ._toolchain_env_var not in os .environ :
74
+ # The following code performs a best-effort check for presence of required tools upfront,
75
+ # before performing any build actions, to provide a better diagnostic. It does not handle
76
+ # several corner cases:
77
+ # 1. `require_tool` does not source toolchain environment scripts, so if such a script
78
+ # is used, the check is skipped, and `execute_local()` may fail;
79
+ # 2. if the design is not built (do_build=False), most of the tools are not required and
80
+ # in fact might not be available if the design will be built manually with a different
81
+ # environment script specified, or on a different machine; however, Yosys is required
82
+ # by virtually every platform anyway, to provide debug Verilog output, and `prepare()`
83
+ # may fail.
84
+ # This is OK because even if `require_tool` succeeds, the toolchain might be broken anyway.
85
+ # The check only serves to catch common errors earlier.
86
+ if do_build and self ._toolchain_env_var not in os .environ :
75
87
for tool in self .required_tools :
76
88
require_tool (tool )
77
89
1 commit comments
whitequark commentedon Apr 12, 2020
cc @anuejn