From f0a3fcfefa61ff3fa6fa276b5fbdd075602ea6d7 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Wed, 13 Oct 2021 14:41:44 +0200 Subject: [PATCH] build/efinix: Improve error message when Efinity toolchain is not found. --- litex/build/efinix/platform.py | 13 ++++++++----- litex/build/efinix/programmer.py | 13 ++++++++----- 2 files changed, 16 insertions(+), 10 deletions(-) diff --git a/litex/build/efinix/platform.py b/litex/build/efinix/platform.py index 5f73823b8..ef550e7ed 100644 --- a/litex/build/efinix/platform.py +++ b/litex/build/efinix/platform.py @@ -22,11 +22,14 @@ class EfinixPlatform(GenericPlatform): self.pll_available = ['PLL_TL0', 'PLL_TR0', 'PLL_TR1', 'PLL_TR2', 'PLL_TR3', 'PLL_BR0', 'PLL_BR1', 'PLL_BR2', 'PLL_BL0'] self.pll_used = [] - if 'LITEX_ENV_EFINITY' in os.environ: - self.efinity_path = os.environ['LITEX_ENV_EFINITY'].rstrip('/') - os.environ['EFINITY_HOME'] = self.efinity_path - else: - raise OSError('Unable to find Efinity toolchain, please set LITEX_ENV_EFINITY to ${install_dir}') + if os.getenv("LITEX_ENV_EFINITY", False) == False: + msg = "Unable to find or source Efinity toolchain, please either:\n" + msg += "- Set LITEX_ENV_EFINITY environment variant to Efinity path.\n" + msg += "- Or add Efinity toolchain to your $PATH." + raise OSError(msg) + + self.efinity_path = os.environ["LITEX_ENV_EFINITY"].rstrip('/') + os.environ["EFINITY_HOME"] = self.efinity_path if toolchain == "efinity": self.toolchain = efinity.EfinityToolchain(self.efinity_path) diff --git a/litex/build/efinix/programmer.py b/litex/build/efinix/programmer.py index c8607bf20..6ed48a64b 100644 --- a/litex/build/efinix/programmer.py +++ b/litex/build/efinix/programmer.py @@ -16,11 +16,14 @@ class EfinixProgrammer(GenericProgrammer): def __init__(self, cable_name=""): self.cable_name = cable_name - if 'LITEX_ENV_EFINITY' in os.environ: - self.efinity_path = os.environ['LITEX_ENV_EFINITY'].rstrip('/') - os.environ['EFINITY_HOME'] = self.efinity_path - else: - raise OSError('Unable to find Efinity toolchain, please set LITEX_ENV_EFINITY to ${install_dir}') + if os.getenv("LITEX_ENV_EFINITY", False) == False: + msg = "Unable to find or source Efinity toolchain, please either:\n" + msg += "- Set LITEX_ENV_EFINITY environment variant to Efinity path.\n" + msg += "- Or add Efinity toolchain to your $PATH." + raise OSError(msg) + + self.efinity_path = os.environ["LITEX_ENV_EFINITY"].rstrip('/') + os.environ["EFINITY_HOME"] = self.efinity_path def load_bitstream(self, bitstream_file, cable_suffix=""): os.environ['EFXPGM_HOME'] = self.efinity_path + '/pgm'