build/parser: support set_default(cpu_type="xxx")

Ensures args_fill() for new cpu_type is called, allowing for patterns
in a target file like:

    parser.set_defaults(cpu_type="vexriscv_smp")
    parser.set_defaults(cpu_variant="linux")
    parser.set_defaults(with_fpu=True)
This commit is contained in:
Andrew Dennison 2023-09-11 12:30:58 +10:00
parent 485341a1cf
commit 4730ee2288
1 changed files with 2 additions and 1 deletions

View File

@ -217,7 +217,8 @@ class LiteXArgumentParser(argparse.ArgumentParser):
self._platform.fill_args(self._toolchain, self)
# Intercept selected CPU to fill arguments.
cpu_cls = cpu.CPUS.get(self.get_value_from_key("--cpu-type"), None)
default_cpu_type = self._args_default.get("cpu_type", None)
cpu_cls = cpu.CPUS.get(self.get_value_from_key("--cpu-type", default_cpu_type))
if cpu_cls is not None and hasattr(cpu_cls, "args_fill"):
cpu_cls.args_fill(self)