-
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
Reading compilation database using rapidjson. #230
base: master
Are you sure you want to change the base?
Conversation
Also, I should say that this lacks support on Windows for now. The only thing that isn't portable AFAIK is the method for getting the time of modification of a compilation database. That is probably really easy to fix, I don't have a Windows computer at hand though. |
Interesting... |
Alright, then I will probably get started on the guessing algorithm in the meantime. Have a nice vacation! |
Also added error checking when parsing the database file.
I also have a prototype for the compilation database guessing by now. If you'd like, I could add it to this pull request. Otherwise I'll just open another request once we're done reviewing/reworking this one. |
Please leave the guessing out of this PR. I will give feedback during the week on this PR, thank you. |
So I was able to give it a quick try (on Linux). I have the feeling that the caching does not work. Timestamp based caching is trivial to implement. The most difficult will be to get it work in a cross-platform way. This leave me wondering about this PR. I have been thinking about server guessing, and I'm wondering if a compilation database for header files should be generated by a python script. The python script would process the compilation database and generate a new one for header files. Python has all the necessary stuff to deal with filesystem, parse JSON, ... This could prove simple and efficient. If we validate that a compilation database for headers make sense, then we could implement what is required in C++/Elisp. Actually the langage doesn't matter much to me, I'm more interested in the idea of a compilation database for headers. If we have such database, the only guessing left will be to find the compile options for files not in any of the compilation database, in this case we could just take the same flags as a sibling file. |
It should be easy to do. All we need is a call to a Windows routine to get the file modification time.
Your right, I see it as well. I will investigate when I have time.
Since it isn't cross platform, I saw this as a proof of concept. Now even more so since the caching doesn't work.
I agree that a more complex solution would be nice looking forward. However, I think that the guessing can be fast and accurate enough for now and that we should consider something similar to what I have been working on as a first step. Do you agree? If you do not want this patch, I won't put anymore time into it. I'm already using this with my C++ guessing patch daily, and I'm content with the way it works. /Karl |
This could be a simple function in support/.
ok
What I'm okay to integrate from this patch is a cross-platform guessing (I can test/do the Windows one if the code is clean enough that I just have to plug the right function call and test), but to integrate it, it should be done based on the current irony-master, we don't need rapidjson and so on for caching, we can use the old infrastructure. That will be a concise feature by itself. For the rest I need to have a feel for it, could you do a PR with the guessing? |
Even recent versions of stdlibc++ doesn't mark the move constructor of std::string as noexcept. Thus CompileCommands move operations cannot be noexcept and copy operations must be supported for CompileCommands to be used with standard contrainers.
Opened a separate PR with the guessing on top of this. |
Interestingly, I think the latest version of libclang now provides the filename (http://clang.llvm.org/doxygen/group__COMPILATIONDB.html#gaea64448378c6174e7896a81d26ff454a). This may obsolete the need for a custom JSON parser. |
That's really nice, we should absolutely use that instead. The problem with making the path operations portable (boost) still remains though. Do you think we should use boost and enable guessing if it is detected on the system? |
Hi,
This is a draft for the compilation database caching using rapidjson. I know rapidjson wasn't your first choice, but since I didn't understand exactly what requirements you have on the JSON reader and how rapidjson failed them I didn't know what else to look for. It should be simple enough to change it in the code though, if you decide we should go with something else. I'm also open to writing our own methods for reading the compilation database, if you prefer.
Let me know what you think,
Karl