Allow using cmake -E server rather than the compilecommands json files we use
nowadays.
Details
- Reviewers
mwolff zhigalin - Group Reviewers
KDevelop - Commits
- R32:752167bb480e: Refactor to embrace a cmake server import backend
Opened few projects locally successfully. Needs a patch I submitted to upstream
cmake and won't be released until 3.7.2 is out.
Diff Detail
- Repository
- R32 KDevelop
- Branch
- apol/cmakeserver
- Lint
No Linters Available - Unit
No Unit Test Coverage
projectmanagers/cmake/cmakemanager.cpp | ||
---|---|---|
142 | for PODs, you don't need Q_GLOBAL_STATIC. simply make this a namespace { on a conceptual level - this depends on the cmake binary that can be selected for every project, no? So this should not be a static at all, but rather a per-project property? | |
154 | make this a warning? also, do we want to show the user that? this can be serious and render the whole cmake support useless after all, right? | |
174 | warning, and see above? actually the whole code is duplicated - move this into a proper slot? or at least share the lambda body? | |
projectmanagers/cmake/cmakeprojectdata.cpp | ||
3 | the future is now! it's 2017 :P | |
31 | missing parent? | |
33 | empty line at end please | |
projectmanagers/cmake/cmakeprojectdata.h | ||
61 | & next to type names | |
71 | simply make it public like the stuff above and remove the getter? | |
projectmanagers/cmake/cmakeserver.cpp | ||
3 | 2017 | |
24 | unused? | |
38 | keep it around, otherwise the file gets removed again, no? or is that OK? | |
45 | QStringLiteral, and I hope cmake supports "--pipe", "path" as two args? i.e. instead of --pipe=path, can you pass --pipe path? | |
62 | can you add a comment saying why this is required? is there really no "good" way to wait for the server to start up? what is creator doing here? have you talked to thunger about this? looks really brittle | |
67 | I'd simplify the above a bit (imo) by doing something like: connect(...started, this, [this, path] () { // please document me QTimer::singleShot(100, this, [this, path] () { m_localSocket->connectToServer(path, QIODevice::ReadWrite); }); }); | |
81 | QByteArrayLiteral, wrap in functions returning QByteArray to get rid of global static initialization | |
90 | qCDebug(...) << "writing..." << object; | |
91 | spaces around operators | |
98 | const auto openTag = ::openTag(); // once you added the getter const auto oepnTagSize = openTag.size(); // use both below | |
99 | this can go into an infinite-loop, no? if m_buffer.size() == openTag.size() + 1, then we go into the loop, but we won't find the close tag and thus cannot ever get out of the loop see below | |
103 | spaces around operators | |
106 | else break? | |
117 | since we don't generate the response data, I wouldn't assert on it. if there's a cmake bug it would kill kdevelop... | |
128 | here and below: QStringLiteral | |
projectmanagers/cmake/cmakeserver.h | ||
3 | dito, 2017 | |
29 | this is actually a CMakeServerClient, right? | |
projectmanagers/cmake/cmakeserverimportjob.cpp | ||
3 | really? | |
30 | you only use it with T == Path::List, so why not hardcode that? | |
39 | please add it as a getter to the MakefileResolver API, which is used elsewhere in CMake already. That way we don't duplicate this magic | |
43 | QStringLiteral | |
69 | this could probably be part of a helper function in the MakefileResolver (see above), since that does something like that already elsewhere, I guess? | |
83 | spaces around operators | |
projectmanagers/cmake/cmakeserverimportjob.h | ||
2–3 | really? | |
34 | indent |
That was one thorough review! Thanks a lot milian!!
Will be submitting a new version with the fixes. Then if there's no big issue I'll merge to master by the end of the week, so we can start testing.
projectmanagers/cmake/cmakemanager.cpp | ||
---|---|---|
174 | As is we can't, they should inherit from the same class. I don't think it's a big deal at the moment... | |
projectmanagers/cmake/cmakeprojectdata.cpp | ||
31 | Hm? It's not a QObject. | |
projectmanagers/cmake/cmakeserver.cpp | ||
38 | No, actually we don't want the file at all. We just want a temporary and unique path but no file. | |
45 | apol@oliver:~$ cmake -E server --experimental --pipe=fu ^C apol@oliver:~$ cmake -E server --experimental --pipe fu CMake Error: Unknown argument for server mode | |
62 | Could be a good idea to talk with him about this, yes. | |
106 | Yep, actually I added it yesterday when testing. Good catch! :D | |
117 | Yeah... I added it when cmake was crashing. I'll remove for now. | |
128 | My brain wants to do it, but then it becomes an unreadable blob... :( | |
projectmanagers/cmake/cmakeserver.h | ||
3 | xD well I wrote this code in 2016. Ah, time, thou art a heartless bitch, | |
29 | Well, whoever interacts with this is interacting with the server after all. | |
projectmanagers/cmake/tests/test_cmakemanager.cpp | ||
283 | Sh... at least we are testing a bit more than we used to... |
lgtm to me mostly, but some stuff still needs to be ironed out, imo
projectmanagers/cmake/cmakemanager.cpp | ||
---|---|---|
142 ↗ | (On Diff #10265) | this is not used anywhere now? |
150–170 ↗ | (On Diff #10265) | Who will delete the server when it is available? this looks like you are piling up servers until the CMakeManager is deleted at shutdown. You probably want to use a unique_ptr here and transfer ownership into the import job when the server is available |
projectmanagers/cmake/cmakeserver.cpp | ||
45 | :-S | |
128 | think of all the little allocations :P | |
64 ↗ | (On Diff #10265) | you don't need the full timer object anymore, do you? Simply use QTimer::singleShot? |
65 ↗ | (On Diff #10265) | what if the first connect fails - we simply get an error and disconnect and don't try thereafter, right? couldn't we retry for up to N times (say every 100ms for up to 1s?) to make this a bit less brittle? |
118 ↗ | (On Diff #10265) | missing curly braces |
projectmanagers/cmake/cmakeserver.h | ||
29 | right, it's a client to the server, I'd welcome the rename personally |
projectmanagers/cmake/cmakeserver.cpp | ||
---|---|---|
65 ↗ | (On Diff #10265) | FWIW, this is the code in QtCreator: m_connectionTimer.setInterval(100); connect(&m_connectionTimer, &QTimer::timeout, this, &ServerMode::connectToServer); I'd prefer doing the same as them and discussing with Tobias how to improve it, as he did cmake-server implementation as well as qtcreator. |
projectmanagers/cmake/cmakeserver.cpp | ||
---|---|---|
65 ↗ | (On Diff #10265) | ah ok, yes that makes sense. |
- Change cmake setup logic slightly
- Don't try to connect if already connected. Otherwise it errors out
- Don't try to connect if already connected. Otherwise it errors out and everything crashes
minor nitpicks, otherwise lgtm
please fix those and then feel free to commit
projectmanagers/cmake/cmakemanager.cpp | ||
---|---|---|
204 ↗ | (On Diff #10265) | these shouldn't be QPointer, or? |
projectmanagers/cmake/cmakeserverimportjob.cpp | ||
72 ↗ | (On Diff #10265) | space after for |
75 ↗ | (On Diff #10265) | add braces and spaces around operator |
148 ↗ | (On Diff #10265) | add braces to all conditionals here |
157 ↗ | (On Diff #10265) | braces |
projectmanagers/cmake/tests/test_cmakeserver.cpp | ||
30 ↗ | (On Diff #10265) | indent |
I have problems with the patch and cmake 3.7.2:
unhandled message QJsonObject({"supportedProtocolVersions":[{"isExperimental":true,"major":1,"minor":0}],"type":"hello"}) error!! QJsonObject({"cookie":"","errorMessage":"Failed to activate protocol version: \"CMAKE_GENERATOR\" is set but incompatible with configured generator value.","inReplyTo":"handshake","type":"error"}) kdevelop.projectmanagers.cmake: couldn't load json successfully "kdev-valgrind" kdevelop.projectmanagers.cmake: couldn't load json successfully "kdev-valgrind"
Background parser now does nothing :(.
cmake 3.8.0-rc2 + full-rebuild kdevplatform/kdevelop - still breaks on project parsing :(
projectmanagers/cmake/cmakemanager.cpp | ||
---|---|---|
151 ↗ | (On Diff #10265) | Somewhy is not working:
|
The revision is still pending acceptance by Kevin, which is why you can't close it.
Removing him as a Reviewer should fix this - which i've just done.