Skip to content

Commit

Permalink
build.plat: don't check for toolchain presence if do_build=False.
Browse files Browse the repository at this point in the history
  • Loading branch information
whitequark committed Apr 12, 2020
1 parent 0e40dc0 commit 9055090
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion nmigen/build/plat.py
Expand Up @@ -71,7 +71,19 @@ def build(self, elaboratable, name="top",
build_dir="build", do_build=True,
program_opts=None, do_program=False,
**kwargs):
if self._toolchain_env_var not in os.environ:
# The following code performs a best-effort check for presence of required tools upfront,
# before performing any build actions, to provide a better diagnostic. It does not handle
# several corner cases:
# 1. `require_tool` does not source toolchain environment scripts, so if such a script
# is used, the check is skipped, and `execute_local()` may fail;
# 2. if the design is not built (do_build=False), most of the tools are not required and
# in fact might not be available if the design will be built manually with a different
# environment script specified, or on a different machine; however, Yosys is required
# by virtually every platform anyway, to provide debug Verilog output, and `prepare()`
# may fail.
# This is OK because even if `require_tool` succeeds, the toolchain might be broken anyway.
# The check only serves to catch common errors earlier.
if do_build and self._toolchain_env_var not in os.environ:
for tool in self.required_tools:
require_tool(tool)

Expand Down

1 comment on commit 9055090

@whitequark
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cc @anuejn

Please sign in to comment.