Skip to content

Wipe anyway if the sketch name has changed #135

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ import (
"arduino.cc/builder/gohasissues"
"arduino.cc/builder/i18n"
"arduino.cc/builder/types"
"encoding/json"
"os"
"path/filepath"
"regexp"
)

type WipeoutBuildPathIfBuildOptionsChanged struct{}
Expand All @@ -53,13 +53,23 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
return nil
}

re := regexp.MustCompile("(?m)^.*" + ctx.SketchLocation + ".*$[\r\n]+")
buildOptionsJson = re.ReplaceAllString(buildOptionsJson, "")
previousBuildOptionsJson = re.ReplaceAllString(previousBuildOptionsJson, "")
// unmarshal jsons and check if every field is equal except SketchLocation
// if SketchLocation path is different but filename is the same, don't wipe
var buildOptions map[string]string
var previousBuildOptions map[string]string
json.Unmarshal([]byte(buildOptionsJson), &buildOptions)
json.Unmarshal([]byte(previousBuildOptionsJson), &previousBuildOptions)

// if the only difference is the sketch path skip deleting everything
if buildOptionsJson == previousBuildOptionsJson {
return nil
for key, _ := range buildOptions {
if buildOptions[key] != previousBuildOptions[key] {
if key == "sketchLocation" {
if filepath.Base(buildOptions[key]) == filepath.Base(previousBuildOptions[key]) {
return nil
}
} else {
break
}
}
}

logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED)
Expand Down