diff options
author | Brad King <brad.king@kitware.com> | 2018-09-21 13:35:28 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2018-09-21 15:36:55 (GMT) |
commit | aabce528519eaa1db64fb4eef48e12669b028f05 (patch) | |
tree | ae54546165d15335184b3d2aceb9ef2a9c4b3dbe /Source/cmServerProtocol.cxx | |
parent | fc43492e44c67ed73a6483a4cd587eae02657949 (diff) | |
download | CMake-aabce528519eaa1db64fb4eef48e12669b028f05.zip CMake-aabce528519eaa1db64fb4eef48e12669b028f05.tar.gz CMake-aabce528519eaa1db64fb4eef48e12669b028f05.tar.bz2 |
server: factor out json object generation entry points
Make entry points for these that do not reference the server code. For
now we leave the "cache" object generation alone because its
implementation interleaves error handling and the format may not
suitable outside a server response.
Diffstat (limited to 'Source/cmServerProtocol.cxx')
-rw-r--r-- | Source/cmServerProtocol.cxx | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 2cad657..266d05c 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -550,23 +550,12 @@ cmServerResponse cmServerProtocol1::ProcessCache( return request.Reply(result); } -cmServerResponse cmServerProtocol1::ProcessCMakeInputs( - const cmServerRequest& request) +static Json::Value DumpCMakeInputs(const cmake* cm) { - if (this->m_State < STATE_CONFIGURED) { - return request.ReportError("This instance was not yet configured."); - } - - const cmake* cm = this->CMakeInstance(); const cmGlobalGenerator* gg = cm->GetGlobalGenerator(); - const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot(); const std::string& buildDir = cm->GetHomeOutputDirectory(); const std::string& sourceDir = cm->GetHomeDirectory(); - Json::Value result = Json::objectValue; - result[kSOURCE_DIRECTORY_KEY] = sourceDir; - result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir; - std::vector<std::string> internalFiles; std::vector<std::string> explicitFiles; std::vector<std::string> tmpFiles; @@ -593,8 +582,24 @@ cmServerResponse cmServerProtocol1::ProcessCMakeInputs( tmp[kSOURCES_KEY] = fromStringList(tmpFiles); array.append(tmp); - result[kBUILD_FILES_KEY] = array; + return array; +} + +cmServerResponse cmServerProtocol1::ProcessCMakeInputs( + const cmServerRequest& request) +{ + if (this->m_State < STATE_CONFIGURED) { + return request.ReportError("This instance was not yet configured."); + } + const cmake* cm = this->CMakeInstance(); + const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot(); + const std::string& sourceDir = cm->GetHomeDirectory(); + + Json::Value result = Json::objectValue; + result[kSOURCE_DIRECTORY_KEY] = sourceDir; + result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir; + result[kBUILD_FILES_KEY] = DumpCMakeInputs(cm); return request.Reply(result); } @@ -958,6 +963,13 @@ static Json::Value DumpCTestConfigurationsList(const cmake* cm) return result; } +static Json::Value DumpCTestInfo(const cmake* cm) +{ + Json::Value result = Json::objectValue; + result[kCONFIGURATIONS_KEY] = DumpCTestConfigurationsList(cm); + return result; +} + static void GetTargetProperty( cmGeneratorExpressionInterpreter& genexInterpreter, cmGeneratorTarget* target, const char* propertyName, @@ -1256,6 +1268,13 @@ static Json::Value DumpConfigurationsList(const cmake* cm) return result; } +static Json::Value DumpCodeModel(const cmake* cm) +{ + Json::Value result = Json::objectValue; + result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(cm); + return result; +} + cmServerResponse cmServerProtocol1::ProcessCodeModel( const cmServerRequest& request) { @@ -1263,9 +1282,7 @@ cmServerResponse cmServerProtocol1::ProcessCodeModel( return request.ReportError("No build system was generated yet."); } - Json::Value result = Json::objectValue; - result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(this->CMakeInstance()); - return request.Reply(result); + return request.Reply(DumpCodeModel(this->CMakeInstance())); } cmServerResponse cmServerProtocol1::ProcessCompute( @@ -1488,10 +1505,7 @@ cmServerResponse cmServerProtocol1::ProcessCTests( return request.ReportError("This instance was not yet computed."); } - Json::Value result = Json::objectValue; - result[kCONFIGURATIONS_KEY] = - DumpCTestConfigurationsList(this->CMakeInstance()); - return request.Reply(result); + return request.Reply(DumpCTestInfo(this->CMakeInstance())); } cmServerProtocol1::GeneratorInformation::GeneratorInformation( |