Skip to content

Commit 0afb8dd

Browse files
committed
[CI] Use sketch folder name for arduino-cli instead of .ino
The folder is the sketch and it is the path to that folder that should specify as the argument to arduino-cli. Because a sketch may consist of multiple files. All source files in the sketch folder are compiled. Signed-off-by: Frederic Pillon <[email protected]>
1 parent 0f24f28 commit 0afb8dd

File tree

2 files changed

+43
-47
lines changed

2 files changed

+43
-47
lines changed

CI/build/arduino-cli.py

+32-36
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@
3838
bin_dir = "binaries"
3939

4040
# Default
41-
sketch_default = os.path.join(script_path, "examples", "BareMinimum", "BareMinimum.ino")
41+
sketch_default = os.path.join(script_path, "examples", "BareMinimum")
4242
exclude_file_default = os.path.join("conf", "exclude_list.txt")
4343
cores_config_file_default = os.path.join("conf", "cores_config.json")
4444
cores_config_file_ci = os.path.join("conf", "cores_config_ci.json")
@@ -351,11 +351,20 @@ def manage_inos():
351351
# Only one sketch
352352
elif args.ino:
353353
if os.path.exists(args.ino):
354-
sketch_list.append(args.ino)
354+
# Store only the path
355+
if os.path.isfile(args.ino):
356+
sketch_list.append(os.path.dirname(args.ino))
357+
else:
358+
sketch_list.append(args.ino)
355359
else:
356360
for path in sketches_path_list:
357-
if os.path.exists(os.path.join(path, args.ino)):
358-
sketch_list.append(os.path.join(path, args.ino))
361+
fp = os.path.join(path, args.ino)
362+
if os.path.exists(fp):
363+
# Store only the path
364+
if os.path.isfile(fp):
365+
sketch_list.append(os.path.dirname(fp))
366+
else:
367+
sketch_list.append(fp)
359368
break
360369
else:
361370
print("Sketch {} path does not exist!".format(args.ino))
@@ -368,11 +377,20 @@ def manage_inos():
368377
if line.rstrip():
369378
ino = line.rstrip()
370379
if os.path.exists(ino):
371-
sketch_list.append(ino)
380+
# Store only the path
381+
if os.path.isfile(ino):
382+
sketch_list.append(os.path.dirname(ino))
383+
else:
384+
sketch_list.append(ino)
372385
else:
373386
for path in sketches_path_list:
374-
if os.path.exists(os.path.join(path, ino)):
375-
sketch_list.append(os.path.join(path, ino))
387+
fp = os.path.join(path, ino)
388+
if os.path.exists(fp):
389+
# Store only the path
390+
if os.path.isfile(fp):
391+
sketch_list.append(os.path.dirname(fp))
392+
else:
393+
sketch_list.append(fp)
376394
break
377395
else:
378396
print("Ignore {} as it does not exist.".format(ino))
@@ -384,17 +402,10 @@ def manage_inos():
384402
quit()
385403

386404

387-
# Find all .ino files
405+
# Find all .ino files and save directory
388406
def find_inos():
389-
# Path list order is important to avoid duplicated sketch name.
390-
# Last one found will be kept.
391-
# So sketches_path_list must take this in account, the last path
392-
# should be the one with higher priority.
393-
407+
global sketch_list
394408
# key: path, value: name
395-
ordered_path = collections.OrderedDict()
396-
# key: name, value: path
397-
ordered_name = collections.OrderedDict()
398409
if args.sketches:
399410
arg_sketch_pattern = re.compile(args.sketches, re.IGNORECASE)
400411
for path in sketches_path_list:
@@ -404,23 +415,8 @@ def find_inos():
404415
if args.sketches:
405416
if arg_sketch_pattern.search(os.path.join(root, file)) is None:
406417
continue
407-
if root in ordered_path:
408-
# If several sketch are in the same path
409-
# Check which one to kept
410-
# Commonly, example structure is:
411-
# dirname/dirname.ino
412-
if (
413-
os.path.basename(root)
414-
== os.path.splitext(ordered_path[root])[0]
415-
):
416-
continue
417-
ordered_path[root] = file
418-
# Remove duplicated sketch name
419-
for path, name in ordered_path.items():
420-
ordered_name[name] = path
421-
for name, path in ordered_name.items():
422-
sketch_list.append(os.path.join(path, name))
423-
sketch_list.sort()
418+
sketch_list.append(root)
419+
sketch_list = sorted(set(sketch_list))
424420

425421

426422
# Return a list of all board using the arduino-cli for the specified architecture
@@ -871,7 +867,7 @@ def build(build_conf):
871867

872868
g1 = parser.add_mutually_exclusive_group()
873869
g1.add_argument("--bin", help="save binaries", action="store_true")
874-
g1.add_argument("--ci", help="Custom configuration for CI build", action="store_true")
870+
g1.add_argument("--ci", help="custom configuration for CI build", action="store_true")
875871

876872
# Sketch options
877873
sketchg0 = parser.add_argument_group(
@@ -880,7 +876,7 @@ def build(build_conf):
880876

881877
sketchg1 = sketchg0.add_mutually_exclusive_group()
882878
sketchg1.add_argument(
883-
"-i", "--ino", metavar="<shetch filepath>", help="single ino file to build"
879+
"-i", "--ino", metavar="<shetch filepath>", help="single sketch file to build"
884880
)
885881
sketchg1.add_argument(
886882
"-f",
@@ -898,7 +894,7 @@ def build(build_conf):
898894
"-e",
899895
"--exclude",
900896
metavar="<excluded sketches list filepath>",
901-
help="file containing pattern of sketches to ignore.\
897+
help="file containing sketches pattern to ignore.\
902898
Default path : "
903899
+ os.path.join(script_path, exclude_file_default),
904900
)

CI/build/conf/cores_config.json

+11-11
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
],
2424
"sketches": [
2525
{
26-
"pattern": "^((?!BareMinimum.ino).)*$",
26+
"pattern": "^((?!BareMinimum).)*$",
2727
"applicable": false,
2828
"boards": [ "DEMO_F030F4", "DEMO_F030F4_16M", "DEMO_F030F4_HSI", "RHF76_052" ]
2929
},
@@ -33,22 +33,22 @@
3333
"boards": [ "DISCO_L475VG_IOT" ]
3434
},
3535
{
36-
"pattern": "SPBTLE_BeaconDemo.ino|SPBTLE_SensorDemo.ino|BTLE_sensors_TimeOfFlight_demo.ino",
36+
"pattern": "SPBTLE_BeaconDemo|SPBTLE_SensorDemo|BTLE_sensors_TimeOfFlight_demo",
3737
"applicable": true,
3838
"boards": [ "DISCO_L475VG_IOT" ]
3939
},
4040
{
41-
"pattern": "STM32Ethernet|Ethernet_MQTT_Adafruit.io.ino|Hello_stm32",
41+
"pattern": "STM32Ethernet|Ethernet_MQTT_Adafruit.io|Hello_stm32",
4242
"applicable": true,
4343
"boards": [ "NUCLEO_F429ZI", "DISCO_F746NG" ]
4444
},
4545
{
46-
"pattern": "ISM43362-M3G-L44|WiFi_MQTT_Adafruit.io.ino|mqtt_B-L475E-IOT01A.ino",
46+
"pattern": "ISM43362-M3G-L44|WiFi_MQTT_Adafruit.io|mqtt_B-L475E-IOT01A",
4747
"applicable": true,
4848
"boards": [ "DISCO_L475VG_IOT" ]
4949
},
5050
{
51-
"pattern": "ExternalWakeup.ino|BleSensors_SensiBLE|NucleoCar",
51+
"pattern": "ExternalWakeup|BleSensors_SensiBLE|NucleoCar",
5252
"applicable": false,
5353
"boards": [
5454
"AFROFLIGHT_F103CB",
@@ -110,7 +110,7 @@
110110
]
111111
},
112112
{
113-
"pattern": "Blink(WithoutDelay)?.ino",
113+
"pattern": "Blink(WithoutDelay)?",
114114
"applicable": false,
115115
"boards": [ "EEXTR_F030_V1", "MALYANM200_F103CB", "PRNTR_V2" ]
116116
},
@@ -148,7 +148,7 @@
148148
"options": "usb=HID"
149149
},
150150
{
151-
"pattern": "X_NUCLEO_IDB05A1_HelloWorld.ino",
151+
"pattern": "X_NUCLEO_IDB05A1_HelloWorld",
152152
"applicable": false,
153153
"boards": [
154154
"AFROFLIGHT_F103CB",
@@ -184,7 +184,7 @@
184184
]
185185
},
186186
{
187-
"pattern": "X_NUCLEO_NFC03A1_HelloWorld.ino",
187+
"pattern": "X_NUCLEO_NFC03A1_HelloWorld",
188188
"applicable": false,
189189
"boards": [
190190
"DISCO_F030R8",
@@ -215,7 +215,7 @@
215215
]
216216
},
217217
{
218-
"pattern": "StringComparisonOperators.ino",
218+
"pattern": "StringComparisonOperators",
219219
"applicable": false,
220220
"boards": [
221221
"ARMED_V1",
@@ -229,7 +229,7 @@
229229
]
230230
},
231231
{
232-
"pattern": "ADXL3xx.ino",
232+
"pattern": "ADXL3xx",
233233
"applicable": false,
234234
"boards": [
235235
"ARMED_V1",
@@ -240,7 +240,7 @@
240240
]
241241
},
242242
{
243-
"pattern": "SerialLoop.ino|Tests_basic_functions.ino",
243+
"pattern": "SerialLoop|Tests_basic_functions",
244244
"applicable": false,
245245
"boards": [ "BLUEPILL_F103C6", "NUCLEO_L031K6", "Wraith32_V1" ]
246246
},

0 commit comments

Comments
 (0)