mirror of
https://github.com/Kitware/CMake.git
synced 2026-05-04 13:19:51 -05:00
server-mode: Query global configuration of cmake via a command
Add "globalSettings" command that returns: * Return capability information * Return currently used generator/extra generator * Return a range of flags for debug/trace/etc.
This commit is contained in:
@@ -17,6 +17,7 @@
|
||||
// Vocabulary:
|
||||
|
||||
static const std::string kERROR_TYPE = "error";
|
||||
static const std::string kGLOBAL_SETTINGS_TYPE = "globalSettings";
|
||||
static const std::string kHANDSHAKE_TYPE = "handshake";
|
||||
static const std::string kMESSAGE_TYPE = "message";
|
||||
static const std::string kPROGRESS_TYPE = "progress";
|
||||
@@ -24,7 +25,10 @@ static const std::string kREPLY_TYPE = "reply";
|
||||
static const std::string kSIGNAL_TYPE = "signal";
|
||||
|
||||
static const std::string kBUILD_DIRECTORY_KEY = "buildDirectory";
|
||||
static const std::string kCAPABILITIES_KEY = "capabilities";
|
||||
static const std::string kCHECK_SYSTEM_VARS_KEY = "checkSystemVars";
|
||||
static const std::string kCOOKIE_KEY = "cookie";
|
||||
static const std::string kDEBUG_OUTPUT_KEY = "debugOutput";
|
||||
static const std::string kERROR_MESSAGE_KEY = "errorMessage";
|
||||
static const std::string kEXTRA_GENERATOR_KEY = "extraGenerator";
|
||||
static const std::string kGENERATOR_KEY = "generator";
|
||||
@@ -43,7 +47,12 @@ static const std::string kSOURCE_DIRECTORY_KEY = "sourceDirectory";
|
||||
static const std::string kSUPPORTED_PROTOCOL_VERSIONS =
|
||||
"supportedProtocolVersions";
|
||||
static const std::string kTITLE_KEY = "title";
|
||||
static const std::string kTRACE_EXPAND_KEY = "traceExpand";
|
||||
static const std::string kTRACE_KEY = "trace";
|
||||
static const std::string kTYPE_KEY = "type";
|
||||
static const std::string kWARN_UNINITIALIZED_KEY = "warnUninitialized";
|
||||
static const std::string kWARN_UNUSED_CLI_KEY = "warnUnusedCli";
|
||||
static const std::string kWARN_UNUSED_KEY = "warnUnused";
|
||||
|
||||
static const std::string kSTART_MAGIC = "[== CMake Server ==[";
|
||||
static const std::string kEND_MAGIC = "]== CMake Server ==]";
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include "cmServerProtocol.h"
|
||||
|
||||
#include "cmExternalMakefileProjectGenerator.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmServer.h"
|
||||
#include "cmServerDictionary.h"
|
||||
#include "cmSystemTools.h"
|
||||
@@ -279,6 +280,10 @@ const cmServerResponse cmServerProtocol1_0::Process(
|
||||
{
|
||||
assert(this->m_State >= STATE_ACTIVE);
|
||||
|
||||
if (request.Type == kGLOBAL_SETTINGS_TYPE) {
|
||||
return this->ProcessGlobalSettings(request);
|
||||
}
|
||||
|
||||
return request.ReportError("Unknown command!");
|
||||
}
|
||||
|
||||
@@ -286,3 +291,32 @@ bool cmServerProtocol1_0::IsExperimental() const
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings(
|
||||
const cmServerRequest& request)
|
||||
{
|
||||
cmake* cm = this->CMakeInstance();
|
||||
Json::Value obj = Json::objectValue;
|
||||
|
||||
// Capabilities information:
|
||||
obj[kCAPABILITIES_KEY] = cm->ReportCapabilitiesJson(true);
|
||||
|
||||
obj[kDEBUG_OUTPUT_KEY] = cm->GetDebugOutput();
|
||||
obj[kTRACE_KEY] = cm->GetTrace();
|
||||
obj[kTRACE_EXPAND_KEY] = cm->GetTraceExpand();
|
||||
obj[kWARN_UNINITIALIZED_KEY] = cm->GetWarnUninitialized();
|
||||
obj[kWARN_UNUSED_KEY] = cm->GetWarnUnused();
|
||||
obj[kWARN_UNUSED_CLI_KEY] = cm->GetWarnUnusedCli();
|
||||
obj[kCHECK_SYSTEM_VARS_KEY] = cm->GetCheckSystemVars();
|
||||
|
||||
obj[kSOURCE_DIRECTORY_KEY] = cm->GetHomeDirectory();
|
||||
obj[kBUILD_DIRECTORY_KEY] = cm->GetHomeOutputDirectory();
|
||||
|
||||
// Currently used generator:
|
||||
cmGlobalGenerator* gen = cm->GetGlobalGenerator();
|
||||
obj[kGENERATOR_KEY] = gen ? gen->GetName() : std::string();
|
||||
obj[kEXTRA_GENERATOR_KEY] =
|
||||
gen ? gen->GetExtraGeneratorName() : std::string();
|
||||
|
||||
return request.Reply(obj);
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#pragma once
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmake.h"
|
||||
|
||||
#if defined(CMAKE_BUILD_WITH_CMAKE)
|
||||
#include "cm_jsoncpp_writer.h"
|
||||
@@ -116,6 +117,9 @@ private:
|
||||
bool DoActivate(const cmServerRequest& request,
|
||||
std::string* errorMessage) override;
|
||||
|
||||
// Handle requests:
|
||||
cmServerResponse ProcessGlobalSettings(const cmServerRequest& request);
|
||||
|
||||
enum State
|
||||
{
|
||||
STATE_INACTIVE,
|
||||
|
||||
Reference in New Issue
Block a user