[Cmake-commits] CMake branch, next, updated. v3.6.2-2223-gb84b2d4

Brad King brad.king at kitware.com
Mon Sep 19 14:16:54 EDT 2016


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "CMake".

The branch, next has been updated
       via  b84b2d40fe7f0b88b919633893351c32762385c8 (commit)
       via  7981172fb6d1e6649dbec0952a4a358b9782d578 (commit)
      from  9027ac7ab915f4c75892bc771130dbbaae93c5d2 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=b84b2d40fe7f0b88b919633893351c32762385c8
commit b84b2d40fe7f0b88b919633893351c32762385c8
Merge: 9027ac7 7981172
Author:     Brad King <brad.king at kitware.com>
AuthorDate: Mon Sep 19 14:16:54 2016 -0400
Commit:     CMake Topic Stage <kwrobot at kitware.com>
CommitDate: Mon Sep 19 14:16:54 2016 -0400

    Merge topic 'cmake-server-experimental-protocols' into next
    
    7981172f server-mode: Add --experimental flag


https://cmake.org/gitweb?p=cmake.git;a=commitdiff;h=7981172fb6d1e6649dbec0952a4a358b9782d578
commit 7981172fb6d1e6649dbec0952a4a358b9782d578
Author:     Tobias Hunger <tobias.hunger at qt.io>
AuthorDate: Fri Sep 9 10:01:44 2016 +0200
Commit:     Tobias Hunger <tobias.hunger at qt.io>
CommitDate: Mon Sep 19 16:21:20 2016 +0200

    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.

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
diff --git a/Source/cmServer.h b/Source/cmServer.h
index 0ef1e17..4a9c3f5 100644
--- a/Source/cmServer.h
+++ b/Source/cmServer.h
@@ -31,10 +31,10 @@ class cmServerResponse;
 class cmServer
 {
 public:
-  cmServer();
+  cmServer(bool supportExperimental);
   ~cmServer();
 
-  void Serve();
+  bool Serve();
 
   // for callbacks:
   void PopOne();
@@ -59,6 +59,8 @@ private:
   static cmServerProtocol* FindMatchingProtocol(
     const std::vector<cmServerProtocol*>& protocols, int major, int minor);
 
+  const bool SupportExperimental;
+
   cmServerProtocol* Protocol = nullptr;
   std::vector<cmServerProtocol*> SupportedProtocols;
   std::vector<std::string> Queue;
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx
index c3a4d8e..d53ac28 100644
--- a/Source/cmServerProtocol.cxx
+++ b/Source/cmServerProtocol.cxx
@@ -262,3 +262,8 @@ const cmServerResponse cmServerProtocol1_0::Process(
 
   return request.ReportError("Unknown command!");
 }
+
+bool cmServerProtocol1_0::IsExperimental() const
+{
+  return true;
+}
diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h
index 33183e9..e95c2f1 100644
--- a/Source/cmServerProtocol.h
+++ b/Source/cmServerProtocol.h
@@ -82,6 +82,7 @@ public:
   virtual ~cmServerProtocol() {}
 
   virtual std::pair<int, int> ProtocolVersion() const = 0;
+  virtual bool IsExperimental() const = 0;
   virtual const cmServerResponse Process(const cmServerRequest& request) = 0;
 
   bool Activate(const cmServerRequest& request, std::string* errorMessage);
@@ -100,6 +101,7 @@ class cmServerProtocol1_0 : public cmServerProtocol
 {
 public:
   std::pair<int, int> ProtocolVersion() const override;
+  bool IsExperimental() const override;
   const cmServerResponse Process(const cmServerRequest& request) override;
 
 private:
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index c09ea8b..7b26000 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -913,14 +913,30 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
       }
       return 0;
     } else if (args[1] == "server") {
-      if (args.size() > 2) {
+      if (args.size() > 3) {
         cmSystemTools::Error("Too many arguments to start server mode");
         return 1;
       }
+      bool supportExperimental = false;
+      if (args.size() == 3) {
+        if (args[2] == "--experimental") {
+          supportExperimental = true;
+        } else {
+          cmSystemTools::Error("Unknown argument for server mode");
+          return 1;
+        }
+      }
 #if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
-      cmServer server;
-      server.Serve();
-      return 0;
+      cmServer server(supportExperimental);
+      if (server.Serve()) {
+        return 0;
+      } else {
+        cmSystemTools::Error(
+          "CMake server could not find any supported protocol. "
+          "Try with \"--experimental\" to enable "
+          "experimental support.");
+        return 1;
+      }
 #else
       cmSystemTools::Error("CMake was not built with server mode enabled");
       return 1;
diff --git a/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt b/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt
index 7877c01..4dcbab9 100644
--- a/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt
+++ b/Tests/RunCMake/CommandLine/E_server-arg-stderr.txt
@@ -1 +1 @@
-^CMake Error: Too many arguments to start server mode$
+^CMake Error: Unknown argument for server mode$
diff --git a/Tests/Server/cmakelib.py b/Tests/Server/cmakelib.py
index 48ebc89..e89b1f0 100644
--- a/Tests/Server/cmakelib.py
+++ b/Tests/Server/cmakelib.py
@@ -79,7 +79,7 @@ def writePayload(cmakeCommand, obj):
   writeRawData(cmakeCommand, json.dumps(obj))
 
 def initProc(cmakeCommand):
-  cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server"],
+  cmakeCommand = subprocess.Popen([cmakeCommand, "-E", "server", "--experimental"],
                                   stdin=subprocess.PIPE,
                                   stdout=subprocess.PIPE)
 

-----------------------------------------------------------------------

Summary of changes:
 Source/cmServer.cxx                                |   19 ++++++++++++----
 Source/cmServer.h                                  |    6 +++--
 Source/cmServerProtocol.cxx                        |    5 ++++
 Source/cmServerProtocol.h                          |    2 ++
 Source/cmcmd.cxx                                   |   24 ++++++++++++++++----
 Tests/RunCMake/CommandLine/E_server-arg-stderr.txt |    2 +-
 Tests/Server/cmakelib.py                           |    2 +-
 7 files changed, 48 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
CMake


More information about the Cmake-commits mailing list