@@ -18,7 +18,9 @@ package builder
18
18
import (
19
19
"encoding/json"
20
20
"path/filepath"
21
+ "os"
21
22
23
+ "github.com/arduino/arduino-cli/cli/errorcodes"
22
24
"github.com/arduino/arduino-cli/legacy/builder/builder_utils"
23
25
"github.com/arduino/arduino-cli/legacy/builder/constants"
24
26
"github.com/arduino/arduino-cli/legacy/builder/types"
@@ -40,11 +42,14 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
40
42
previousBuildOptionsJson := ctx .BuildOptionsJsonPrevious
41
43
42
44
var opts * properties.Map
43
- json .Unmarshal ([]byte (buildOptionsJson ), & opts )
45
+ if err := json .Unmarshal ([]byte (buildOptionsJson ), & opts ); err != nil || opts == nil {
46
+ ctx .GetLogger ().Println (constants .LOG_LEVEL_DEBUG , constants .MSG_BUILD_OPTIONS_INVALID , constants .BUILD_OPTIONS_FILE )
47
+ os .Exit (errorcodes .ErrGeneric )
48
+ }
44
49
45
50
var prevOpts * properties.Map
46
51
if err := json .Unmarshal ([]byte (previousBuildOptionsJson ), & prevOpts ); err != nil || prevOpts == nil {
47
- ctx .GetLogger ().Println (constants .LOG_LEVEL_DEBUG , constants .MSG_BUILD_OPTIONS_INVALID , constants .BUILD_OPTIONS_FILE )
52
+ ctx .GetLogger ().Println (constants .LOG_LEVEL_DEBUG , constants .MSG_BUILD_OPTIONS_INVALID + constants . MSG_REBUILD_ALL , constants .BUILD_OPTIONS_FILE )
48
53
return doCleanup (ctx .BuildPath )
49
54
}
50
55
@@ -77,7 +82,7 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
77
82
func doCleanup (buildPath * paths.Path ) error {
78
83
// FIXME: this should go outside legacy and behind a `logrus` call so users can
79
84
// control when this should be printed.
80
- // logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED)
85
+ // logger.Println(constants.LOG_LEVEL_INFO, constants.MSG_BUILD_OPTIONS_CHANGED + MSG_REBUILD_ALL )
81
86
82
87
if files , err := buildPath .ReadDir (); err != nil {
83
88
return errors .WithMessage (err , "cleaning build path" )
0 commit comments