Skip to content

Add support for compile_command.json output #1081

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 9 commits into from
Dec 15, 2020
Prev Previous commit
Next Next commit
Save compilation database inside build path
  • Loading branch information
cmaglie committed Dec 14, 2020
commit f94d2fe9e5df33c306b41ea23771e89f2d9aaefc
7 changes: 3 additions & 4 deletions commands/compile/compile.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,6 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W
builderCtx.PackageManager = pm
builderCtx.FQBN = fqbn
builderCtx.SketchLocation = sketch.FullPath
builderCtx.CompilationDatabase = bldr.NewCompilationDatabase(
sketch.FullPath.Join("compile_commands.json"),
)

// FIXME: This will be redundant when arduino-builder will be part of the cli
builderCtx.HardwareDirs = configuration.HardwareDirectories(configuration.Settings)
Expand All @@ -132,10 +129,12 @@ func Compile(ctx context.Context, req *rpc.CompileReq, outStream, errStream io.W
} else {
builderCtx.BuildPath = paths.New(req.GetBuildPath())
}

if err = builderCtx.BuildPath.MkdirAll(); err != nil {
return nil, fmt.Errorf("cannot create build directory: %s", err)
}
builderCtx.CompilationDatabase = bldr.NewCompilationDatabase(
builderCtx.BuildPath.Join("compile_commands.json"),
)

builderCtx.Verbose = req.GetVerbose()

Expand Down