summaryrefslogtreecommitdiff
path: root/Source/cmcmd.cxx
diff options
context:
space:
mode:
authorTobias Hunger <tobias.hunger@qt.io>2016-09-13 11:26:34 +0200
committerBrad King <brad.king@kitware.com>2016-09-19 08:57:57 -0400
commitb13d3e0d0b3c644242ef8dc4977d35da73398a9d (patch)
tree76312d0c8123d1053d4f98cd3c81edf7f860198d /Source/cmcmd.cxx
parentcd049f012ef22f8f1214b35e351fda823d534b92 (diff)
downloadcmake-b13d3e0d0b3c644242ef8dc4977d35da73398a9d.tar.gz
cmake-server: Bare-bones server implementation
Adds a bare-bones cmake-server implementation and makes it possible to start that with "cmake -E server". Communication happens via stdin/stdout for now. Protocol is based on Json objects surrounded by magic strings ("[== CMake Server ==[" and "]== CMake Server ==]"), which simplifies Json parsing significantly. This patch also defines an interface used to implement different versions of the protocol spoken by the server, but does not include any protocol implementaiton.
Diffstat (limited to 'Source/cmcmd.cxx')
-rw-r--r--Source/cmcmd.cxx18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/cmcmd.cxx b/Source/cmcmd.cxx
index 3b385ab2ed..c09ea8bb9b 100644
--- a/Source/cmcmd.cxx
+++ b/Source/cmcmd.cxx
@@ -23,6 +23,10 @@
#include "cm_auto_ptr.hxx"
#include "cmake.h"
+#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
+#include "cmServer.h"
+#endif
+
#if defined(CMAKE_BUILD_WITH_CMAKE)
#include "cmDependsFortran.h" // For -E cmake_copy_f90_mod callback.
#endif
@@ -91,6 +95,7 @@ void CMakeCommandUsage(const char* program)
<< " remove_directory dir - remove a directory and its contents\n"
<< " rename oldname newname - rename a file or directory "
"(on one volume)\n"
+ << " server - start cmake in server mode\n"
<< " sleep <number>... - sleep for given number of seconds\n"
<< " tar [cxt][vf][zjJ] file.tar [file/dir1 file/dir2 ...]\n"
<< " - create or extract a tar or zip archive\n"
@@ -907,6 +912,19 @@ int cmcmd::ExecuteCMakeCommand(std::vector<std::string>& args)
#endif
}
return 0;
+ } else if (args[1] == "server") {
+ if (args.size() > 2) {
+ cmSystemTools::Error("Too many arguments to start server mode");
+ return 1;
+ }
+#if defined(HAVE_SERVER_MODE) && HAVE_SERVER_MODE
+ cmServer server;
+ server.Serve();
+ return 0;
+#else
+ cmSystemTools::Error("CMake was not built with server mode enabled");
+ return 1;
+#endif
}
#if defined(CMAKE_BUILD_WITH_CMAKE)