diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2016-09-09 08:01:44 (GMT) |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2016-09-20 18:48:10 (GMT) |
commit | ca7799482cbbb38b667fd5d045a0fc95d09a8cf2 (patch) | |
tree | d79dc456a8130dcd7ee86137df98b0fe39ae29fd /Source/cmServer.cxx | |
parent | 70b8ba9a0f4403729b9d68719503243982b883f4 (diff) | |
download | CMake-ca7799482cbbb38b667fd5d045a0fc95d09a8cf2.zip CMake-ca7799482cbbb38b667fd5d045a0fc95d09a8cf2.tar.gz CMake-ca7799482cbbb38b667fd5d045a0fc95d09a8cf2.tar.bz2 |
server-mode: Automate progress reporting
Wire up cmake::SetProgressUpdate to do progress reporting via the
cmake server.
Diffstat (limited to 'Source/cmServer.cxx')
-rw-r--r-- | Source/cmServer.cxx | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx index c0575af..8fb452b 100644 --- a/Source/cmServer.cxx +++ b/Source/cmServer.cxx @@ -134,8 +134,13 @@ void cmServer::PopOne() return; } - this->WriteResponse(this->Protocol ? this->Protocol->Process(request) - : this->SetProtocolVersion(request)); + if (this->Protocol) { + this->Protocol->CMakeInstance()->SetProgressCallback( + reportProgress, const_cast<cmServerRequest*>(&request)); + this->WriteResponse(this->Protocol->Process(request)); + } else { + this->WriteResponse(this->SetProtocolVersion(request)); + } } void cmServer::handleData(const std::string& data) @@ -210,6 +215,17 @@ void cmServer::PrintHello() const this->WriteJsonObject(hello); } +void cmServer::reportProgress(const char* msg, float progress, void* data) +{ + const cmServerRequest* request = static_cast<const cmServerRequest*>(data); + assert(request); + if (progress < 0.0 || progress > 1.0) { + request->ReportProgress(0, 0, 0, msg); + } else { + request->ReportProgress(0, static_cast<int>(progress * 1000), 1000, msg); + } +} + cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request) { if (request.Type != "handshake") |