build/parser: adding a fallback to search for a platform explicitly into litex-boards package when platform name isn't found

This commit is contained in:
Gwenhael Goavec-Merou 2023-01-11 18:33:48 +01:00
parent 35f4913588
commit d70049c2e1
1 changed files with 8 additions and 1 deletions

View File

@ -177,7 +177,14 @@ class LiteXArgumentParser(argparse.ArgumentParser):
if platform is None: # no user selection: try default if platform is None: # no user selection: try default
platform = self.get_default_value_from_actions("platform", None) platform = self.get_default_value_from_actions("platform", None)
if platform is not None: if platform is not None:
self.set_platform(importlib.import_module(platform).Platform) try:
platform_cls = importlib.import_module(platform).Platform
except ModuleNotFoundError as e:
# platform not found: try litex-boards package
platform = "litex_boards.platforms." + platform
platform_cls = importlib.import_module(platform).Platform
self.set_platform(platform_cls)
self.add_target_group() self.add_target_group()
# When platform provided/set, set builder/soc_core args. # When platform provided/set, set builder/soc_core args.