3838bin_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" )
4242exclude_file_default = os .path .join ("conf" , "exclude_list.txt" )
4343cores_config_file_default = os .path .join ("conf" , "cores_config.json" )
4444cores_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
388406def 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
872868g1 = parser .add_mutually_exclusive_group ()
873869g1 .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
877873sketchg0 = parser .add_argument_group (
@@ -880,7 +876,7 @@ def build(build_conf):
880876
881877sketchg1 = sketchg0 .add_mutually_exclusive_group ()
882878sketchg1 .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)
885881sketchg1 .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)
0 commit comments