@@ -40,11 +40,12 @@ import (
40
40
"strings"
41
41
"syscall"
42
42
43
+ "github.com/arduino/go-paths-helper"
44
+
43
45
"github.com/arduino/arduino-builder"
44
46
"github.com/arduino/arduino-builder/gohasissues"
45
47
"github.com/arduino/arduino-builder/i18n"
46
48
"github.com/arduino/arduino-builder/types"
47
- "github.com/arduino/arduino-builder/utils"
48
49
"github.com/arduino/go-properties-map"
49
50
"github.com/go-errors/errors"
50
51
)
@@ -194,7 +195,7 @@ func main() {
194
195
if hardwareFolders , err := toSliceOfUnquoted (hardwareFoldersFlag ); err != nil {
195
196
printCompleteError (err )
196
197
} else if len (hardwareFolders ) > 0 {
197
- ctx .HardwareFolders = hardwareFolders
198
+ ctx .HardwareFolders = paths . NewPathList ( hardwareFolders ... )
198
199
}
199
200
if len (ctx .HardwareFolders ) == 0 {
200
201
printErrorMessageAndFlagUsage (errors .New ("Parameter '" + FLAG_HARDWARE + "' is mandatory" ))
@@ -204,7 +205,7 @@ func main() {
204
205
if toolsFolders , err := toSliceOfUnquoted (toolsFoldersFlag ); err != nil {
205
206
printCompleteError (err )
206
207
} else if len (toolsFolders ) > 0 {
207
- ctx .ToolsFolders = toolsFolders
208
+ ctx .ToolsFolders = paths . NewPathList ( toolsFolders ... )
208
209
}
209
210
if len (ctx .ToolsFolders ) == 0 {
210
211
printErrorMessageAndFlagUsage (errors .New ("Parameter '" + FLAG_TOOLS + "' is mandatory" ))
@@ -214,14 +215,14 @@ func main() {
214
215
if librariesFolders , err := toSliceOfUnquoted (librariesFoldersFlag ); err != nil {
215
216
printCompleteError (err )
216
217
} else if len (librariesFolders ) > 0 {
217
- ctx .OtherLibrariesFolders = librariesFolders
218
+ ctx .OtherLibrariesFolders = paths . NewPathList ( librariesFolders ... )
218
219
}
219
220
220
221
// FLAG_BUILT_IN_LIBRARIES
221
222
if librariesBuiltInFolders , err := toSliceOfUnquoted (librariesBuiltInFoldersFlag ); err != nil {
222
223
printCompleteError (err )
223
224
} else if len (librariesBuiltInFolders ) > 0 {
224
- ctx .BuiltInLibrariesFolders = librariesBuiltInFolders
225
+ ctx .BuiltInLibrariesFolders = paths . NewPathList ( librariesBuiltInFolders ... )
225
226
}
226
227
227
228
// FLAG_PREFS
@@ -242,38 +243,38 @@ func main() {
242
243
}
243
244
244
245
// FLAG_BUILD_PATH
245
- buildPath , err := gohasissues .Unquote (* buildPathFlag )
246
+ buildPathUnquoted , err := gohasissues .Unquote (* buildPathFlag )
246
247
if err != nil {
247
248
printCompleteError (err )
248
249
}
249
- if buildPath != "" {
250
- _ , err := os .Stat (buildPath )
251
- if err != nil {
250
+ buildPath := paths .New (buildPathUnquoted )
251
+ if buildPath != nil {
252
+ // TODO: mmmmhhh... this one looks like a bug, why check existence?
253
+ if _ , err := buildPath .Stat (); err != nil {
252
254
fmt .Fprintln (os .Stderr , err )
253
255
os .Exit (1 )
254
256
}
255
257
256
- err = utils .EnsureFolderExists (buildPath )
257
- if err != nil {
258
+ if err := buildPath .MkdirAll (); err != nil {
258
259
printCompleteError (err )
259
260
}
260
261
}
261
262
ctx .BuildPath = buildPath
262
263
263
264
// FLAG_BUILD_CACHE
264
- buildCachePath , err := gohasissues .Unquote (* buildCachePathFlag )
265
+ buildCachePathUnquoted , err := gohasissues .Unquote (* buildCachePathFlag )
265
266
if err != nil {
266
267
printCompleteError (err )
267
268
}
268
- if buildCachePath != "" {
269
- _ , err := os .Stat (buildCachePath )
270
- if err != nil {
269
+ buildCachePath := paths .New (buildCachePathUnquoted )
270
+ if buildCachePath != nil {
271
+ // TODO: mmmmhhh... this one looks like a bug, why check existence?
272
+ if _ , err := buildCachePath .Stat (); err != nil {
271
273
fmt .Fprintln (os .Stderr , err )
272
274
os .Exit (1 )
273
275
}
274
276
275
- err = utils .EnsureFolderExists (buildCachePath )
276
- if err != nil {
277
+ if err := buildCachePath .MkdirAll (); err != nil {
277
278
printCompleteError (err )
278
279
}
279
280
}
@@ -285,12 +286,11 @@ func main() {
285
286
}
286
287
287
288
if flag .NArg () > 0 {
288
- sketchLocation := flag .Arg (0 )
289
- sketchLocation , err := gohasissues .Unquote (sketchLocation )
289
+ sketchLocationUnquoted , err := gohasissues .Unquote (flag .Arg (0 ))
290
290
if err != nil {
291
291
printCompleteError (err )
292
292
}
293
- ctx .SketchLocation = sketchLocation
293
+ ctx .SketchLocation = paths . New ( sketchLocationUnquoted )
294
294
}
295
295
296
296
if * verboseFlag && * quietFlag {
0 commit comments