Skip to content

Commit 9b0a81a

Browse files
committed
Wipe build dir only if txt build rules has changed
All other source files are "tracked" by .d dependency files Solves arduino#251
1 parent 849faa1 commit 9b0a81a

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

Diff for: builder_utils/utils.go

+26
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,32 @@ func CoreOrReferencedCoreHasChanged(corePath, targetCorePath, targetFile string)
392392
return true
393393
}
394394

395+
func TXTBuildRulesHaveChanged(corePath, targetCorePath, targetFile string) bool {
396+
397+
targetFileStat, err := os.Stat(targetFile)
398+
if err == nil {
399+
files, err := findAllFilesInFolder(corePath, true)
400+
if err != nil {
401+
return true
402+
}
403+
for _, file := range files {
404+
// report changes only for .txt files
405+
if filepath.Ext(file) != ".txt" {
406+
continue
407+
}
408+
fileStat, err := os.Stat(file)
409+
if err != nil || fileStat.ModTime().After(targetFileStat.ModTime()) {
410+
return true
411+
}
412+
}
413+
if targetCorePath != constants.EMPTY_STRING && !strings.EqualFold(corePath, targetCorePath) {
414+
return TXTBuildRulesHaveChanged(targetCorePath, constants.EMPTY_STRING, targetFile)
415+
}
416+
return false
417+
}
418+
return true
419+
}
420+
395421
func ArchiveCompiledFiles(ctx *types.Context, buildPath string, archiveFile string, objectFiles []string, buildProperties properties.Map) (string, error) {
396422
logger := ctx.GetLogger()
397423
archiveFilePath := filepath.Join(buildPath, archiveFile)

Diff for: wipeout_build_path_if_build_options_changed.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
7373
coreFolder := buildProperties[constants.BUILD_PROPERTIES_BUILD_CORE_PATH]
7474
realCoreFolder := utils.GetParentFolder(coreFolder, 2)
7575
jsonPath := filepath.Join(ctx.BuildPath, constants.BUILD_OPTIONS_FILE)
76-
coreHasChanged := builder_utils.CoreOrReferencedCoreHasChanged(realCoreFolder, targetCoreFolder, jsonPath)
76+
coreHasChanged := builder_utils.TXTBuildRulesHaveChanged(realCoreFolder, targetCoreFolder, jsonPath)
7777

7878
if opts.Equals(prevOpts) && !coreHasChanged {
7979
return nil

0 commit comments

Comments
 (0)