Skip to content

Commit 94b1983

Browse files
committed
Do not force build-cache path creation if not needed
1 parent 8797c63 commit 94b1983

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

internal/arduino/builder/core.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -109,11 +109,12 @@ func (b *Builder) compileCore() (*paths.Path, paths.PathList, error) {
109109
}
110110

111111
// If there is an archived core in the current build cache, use it
112-
if _, err := buildcache.New(b.coreBuildCachePath).GetOrCreate(archivedCoreName); errors.Is(err, buildcache.CreateDirErr) {
113-
return nil, nil, errors.New(i18n.Tr("creating core cache folder: %s", err))
114-
}
115112
targetArchivedCore = b.coreBuildCachePath.Join(archivedCoreName, "core.a")
116113
if canUseArchivedCore(targetArchivedCore) {
114+
// Extend the build cache expiration time
115+
if _, err := buildcache.New(b.coreBuildCachePath).GetOrCreate(archivedCoreName); errors.Is(err, buildcache.CreateDirErr) {
116+
return nil, nil, errors.New(i18n.Tr("creating core cache folder: %s", err))
117+
}
117118
// use archived core
118119
if b.logger.Verbose() {
119120
b.logger.Info(i18n.Tr("Using precompiled core: %[1]s", targetArchivedCore))
@@ -133,6 +134,11 @@ func (b *Builder) compileCore() (*paths.Path, paths.PathList, error) {
133134
return extraTargetArchivedCore, variantObjectFiles, nil
134135
}
135136
}
137+
138+
// Create the build cache folder for the core
139+
if _, err := buildcache.New(b.coreBuildCachePath).GetOrCreate(archivedCoreName); errors.Is(err, buildcache.CreateDirErr) {
140+
return nil, nil, errors.New(i18n.Tr("creating core cache folder: %s", err))
141+
}
136142
}
137143

138144
coreObjectFiles, err := b.compileFiles(

0 commit comments

Comments
 (0)