From 4b6614e4d3751b714124688e162d12b7d127f9e8 Mon Sep 17 00:00:00 2001 From: Martino Facchin Date: Tue, 22 Mar 2016 11:46:22 +0100 Subject: [PATCH] Don't wipe everything is only sketch path changed Signed-off-by: Martino Facchin --- .../wipeout_build_path_if_build_options_changed.go | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/arduino.cc/builder/wipeout_build_path_if_build_options_changed.go b/src/arduino.cc/builder/wipeout_build_path_if_build_options_changed.go index 71a30e01..a974164e 100644 --- a/src/arduino.cc/builder/wipeout_build_path_if_build_options_changed.go +++ b/src/arduino.cc/builder/wipeout_build_path_if_build_options_changed.go @@ -36,6 +36,7 @@ import ( "arduino.cc/builder/utils" "os" "path/filepath" + "regexp" ) type WipeoutBuildPathIfBuildOptionsChanged struct{} @@ -44,7 +45,6 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(context map[string]interface if !utils.MapHas(context, constants.CTX_BUILD_OPTIONS_PREVIOUS_JSON) { return nil } - buildOptionsJson := context[constants.CTX_BUILD_OPTIONS_JSON].(string) previousBuildOptionsJson := context[constants.CTX_BUILD_OPTIONS_PREVIOUS_JSON].(string) logger := context[constants.CTX_LOGGER].(i18n.Logger) @@ -53,6 +53,15 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(context map[string]interface return nil } + re := regexp.MustCompile("(?m)^.*" + constants.CTX_SKETCH_LOCATION + ".*$[\r\n]+") + buildOptionsJson = re.ReplaceAllString(buildOptionsJson, "") + previousBuildOptionsJson = re.ReplaceAllString(previousBuildOptionsJson, "") + + // if the only difference is the sketch path skip deleting everything + if buildOptionsJson == previousBuildOptionsJson { + return nil + } + logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED) buildPath := context[constants.CTX_BUILD_PATH].(string)