summaryrefslogtreecommitdiffstats
path: root/Source/cmServer.cxx
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-09-09 08:01:44 (GMT)
committerBrad King <brad.king@kitware.com>2016-09-20 12:32:26 (GMT)
commit7df8a8f2769de784c24dc6baeb55ad2038aa059f (patch)
tree3b2535b239d205da500802c7f427f8a37fbf89d3 /Source/cmServer.cxx
parent5c87b92b1b7888ee032e3c2a75f35f1f94f4dfa5 (diff)
downloadCMake-7df8a8f2769de784c24dc6baeb55ad2038aa059f.zip
CMake-7df8a8f2769de784c24dc6baeb55ad2038aa059f.tar.gz
CMake-7df8a8f2769de784c24dc6baeb55ad2038aa059f.tar.bz2
server-mode: Add --experimental flag
Allow for experimental cmProtocolVersions, which will only ever get listed if the server was started with the (undocumented) "--experimental" flag. Mark current protocol version 1.0 as experimental.
Diffstat (limited to 'Source/cmServer.cxx')
-rw-r--r--Source/cmServer.cxx19
1 files changed, 15 insertions, 4 deletions
diff --git a/Source/cmServer.cxx b/Source/cmServer.cxx
index 123b6a4..208fac6 100644
--- a/Source/cmServer.cxx
+++ b/Source/cmServer.cxx
@@ -85,7 +85,8 @@ void read_stdin(uv_stream_t* stream, ssize_t nread, const uv_buf_t* buf)
free(buf->base);
}
-cmServer::cmServer()
+cmServer::cmServer(bool supportExperimental)
+ : SupportExperimental(supportExperimental)
{
// Register supported protocols:
this->RegisterProtocol(new cmServerProtocol1_0);
@@ -93,8 +94,9 @@ cmServer::cmServer()
cmServer::~cmServer()
{
- if (!this->Protocol) // Daemon was never fully started!
+ if (!this->Protocol) { // Server was never fully started!
return;
+ }
uv_close(reinterpret_cast<uv_handle_t*>(this->InputStream), NULL);
uv_close(reinterpret_cast<uv_handle_t*>(this->OutputStream), NULL);
@@ -171,6 +173,9 @@ void cmServer::handleData(const std::string& data)
void cmServer::RegisterProtocol(cmServerProtocol* protocol)
{
+ if (protocol->IsExperimental() && !this->SupportExperimental) {
+ return;
+ }
auto version = protocol->ProtocolVersion();
assert(version.first >= 0);
assert(version.second >= 0);
@@ -196,6 +201,9 @@ void cmServer::PrintHello() const
Json::Value tmp = Json::objectValue;
tmp["major"] = version.first;
tmp["minor"] = version.second;
+ if (proto->IsExperimental()) {
+ tmp["experimental"] = true;
+ }
protocolVersions.append(tmp);
}
@@ -245,9 +253,11 @@ cmServerResponse cmServer::SetProtocolVersion(const cmServerRequest& request)
return request.Reply(Json::objectValue);
}
-void cmServer::Serve()
+bool cmServer::Serve()
{
- assert(!this->SupportedProtocols.empty());
+ if (this->SupportedProtocols.empty()) {
+ return false;
+ }
assert(!this->Protocol);
this->Loop = uv_default_loop();
@@ -279,6 +289,7 @@ void cmServer::Serve()
uv_read_start(this->InputStream, alloc_buffer, read_stdin);
uv_run(this->Loop, UV_RUN_DEFAULT);
+ return true;
}
void cmServer::WriteJsonObject(const Json::Value& jsonValue) const