@@ -34,9 +34,9 @@ import (
34
34
"arduino.cc/builder/gohasissues"
35
35
"arduino.cc/builder/i18n"
36
36
"arduino.cc/builder/types"
37
+ "encoding/json"
37
38
"os"
38
39
"path/filepath"
39
- "regexp"
40
40
)
41
41
42
42
type WipeoutBuildPathIfBuildOptionsChanged struct {}
@@ -53,13 +53,23 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
53
53
return nil
54
54
}
55
55
56
- re := regexp .MustCompile ("(?m)^.*" + ctx .SketchLocation + ".*$[\r \n ]+" )
57
- buildOptionsJson = re .ReplaceAllString (buildOptionsJson , "" )
58
- previousBuildOptionsJson = re .ReplaceAllString (previousBuildOptionsJson , "" )
56
+ // unmarshal jsons and check if every field is equal except SketchLocation
57
+ // if SketchLocation path is different but filename is the same, don't wipe
58
+ var buildOptions map [string ]string
59
+ var previousBuildOptions map [string ]string
60
+ json .Unmarshal ([]byte (buildOptionsJson ), & buildOptions )
61
+ json .Unmarshal ([]byte (previousBuildOptionsJson ), & previousBuildOptions )
59
62
60
- // if the only difference is the sketch path skip deleting everything
61
- if buildOptionsJson == previousBuildOptionsJson {
62
- return nil
63
+ for key , _ := range buildOptions {
64
+ if buildOptions [key ] != previousBuildOptions [key ] {
65
+ if key == "sketchLocation" {
66
+ if filepath .Base (buildOptions [key ]) == filepath .Base (previousBuildOptions [key ]) {
67
+ return nil
68
+ }
69
+ } else {
70
+ break
71
+ }
72
+ }
63
73
}
64
74
65
75
logger .Println (constants .LOG_LEVEL_INFO , constants .MSG_BUILD_OPTIONS_CHANGED )
0 commit comments