3030import shutil
3131
3232def compile (tmp_dir , sketch , cache , tools_dir , hardware_dir , ide_path , f , args ):
33- cmd = ide_path + '/arduino-builder '
34- cmd += '-compile -logger=human '
35- cmd += '-build-path ' + tmp_dir + ' '
36- cmd += '-tools ' + ide_path + '/tools-builder '
33+ cmd = []
34+ cmd += [ide_path + '/arduino-builder' ]
35+ cmd += ['-compile' , '-logger=human' ]
36+ cmd += ['-build-path' , tmp_dir ]
37+ cmd += ['-tools' , ide_path + '/tools-builder' ]
3738 if cache != "" :
38- cmd += '-build-cache ' + cache + ' '
39+ cmd += [ '-build-cache' , cache ]
3940 if args .library_path :
4041 for lib_dir in args .library_path :
41- cmd += '-libraries ' + lib_dir + ' '
42- cmd += '-hardware ' + ide_path + '/hardware '
42+ cmd += [ '-libraries' , lib_dir ]
43+ cmd += [ '-hardware' , ide_path + '/hardware' ]
4344 if args .hardware_dir :
4445 for hw_dir in args .hardware_dir :
45- cmd += '-hardware ' + hw_dir + ' '
46+ cmd += [ '-hardware' , hw_dir ]
4647 else :
47- cmd += '-hardware ' + hardware_dir + ' '
48+ cmd += [ '-hardware' , hardware_dir ]
4849 # Debug=Serial,DebugLevel=Core____
49- cmd + = '-fqbn=esp8266com:esp8266:{board_name}:' \
50+ fqbn = '-fqbn=esp8266com:esp8266:{board_name}:' \
5051 'xtal={cpu_freq},' \
5152 'FlashFreq={flash_freq},' \
5253 'FlashMode={flash_mode},' \
@@ -55,24 +56,19 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args):
5556 'ip={lwIP},' \
5657 'ResetMethod=nodemcu' .format (** vars (args ))
5758 if args .debug_port and args .debug_level :
58- cmd += 'dbg={debug_port},lvl={debug_level}' .format (** vars (args ))
59- cmd += ' '
60- cmd += '-built-in-libraries ' + ide_path + '/libraries '
61- cmd += '-ide-version=10607 '
62- cmd += '-warnings={warnings} ' .format (** vars (args ))
59+ fqbn += 'dbg={debug_port},lvl={debug_level}' .format (** vars (args ))
60+ cmd += [ fqbn ]
61+ cmd += [ '-built-in-libraries' , ide_path + '/libraries' ]
62+ cmd += [ '-ide-version=10607' ]
63+ cmd += [ '-warnings={warnings}' .format (** vars (args ))]
6364 if args .verbose :
64- cmd += '-verbose '
65- cmd += sketch
66-
67- # Try removing quotes to make arduino-cli work
68- #if platform.system() == "Windows":
69- # cmd = cmd.replace('/', '\\')
65+ cmd += ['-verbose' ]
66+ cmd += [sketch ]
7067
7168 if args .verbose :
72- print ('Building: ' + cmd , file = f )
69+ print ('Building: ' + " " . join ( cmd ) , file = f )
7370
74- cmds = cmd .split (' ' )
75- p = subprocess .Popen (cmds , stdout = f , stderr = subprocess .STDOUT )
71+ p = subprocess .Popen (cmd , stdout = f , stderr = subprocess .STDOUT )
7672 p .wait ()
7773 return p .returncode
7874
@@ -113,13 +109,18 @@ def main():
113109 args = parse_args ()
114110
115111 ide_path = args .ide_path
112+ try :
113+ print ("IDE dir1: " , ide_path )
114+ except :
115+ pass
116116 if not ide_path :
117117 ide_path = os .environ .get ('ARDUINO_IDE_PATH' )
118118 if not ide_path :
119119 print ("Please specify Arduino IDE path via --ide_path option"
120120 "or ARDUINO_IDE_PATH environment variable." , file = sys .stderr )
121121 return 2
122122
123+ print ("IDE dir2: " , ide_path )
123124 sketch_path = args .sketch_path
124125 tmp_dir = args .build_path
125126 created_tmp_dir = False
@@ -134,6 +135,7 @@ def main():
134135 output_name = tmp_dir + '/' + os .path .basename (sketch_path ) + '.bin'
135136
136137 if args .verbose :
138+ print ("IDE dir: " , ide_path )
137139 print ("Sketch: " , sketch_path )
138140 print ("Build dir: " , tmp_dir )
139141 print ("Cache dir: " , args .build_cache )
0 commit comments