diff options
author | Tobias Hunger <tobias.hunger@qt.io> | 2016-09-09 08:01:46 (GMT) |
---|---|---|
committer | Tobias Hunger <tobias.hunger@qt.io> | 2016-09-29 20:34:10 (GMT) |
commit | 4e34f042504f1c62f36a0f16e137e137a7bf1e72 (patch) | |
tree | 6a9079a16e93dd82dce7d04c36d4bb8805546f25 /Source | |
parent | 262500028cb5e6c278cbc0f0a2694b50833dc3ec (diff) | |
download | CMake-4e34f042504f1c62f36a0f16e137e137a7bf1e72.zip CMake-4e34f042504f1c62f36a0f16e137e137a7bf1e72.tar.gz CMake-4e34f042504f1c62f36a0f16e137e137a7bf1e72.tar.bz2 |
server-mode: Watch CMakeLists.txt files
Watch CMakeLists.txt files (and similar) from the Server
Diffstat (limited to 'Source')
-rw-r--r-- | Source/cmServerDictionary.h | 6 | ||||
-rw-r--r-- | Source/cmServerProtocol.cxx | 34 | ||||
-rw-r--r-- | Source/cmServerProtocol.h | 4 |
3 files changed, 44 insertions, 0 deletions
diff --git a/Source/cmServerDictionary.h b/Source/cmServerDictionary.h index 61cde75..c82274a 100644 --- a/Source/cmServerDictionary.h +++ b/Source/cmServerDictionary.h @@ -6,6 +6,9 @@ // Vocabulary: +static const std::string kDIRTY_SIGNAL = "dirty"; +static const std::string kFILE_CHANGE_SIGNAL = "fileChange"; + static const std::string kCACHE_TYPE = "cache"; static const std::string kCMAKE_INPUTS_TYPE = "cmakeInputs"; static const std::string kCODE_MODEL_TYPE = "codemodel"; @@ -86,3 +89,6 @@ static const std::string kWATCHED_FILES_KEY = "watchedFiles"; static const std::string kSTART_MAGIC = "[== CMake Server ==["; static const std::string kEND_MAGIC = "]== CMake Server ==]"; + +static const std::string kRENAME_PROPERTY_VALUE = "rename"; +static const std::string kCHANGE_PROPERTY_VALUE = "change"; diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 626bff0..a2bdf49 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -371,6 +371,30 @@ bool cmServerProtocol1_0::DoActivate(const cmServerRequest& request, return true; } +void cmServerProtocol1_0::HandleCMakeFileChanges(const std::string& path, + int event, int status) +{ + assert(status == 0); + static_cast<void>(status); + + if (!m_isDirty) { + m_isDirty = true; + SendSignal(kDIRTY_SIGNAL, Json::objectValue); + } + Json::Value obj = Json::objectValue; + obj[kPATH_KEY] = path; + Json::Value properties = Json::arrayValue; + if (event & UV_RENAME) { + properties.append(kRENAME_PROPERTY_VALUE); + } + if (event & UV_CHANGE) { + properties.append(kCHANGE_PROPERTY_VALUE); + } + + obj[kPROPERTIES_KEY] = properties; + SendSignal(kFILE_CHANGE_SIGNAL, obj); +} + const cmServerResponse cmServerProtocol1_0::Process( const cmServerRequest& request) { @@ -949,7 +973,17 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure( if (ret < 0) { return request.ReportError("Configuration failed."); } + + std::vector<std::string> toWatchList; + getCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList, nullptr); + + FileMonitor()->MonitorPaths(toWatchList, + [this](const std::string& p, int e, int s) { + this->HandleCMakeFileChanges(p, e, s); + }); + m_State = STATE_CONFIGURED; + m_isDirty = false; return request.Reply(Json::Value()); } diff --git a/Source/cmServerProtocol.h b/Source/cmServerProtocol.h index c516d68..5238d5d 100644 --- a/Source/cmServerProtocol.h +++ b/Source/cmServerProtocol.h @@ -109,6 +109,8 @@ private: bool DoActivate(const cmServerRequest& request, std::string* errorMessage) override; + void HandleCMakeFileChanges(const std::string& path, int event, int status); + // Handle requests: cmServerResponse ProcessCache(const cmServerRequest& request); cmServerResponse ProcessCMakeInputs(const cmServerRequest& request); @@ -127,4 +129,6 @@ private: STATE_COMPUTED }; State m_State = STATE_INACTIVE; + + bool m_isDirty = false; }; |