Skip to content

Commit 11e3e8d

Browse files
committed
Wipe anyway if the sketch name has changed
solves arduino/Arduino#4862
1 parent 80849e7 commit 11e3e8d

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

Diff for: src/arduino.cc/builder/wipeout_build_path_if_build_options_changed.go

+10-6
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import (
3737
"os"
3838
"path/filepath"
3939
"regexp"
40+
"strings"
4041
)
4142

4243
type WipeoutBuildPathIfBuildOptionsChanged struct{}
@@ -53,13 +54,16 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(context map[string]interface
5354
return nil
5455
}
5556

56-
re := regexp.MustCompile("(?m)^.*" + constants.CTX_SKETCH_LOCATION + ".*$[\r\n]+")
57-
buildOptionsJson = re.ReplaceAllString(buildOptionsJson, "")
58-
previousBuildOptionsJson = re.ReplaceAllString(previousBuildOptionsJson, "")
57+
sketchName := filepath.Base(context[constants.CTX_SKETCH_LOCATION].(string)) + ".ino"
58+
if strings.Contains(previousBuildOptionsJson, sketchName) {
59+
re := regexp.MustCompile("(?m)^.*" + constants.CTX_SKETCH_LOCATION + ".*$[\r\n]+")
60+
buildOptionsJson = re.ReplaceAllString(buildOptionsJson, "")
61+
previousBuildOptionsJson = re.ReplaceAllString(previousBuildOptionsJson, "")
5962

60-
// if the only difference is the sketch path skip deleting everything
61-
if buildOptionsJson == previousBuildOptionsJson {
62-
return nil
63+
// if the only difference is the sketch path skip deleting everything
64+
if buildOptionsJson == previousBuildOptionsJson {
65+
return nil
66+
}
6367
}
6468

6569
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED)

0 commit comments

Comments
 (0)