Skip to content

Commit 8bfc2c7

Browse files
authored
Merge pull request #340 from fpistm/c_arduino_version
[CI] Use real core-api-version if possible
2 parents 32e92d3 + 998af85 commit 8bfc2c7

File tree

1 file changed

+24
-1
lines changed

1 file changed

+24
-1
lines changed

CI/build/arduino-builder.py

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,7 @@
145145
board_options = {} # key: board name, value: options
146146
sketch_options = {} # key: sketch pattern, value: options
147147
na_sketch_pattern = {} # key: board name, value: sketch pattern list
148+
core_api_version = "10805"
148149

149150
# Counter
150151
nb_build_passed = 0
@@ -193,6 +194,25 @@ def create_output_log_tree():
193194
createFolder(os.path.join(build_output_dir, board))
194195

195196

197+
def get_ide_version():
198+
global core_api_version
199+
try:
200+
output = subprocess.check_output(
201+
[os.path.join(arduino_path, "arduino"), "--version"],
202+
stderr=subprocess.DEVNULL,
203+
)
204+
res = re.match("\D*(\d)\.(\d+)\.(\d+)", output.decode("utf-8"))
205+
if res:
206+
core_api_version = (
207+
res.group(1) + res.group(2).zfill(2) + res.group(3).zfill(2)
208+
)
209+
print("Arduino IDE version used: " + core_api_version)
210+
else:
211+
raise subprocess.CalledProcessError(1, "re")
212+
except subprocess.CalledProcessError as err:
213+
print("Unable to define Arduino IDE version, use default: " + core_api_version)
214+
215+
196216
def load_core_config():
197217
global core_config
198218
global maintainer
@@ -482,6 +502,7 @@ def log_sketch_build_result(sketch, boardKo, boardSkipped):
482502
f.write("Skipped boards :\n" + "\n".join(boardSkipped))
483503
f.write("\n")
484504

505+
485506
# Log final result
486507
def log_final_result():
487508
# Also equal to len(board_type) * len(sketch_list)
@@ -569,7 +590,7 @@ def genBasicCommand(b_name, b_type):
569590
cmd.append(arduino_lib_path)
570591
cmd.append("-libraries")
571592
cmd.append(arduino_user_lib_path)
572-
cmd.append("-ide-version=10805")
593+
cmd.append("-core-api-version=" + core_api_version)
573594
cmd.append("-warnings=all")
574595
if args.verbose:
575596
cmd.append("-verbose")
@@ -766,6 +787,8 @@ def main():
766787
if args.clean:
767788
deleteFolder(root_output_dir)
768789

790+
get_ide_version()
791+
769792
load_core_config()
770793

771794
find_board()

0 commit comments

Comments
 (0)