Skip to content

Commit b65c37b

Browse files
author
Luca Bianconi
committed
fix: handle cache dir not created
1 parent 165789c commit b65c37b

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

Diff for: legacy/builder/phases/core_builder.go

+9-1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
package phases
1717

1818
import (
19+
"fmt"
1920
"os"
2021
"strings"
2122

@@ -92,11 +93,13 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path
9293
realCoreFolder := coreFolder.Parent().Parent()
9394

9495
var targetArchivedCore *paths.Path
96+
var buildCacheErr error
9597
if buildCachePath != nil {
9698
archivedCoreName := GetCachedCoreArchiveDirName(buildProperties.Get(constants.BUILD_PROPERTIES_FQBN),
9799
buildProperties.Get("compiler.optimization_flags"), realCoreFolder)
98-
buildcache.GetOrCreate(buildCachePath.Join(archivedCoreName))
99100
targetArchivedCore = buildCachePath.Join(archivedCoreName, "core.a")
101+
_, buildCacheErr = buildcache.GetOrCreate(targetArchivedCore.Parent())
102+
100103
canUseArchivedCore := !ctx.OnlyUpdateCompilationDatabase &&
101104
!ctx.Clean &&
102105
!builder_utils.CoreOrReferencedCoreHasChanged(realCoreFolder, targetCoreFolder, targetArchivedCore)
@@ -122,6 +125,11 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path
122125

123126
// archive core.a
124127
if targetArchivedCore != nil && !ctx.OnlyUpdateCompilationDatabase {
128+
if buildCacheErr != nil {
129+
if err := targetArchivedCore.Parent().Mkdir(); err != nil {
130+
return nil, nil, fmt.Errorf(tr("creating core cache folder: %s", err))
131+
}
132+
}
125133
err := archiveFile.CopyTo(targetArchivedCore)
126134
if ctx.Verbose {
127135
if err == nil {

0 commit comments

Comments
 (0)