Skip to content

Commit d830f6a

Browse files
committed
[CI] Manage arduino-cli version
Signed-off-by: Frederic Pillon <[email protected]>
1 parent 2c361ef commit d830f6a

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

Diff for: CI/build/arduino-cli.py

+32-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from datetime import timedelta
55
import json
66
import os
7+
from packaging import version
78
import re
89
import shutil
910
import subprocess
@@ -52,6 +53,8 @@
5253
arch = arch_default
5354
arduino_platform = arduino_platform_default
5455
arduino_cli = ""
56+
arduino_cli_default_version = "0.10.0"
57+
arduino_cli_version = arduino_cli_default_version
5558

5659
# List
5760
sketch_list = []
@@ -117,6 +120,7 @@ def create_output_log_tree():
117120
file.write(build_separator + "\n")
118121
# Folders
119122
for board in board_fqbn:
123+
createFolder(os.path.join(output_dir, board, bin_dir))
120124
createFolder(os.path.join(output_dir, board))
121125
createFolder(os.path.join(build_output_dir, board))
122126

@@ -150,6 +154,7 @@ def create_config():
150154

151155
def check_config():
152156
global arduino_cli
157+
global arduino_cli_version
153158
global arduino_cli_path
154159
global sketches_path_list
155160
global build_output_dir
@@ -191,6 +196,23 @@ def check_config():
191196
else:
192197
arduino_cli = "arduino-cli"
193198

199+
try:
200+
output = subprocess.check_output(
201+
[arduino_cli, "version"], stderr=subprocess.DEVNULL,
202+
)
203+
res = re.match(r".*Version:\s+(\d+\.\d+\.\d+).*", output.decode("utf-8"))
204+
205+
if res:
206+
arduino_cli_version = res.group(1)
207+
print("Arduino CLI version used: " + arduino_cli_version)
208+
else:
209+
raise subprocess.CalledProcessError(1, "re")
210+
except subprocess.CalledProcessError:
211+
print(
212+
"Unable to define Arduino CLI version, use default: "
213+
+ arduino_cli_default_version
214+
)
215+
194216
try:
195217
output = subprocess.check_output(
196218
[arduino_cli, "core", "search", "stm32", "--additional-urls", stm32_url],
@@ -466,7 +488,7 @@ def find_board():
466488
else:
467489
raise subprocess.CalledProcessError(1, "No fqbn")
468490
except subprocess.CalledProcessError as e:
469-
print("No fqbn detail found for:\"" + " ".join(e.cmd) + "\"!")
491+
print('No fqbn detail found for:"' + " ".join(e.cmd) + '"!')
470492
if board_found:
471493
board_fqbn = collections.OrderedDict(sorted(board_found.items()))
472494
else:
@@ -662,8 +684,12 @@ def genBasicCommand(b_name):
662684
cmd.append(build_output_cache_dir)
663685
if args.verbose:
664686
cmd.append("--verbose")
665-
cmd.append("--output-dir")
666-
cmd.append(os.path.join(output_dir, b_name, bin_dir))
687+
if version.parse(arduino_cli_version) <= version.parse(arduino_cli_default_version):
688+
cmd.append("--output")
689+
cmd.append(os.path.join(output_dir, b_name, bin_dir, "dummy_sketch"))
690+
else:
691+
cmd.append("--output-dir")
692+
cmd.append(os.path.join(output_dir, b_name, bin_dir))
667693
cmd.append("--fqbn")
668694
cmd.append(get_fqbn(b_name))
669695
cmd.append("dummy_sketch")
@@ -693,6 +719,9 @@ def build_config(sketch, boardSkipped):
693719

694720
for idx in reversed(range(len(build_conf_list))):
695721
build_conf_list[idx][4][-1] = sketch
722+
build_conf_list[idx][4][-4] = build_conf_list[idx][4][-4].replace(
723+
"dummy_sketch", os.path.basename(sketch)
724+
)
696725
if na_sketch_pattern:
697726
if build_conf_list[idx][0] in na_sketch_pattern:
698727
for pattern in na_sketch_pattern[build_conf_list[idx][0]]:

0 commit comments

Comments
 (0)