Skip to content

Commit

Permalink
Do not force build-cache path creation if not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
cmaglie committed May 27, 2024
1 parent 8797c63 commit 94b1983
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/arduino/builder/core.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,11 +109,12 @@ func (b *Builder) compileCore() (*paths.Path, paths.PathList, error) {
}

// If there is an archived core in the current build cache, use it
if _, err := buildcache.New(b.coreBuildCachePath).GetOrCreate(archivedCoreName); errors.Is(err, buildcache.CreateDirErr) {
return nil, nil, errors.New(i18n.Tr("creating core cache folder: %s", err))
}
targetArchivedCore = b.coreBuildCachePath.Join(archivedCoreName, "core.a")
if canUseArchivedCore(targetArchivedCore) {
// Extend the build cache expiration time
if _, err := buildcache.New(b.coreBuildCachePath).GetOrCreate(archivedCoreName); errors.Is(err, buildcache.CreateDirErr) {
return nil, nil, errors.New(i18n.Tr("creating core cache folder: %s", err))
}
// use archived core
if b.logger.Verbose() {
b.logger.Info(i18n.Tr("Using precompiled core: %[1]s", targetArchivedCore))
Expand All @@ -133,6 +134,11 @@ func (b *Builder) compileCore() (*paths.Path, paths.PathList, error) {
return extraTargetArchivedCore, variantObjectFiles, nil
}
}

// Create the build cache folder for the core
if _, err := buildcache.New(b.coreBuildCachePath).GetOrCreate(archivedCoreName); errors.Is(err, buildcache.CreateDirErr) {
return nil, nil, errors.New(i18n.Tr("creating core cache folder: %s", err))
}
}

coreObjectFiles, err := b.compileFiles(
Expand Down

0 comments on commit 94b1983

Please sign in to comment.