30
30
import shutil
31
31
32
32
def 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' ]
37
38
if cache != "" :
38
- cmd += '-build-cache ' + cache + ' '
39
+ cmd += [ '-build-cache' , cache ]
39
40
if args .library_path :
40
41
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' ]
43
44
if args .hardware_dir :
44
45
for hw_dir in args .hardware_dir :
45
- cmd += '-hardware ' + hw_dir + ' '
46
+ cmd += [ '-hardware' , hw_dir ]
46
47
else :
47
- cmd += '-hardware ' + hardware_dir + ' '
48
+ cmd += [ '-hardware' , hardware_dir ]
48
49
# Debug=Serial,DebugLevel=Core____
49
- cmd + = '-fqbn=esp8266com:esp8266:{board_name}:' \
50
+ fqbn = '-fqbn=esp8266com:esp8266:{board_name}:' \
50
51
'xtal={cpu_freq},' \
51
52
'FlashFreq={flash_freq},' \
52
53
'FlashMode={flash_mode},' \
@@ -55,24 +56,19 @@ def compile(tmp_dir, sketch, cache, tools_dir, hardware_dir, ide_path, f, args):
55
56
'ip={lwIP},' \
56
57
'ResetMethod=nodemcu' .format (** vars (args ))
57
58
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 ))]
63
64
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 ]
70
67
71
68
if args .verbose :
72
- print ('Building: ' + cmd , file = f )
69
+ print ('Building: ' + " " . join ( cmd ) , file = f )
73
70
74
- cmds = cmd .split (' ' )
75
- p = subprocess .Popen (cmds , stdout = f , stderr = subprocess .STDOUT )
71
+ p = subprocess .Popen (cmd , stdout = f , stderr = subprocess .STDOUT )
76
72
p .wait ()
77
73
return p .returncode
78
74
@@ -113,13 +109,18 @@ def main():
113
109
args = parse_args ()
114
110
115
111
ide_path = args .ide_path
112
+ try :
113
+ print ("IDE dir1: " , ide_path )
114
+ except :
115
+ pass
116
116
if not ide_path :
117
117
ide_path = os .environ .get ('ARDUINO_IDE_PATH' )
118
118
if not ide_path :
119
119
print ("Please specify Arduino IDE path via --ide_path option"
120
120
"or ARDUINO_IDE_PATH environment variable." , file = sys .stderr )
121
121
return 2
122
122
123
+ print ("IDE dir2: " , ide_path )
123
124
sketch_path = args .sketch_path
124
125
tmp_dir = args .build_path
125
126
created_tmp_dir = False
@@ -134,6 +135,7 @@ def main():
134
135
output_name = tmp_dir + '/' + os .path .basename (sketch_path ) + '.bin'
135
136
136
137
if args .verbose :
138
+ print ("IDE dir: " , ide_path )
137
139
print ("Sketch: " , sketch_path )
138
140
print ("Build dir: " , tmp_dir )
139
141
print ("Cache dir: " , args .build_cache )
0 commit comments