38
38
bin_dir = "binaries"
39
39
40
40
# Default
41
- sketch_default = os .path .join (script_path , "examples" , "BareMinimum" , "BareMinimum.ino" )
41
+ sketch_default = os .path .join (script_path , "examples" , "BareMinimum" )
42
42
exclude_file_default = os .path .join ("conf" , "exclude_list.txt" )
43
43
cores_config_file_default = os .path .join ("conf" , "cores_config.json" )
44
44
cores_config_file_ci = os .path .join ("conf" , "cores_config_ci.json" )
@@ -351,11 +351,20 @@ def manage_inos():
351
351
# Only one sketch
352
352
elif args .ino :
353
353
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 )
355
359
else :
356
360
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 )
359
368
break
360
369
else :
361
370
print ("Sketch {} path does not exist!" .format (args .ino ))
@@ -368,11 +377,20 @@ def manage_inos():
368
377
if line .rstrip ():
369
378
ino = line .rstrip ()
370
379
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 )
372
385
else :
373
386
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 )
376
394
break
377
395
else :
378
396
print ("Ignore {} as it does not exist." .format (ino ))
@@ -384,17 +402,10 @@ def manage_inos():
384
402
quit ()
385
403
386
404
387
- # Find all .ino files
405
+ # Find all .ino files and save directory
388
406
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
394
408
# key: path, value: name
395
- ordered_path = collections .OrderedDict ()
396
- # key: name, value: path
397
- ordered_name = collections .OrderedDict ()
398
409
if args .sketches :
399
410
arg_sketch_pattern = re .compile (args .sketches , re .IGNORECASE )
400
411
for path in sketches_path_list :
@@ -404,23 +415,8 @@ def find_inos():
404
415
if args .sketches :
405
416
if arg_sketch_pattern .search (os .path .join (root , file )) is None :
406
417
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 ))
424
420
425
421
426
422
# Return a list of all board using the arduino-cli for the specified architecture
@@ -871,7 +867,7 @@ def build(build_conf):
871
867
872
868
g1 = parser .add_mutually_exclusive_group ()
873
869
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" )
875
871
876
872
# Sketch options
877
873
sketchg0 = parser .add_argument_group (
@@ -880,7 +876,7 @@ def build(build_conf):
880
876
881
877
sketchg1 = sketchg0 .add_mutually_exclusive_group ()
882
878
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"
884
880
)
885
881
sketchg1 .add_argument (
886
882
"-f" ,
@@ -898,7 +894,7 @@ def build(build_conf):
898
894
"-e" ,
899
895
"--exclude" ,
900
896
metavar = "<excluded sketches list filepath>" ,
901
- help = "file containing pattern of sketches to ignore.\
897
+ help = "file containing sketches pattern to ignore.\
902
898
Default path : "
903
899
+ os .path .join (script_path , exclude_file_default ),
904
900
)
0 commit comments