Merge branch 'cmake-server-message-quoting' into release

This commit is contained in:
Brad King 2016-10-24 14:36:50 -04:00
commit 4ec0329bf1
3 changed files with 61 additions and 61 deletions

View File

@ -57,17 +57,17 @@ or using a named pipe (with the ``--pipe <NAMED_PIPE>`` parameter).
When connecting to the server (via named pipe or by starting it in ``--debug`` When connecting to the server (via named pipe or by starting it in ``--debug``
mode), the server will reply with a hello message:: mode), the server will reply with a hello message::
[== CMake Server ==[ [== "CMake Server" ==[
{"supportedProtocolVersions":[{"major":1,"minor":0}],"type":"hello"} {"supportedProtocolVersions":[{"major":1,"minor":0}],"type":"hello"}
]== CMake Server ==] ]== "CMake Server" ==]
Messages sent to and from the process are wrapped in magic strings:: Messages sent to and from the process are wrapped in magic strings::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
... some JSON message ... ... some JSON message ...
} }
]== CMake Server ==] ]== "CMake Server" ==]
The server is now ready to accept further requests via the named pipe The server is now ready to accept further requests via the named pipe
or stdin. or stdin.
@ -87,7 +87,7 @@ the response into the given filename.
This is a response from the cmake server with "showStats" set to true:: This is a response from the cmake server with "showStats" set to true::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
"cookie":"", "cookie":"",
"errorMessage":"Waiting for type \"handshake\".", "errorMessage":"Waiting for type \"handshake\".",
@ -100,7 +100,7 @@ This is a response from the cmake server with "showStats" set to true::
"totalTime":0.025995 "totalTime":0.025995
} }
} }
]== CMake Server ==] ]== "CMake Server" ==]
The server has made a copy of this response into the file /tmp/error.txt and The server has made a copy of this response into the file /tmp/error.txt and
took 0.011 seconds to turn the JSON response into a string, and it took 0.025 took 0.011 seconds to turn the JSON response into a string, and it took 0.025
@ -137,9 +137,9 @@ contain values.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"zimtstern","inReplyTo":"handshake","type":"reply"} {"cookie":"zimtstern","inReplyTo":"handshake","type":"reply"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "error" Type "error"
@ -150,9 +150,9 @@ contain an "errorMessage".
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"","errorMessage":"Protocol version not supported.","inReplyTo":"handshake","type":"error"} {"cookie":"","errorMessage":"Protocol version not supported.","inReplyTo":"handshake","type":"error"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "progress" Type "progress"
@ -181,9 +181,9 @@ box title.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"","message":"Something happened.","title":"Title Text","inReplyTo":"handshake","type":"message"} {"cookie":"","message":"Something happened.","title":"Title Text","inReplyTo":"handshake","type":"message"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "signal" Type "signal"
@ -208,13 +208,13 @@ an influence on the build system is changed.
The "dirty" signal may look like this:: The "dirty" signal may look like this::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
"cookie":"", "cookie":"",
"inReplyTo":"", "inReplyTo":"",
"name":"dirty", "name":"dirty",
"type":"signal"} "type":"signal"}
]== CMake Server ==] ]== "CMake Server" ==]
"fileChange" Signal "fileChange" Signal
@ -226,7 +226,7 @@ that was detected. Possible changes are "change" and "rename".
The "fileChange" signal looks like this:: The "fileChange" signal looks like this::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
"cookie":"", "cookie":"",
"inReplyTo":"", "inReplyTo":"",
@ -234,7 +234,7 @@ The "fileChange" signal looks like this::
"path":"/absolute/CMakeLists.txt", "path":"/absolute/CMakeLists.txt",
"properties":["change"], "properties":["change"],
"type":"signal"} "type":"signal"}
]== CMake Server ==] ]== "CMake Server" ==]
Specific Message Types Specific Message Types
@ -256,9 +256,9 @@ these requires a special command line argument when starting the cmake server mo
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"supportedProtocolVersions":[{"major":0,"minor":1}],"type":"hello"} {"supportedProtocolVersions":[{"major":0,"minor":1}],"type":"hello"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "handshake" Type "handshake"
@ -280,17 +280,17 @@ Protocol version 1.0 requires the following attributes to be set:
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"zimtstern","type":"handshake","protocolVersion":{"major":0}, {"cookie":"zimtstern","type":"handshake","protocolVersion":{"major":0},
"sourceDirectory":"/home/code/cmake", "buildDirectory":"/tmp/testbuild", "sourceDirectory":"/home/code/cmake", "buildDirectory":"/tmp/testbuild",
"generator":"Ninja"} "generator":"Ninja"}
]== CMake Server ==] ]== "CMake Server" ==]
which will result in a response type "reply":: which will result in a response type "reply"::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"zimtstern","inReplyTo":"handshake","type":"reply"} {"cookie":"zimtstern","inReplyTo":"handshake","type":"reply"}
]== CMake Server ==] ]== "CMake Server" ==]
indicating that the server is ready for action. indicating that the server is ready for action.
@ -303,13 +303,13 @@ JSON structure with information on cmake state.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"globalSettings"} {"type":"globalSettings"}
]== CMake Server ==] ]== "CMake Server" ==]
which will result in a response type "reply":: which will result in a response type "reply"::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
"buildDirectory": "/tmp/test-build", "buildDirectory": "/tmp/test-build",
"capabilities": { "capabilities": {
@ -346,7 +346,7 @@ which will result in a response type "reply"::
"warnUnused": false, "warnUnused": false,
"warnUnusedCli": true "warnUnusedCli": true
} }
]== CMake Server ==] ]== "CMake Server" ==]
Type "setGlobalSettings" Type "setGlobalSettings"
@ -364,15 +364,15 @@ The server will respond with an empty reply message or an error.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"setGlobalSettings","debugOutput":true} {"type":"setGlobalSettings","debugOutput":true}
]== CMake Server ==] ]== "CMake Server" ==]
CMake will reply to this with:: CMake will reply to this with::
[== CMake Server ==[ [== "CMake Server" ==[
{"inReplyTo":"setGlobalSettings","type":"reply"} {"inReplyTo":"setGlobalSettings","type":"reply"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "configure" Type "configure"
@ -391,15 +391,15 @@ cache handling that are passed to the cmake command line client.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"configure", "cacheArguments":["-Dsomething=else"]} {"type":"configure", "cacheArguments":["-Dsomething=else"]}
]== CMake Server ==] ]== "CMake Server" ==]
CMake will reply like this (after reporting progress for some time):: CMake will reply like this (after reporting progress for some time)::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"","inReplyTo":"configure","type":"reply"} {"cookie":"","inReplyTo":"configure","type":"reply"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "compute" Type "compute"
@ -410,15 +410,15 @@ is only available after a project was successfully "configure"d.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"compute"} {"type":"compute"}
]== CMake Server ==] ]== "CMake Server" ==]
CMake will reply (after reporting progress information):: CMake will reply (after reporting progress information)::
[== CMake Server ==[ [== "CMake Server" ==[
{"cookie":"","inReplyTo":"compute","type":"reply"} {"cookie":"","inReplyTo":"compute","type":"reply"}
]== CMake Server ==] ]== "CMake Server" ==]
Type "codemodel" Type "codemodel"
@ -521,13 +521,13 @@ sourceDirectory of the target.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"codemodel"} {"type":"codemodel"}
]== CMake Server ==] ]== "CMake Server" ==]
CMake will reply:: CMake will reply::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
"configurations": [ "configurations": [
{ {
@ -567,7 +567,7 @@ CMake will reply::
"inReplyTo": "codemodel", "inReplyTo": "codemodel",
"type": "reply" "type": "reply"
} }
]== CMake Server ==] ]== "CMake Server" ==]
Type "cmakeInputs" Type "cmakeInputs"
@ -581,13 +581,13 @@ This request is only available after a project was successfully
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"cmakeInputs"} {"type":"cmakeInputs"}
]== CMake Server ==] ]== "CMake Server" ==]
CMake will reply with the following information:: CMake will reply with the following information::
[== CMake Server ==[ [== "CMake Server" ==[
{"buildFiles": {"buildFiles":
[ [
{"isCMake":true,"isTemporary":false,"sources":["/usr/lib/cmake/...", ... ]}, {"isCMake":true,"isTemporary":false,"sources":["/usr/lib/cmake/...", ... ]},
@ -600,7 +600,7 @@ CMake will reply with the following information::
"inReplyTo":"cmakeInputs", "inReplyTo":"cmakeInputs",
"type":"reply" "type":"reply"
} }
]== CMake Server ==] ]== "CMake Server" ==]
All file names are either relative to the top level source directory or All file names are either relative to the top level source directory or
absolute. absolute.
@ -619,13 +619,13 @@ list the cached configuration values.
Example:: Example::
[== CMake Server ==[ [== "CMake Server" ==[
{"type":"cache"} {"type":"cache"}
]== CMake Server ==] ]== "CMake Server" ==]
CMake will respond with the following output:: CMake will respond with the following output::
[== CMake Server ==[ [== "CMake Server" ==[
{ {
"cookie":"","inReplyTo":"cache","type":"reply", "cookie":"","inReplyTo":"cache","type":"reply",
"cache": "cache":
@ -641,7 +641,7 @@ CMake will respond with the following output::
"value":"TEST"} "value":"TEST"}
] ]
} }
]== CMake Server ==] ]== "CMake Server" ==]
The output can be limited to a list of keys by passing an array of key names The output can be limited to a list of keys by passing an array of key names
to the "keys" optional field of the "cache" request. to the "keys" optional field of the "cache" request.
@ -655,16 +655,16 @@ command will report on the files and directories watched.
Example:: Example::
[== CMake Server ==] [== "CMake Server" ==[
{"type":"fileSystemWatchers"} {"type":"fileSystemWatchers"}
[== CMake Server ==] ]== "CMake Server" ==]
CMake will respond with the following output:: CMake will respond with the following output::
[== CMake Server ==] [== "CMake Server" ==[
{ {
"cookie":"","inReplyTo":"fileSystemWatchers","type":"reply", "cookie":"","inReplyTo":"fileSystemWatchers","type":"reply",
"watchedFiles": [ "/absolute/path" ], "watchedFiles": [ "/absolute/path" ],
"watchedDirectories": [ "/absolute" ] "watchedDirectories": [ "/absolute" ]
} }
[== CMake Server ==] ]== "CMake Server" ==]

View File

@ -87,8 +87,8 @@ static const std::string kWARN_UNUSED_KEY = "warnUnused";
static const std::string kWATCHED_DIRECTORIES_KEY = "watchedDirectories"; static const std::string kWATCHED_DIRECTORIES_KEY = "watchedDirectories";
static const std::string kWATCHED_FILES_KEY = "watchedFiles"; static const std::string kWATCHED_FILES_KEY = "watchedFiles";
static const std::string kSTART_MAGIC = "[== CMake Server ==["; static const std::string kSTART_MAGIC = "[== \"CMake Server\" ==[";
static const std::string kEND_MAGIC = "]== CMake Server ==]"; static const std::string kEND_MAGIC = "]== \"CMake Server\" ==]";
static const std::string kRENAME_PROPERTY_VALUE = "rename"; static const std::string kRENAME_PROPERTY_VALUE = "rename";
static const std::string kCHANGE_PROPERTY_VALUE = "change"; static const std::string kCHANGE_PROPERTY_VALUE = "change";

View File

@ -46,11 +46,11 @@ def waitForRawMessage(cmakeCommand):
stdoutdata += stdoutdataLine.decode('utf-8') stdoutdata += stdoutdataLine.decode('utf-8')
else: else:
break break
begin = stdoutdata.find("[== CMake Server ==[\n") begin = stdoutdata.find('[== "CMake Server" ==[\n')
end = stdoutdata.find("]== CMake Server ==]") end = stdoutdata.find(']== "CMake Server" ==]')
if (begin != -1 and end != -1): if (begin != -1 and end != -1):
begin += len("[== CMake Server ==[\n") begin += len('[== "CMake Server" ==[\n')
payload = stdoutdata[begin:end] payload = stdoutdata[begin:end]
if print_communication: if print_communication:
print("\nSERVER>", json.loads(payload), "\n") print("\nSERVER>", json.loads(payload), "\n")
@ -59,9 +59,9 @@ def waitForRawMessage(cmakeCommand):
def writeRawData(cmakeCommand, content): def writeRawData(cmakeCommand, content):
writeRawData.counter += 1 writeRawData.counter += 1
payload = """ payload = """
[== CMake Server ==[ [== "CMake Server" ==[
%s %s
]== CMake Server ==] ]== "CMake Server" ==]
""" % content """ % content
rn = ( writeRawData.counter % 2 ) == 0 rn = ( writeRawData.counter % 2 ) == 0