Skip to content

Commit f9eafe3

Browse files
committed
Added cmd line flag to enable faster builds
1 parent 769aaf6 commit f9eafe3

File tree

4 files changed

+26
-17
lines changed

4 files changed

+26
-17
lines changed

Diff for: ls/builder.go

+1-1
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")

Diff for: ls/ls.go

+9-8
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)

Diff for: ls/lsp_server_ide.go

+4
Original file line numberDiff line numberDiff line change
@@ -282,6 +282,10 @@ type DidCompleteBuildParams struct {
282282
}
283283

284284
func (server *IDELSPServer) ArduinoBuildCompleted(logger jsonrpc.FunctionLogger, raw json.RawMessage) {
285+
if !server.ls.config.SkipLibrariesDiscoveryOnRebuild {
286+
return
287+
}
288+
285289
var params DidCompleteBuildParams
286290
if err := json.Unmarshal(raw, &params); err != nil {
287291
logger.Logf("ERROR decoding DidCompleteBuildParams: %s", err)

Diff for: main.go

+12-8
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ func main() {
5050
cliDaemonInstanceNumber := flag.Int(
5151
"cli-daemon-instance", -1,
5252
"Instance number of the Arduino CLI daemon")
53+
skipLibrariesDiscoveryOnRebuild := flag.Bool(
54+
"skip-libraries-discovery-on-rebuild", false,
55+
"Skip libraries discovery on rebuild, it will make rebuilds faster but it will fail if the used libraries changes.")
5356
flag.Parse()
5457

5558
if *loggingBasePath != "" {
@@ -111,14 +114,15 @@ func main() {
111114
}
112115

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

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

0 commit comments

Comments
 (0)