-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
[Feature] Generate compilation database with compilation commands #272
Comments
this would be really nice but this project seems somewhat dead? |
Which project? |
arduino builder, last commit one year ago edited: |
Is this feature something which is being considered to be in development? SonarLint would require this as described here and this would integrate really well with the Arduino VSCode plugin. |
arduino-builder is no longer developed, relevant code has been moved to arduino-cli instead, and that has a basic implementation of this feature implemented already. There's still stuff left for improvement, see e.g. arduino/arduino-cli#849 (comment) for a (possibly) outdated list of some points. |
Thanks @matthijskooijman. What do you suggest be done with this issue? |
I was mostly ignoring it because arduino-builder isn't really relevant anymore, but I guess arduino-builder is actually still used in the java IDE to run the build code from arduino-cli, right? I wonder if that means that this compilation database is actually generated by the Java IDE now as well? In any case, I guess we can close as wontfix, since any usecases that need the compilation database, like the vscode plugin suggested above, are likely going to be using arduino-cli anyway? |
That is correct, so probably not quite ready to be considered irrelevant yet since it is very much in use by many people. It is certainly not under active development, but on the other hand it doesn't need much development because at this point it is pretty much just a wrapper around Arduino CLI used to translate the arduino-builder interface.
It is not:
The reason is because arduino-builder is missing this: builderCtx.CompilationDatabase = bldr.NewCompilationDatabase(
builderCtx.BuildPath.Join("compile_commands.json"),
) The required change to arduino-builder: --- a/main.go
+++ b/main.go
@@ -45,6 +45,7 @@ import (
"syscall"
"github.com/arduino/arduino-builder/grpc"
+ bldr "github.com/arduino/arduino-cli/arduino/builder"
"github.com/arduino/arduino-cli/arduino/cores"
"github.com/arduino/arduino-cli/legacy/builder"
"github.com/arduino/arduino-cli/legacy/builder/i18n"
@@ -258,6 +259,10 @@ func main() {
ctx.BuildPath, _ = buildPath.Abs()
}
+ ctx.CompilationDatabase = bldr.NewCompilationDatabase(
+ ctx.BuildPath.Join("compile_commands.json"),
+ )
+
// FLAG_BUILD_CACHE
if *buildCachePathFlag != "" {
buildCachePathUnquoted, err := unquote(*buildCachePathFlag) So it seems that this issue is still not resolved. It is also arduino-builder specific and thus not appropriate for transfer to the Arduino CLI repo. I don't feel knowledgeable enough about the subject matter to determine whether or not it should be considered "wontfix". I'll leave that decision up to you or one of the other maintainers. |
It would be interesting if arduino-builder could generate a "compilation database", as a side effect of building a sketch. This is a JSON file containing the gcc commands used to compile each file in the project. Third party tools can use such a database to figure out the compilation flags used, to simplify analysis of the source code, or to easily support code completion in a third-party editor.
For docs, see http://clang.llvm.org/docs/JSONCompilationDatabase.html According to the YouCompleteMe docs, this file is customary called
compilation_commands.json
: https://github.com/Valloric/YouCompleteMe#option-1-use-a-compilation-databaseGenerating such a file is not entirely trivial, especially since files are currently compiled from a temporary directory (so the commands should probably be slightly faked using the original filenames) and because .ino files are preprocessed before being compiled (but for the purposes of completion, it might be sufficient if the flags for each .ino file can be read separatey).
This might need some further thought, but I wanted to create this issue to track any discussion around this topic.
The text was updated successfully, but these errors were encountered: