Skip to content

Commit f9276b5

Browse files
committed
go-paths-helper API change
1 parent f99ab5a commit f9276b5

14 files changed

+90
-95
lines changed

container_find_includes.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func (s *ContainerFindIncludes) Run(ctx *types.Context) error {
144144
sourceFilePaths := ctx.CollectedSourceFiles
145145
queueSourceFilesFromFolder(ctx, sourceFilePaths, sketch, ctx.SketchBuildPath, false /* recurse */)
146146
srcSubfolderPath := ctx.SketchBuildPath.Join(constants.SKETCH_FOLDER_SRC)
147-
if isDir, _ := srcSubfolderPath.IsDir(); isDir {
147+
if srcSubfolderPath.IsDir() {
148148
queueSourceFilesFromFolder(ctx, sourceFilePaths, sketch, srcSubfolderPath, true /* recurse */)
149149
}
150150

fail_if_imported_library_is_wrong.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ func (s *FailIfImportedLibraryIsWrong) Run(ctx *types.Context) error {
4747

4848
for _, library := range ctx.ImportedLibraries {
4949
if !library.IsLegacy {
50-
if isDir, _ := library.InstallDir.Join(constants.LIBRARY_FOLDER_ARCH).IsDir(); isDir {
50+
if library.InstallDir.Join(constants.LIBRARY_FOLDER_ARCH).IsDir() {
5151
return i18n.ErrorfWithLogger(logger, constants.MSG_ARCH_FOLDER_NOT_SUPPORTED)
5252
}
5353
for _, propName := range libraries.MandatoryProperties {

load_previous_build_options.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ type LoadPreviousBuildOptionsMap struct{}
4040
func (s *LoadPreviousBuildOptionsMap) Run(ctx *types.Context) error {
4141
buildOptionsFile := ctx.BuildPath.Join(constants.BUILD_OPTIONS_FILE)
4242

43-
if exist, err := buildOptionsFile.Exist(); err == nil {
44-
if !exist {
45-
return nil
46-
}
47-
} else {
48-
return i18n.WrapError(err)
43+
if buildOptionsFile.NotExist() {
44+
return nil
4945
}
5046

5147
bytes, err := buildOptionsFile.ReadFile()
@@ -54,6 +50,5 @@ func (s *LoadPreviousBuildOptionsMap) Run(ctx *types.Context) error {
5450
}
5551

5652
ctx.BuildOptionsJsonPrevious = string(bytes)
57-
5853
return nil
5954
}

merge_sketch_with_bootloader.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,9 @@ func (s *MergeSketchWithBootloader) Run(ctx *types.Context) error {
5858
sketchInSubfolder := buildPath.Join(constants.FOLDER_SKETCH, sketchFileName+".hex")
5959

6060
var builtSketchPath *paths.Path
61-
if exist, _ := sketchInBuildPath.Exist(); exist {
61+
if sketchInBuildPath.Exist() {
6262
builtSketchPath = sketchInBuildPath
63-
} else if exist, _ := sketchInSubfolder.Exist(); exist {
63+
} else if sketchInSubfolder.Exist() {
6464
builtSketchPath = sketchInSubfolder
6565
} else {
6666
return nil
@@ -75,7 +75,7 @@ func (s *MergeSketchWithBootloader) Run(ctx *types.Context) error {
7575
bootloader = buildProperties.ExpandPropsInString(bootloader)
7676

7777
bootloaderPath := buildProperties.GetPath(constants.BUILD_PROPERTIES_RUNTIME_PLATFORM_PATH).Join(constants.FOLDER_BOOTLOADERS, bootloader)
78-
if exist, _ := bootloaderPath.Exist(); !exist {
78+
if bootloaderPath.NotExist() {
7979
logger.Fprintln(os.Stdout, constants.LOG_LEVEL_WARN, constants.MSG_BOOTLOADER_FILE_MISSING, bootloaderPath)
8080
return nil
8181
}

phases/sketch_builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ func (s *SketchBuilder) Run(ctx *types.Context) error {
5555

5656
// The "src/" subdirectory of a sketch is compiled recursively
5757
sketchSrcPath := sketchBuildPath.Join(constants.SKETCH_FOLDER_SRC)
58-
if isDir, _ := sketchSrcPath.IsDir(); isDir {
58+
if sketchSrcPath.IsDir() {
5959
srcObjectFiles, err := builder_utils.CompileFiles(ctx, sketchSrcPath, true, sketchSrcPath, buildProperties, includes)
6060
if err != nil {
6161
return i18n.WrapError(err)

platform_keys_rewrite_loader.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (s *PlatformKeysRewriteLoader) Run(ctx *types.Context) error {
8989
func findPlatformKeysRewriteTxt(folders paths.PathList) (*paths.Path, error) {
9090
for _, folder := range folders {
9191
txtPath := folder.Join(constants.FILE_PLATFORM_KEYS_REWRITE_TXT)
92-
if exist, err := txtPath.Exist(); exist {
92+
if exist, err := txtPath.ExistCheck(); exist {
9393
return txtPath, nil
9494
} else if err != nil {
9595
return nil, i18n.WrapError(err)

test/additional_sketch_files_copier_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ func TestCopyOtherFiles(t *testing.T) {
7474
NoError(t, err)
7575
}
7676

77-
exist, err1 := buildPath.Join(constants.FOLDER_SKETCH, "header.h").Exist()
77+
exist, err1 := buildPath.Join(constants.FOLDER_SKETCH, "header.h").ExistCheck()
7878
NoError(t, err1)
7979
require.True(t, exist)
8080

test/builder_test.go

Lines changed: 39 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -71,19 +71,19 @@ func TestBuilderEmptySketch(t *testing.T) {
7171
err := command.Run(ctx)
7272
NoError(t, err)
7373

74-
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").Exist()
74+
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").ExistCheck()
7575
NoError(t, err)
7676
require.True(t, exist)
77-
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).Exist()
77+
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).ExistCheck()
7878
NoError(t, err)
7979
require.True(t, exist)
80-
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "sketch.ino.cpp.o").Exist()
80+
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "sketch.ino.cpp.o").ExistCheck()
8181
NoError(t, err)
8282
require.True(t, exist)
83-
exist, err = buildPath.Join("sketch.ino.elf").Exist()
83+
exist, err = buildPath.Join("sketch.ino.elf").ExistCheck()
8484
NoError(t, err)
8585
require.True(t, exist)
86-
exist, err = buildPath.Join("sketch.ino.hex").Exist()
86+
exist, err = buildPath.Join("sketch.ino.hex").ExistCheck()
8787
NoError(t, err)
8888
require.True(t, exist)
8989
}
@@ -101,22 +101,22 @@ func TestBuilderBridge(t *testing.T) {
101101
err := command.Run(ctx)
102102
NoError(t, err)
103103

104-
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").Exist()
104+
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").ExistCheck()
105105
NoError(t, err)
106106
require.True(t, exist)
107-
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).Exist()
107+
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).ExistCheck()
108108
NoError(t, err)
109109
require.True(t, exist)
110-
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").Exist()
110+
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").ExistCheck()
111111
NoError(t, err)
112112
require.True(t, exist)
113-
exist, err = buildPath.Join("Bridge.ino.elf").Exist()
113+
exist, err = buildPath.Join("Bridge.ino.elf").ExistCheck()
114114
NoError(t, err)
115115
require.True(t, exist)
116-
exist, err = buildPath.Join("Bridge.ino.hex").Exist()
116+
exist, err = buildPath.Join("Bridge.ino.hex").ExistCheck()
117117
NoError(t, err)
118118
require.True(t, exist)
119-
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").Exist()
119+
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").ExistCheck()
120120
NoError(t, err)
121121
require.True(t, exist)
122122
}
@@ -134,22 +134,22 @@ func TestBuilderSketchWithConfig(t *testing.T) {
134134
err := command.Run(ctx)
135135
NoError(t, err)
136136

137-
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").Exist()
137+
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").ExistCheck()
138138
NoError(t, err)
139139
require.True(t, exist)
140-
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).Exist()
140+
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).ExistCheck()
141141
NoError(t, err)
142142
require.True(t, exist)
143-
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "sketch_with_config.ino.cpp.o").Exist()
143+
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "sketch_with_config.ino.cpp.o").ExistCheck()
144144
NoError(t, err)
145145
require.True(t, exist)
146-
exist, err = buildPath.Join("sketch_with_config.ino.elf").Exist()
146+
exist, err = buildPath.Join("sketch_with_config.ino.elf").ExistCheck()
147147
NoError(t, err)
148148
require.True(t, exist)
149-
exist, err = buildPath.Join("sketch_with_config.ino.hex").Exist()
149+
exist, err = buildPath.Join("sketch_with_config.ino.hex").ExistCheck()
150150
NoError(t, err)
151151
require.True(t, exist)
152-
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").Exist()
152+
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").ExistCheck()
153153
NoError(t, err)
154154
require.True(t, exist)
155155
}
@@ -172,22 +172,22 @@ func TestBuilderBridgeTwice(t *testing.T) {
172172
err = command.Run(ctx)
173173
NoError(t, err)
174174

175-
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").Exist()
175+
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").ExistCheck()
176176
NoError(t, err)
177177
require.True(t, exist)
178-
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).Exist()
178+
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).ExistCheck()
179179
NoError(t, err)
180180
require.True(t, exist)
181-
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").Exist()
181+
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").ExistCheck()
182182
NoError(t, err)
183183
require.True(t, exist)
184-
exist, err = buildPath.Join("Bridge.ino.elf").Exist()
184+
exist, err = buildPath.Join("Bridge.ino.elf").ExistCheck()
185185
NoError(t, err)
186186
require.True(t, exist)
187-
exist, err = buildPath.Join("Bridge.ino.hex").Exist()
187+
exist, err = buildPath.Join("Bridge.ino.hex").ExistCheck()
188188
NoError(t, err)
189189
require.True(t, exist)
190-
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").Exist()
190+
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").ExistCheck()
191191
NoError(t, err)
192192
require.True(t, exist)
193193
}
@@ -206,28 +206,28 @@ func TestBuilderBridgeSAM(t *testing.T) {
206206
err := command.Run(ctx)
207207
NoError(t, err)
208208

209-
exist, err := buildPath.Join(constants.FOLDER_CORE, "syscalls_sam3.c.o").Exist()
209+
exist, err := buildPath.Join(constants.FOLDER_CORE, "syscalls_sam3.c.o").ExistCheck()
210210
NoError(t, err)
211211
require.True(t, exist)
212-
exist, err = buildPath.Join(constants.FOLDER_CORE, "USB", "PluggableUSB.cpp.o").Exist()
212+
exist, err = buildPath.Join(constants.FOLDER_CORE, "USB", "PluggableUSB.cpp.o").ExistCheck()
213213
NoError(t, err)
214214
require.True(t, exist)
215-
exist, err = buildPath.Join(constants.FOLDER_CORE, "avr", "dtostrf.c.d").Exist()
215+
exist, err = buildPath.Join(constants.FOLDER_CORE, "avr", "dtostrf.c.d").ExistCheck()
216216
NoError(t, err)
217217
require.True(t, exist)
218-
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).Exist()
218+
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).ExistCheck()
219219
NoError(t, err)
220220
require.True(t, exist)
221-
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").Exist()
221+
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").ExistCheck()
222222
NoError(t, err)
223223
require.True(t, exist)
224-
exist, err = buildPath.Join("Bridge.ino.elf").Exist()
224+
exist, err = buildPath.Join("Bridge.ino.elf").ExistCheck()
225225
NoError(t, err)
226226
require.True(t, exist)
227-
exist, err = buildPath.Join("Bridge.ino.bin").Exist()
227+
exist, err = buildPath.Join("Bridge.ino.bin").ExistCheck()
228228
NoError(t, err)
229229
require.True(t, exist)
230-
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").Exist()
230+
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").ExistCheck()
231231
NoError(t, err)
232232
require.True(t, exist)
233233

@@ -252,22 +252,22 @@ func TestBuilderBridgeRedBearLab(t *testing.T) {
252252
err := command.Run(ctx)
253253
NoError(t, err)
254254

255-
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").Exist()
255+
exist, err := buildPath.Join(constants.FOLDER_CORE, "HardwareSerial.cpp.o").ExistCheck()
256256
NoError(t, err)
257257
require.True(t, exist)
258-
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).Exist()
258+
exist, err = buildPath.Join(constants.FOLDER_PREPROC, constants.FILE_CTAGS_TARGET_FOR_GCC_MINUS_E).ExistCheck()
259259
NoError(t, err)
260260
require.True(t, exist)
261-
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").Exist()
261+
exist, err = buildPath.Join(constants.FOLDER_SKETCH, "Bridge.ino.cpp.o").ExistCheck()
262262
NoError(t, err)
263263
require.True(t, exist)
264-
exist, err = buildPath.Join("Bridge.ino.elf").Exist()
264+
exist, err = buildPath.Join("Bridge.ino.elf").ExistCheck()
265265
NoError(t, err)
266266
require.True(t, exist)
267-
exist, err = buildPath.Join("Bridge.ino.hex").Exist()
267+
exist, err = buildPath.Join("Bridge.ino.hex").ExistCheck()
268268
NoError(t, err)
269269
require.True(t, exist)
270-
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").Exist()
270+
exist, err = buildPath.Join("libraries", "Bridge", "Mailbox.cpp.o").ExistCheck()
271271
NoError(t, err)
272272
require.True(t, exist)
273273
}
@@ -347,10 +347,10 @@ func TestBuilderSketchBuildPathContainsUnusedPreviouslyCompiledLibrary(t *testin
347347
err := command.Run(ctx)
348348
NoError(t, err)
349349

350-
exist, err := buildPath.Join("libraries", "SPI").Exist()
350+
exist, err := buildPath.Join("libraries", "SPI").ExistCheck()
351351
NoError(t, err)
352352
require.False(t, exist)
353-
exist, err = buildPath.Join("libraries", "Bridge").Exist()
353+
exist, err = buildPath.Join("libraries", "Bridge").ExistCheck()
354354
NoError(t, err)
355355
require.True(t, exist)
356356
}

0 commit comments

Comments
 (0)