Skip to content

Commit 4b6614e

Browse files
committed
Don't wipe everything is only sketch path changed
Signed-off-by: Martino Facchin <[email protected]>
1 parent ab082ad commit 4b6614e

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

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

+10-1
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ import (
3636
"arduino.cc/builder/utils"
3737
"os"
3838
"path/filepath"
39+
"regexp"
3940
)
4041

4142
type WipeoutBuildPathIfBuildOptionsChanged struct{}
@@ -44,7 +45,6 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(context map[string]interface
4445
if !utils.MapHas(context, constants.CTX_BUILD_OPTIONS_PREVIOUS_JSON) {
4546
return nil
4647
}
47-
4848
buildOptionsJson := context[constants.CTX_BUILD_OPTIONS_JSON].(string)
4949
previousBuildOptionsJson := context[constants.CTX_BUILD_OPTIONS_PREVIOUS_JSON].(string)
5050
logger := context[constants.CTX_LOGGER].(i18n.Logger)
@@ -53,6 +53,15 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(context map[string]interface
5353
return nil
5454
}
5555

56+
re := regexp.MustCompile("(?m)^.*" + constants.CTX_SKETCH_LOCATION + ".*$[\r\n]+")
57+
buildOptionsJson = re.ReplaceAllString(buildOptionsJson, "")
58+
previousBuildOptionsJson = re.ReplaceAllString(previousBuildOptionsJson, "")
59+
60+
// if the only difference is the sketch path skip deleting everything
61+
if buildOptionsJson == previousBuildOptionsJson {
62+
return nil
63+
}
64+
5665
logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED)
5766

5867
buildPath := context[constants.CTX_BUILD_PATH].(string)

0 commit comments

Comments
 (0)