server-mode: Add command to compute the build system

This commit is contained in:
Tobias Hunger 2016-09-09 10:01:45 +02:00 committed by Brad King
parent 0a8ad6700e
commit 890432672b
4 changed files with 46 additions and 1 deletions

View File

@ -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 ==]

View File

@ -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";

View File

@ -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)
{

View File

@ -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;
};