Skip to content

add check on arduino-cli version used #18

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

Merged
merged 4 commits into from
Feb 2, 2022
Merged
Show file tree
Hide file tree
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
22 changes: 21 additions & 1 deletion cmd/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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-<date> - nightly build
// - test-<hash>-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
Expand Down
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
)

Expand Down
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -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=
Expand Down