From 890432672bc9fe91365e5e5305285ab193e9060a Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Fri, 9 Sep 2016 10:01:45 +0200 Subject: server-mode: Add command to compute the build system --- Help/manual/cmake-server.7.rst | 19 +++++++++++++++++++ Source/cmServerDictionary.h | 1 + Source/cmServerProtocol.cxx | 23 +++++++++++++++++++++++ Source/cmServerProtocol.h | 4 +++- 4 files changed, 46 insertions(+), 1 deletion(-) diff --git a/Help/manual/cmake-server.7.rst b/Help/manual/cmake-server.7.rst index c5d4968..b8a425c 100644 --- a/Help/manual/cmake-server.7.rst +++ b/Help/manual/cmake-server.7.rst @@ -355,3 +355,22 @@ CMake will reply like this (after reporting progress for some time):: [== CMake Server ==[ {"cookie":"","inReplyTo":"configure","type":"reply"} ]== CMake Server ==] + + +Type "compute" +^^^^^^^^^^^^^^ + +This requist will generate build system files in the build directory and +is only available after a project was successfully "configure"d. + +Example:: + + [== CMake Server ==[ + {"type":"compute"} + ]== CMake Server ==] + +CMake will reply (after reporting progress information):: + + [== CMake Server ==[ + {"cookie":"","inReplyTo":"compute","type":"reply"} + ]== CMake Server ==] diff --git a/Source/cmServerDictionary.h b/Source/cmServerDictionary.h index b78a1f4..fc1b44d 100644 --- a/Source/cmServerDictionary.h +++ b/Source/cmServerDictionary.h @@ -16,6 +16,7 @@ // Vocabulary: +static const std::string kCOMPUTE_TYPE = "compute"; static const std::string kCONFIGURE_TYPE = "configure"; static const std::string kERROR_TYPE = "error"; static const std::string kGLOBAL_SETTINGS_TYPE = "globalSettings"; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 06f5177..134edf3 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -280,6 +280,9 @@ const cmServerResponse cmServerProtocol1_0::Process( { assert(this->m_State >= STATE_ACTIVE); + if (request.Type == kCOMPUTE_TYPE) { + return this->ProcessCompute(request); + } if (request.Type == kCONFIGURE_TYPE) { return this->ProcessConfigure(request); } @@ -298,6 +301,26 @@ bool cmServerProtocol1_0::IsExperimental() const return true; } +cmServerResponse cmServerProtocol1_0::ProcessCompute( + const cmServerRequest& request) +{ + if (this->m_State > STATE_CONFIGURED) { + return request.ReportError("This build system was already generated."); + } + if (this->m_State < STATE_CONFIGURED) { + return request.ReportError("This project was not configured yet."); + } + + cmake* cm = this->CMakeInstance(); + int ret = cm->Generate(); + + if (ret < 0) { + return request.ReportError("Failed to compute build system."); + } + m_State = STATE_COMPUTED; + return request.Reply(Json::Value()); +} + cmServerResponse cmServerProtocol1_0::ProcessConfigure( const cmServerRequest& request) { diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h index c0148a4..e772eca 100644 --- a/Source/cmServerProtocol.h +++ b/Source/cmServerProtocol.h @@ -118,6 +118,7 @@ private: std::string* errorMessage) override; // Handle requests: + cmServerResponse ProcessCompute(const cmServerRequest& request); cmServerResponse ProcessConfigure(const cmServerRequest& request); cmServerResponse ProcessGlobalSettings(const cmServerRequest& request); cmServerResponse ProcessSetGlobalSettings(const cmServerRequest& request); @@ -126,7 +127,8 @@ private: { STATE_INACTIVE, STATE_ACTIVE, - STATE_CONFIGURED + STATE_CONFIGURED, + STATE_COMPUTED }; State m_State = STATE_INACTIVE; }; -- cgit v0.12