Skip to content

Commit f4e9cb1

Browse files
committed
Added cmd line flag to enable faster builds
1 parent 98c8115 commit f4e9cb1

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

ls/builder.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ func (r *SketchRebuilder) rebuilderLoop() {
106106

107107
func (r *SketchRebuilder) doRebuildArduinoPreprocessedSketch(ctx context.Context, logger jsonrpc.FunctionLogger) error {
108108
ls := r.ls
109-
if success, err := ls.generateBuildEnvironment(ctx, false, logger); err != nil {
109+
if success, err := ls.generateBuildEnvironment(ctx, !r.ls.config.SkipLibrariesDiscoveryOnRebuild, logger); err != nil {
110110
return err
111111
} else if !success {
112112
return fmt.Errorf("build failed")

ls/ls.go

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,14 +51,15 @@ type INOLanguageServer struct {
5151

5252
// Config describes the language server configuration.
5353
type Config struct {
54-
Fqbn string
55-
CliPath *paths.Path
56-
CliConfigPath *paths.Path
57-
ClangdPath *paths.Path
58-
CliDaemonAddress string
59-
CliInstanceNumber int
60-
FormatterConf *paths.Path
61-
EnableLogging bool
54+
Fqbn string
55+
CliPath *paths.Path
56+
CliConfigPath *paths.Path
57+
ClangdPath *paths.Path
58+
CliDaemonAddress string
59+
CliInstanceNumber int
60+
FormatterConf *paths.Path
61+
EnableLogging bool
62+
SkipLibrariesDiscoveryOnRebuild bool
6263
}
6364

6465
var yellow = color.New(color.FgHiYellow)

ls/lsp_server_ide.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -275,6 +275,10 @@ type DidCompleteBuildParams struct {
275275
}
276276

277277
func (server *IDELSPServer) ArduinoBuildCompleted(logger jsonrpc.FunctionLogger, raw json.RawMessage) {
278+
if !server.ls.config.SkipLibrariesDiscoveryOnRebuild {
279+
return
280+
}
281+
278282
var params DidCompleteBuildParams
279283
if err := json.Unmarshal(raw, &params); err != nil {
280284
logger.Logf("ERROR decoding DidCompleteBuildParams: %s", err)

main.go

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,9 @@ func main() {
4848
cliDaemonInstanceNumber := flag.Int(
4949
"cli-daemon-instance", -1,
5050
"Instance number of the Arduino CLI daemon")
51+
skipLibrariesDiscoveryOnRebuild := flag.Bool(
52+
"skip-libraries-discovery-on-rebuild", false,
53+
"Skip libraries discovery on rebuild, it will make rebuilds faster but it will fail if the used libraries changes.")
5154
flag.Parse()
5255

5356
if *loggingBasePath != "" {
@@ -109,14 +112,15 @@ func main() {
109112
}
110113

111114
config := &ls.Config{
112-
Fqbn: *fqbn,
113-
ClangdPath: paths.New(*clangdPath),
114-
EnableLogging: *enableLogging,
115-
CliPath: paths.New(*cliPath),
116-
CliConfigPath: paths.New(*cliConfigPath),
117-
FormatterConf: paths.New(*formatFilePath),
118-
CliDaemonAddress: *cliDaemonAddress,
119-
CliInstanceNumber: *cliDaemonInstanceNumber,
115+
Fqbn: *fqbn,
116+
ClangdPath: paths.New(*clangdPath),
117+
EnableLogging: *enableLogging,
118+
CliPath: paths.New(*cliPath),
119+
CliConfigPath: paths.New(*cliConfigPath),
120+
FormatterConf: paths.New(*formatFilePath),
121+
CliDaemonAddress: *cliDaemonAddress,
122+
CliInstanceNumber: *cliDaemonInstanceNumber,
123+
SkipLibrariesDiscoveryOnRebuild: *skipLibrariesDiscoveryOnRebuild,
120124
}
121125

122126
stdio := streams.NewReadWriteCloser(os.Stdin, os.Stdout)

0 commit comments

Comments
 (0)