server-mode: Set global configuration of cmake via a command
"setGlobalSettings" can be used to change settings reported by "globalSettings" command.
This commit is contained in:
parent
82104cc7a8
commit
544f65f44d
|
@ -302,3 +302,29 @@ which will result in a response type "reply"::
|
||||||
"warnUnusedCli": true
|
"warnUnusedCli": true
|
||||||
}
|
}
|
||||||
]== CMake Server ==]
|
]== CMake Server ==]
|
||||||
|
|
||||||
|
|
||||||
|
Type "setGlobalSettings"
|
||||||
|
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
|
This request can be sent to change the global settings attributes. Unknown
|
||||||
|
attributes are going to be ignored. Read-only attributes reported by
|
||||||
|
"globalSettings" are all capabilities, buildDirectory, generator,
|
||||||
|
extraGenerator and sourceDirectory. Any attempt to set these will be ignored,
|
||||||
|
too.
|
||||||
|
|
||||||
|
All other settings will be changed.
|
||||||
|
|
||||||
|
The server will respond with an empty reply message or an error.
|
||||||
|
|
||||||
|
Example::
|
||||||
|
|
||||||
|
[== CMake Server ==[
|
||||||
|
{"type":"setGlobalSettings","debugOutput":true}
|
||||||
|
]== CMake Server ==]
|
||||||
|
|
||||||
|
CMake will reply to this with::
|
||||||
|
|
||||||
|
[== CMake Server ==[
|
||||||
|
{"inReplyTo":"setGlobalSettings","type":"reply"}
|
||||||
|
]== CMake Server ==]
|
||||||
|
|
|
@ -22,6 +22,7 @@ static const std::string kHANDSHAKE_TYPE = "handshake";
|
||||||
static const std::string kMESSAGE_TYPE = "message";
|
static const std::string kMESSAGE_TYPE = "message";
|
||||||
static const std::string kPROGRESS_TYPE = "progress";
|
static const std::string kPROGRESS_TYPE = "progress";
|
||||||
static const std::string kREPLY_TYPE = "reply";
|
static const std::string kREPLY_TYPE = "reply";
|
||||||
|
static const std::string kSET_GLOBAL_SETTINGS_TYPE = "setGlobalSettings";
|
||||||
static const std::string kSIGNAL_TYPE = "signal";
|
static const std::string kSIGNAL_TYPE = "signal";
|
||||||
|
|
||||||
static const std::string kBUILD_DIRECTORY_KEY = "buildDirectory";
|
static const std::string kBUILD_DIRECTORY_KEY = "buildDirectory";
|
||||||
|
|
|
@ -283,6 +283,9 @@ const cmServerResponse cmServerProtocol1_0::Process(
|
||||||
if (request.Type == kGLOBAL_SETTINGS_TYPE) {
|
if (request.Type == kGLOBAL_SETTINGS_TYPE) {
|
||||||
return this->ProcessGlobalSettings(request);
|
return this->ProcessGlobalSettings(request);
|
||||||
}
|
}
|
||||||
|
if (request.Type == kSET_GLOBAL_SETTINGS_TYPE) {
|
||||||
|
return this->ProcessSetGlobalSettings(request);
|
||||||
|
}
|
||||||
|
|
||||||
return request.ReportError("Unknown command!");
|
return request.ReportError("Unknown command!");
|
||||||
}
|
}
|
||||||
|
@ -320,3 +323,44 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings(
|
||||||
|
|
||||||
return request.Reply(obj);
|
return request.Reply(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void setBool(const cmServerRequest& request, const std::string& key,
|
||||||
|
std::function<void(bool)> setter)
|
||||||
|
{
|
||||||
|
if (request.Data[key].isNull()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
setter(request.Data[key].asBool());
|
||||||
|
}
|
||||||
|
|
||||||
|
cmServerResponse cmServerProtocol1_0::ProcessSetGlobalSettings(
|
||||||
|
const cmServerRequest& request)
|
||||||
|
{
|
||||||
|
const std::vector<std::string> boolValues = {
|
||||||
|
kDEBUG_OUTPUT_KEY, kTRACE_KEY, kTRACE_EXPAND_KEY,
|
||||||
|
kWARN_UNINITIALIZED_KEY, kWARN_UNUSED_KEY, kWARN_UNUSED_CLI_KEY,
|
||||||
|
kCHECK_SYSTEM_VARS_KEY
|
||||||
|
};
|
||||||
|
for (auto i : boolValues) {
|
||||||
|
if (!request.Data[i].isNull() && !request.Data[i].isBool()) {
|
||||||
|
return request.ReportError("\"" + i +
|
||||||
|
"\" must be unset or a bool value.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
cmake* cm = this->CMakeInstance();
|
||||||
|
|
||||||
|
setBool(request, kDEBUG_OUTPUT_KEY,
|
||||||
|
[cm](bool e) { cm->SetDebugOutputOn(e); });
|
||||||
|
setBool(request, kTRACE_KEY, [cm](bool e) { cm->SetTrace(e); });
|
||||||
|
setBool(request, kTRACE_EXPAND_KEY, [cm](bool e) { cm->SetTraceExpand(e); });
|
||||||
|
setBool(request, kWARN_UNINITIALIZED_KEY,
|
||||||
|
[cm](bool e) { cm->SetWarnUninitialized(e); });
|
||||||
|
setBool(request, kWARN_UNUSED_KEY, [cm](bool e) { cm->SetWarnUnused(e); });
|
||||||
|
setBool(request, kWARN_UNUSED_CLI_KEY,
|
||||||
|
[cm](bool e) { cm->SetWarnUnusedCli(e); });
|
||||||
|
setBool(request, kCHECK_SYSTEM_VARS_KEY,
|
||||||
|
[cm](bool e) { cm->SetCheckSystemVars(e); });
|
||||||
|
|
||||||
|
return request.Reply(Json::Value());
|
||||||
|
}
|
||||||
|
|
|
@ -119,6 +119,7 @@ private:
|
||||||
|
|
||||||
// Handle requests:
|
// Handle requests:
|
||||||
cmServerResponse ProcessGlobalSettings(const cmServerRequest& request);
|
cmServerResponse ProcessGlobalSettings(const cmServerRequest& request);
|
||||||
|
cmServerResponse ProcessSetGlobalSettings(const cmServerRequest& request);
|
||||||
|
|
||||||
enum State
|
enum State
|
||||||
{
|
{
|
||||||
|
|
|
@ -154,12 +154,16 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
|
||||||
for line in cmakeoutput[index + 12:].splitlines():
|
for line in cmakeoutput[index + 12:].splitlines():
|
||||||
if not line.startswith(' '):
|
if not line.startswith(' '):
|
||||||
continue
|
continue
|
||||||
|
if line.startswith(' '):
|
||||||
|
continue
|
||||||
equalPos = line.find('=')
|
equalPos = line.find('=')
|
||||||
tmp = ''
|
tmp = ''
|
||||||
if (equalPos > 0):
|
if (equalPos > 0):
|
||||||
tmp = line[2:equalPos].strip()
|
tmp = line[2:equalPos].strip()
|
||||||
else:
|
else:
|
||||||
tmp = line.strip()
|
tmp = line.strip()
|
||||||
|
if tmp.endswith(" [arch]"):
|
||||||
|
tmp = tmp[0:len(tmp) - 7]
|
||||||
if (len(tmp) > 0) and (" - " not in tmp) and (tmp != 'KDevelop3'):
|
if (len(tmp) > 0) and (" - " not in tmp) and (tmp != 'KDevelop3'):
|
||||||
cmakeGenerators.append(tmp)
|
cmakeGenerators.append(tmp)
|
||||||
|
|
||||||
|
@ -170,7 +174,8 @@ def validateGlobalSettings(cmakeCommand, cmakeCommandPath, data):
|
||||||
generators.sort()
|
generators.sort()
|
||||||
cmakeGenerators.sort()
|
cmakeGenerators.sort()
|
||||||
|
|
||||||
if (generators != cmakeGenerators):
|
for gen in cmakeGenerators:
|
||||||
|
if (not gen in generators):
|
||||||
sys.exit(1)
|
sys.exit(1)
|
||||||
|
|
||||||
gen = packet['generator']
|
gen = packet['generator']
|
||||||
|
|
|
@ -3,8 +3,138 @@
|
||||||
|
|
||||||
{ "handshake": {"major": 1} },
|
{ "handshake": {"major": 1} },
|
||||||
|
|
||||||
{ "send": {"type": "globalSettings"} },
|
{ "send": { "type": "globalSettings"} },
|
||||||
{ "validateGlobalSettings": { } },
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ "message": "Change settings:" },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "debugOutput": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": true, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "debugOutput": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUninitialized": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": true, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUninitialized": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "traceExpand": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": true, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "traceExpand": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "trace": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": true, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "trace": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnusedCli": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": false, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnusedCli": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "checkSystemVars": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": true } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "checkSystemVars": false } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": false, "debugOutput": false, "warnUninitialized": false, "traceExpand": false, "trace": false, "warnUnusedCli": true, "checkSystemVars": false } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } },
|
||||||
|
|
||||||
|
{ "message": "Ignore unknown/readonly" },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "unknownKey": "unknownValue", "extraGenerator": "XXX", "generator": "YYY", "sourceDirectory": "/tmp/source", "buildDirectory": "/tmp/build" } },
|
||||||
|
{ "reply": { "type": "setGlobalSettings" } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } },
|
||||||
|
|
||||||
|
{ "message": "Error paths:" },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "debugOutput": true, "warnUnused": 1 } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"warnUnused\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": 1 } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"debugOutput\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUninitialized": 1, "warnUnused": true, "debugOutput": true } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"warnUninitialized\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "traceExpand": 1 } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"traceExpand\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "debugOutput": true, "trace": 1, "warnUnused": true } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"trace\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "warnUnusedCli": 1.0 } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"warnUnusedCli\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "setGlobalSettings", "warnUnused": true, "debugOutput": true, "checkSystemVars": "some string" } },
|
||||||
|
{ "error": { "type": "setGlobalSettings", "message": "\"checkSystemVars\" must be unset or a bool value." } },
|
||||||
|
|
||||||
|
{ "send": { "type": "globalSettings"} },
|
||||||
|
{ "validateGlobalSettings": { "warnUnused": true, "debugOutput": true, "warnUninitialized": true, "traceExpand": true, "trace": true, "warnUnusedCli": false, "checkSystemVars": true } },
|
||||||
|
|
||||||
{ "message": "Everything ok." }
|
{ "message": "Everything ok." }
|
||||||
]
|
]
|
||||||
|
|
Loading…
Reference in New Issue