16
16
package phases
17
17
18
18
import (
19
+ "fmt"
19
20
"os"
20
21
"strings"
21
22
@@ -92,11 +93,13 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path
92
93
realCoreFolder := coreFolder .Parent ().Parent ()
93
94
94
95
var targetArchivedCore * paths.Path
96
+ var buildCacheErr error
95
97
if buildCachePath != nil {
96
98
archivedCoreName := GetCachedCoreArchiveDirName (buildProperties .Get (constants .BUILD_PROPERTIES_FQBN ),
97
99
buildProperties .Get ("compiler.optimization_flags" ), realCoreFolder )
98
- buildcache .GetOrCreate (buildCachePath .Join (archivedCoreName ))
99
100
targetArchivedCore = buildCachePath .Join (archivedCoreName , "core.a" )
101
+ _ , buildCacheErr = buildcache .GetOrCreate (targetArchivedCore .Parent ())
102
+
100
103
canUseArchivedCore := ! ctx .OnlyUpdateCompilationDatabase &&
101
104
! ctx .Clean &&
102
105
! builder_utils .CoreOrReferencedCoreHasChanged (realCoreFolder , targetCoreFolder , targetArchivedCore )
@@ -122,6 +125,11 @@ func compileCore(ctx *types.Context, buildPath *paths.Path, buildCachePath *path
122
125
123
126
// archive core.a
124
127
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
+ }
125
133
err := archiveFile .CopyTo (targetArchivedCore )
126
134
if ctx .Verbose {
127
135
if err == nil {
0 commit comments