Skip to content

Commit 3426f64

Browse files
committed
Removed builderCtx.BuildCachePath
Because it creates a lot of confusion
1 parent 271d241 commit 3426f64

File tree

5 files changed

+9
-16
lines changed

5 files changed

+9
-16
lines changed

commands/compile/compile.go

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -144,8 +144,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
144144
// Optimize for debug
145145
builderCtx.OptimizeForDebug = req.GetOptimizeForDebug()
146146

147-
builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino", "core-cache")
148-
149147
builderCtx.Jobs = int(req.GetJobs())
150148

151149
builderCtx.USBVidPid = req.GetVidPid()
@@ -155,11 +153,16 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
155153
builderCtx.CustomBuildProperties = append(req.GetBuildProperties(), securityKeysOverride...)
156154

157155
if req.GetBuildCachePath() != "" {
158-
builderCtx.BuildCachePath = paths.New(req.GetBuildCachePath())
159-
err = builderCtx.BuildCachePath.MkdirAll()
156+
buildCachePath, err := paths.New(req.GetBuildCachePath()).Abs()
160157
if err != nil {
161158
return nil, &arduino.PermissionDeniedError{Message: tr("Cannot create build cache directory"), Cause: err}
162159
}
160+
if err := buildCachePath.MkdirAll(); err != nil {
161+
return nil, &arduino.PermissionDeniedError{Message: tr("Cannot create build cache directory"), Cause: err}
162+
}
163+
builderCtx.CoreBuildCachePath = buildCachePath.Join("core")
164+
} else {
165+
builderCtx.CoreBuildCachePath = paths.TempDir().Join("arduino", "core-cache")
163166
}
164167

165168
builderCtx.BuiltInLibrariesDirs = configuration.IDEBuiltinLibrariesDir(configuration.Settings)

legacy/builder/add_additional_entries_to_context.go

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -50,15 +50,6 @@ func (*AddAdditionalEntriesToContext) Run(ctx *types.Context) error {
5050
ctx.CoreBuildPath = coreBuildPath
5151
}
5252

53-
if ctx.BuildCachePath != nil {
54-
coreBuildCachePath, err := ctx.BuildCachePath.Join(constants.FOLDER_CORE).Abs()
55-
if err != nil {
56-
return errors.WithStack(err)
57-
}
58-
59-
ctx.CoreBuildCachePath = coreBuildCachePath
60-
}
61-
6253
if ctx.WarningsLevel == "" {
6354
ctx.WarningsLevel = DEFAULT_WARNINGS_LEVEL
6455
}

legacy/builder/test/builder_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ func TestBuilderCacheCoreAFile(t *testing.T) {
371371
SetupBuildPath(t, ctx)
372372
defer ctx.BuildPath.RemoveAll()
373373
SetupBuildCachePath(t, ctx)
374-
defer ctx.BuildCachePath.RemoveAll()
374+
defer ctx.CoreBuildCachePath.RemoveAll()
375375

376376
// Run build
377377
bldr := builder.Builder{}

legacy/builder/test/helper.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ func SetupBuildPath(t *testing.T, ctx *types.Context) *paths.Path {
7171
func SetupBuildCachePath(t *testing.T, ctx *types.Context) *paths.Path {
7272
buildCachePath, err := paths.MkTempDir(constants.EMPTY_STRING, "test_build_cache")
7373
NoError(t, err)
74-
ctx.BuildCachePath = buildCachePath
74+
ctx.CoreBuildCachePath = buildCachePath
7575
return buildCachePath
7676
}
7777

legacy/builder/types/context.go

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ type Context struct {
9999
BuildProperties *properties.Map
100100
BuildCore string
101101
BuildPath *paths.Path
102-
BuildCachePath *paths.Path
103102
SketchBuildPath *paths.Path
104103
CoreBuildPath *paths.Path
105104
CoreBuildCachePath *paths.Path

0 commit comments

Comments
 (0)