Skip to content

Commit c6fccf8

Browse files
authored
Fix automatic platform dependency detection when FQBN uses custom board option (#63)
1 parent 1f59021 commit c6fccf8

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

compilesketches/compilesketches.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -214,7 +214,8 @@ def install_platforms(self):
214214
def get_fqbn_platform_dependency(self):
215215
"""Return the platform dependency definition automatically generated from the FQBN."""
216216
# Extract the platform name from the FQBN (e.g., arduino:avr:uno => arduino:avr)
217-
fqbn_platform_dependency = {self.dependency_name_key: self.fqbn.rsplit(sep=":", maxsplit=1)[0]}
217+
fqbn_component_list = self.fqbn.split(sep=":")
218+
fqbn_platform_dependency = {self.dependency_name_key: fqbn_component_list[0] + ":" + fqbn_component_list[1]}
218219
if self.additional_url is not None:
219220
fqbn_platform_dependency[self.dependency_source_url_key] = self.additional_url
220221

compilesketches/tests/test_compilesketches.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -338,7 +338,9 @@ def test_install_platforms(mocker, platforms):
338338
[("arduino:avr:uno", "arduino:avr", None),
339339
# FQBN with space, additional Board Manager URL
340340
('\'"foo bar:baz:asdf" "https://example.com/platform_foo_index.json"\'', "foo bar:baz",
341-
"https://example.com/platform_foo_index.json")]
341+
"https://example.com/platform_foo_index.json"),
342+
# Custom board option
343+
("arduino:avr:nano:cpu=atmega328old", "arduino:avr", None)]
342344
)
343345
def test_get_fqbn_platform_dependency(fqbn_arg, expected_platform, expected_additional_url):
344346
compile_sketches = get_compilesketches_object(fqbn_arg=fqbn_arg)

0 commit comments

Comments
 (0)