From 3c52d440a6e4017dacd938bfa14ed254141e9103 Mon Sep 17 00:00:00 2001 From: Florent Kermarrec Date: Mon, 7 Nov 2022 13:34:09 +0100 Subject: [PATCH] build/parser: Fix CPU listing when invalid one is provided and simplify. --- litex/build/parser.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/litex/build/parser.py b/litex/build/parser.py index 1c00c798b..ad5271fa7 100644 --- a/litex/build/parser.py +++ b/litex/build/parser.py @@ -2,6 +2,7 @@ # This file is part of LiteX. # # This file is Copyright (c) 2022 Gwenhael Goavec-Merou +# This file is Copyright (c) 2022 Florent Kermarrec # SPDX-License-Identifier: BSD-2-Clause import argparse @@ -161,12 +162,11 @@ class LiteXArgumentParser(argparse.ArgumentParser): self._platform.fill_args(self._toolchain, self) # Intercept selected CPU to fill arguments. - cpu_cls = None - cpu_name = self.get_value_from_key("--cpu-type") - if cpu_name is not None: - cpu_cls = cpu.CPUS[cpu_name] - if cpu_cls is not None and hasattr(cpu_cls, "args_fill"): - cpu_cls.args_fill(self) + cpu_cls = cpu.CPUS.get(self.get_value_from_key("--cpu-type"), None) + if cpu_cls is not None and hasattr(cpu_cls, "args_fill"): + cpu_cls.args_fill(self) + + # Parse args. self._args = argparse.ArgumentParser.parse_args(self, args, namespace) # Re-inject CPU read arguments.