30
30
package compile
31
31
32
32
import (
33
+ "fmt"
33
34
"os"
34
35
"path/filepath"
35
36
"strings"
@@ -40,6 +41,7 @@ import (
40
41
"github.com/bcmi-labs/arduino-cli/commands"
41
42
"github.com/bcmi-labs/arduino-cli/common"
42
43
"github.com/bcmi-labs/arduino-cli/common/formatter"
44
+ "github.com/bcmi-labs/arduino-cli/cores"
43
45
"github.com/bcmi-labs/arduino-cli/sketches"
44
46
"github.com/sirupsen/logrus"
45
47
"github.com/spf13/cobra"
@@ -90,7 +92,7 @@ func run(cmd *cobra.Command, args []string) {
90
92
formatter .PrintError (err , "Sketch file not found." )
91
93
isCorrectSyntax = false
92
94
}
93
- var packageName string
95
+ var packageName , coreName string
94
96
fullyQualifiedBoardName := flags .fullyQualifiedBoardName
95
97
if fullyQualifiedBoardName == "" && sketch != nil {
96
98
fullyQualifiedBoardName = sketch .Metadata .CPU .Fqbn
@@ -105,8 +107,31 @@ func run(cmd *cobra.Command, args []string) {
105
107
isCorrectSyntax = false
106
108
} else {
107
109
packageName = fqbnParts [0 ]
110
+ coreName = fqbnParts [1 ]
108
111
}
109
112
}
113
+
114
+ isCtagsInstalled , err := cores .IsToolInstalled (packageName , "ctags" )
115
+ if err != nil {
116
+ formatter .PrintError (err , "Cannot check ctags installation." )
117
+ os .Exit (commands .ErrCoreConfig )
118
+ }
119
+ if ! isCtagsInstalled {
120
+ // TODO: how to properly install ctags?
121
+ formatter .PrintErrorMessage ("\" ctags\" tool not installed, please install it." )
122
+ isCorrectSyntax = false
123
+ }
124
+
125
+ isCoreInstalled , err := cores .IsCoreInstalled (packageName , coreName )
126
+ if err != nil {
127
+ formatter .PrintError (err , "Cannot check core installation." )
128
+ os .Exit (commands .ErrCoreConfig )
129
+ }
130
+ if ! isCoreInstalled {
131
+ formatter .PrintErrorMessage (fmt .Sprintf ("\" %[1]s:%[2]s\" core is not installed, please install it by running \" arduino core install %[1]s:%[2]s\" ." , packageName , coreName ))
132
+ isCorrectSyntax = false
133
+ }
134
+
110
135
if ! isCorrectSyntax {
111
136
os .Exit (commands .ErrBadCall )
112
137
}
0 commit comments