Skip to content

Commit 34762a6

Browse files
authored
Store all temporary files under a single folder (#2031)
Fix #2028 Any temporary file will be persisted in a new dedicated folder named as "arduino" located in the OS-specific temporary directory, e.g.: /tmp/ ├── arduino │   ├── arduino-core-cache │   │   └── core_arduino_avr_uno_640aa5b4d646262327bbea65c3462b39.a │   └── arduino-sketch-89E1544CF5F196B29E530BA6940B661F │   ├── 06.ino.elf │   ├── 06.ino.with_bootloader.bin │   ├── build.options.json │   ├── compile_commands.json │   ├── core │   │   ├── abi.cpp.d [...] This change is meant to make easier maintenance operations for both end-users and operating-systems. Signed-off-by: giuliano <panzironi.giuliano@gmail.com>
1 parent c0d4e44 commit 34762a6

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

arduino/sketch/sketch.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -302,5 +302,5 @@ func GenBuildPath(sketchPath *paths.Path) *paths.Path {
302302
}
303303
md5SumBytes := md5.Sum([]byte(path))
304304
md5Sum := strings.ToUpper(hex.EncodeToString(md5SumBytes[:]))
305-
return paths.TempDir().Join("arduino-sketch-" + md5Sum)
305+
return paths.TempDir().Join("arduino", "sketch-"+md5Sum)
306306
}

arduino/sketch/sketch_test.go

+2-2
Original file line numberDiff line numberDiff line change
@@ -286,10 +286,10 @@ func TestNewSketchFolderSymlink(t *testing.T) {
286286
}
287287

288288
func TestGenBuildPath(t *testing.T) {
289-
want := paths.TempDir().Join("arduino-sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
289+
want := paths.TempDir().Join("arduino", "sketch-ACBD18DB4CC2F85CEDEF654FCCC4A4D8")
290290
assert.True(t, GenBuildPath(paths.New("foo")).EquivalentTo(want))
291291

292-
want = paths.TempDir().Join("arduino-sketch-D41D8CD98F00B204E9800998ECF8427E")
292+
want = paths.TempDir().Join("arduino", "sketch-D41D8CD98F00B204E9800998ECF8427E")
293293
assert.True(t, GenBuildPath(nil).EquivalentTo(want))
294294
}
295295

commands/compile/compile.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
143143
// Optimize for debug
144144
builderCtx.OptimizeForDebug = req.GetOptimizeForDebug()
145145

146-
builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino-core-cache")
146+
builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino", "core-cache")
147147

148148
builderCtx.Jobs = int(req.GetJobs())
149149

internal/integrationtest/compile_1/compile_test.go

+4-4
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ func compileWithSimpleSketch(t *testing.T, env *integrationtest.Environment, cli
140140
md5 := md5.Sum(([]byte(sketchPath.String())))
141141
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
142142
require.NotEmpty(t, sketchPathMd5)
143-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
143+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
144144
require.FileExists(t, buildDir.Join(sketchName+".ino.eep").String())
145145
require.FileExists(t, buildDir.Join(sketchName+".ino.elf").String())
146146
require.FileExists(t, buildDir.Join(sketchName+".ino.hex").String())
@@ -374,7 +374,7 @@ func compileWithOutputDirFlag(t *testing.T, env *integrationtest.Environment, cl
374374
md5 := md5.Sum(([]byte(sketchPath.String())))
375375
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
376376
require.NotEmpty(t, sketchPathMd5)
377-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
377+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
378378
require.FileExists(t, buildDir.Join(sketchName+".ino.eep").String())
379379
require.FileExists(t, buildDir.Join(sketchName+".ino.elf").String())
380380
require.FileExists(t, buildDir.Join(sketchName+".ino.hex").String())
@@ -441,7 +441,7 @@ func compileWithCustomBuildPath(t *testing.T, env *integrationtest.Environment,
441441
md5 := md5.Sum(([]byte(sketchPath.String())))
442442
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
443443
require.NotEmpty(t, sketchPathMd5)
444-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
444+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
445445
require.NoFileExists(t, buildDir.Join(sketchName+".ino.eep").String())
446446
require.NoFileExists(t, buildDir.Join(sketchName+".ino.elf").String())
447447
require.NoFileExists(t, buildDir.Join(sketchName+".ino.hex").String())
@@ -975,7 +975,7 @@ func compileWithInvalidBuildOptionJson(t *testing.T, env *integrationtest.Enviro
975975
md5 := md5.Sum(([]byte(sketchPath.String())))
976976
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
977977
require.NotEmpty(t, sketchPathMd5)
978-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
978+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
979979

980980
_, _, err = cli.Run("compile", "-b", fqbn, sketchPath.String(), "--verbose")
981981
require.NoError(t, err)

internal/integrationtest/compile_2/compile_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ func recompileWithDifferentLibrary(t *testing.T, env *integrationtest.Environmen
145145
md5 := md5.Sum(([]byte(sketchPath.String())))
146146
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
147147
require.NotEmpty(t, sketchPathMd5)
148-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
148+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
149149

150150
// Compile sketch using library not managed by CLI
151151
stdout, _, err := cli.Run("compile", "-b", fqbn, "--library", manuallyInstalledLibPath.String(), sketchPath.String(), "-v")

internal/integrationtest/core/core_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ func TestCoreInstallEsp32(t *testing.T) {
253253
md5 := md5.Sum(([]byte(sketchPath.String())))
254254
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
255255
require.NotEmpty(t, sketchPathMd5)
256-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
256+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
257257
require.FileExists(t, buildDir.Join(sketchName+".ino.partitions.bin").String())
258258
}
259259

internal/integrationtest/upload_mock/upload_mock_test.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -697,7 +697,7 @@ func TestUploadSketch(t *testing.T) {
697697
func generateBuildDir(sketchPath *paths.Path, t *testing.T) *paths.Path {
698698
md5 := md5.Sum(([]byte(sketchPath.String())))
699699
sketchPathMd5 := strings.ToUpper(hex.EncodeToString(md5[:]))
700-
buildDir := paths.TempDir().Join("arduino-sketch-" + sketchPathMd5)
700+
buildDir := paths.TempDir().Join("arduino", "sketch-"+sketchPathMd5)
701701
require.NoError(t, buildDir.MkdirAll())
702702
require.NoError(t, buildDir.ToAbs())
703703
return buildDir

0 commit comments

Comments
 (0)