From: whitequark Date: Sun, 12 Apr 2020 03:28:29 +0000 (+0000) Subject: build.plat: don't check for toolchain presence if do_build=False. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=00544ece2a46f3129d77e4a8e9884e5dd4cabe6a;p=nmigen.git build.plat: don't check for toolchain presence if do_build=False. --- diff --git a/nmigen/build/plat.py b/nmigen/build/plat.py index 422cc85..291d90c 100644 --- a/nmigen/build/plat.py +++ b/nmigen/build/plat.py @@ -71,7 +71,19 @@ class Platform(ResourceManager, metaclass=ABCMeta): 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)