Skip to content

Commit 52ea9b3

Browse files
committed
[repo] Add revisions for board configs
1 parent f5cdf6a commit 52ea9b3

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

repo.lb

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ from os.path import normpath
2424

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

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

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

0 commit comments

Comments
 (0)