Skip to content

Commit

Permalink
[repo] Add revisions for board configs
Browse files Browse the repository at this point in the history
  • Loading branch information
salkinium committed Feb 11, 2022
1 parent f5cdf6a commit 52ea9b3
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions repo.lb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ from os.path import normpath

# Check for miminum required lbuild version
import lbuild
min_lbuild_version = "1.20.0"
min_lbuild_version = "1.21.0"
if StrictVersion(getattr(lbuild, "__version__", "0.1.0")) < StrictVersion(min_lbuild_version):
print("modm requires at least lbuild v{}, please upgrade!\n"
" pip3 install -U lbuild".format(min_lbuild_version))
Expand Down Expand Up @@ -224,15 +224,19 @@ def init(repo):
repo.add_ignore_patterns("*/*.lb", "*/board.xml")

# Add the board configuration files as their module name aliases
for config in Path(repopath("src/modm/board")).glob("*/board.xml"):
name = re.search(r"<module>modm:board:(.*?)</module>", config.read_text()).group(1)
if (config.parent / "module.md").exists():
description = FileReader(str(config.parent / "module.md"))
for module in Path(repopath("src/modm/board")).glob("*/module.lb"):
module_text = module.read_text()
name = re.search(r"\.name += +\".*?:board:(.*?)\"", module_text).group(1)
if (module.parent / "module.md").exists():
description = FileReader(str(module.parent / "module.md"))
else:
description = re.search(r'\.description += +(""".*?"""|".*?")',
(config.parent / "module.lb").read_text(), flags=re.S|re.M)
module_text, flags=re.S|re.M)
description = description.group(1).strip('"\\') if description else None
repo.add_configuration(name, config, description)
versions = re.search(r"#+ +[Rr]evisions? += +\[(.*)\]", module_text)
versions = versions.group(1).split(",") if versions is not None else [""]
config = {v.strip(): (module.parent / "board.xml") for v in versions}
repo.add_configuration(Configuration(name, description, config, versions[0].strip()))

# Backwards compatible move, remove this in 2022.
repo.add_alias(Alias(name="blue-pill", destination=":blue-pill-f103",
Expand Down

0 comments on commit 52ea9b3

Please sign in to comment.