-
Notifications
You must be signed in to change notification settings - Fork 99
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
Trouble with compilation database #190
Comments
Hi, So it will be a little bit of trials and errors to debug this I think, the way the JSON compilation database is handled may change a little bit in the future. Can you print me some values:
And if the last command worked, this one may be big if you compilation database is big:
|
Thanks for your quick reply! The first command produces: ((" And the second produces: nil Of course, the last command does nothing because the location returned is nil, but if I directly enter: (irony-cdb-json--load-db "~/Build-Dev/compile_commands.json") it outputs what looks like the contents of the compilation database as a elisp expression. Cheers, |
What does the following give you?
|
I made a mistake in copying paths, so I'll give you everything again to avoid confusion: Source dir: ~/workspaces/UAToolKit_NEW/Dev/ I do: Results: M-: (irony-cdb-json--locate-db) RET M-: (irony-cdb-json--target-path) RET C-h v irony-cdb-json--project-alist RET M-: (irony-cdb-json--find-best-prefix-path (irony-cdb-json--target-path) '("~/workspace/UAToolKit_NEW/Dev/")) |
What about?
Maybe I'm not expanding the paths every time it's needed. Can you:
|
The first command returns /home/patrick/workspace/UAToolKit_NEW/Dev/ Expanding the ~ did the trick! With the ~ expanded manually, the CDB is found and completion works well in .cpp files. It doesn't seem to be working in .h files though. Anything I can do to make it it give sensible results in .h files? |
Okay, glad to see that we were able to catch the first issue. For the second one I'm surprised (how unlucky can you get? :P) Can you try to evaluate this function which replicate the (defun check-compile-options ()
(interactive)
(irony-cdb-json--ensure-project-alist-loaded)
(irony--aif (irony-cdb-json--locate-db)
(progn
(message "I: found compilation database: %s" it)
(let ((db (irony-cdb-json--load-db it)))
(irony--aif (irony-cdb-json--exact-flags db)
(progn
(message "I: found exact match: %s" it)
it)
(let ((dir-cdb (irony-cdb-json--compute-directory-cdb db)))
(irony--aif (irony-cdb-json--guess-flags dir-cdb)
(message "I: found by guessing: %s" it)
(message "E: guessing failed"))))))
(message "E: failed to locate compilation database"))) Then in the header file, you can call the function |
Thanks again for all your help. This is what I get from M-x check-compile-options RET. I: found compilation database: /home/patrick/Build-Dev/compile_commands.json The include paths in particular look incorrect. |
So this |
Sorry. I wasn't clear. Both check-compile-options and irony-cdb-menu show compile options and they are the same options. The problem is that the settings aren't the correct ones for the header. |
What do you have VS what do you expect for the compile options? The build system provide no information about the compile option needed for a header file, irony mode has to guess something that will work. The guessing works like this: We build a compilation database for the directories, as follow:
With this second, generated compilation database, we look for the best match (longest prefix) for the current buffer. Not sure if that's clear. What I'm wondering is whether or not your flags are just "too convoluted" or does your header fail to compile/complete? |
I think the options might be incorrect. Here's an concreate example using Request.h and Request.cpp in ~/workspaces/UAToolKit_NEW/Dev/StackWrapper/.
I: found compilation database: /home/patrick/Build-Dev/compile_commands.json
To understand Request.h, libclang is going to need most of the same -I options as Request.cpp, but they are missing. Thanks for your help! |
Sorry for the delay. It is weird indeed, something is off in the guessing mechanism I guess. Would you be able to find which file uses these gtest flags in the compilation database and print the entry? If you are not familiar with elisp, the most helpful for debugging would be to provide a reduced test case if you can but I would understand if that's not easy to do. While waiting for this bug to be fixed you can still create a |
On 20/04/2015 3:04 PM, Guillaume Papin wrote:
I'm not familiar with elisp, but I know scheme. When I get a chance I'll Thanks again. |
First, thanks for irony-mode. It looks like a great package. I am having trouble configuring the compilation database. I've tried to sort it out with no success.
Briefly: Running Emacs 24.3.1. I installed ironyfrom elpa. Then I did M-x irony-install-server and it succeeds.
My source is built outside the source tree. CMake generates the json compilation database in the build directory.
To configure the compilation database, I do M-x irony-cdb-json-add-compile-commands-path RET ~/path/to/source/root RET ~/builddir/compile_commands.json
But it doesn't seem to have any effect, and M-x irony-cdb-menu report "No compilation database in use".
Explicitly doing M-x irony-cdb-autosetup-compile-options RET has no effect.
C-h v irony--compile-options RET says the value is nil.
I'm suspect I'm just doing something wrong ... but I can't figure out what. Any help much appreciated.
The text was updated successfully, but these errors were encountered: