def open(self, sourceDirectory, buildDirectory, generatorName, extraGeneratorName="", extraEnv={}): self.sourceDirectory = sourceDirectory self.buildDirectory = buildDirectory self.proc = cmakelib.initServerProc(self.cmakeExecutable, cmakelib.communicationMethods[0], extraEnv) if self.proc is None: raise Exception("Failed starting cmake server") packet = cmakelib.waitForRawMessage(self.proc) if packet == None: raise Exception( "Unknown failure, maybe cmake does not support server mode") if packet['type'] != 'hello': raise Exception("No hello message received from server") self.protocolVersion = [ packet["supportedProtocolVersions"][0]["major"], packet["supportedProtocolVersions"][0]["minor"] ] self.logger.debug("Server Protocol version: %s", self.protocolVersion) sourceDirectory = sourceDirectory.replace('\\', '/') buildDirectory = buildDirectory.replace('\\', '/') cmakelib.writePayload( self.proc, { 'type': 'handshake', 'protocolVersion': { 'major': self.protocolVersion[0], 'minor': self.protocolVersion[1] }, 'cookie': 'OPEN_HANDSHAKE', 'sourceDirectory': sourceDirectory, 'buildDirectory': buildDirectory, 'generator': generatorName, 'extraGenerator': extraGeneratorName }) reply = cmakelib.waitForReply(self.proc, 'handshake', 'OPEN_HANDSHAKE', False) cmakelib.writePayload(self.proc, {"type": "globalSettings"}) packet = cmakelib.waitForReply(self.proc, 'globalSettings', '', False) self.globalSettings = packet self.sourceDirectory = sourceDirectory self.logger.debug( "VERSION: %s" % self.globalSettings["capabilities"]["version"]["string"])
if debug: print("Sending:", json.dumps(data)) cmakelib.writePayload(proc, data) elif 'recv' in obj: data = obj['recv'] if debug: print("Waiting for:", json.dumps(data)) cmakelib.waitForMessage(proc, data) elif 'reply' in obj: data = obj['reply'] if debug: print("Waiting for reply:", json.dumps(data)) originalType = "" cookie = "" skipProgress = False; if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] if 'skipProgress' in data: skipProgress = data['skipProgress'] cmakelib.waitForReply(proc, originalType, cookie, skipProgress) elif 'error' in obj: data = obj['error'] if debug: print("Waiting for error:", json.dumps(data)) originalType = "" cookie = "" message = "" if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] if 'message' in data: message = data['message'] cmakelib.waitForError(proc, originalType, cookie, message) elif 'progress' in obj: data = obj['progress'] if debug: print("Waiting for progress:", json.dumps(data)) originalType = '' cookie = ""
if debug: print("Sending:", json.dumps(data)) cmakelib.writePayload(proc, data) elif 'recv' in obj: data = obj['recv'] if debug: print("Waiting for:", json.dumps(data)) cmakelib.waitForMessage(proc, data) elif 'reply' in obj: data = obj['reply'] if debug: print("Waiting for reply:", json.dumps(data)) originalType = "" cookie = "" skipProgress = False if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] if 'skipProgress' in data: skipProgress = data['skipProgress'] cmakelib.waitForReply(proc, originalType, cookie, skipProgress) elif 'error' in obj: data = obj['error'] if debug: print("Waiting for error:", json.dumps(data)) originalType = "" cookie = "" message = "" if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] if 'message' in data: message = data['message'] cmakelib.waitForError(proc, originalType, cookie, message) elif 'progress' in obj: data = obj['progress'] if debug: print("Waiting for progress:", json.dumps(data)) originalType = '' cookie = ""
elif 'send' in obj: data = obj['send'] if debug: print("Sending:", json.dumps(data)) cmakelib.writePayload(proc, data) elif 'recv' in obj: data = obj['recv'] if debug: print("Waiting for:", json.dumps(data)) cmakelib.waitForMessage(proc, data) elif 'reply' in obj: data = obj['reply'] if debug: print("Waiting for reply:", json.dumps(data)) originalType = "" cookie = "" if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] cmakelib.waitForReply(proc, originalType, cookie) elif 'error' in obj: data = obj['error'] if debug: print("Waiting for error:", json.dumps(data)) originalType = "" cookie = "" message = "" if 'cookie' in data: cookie = data['cookie'] if 'type' in data: originalType = data['type'] if 'message' in data: message = data['message'] cmakelib.waitForError(proc, originalType, cookie, message) elif 'progress' in obj: data = obj['progress'] if debug: print("Waiting for progress:", json.dumps(data)) originalType = '' cookie = ""