|
4 | 4 | from datetime import timedelta
|
5 | 5 | import json
|
6 | 6 | import os
|
| 7 | +from packaging import version |
7 | 8 | import re
|
8 | 9 | import shutil
|
9 | 10 | import subprocess
|
|
52 | 53 | arch = arch_default
|
53 | 54 | arduino_platform = arduino_platform_default
|
54 | 55 | arduino_cli = ""
|
| 56 | +arduino_cli_default_version = "0.10.0" |
| 57 | +arduino_cli_version = arduino_cli_default_version |
55 | 58 |
|
56 | 59 | # List
|
57 | 60 | sketch_list = []
|
@@ -117,6 +120,7 @@ def create_output_log_tree():
|
117 | 120 | file.write(build_separator + "\n")
|
118 | 121 | # Folders
|
119 | 122 | for board in board_fqbn:
|
| 123 | + createFolder(os.path.join(output_dir, board, bin_dir)) |
120 | 124 | createFolder(os.path.join(output_dir, board))
|
121 | 125 | createFolder(os.path.join(build_output_dir, board))
|
122 | 126 |
|
@@ -150,6 +154,7 @@ def create_config():
|
150 | 154 |
|
151 | 155 | def check_config():
|
152 | 156 | global arduino_cli
|
| 157 | + global arduino_cli_version |
153 | 158 | global arduino_cli_path
|
154 | 159 | global sketches_path_list
|
155 | 160 | global build_output_dir
|
@@ -191,6 +196,23 @@ def check_config():
|
191 | 196 | else:
|
192 | 197 | arduino_cli = "arduino-cli"
|
193 | 198 |
|
| 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 | + |
194 | 216 | try:
|
195 | 217 | output = subprocess.check_output(
|
196 | 218 | [arduino_cli, "core", "search", "stm32", "--additional-urls", stm32_url],
|
@@ -466,7 +488,7 @@ def find_board():
|
466 | 488 | else:
|
467 | 489 | raise subprocess.CalledProcessError(1, "No fqbn")
|
468 | 490 | 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) + '"!') |
470 | 492 | if board_found:
|
471 | 493 | board_fqbn = collections.OrderedDict(sorted(board_found.items()))
|
472 | 494 | else:
|
@@ -662,8 +684,12 @@ def genBasicCommand(b_name):
|
662 | 684 | cmd.append(build_output_cache_dir)
|
663 | 685 | if args.verbose:
|
664 | 686 | 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)) |
667 | 693 | cmd.append("--fqbn")
|
668 | 694 | cmd.append(get_fqbn(b_name))
|
669 | 695 | cmd.append("dummy_sketch")
|
@@ -693,6 +719,9 @@ def build_config(sketch, boardSkipped):
|
693 | 719 |
|
694 | 720 | for idx in reversed(range(len(build_conf_list))):
|
695 | 721 | 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 | + ) |
696 | 725 | if na_sketch_pattern:
|
697 | 726 | if build_conf_list[idx][0] in na_sketch_pattern:
|
698 | 727 | for pattern in na_sketch_pattern[build_conf_list[idx][0]]:
|
|
0 commit comments