ccollins476ad commented on a change in pull request #77: Create
compile_commands.json file on build
URL: https://github.com/apache/mynewt-newt/pull/77#discussion_r128610830
##########
File path: newt/builder/build.go
##########
@@ -568,6 +571,35 @@ func (b *Builder) Build() error {
}
}
+ var compileCommands []toolchain.CompileCommand
+
+ for _, bpkg := range bpkgs {
+ c := bpkgCompilerMap[bpkg]
+ if c != nil {
+ compileCommands = append(compileCommands,
+ c.GetCompileCommands()...)
+ }
+ }
+
+ projectPath := interfaces.GetProject().Path() + "/"
+ for i := range compileCommands {
+ compileCommands[i].Directory = projectPath
+ }
+
+ cmdBytes, err := json.MarshalIndent(compileCommands, "", " ")
+ if err != nil {
+ log.Error("Unable to encode compilation commands as JSON")
+ return nil
+ }
+
+ outDir := filepath.Dir(b.AppElfPath())
+ cmdPath := outDir + "/compile_commands.json"
Review comment:
It might be better to define a function in `builder/paths.go` which returns
the compile commands json path (CompileCmdsPath() or similar). That way, all
the paths are defined in the same place.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services