Skip to content
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

Add support for compile_command.json output #1081

Merged
merged 9 commits into from
Dec 15, 2020

Conversation

cmaglie
Copy link
Member

@cmaglie cmaglie commented Nov 18, 2020

This implementation is a tentative draft based on @matthijskooijman's #944

I've added a flag --only-compilation-database flag in compile command. When this flag is specified the build run will perform only:

  • library discovery
  • sketch preprocessing (the preprocessed sketch.ino.cpp is saved in the usual ${build_path}/sketch/... subdir)
  • generation of compile_command.json (saved in the build-path). In this case the sketch/core/libraries are not compiled but the command line is saved for compile_command.json

@cmaglie cmaglie marked this pull request as draft November 18, 2020 16:38
@cmaglie cmaglie marked this pull request as ready for review December 14, 2020 15:57
@cmaglie cmaglie merged commit 441f8eb into arduino:master Dec 15, 2020
@cmaglie cmaglie deleted the compile_commands branch December 15, 2020 09:53
@matthijskooijman
Copy link
Collaborator

I finally gotten around to giving this code a whirl, seems to work nicely overall. There's still some points unsolved from #944, but let's further discuss them in #849.

Why did you removing the "Writing compilation database..." message? IMHO it helps to both let people know that this feature is supported in the first place, and helps figure out where the file was written to, especially now it's only written to the build folder. In verbose mode, all commands run are printed, then why not show the compilation database was generated?

@cmaglie
Copy link
Member Author

cmaglie commented Feb 16, 2021

Why did you removing the "Writing compilation database..." message?

Mainly because:

  • it was inside a CompilationDatabase class, from the caller point of view calling SaveToFile should just save or return an error, without any other output
  • it used fmt.Printf instead of the logging system

BTW, you have a good point, I'll put a message output on the caller side.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants