@@ -18,7 +18,9 @@ package builder
1818import (
1919 "encoding/json"
2020 "path/filepath"
21+ "os"
2122
23+ "github.com/arduino/arduino-cli/cli/errorcodes"
2224 "github.com/arduino/arduino-cli/legacy/builder/builder_utils"
2325 "github.com/arduino/arduino-cli/legacy/builder/constants"
2426 "github.com/arduino/arduino-cli/legacy/builder/types"
@@ -40,11 +42,14 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
4042 previousBuildOptionsJson := ctx .BuildOptionsJsonPrevious
4143
4244 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+ }
4449
4550 var prevOpts * properties.Map
4651 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 )
4853 return doCleanup (ctx .BuildPath )
4954 }
5055
@@ -77,7 +82,7 @@ func (s *WipeoutBuildPathIfBuildOptionsChanged) Run(ctx *types.Context) error {
7782func doCleanup (buildPath * paths.Path ) error {
7883 // FIXME: this should go outside legacy and behind a `logrus` call so users can
7984 // 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 )
8186
8287 if files , err := buildPath .ReadDir (); err != nil {
8388 return errors .WithMessage (err , "cleaning build path" )
0 commit comments