litex/build/parser: check if self._target_group is not None before calling add_argument

This commit is contained in:
Gwenhael Goavec-Merou 2022-11-07 20:40:09 +01:00
parent f43b92103a
commit 98912f45e0
1 changed files with 3 additions and 1 deletions

View File

@ -52,6 +52,7 @@ class LiteXArgumentParser(argparse.ArgumentParser):
self._default_toolchain = None self._default_toolchain = None
self._args = None self._args = None
self._toolchain = None self._toolchain = None
self._target_group = None
if platform is not None: if platform is not None:
self.set_platform(platform) self.set_platform(platform)
self.add_target_group() self.add_target_group()
@ -82,7 +83,6 @@ class LiteXArgumentParser(argparse.ArgumentParser):
def add_target_group(self): def add_target_group(self):
""" create target group and add --toolchain/build/load args. """ create target group and add --toolchain/build/load args.
""" """
self._target_group = self.add_argument_group(title="Target options")
if self.toolchains is not None: if self.toolchains is not None:
self.add_target_argument("--toolchain", self.add_target_argument("--toolchain",
default = self._default_toolchain, default = self._default_toolchain,
@ -97,6 +97,8 @@ class LiteXArgumentParser(argparse.ArgumentParser):
""" wrapper to add argument to "Target options group" from outer of this """ wrapper to add argument to "Target options group" from outer of this
class class
""" """
if self._target_group is None:
self._target_group = self.add_argument_group(title="Target options")
self._target_group.add_argument(*args, **kwargs) self._target_group.add_argument(*args, **kwargs)
@property @property