diff --git a/cmd/compile.go b/cmd/compile.go index b7f50d2..fc5275e 100644 --- a/cmd/compile.go +++ b/cmd/compile.go @@ -15,6 +15,7 @@ import ( "github.com/arduino/go-paths-helper" "github.com/sirupsen/logrus" "github.com/spf13/cobra" + semver "go.bug.st/relaxed-semver" ) var fqbn string @@ -90,7 +91,8 @@ func compileSketch(cmd *cobra.Command, args []string) { } var unmarshalledOutput map[string]interface{} json.Unmarshal(cmdOutput, &unmarshalledOutput) - logrus.Infof("arduino-cli version: %s", unmarshalledOutput["VersionString"]) + currentCliVersion := fmt.Sprint(unmarshalledOutput["VersionString"]) + checkCliVersion(currentCliVersion) // let's check if gcc-ar version cmdOutput, err = exec.Command("gcc-ar", "--version").CombinedOutput() @@ -144,6 +146,24 @@ func compileSketch(cmd *cobra.Command, args []string) { createLib(sketchName, buildMcu, fqbn, returnJson, objFilePaths) } +// checkCliVersion will check if the version of the arduino-cli used is the correct one. +// It will skip the check if the version comes from a non stable release +// The version must be > 0.20.2 +func checkCliVersion(currentCliVersion string) { + logrus.Infof("arduino-cli version: %s", currentCliVersion) + version, err := semver.Parse(currentCliVersion) + if err == nil { + // do the check + incompatibleVersion, _ := semver.Parse("0.20.2") + if version.LessThanOrEqual(incompatibleVersion) { + logrus.Fatalf("please use a version > %s of the arduino-cli, installed version: %s", incompatibleVersion, version) + } + } // we continue the execution, it means that the version could be one of: + // - git-snapshot - local build using task build + // - nightly- - nightly build + // - test--git-snapshot - tester builds generated by the CI system +} + // parseCliCompileOutput function takes cmdOutToParse as argument, // cmdOutToParse is the json output captured from the command run // the function extracts and returns the paths of the .o files diff --git a/go.mod b/go.mod index 1d8192e..8afdb0d 100644 --- a/go.mod +++ b/go.mod @@ -9,6 +9,7 @@ require ( require ( github.com/pkg/errors v0.9.1 // indirect + go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18 // indirect golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e // indirect ) diff --git a/go.sum b/go.sum index f454faf..4c6f7ef 100644 --- a/go.sum +++ b/go.sum @@ -332,6 +332,8 @@ github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9de github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= +go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18 h1:F1qxtaFuewctYc/SsHRn+Q7Dtwi+yJGPgVq8YLtQz98= +go.bug.st/relaxed-semver v0.0.0-20190922224835-391e10178d18/go.mod h1:Cx1VqMtEhE9pIkEyUj3LVVVPkv89dgW8aCKrRPDR/uE= go.etcd.io/etcd/api/v3 v3.5.1/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= go.etcd.io/etcd/client/pkg/v3 v3.5.1/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= go.etcd.io/etcd/client/v2 v2.305.1/go.mod h1:pMEacxZW7o8pg4CrFE7pquyCJJzZvkvdD2RibOCCCGs=