Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 0710afa

Browse files
author
Luca Bianconi
committed
fix: core cache non working
1 parent df1ec17 commit 0710afa

File tree

3 files changed

+11
-9
lines changed

3 files changed

+11
-9
lines changed

‎commands/compile/compile.go‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
6666
if lm == nil {
6767
return nil, &arduino.InvalidInstanceError{}
6868
}
69-
// cache is purged after compilation to not remove entries that might be required
70-
defer maybePurgeBuildCache()
7169

7270
logrus.Tracef("Compile %s for %s started", req.GetSketchPath(), req.GetFqbn())
7371
if req.GetSketchPath() == "" {
@@ -138,6 +136,11 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
138136
if err = builderCtx.BuildPath.MkdirAll(); err != nil {
139137
return nil, &arduino.PermissionDeniedError{Message: tr("Cannot create build directory"), Cause: err}
140138
}
139+
140+
buildcache.Used(builderCtx.BuildPath)
141+
// cache is purged after compilation to not remove entries that might be required
142+
defer maybePurgeBuildCache()
143+
141144
builderCtx.CompilationDatabase = bldr.NewCompilationDatabase(
142145
builderCtx.BuildPath.Join("compile_commands.json"),
143146
)
@@ -216,8 +219,6 @@ func Compile(ctx context.Context, req *rpc.CompileRequest, outStream, errStream
216219
r.UsedLibraries = importedLibs
217220
}()
218221

219-
defer buildcache.Used(builderCtx.BuildPath)
220-
221222
// if it's a regular build, go on...
222223
if err := builder.RunBuilder(builderCtx); err != nil {
223224
return r, &arduino.CompileFailedError{Message: err.Error()}

‎legacy/builder/phases/core_builder.go‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,10 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path
9292
realCoreFolder := coreFolder.Parent().Parent()
9393

9494
var targetArchivedCore *paths.Path
95-
var targetArchivedCoreDir *paths.Path
9695
if buildCachePath != nil {
9796
archivedCoreName := GetCachedCoreArchiveDirName(buildProperties.Get(constants.BUILD_PROPERTIES_FQBN),
9897
buildProperties.Get("compiler.optimization_flags"), realCoreFolder)
99-
targetArchivedCoreDir = buildCachePath.Join(archivedCoreName)
100-
targetArchivedCore = targetArchivedCoreDir.Join("core.a")
98+
targetArchivedCore = buildCachePath.Join(archivedCoreName).Join("core.a")
10199
canUseArchivedCore := !ctx.OnlyUpdateCompilationDatabase &&
102100
!ctx.Clean &&
103101
!builder_utils.CoreOrReferencedCoreHasChanged(realCoreFolder, targetCoreFolder, targetArchivedCore)
@@ -123,9 +121,9 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path
123121

124122
// archive core.a
125123
if targetArchivedCore != nil && !ctx.OnlyUpdateCompilationDatabase {
126-
defer buildcache.Used(targetArchivedCore)
127-
targetArchivedCoreDir.MkdirAll()
124+
targetArchivedCore.Parent().MkdirAll()
128125
err := archiveFile.CopyTo(targetArchivedCore)
126+
buildcache.Used(targetArchivedCore.Parent())
129127
if ctx.Verbose {
130128
if err == nil {
131129
ctx.Info(tr("Archiving built core (caching) in: %[1]s", targetArchivedCore))

‎legacy/builder/test/builder_test.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,9 @@ func TestBuilderCacheCoreAFile(t *testing.T) {
384384
cachedCoreFile := ctx.CoreBuildCachePath.Join(coreFileName, "core.a")
385385
coreStatBefore, err := cachedCoreFile.Stat()
386386
require.NoError(t, err)
387+
lastUsedFile := ctx.CoreBuildCachePath.Join(coreFileName, ".last-used")
388+
_, err = lastUsedFile.Stat()
389+
require.NoError(t, err)
387390

388391
// Run build again, to verify that the builder skips rebuilding core.a
389392
err = bldr.Run(ctx)

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /