mirror of
https://github.com/Kitware/CMake.git
synced 2026-02-25 10:18:34 -06:00
server: Compile json object generation source separately
Declare entry points in a dedicated header and compile the source separately instead of including it in the server implementation.
This commit is contained in:
@@ -1047,6 +1047,9 @@ target_link_libraries(cmake CMakeLib)
|
|||||||
add_library(CMakeServerLib
|
add_library(CMakeServerLib
|
||||||
cmConnection.h cmConnection.cxx
|
cmConnection.h cmConnection.cxx
|
||||||
cmFileMonitor.cxx cmFileMonitor.h
|
cmFileMonitor.cxx cmFileMonitor.h
|
||||||
|
cmJsonObjectDictionary.h
|
||||||
|
cmJsonObjects.h
|
||||||
|
cmJsonObjects.cxx
|
||||||
cmPipeConnection.cxx cmPipeConnection.h
|
cmPipeConnection.cxx cmPipeConnection.h
|
||||||
cmServer.cxx cmServer.h
|
cmServer.cxx cmServer.h
|
||||||
cmServerConnection.cxx cmServerConnection.h
|
cmServerConnection.cxx cmServerConnection.h
|
||||||
|
|||||||
@@ -1,11 +1,14 @@
|
|||||||
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
#include "cmJsonObjects.h" // IWYU pragma: keep
|
||||||
|
|
||||||
#include "cmGeneratorExpression.h"
|
#include "cmGeneratorExpression.h"
|
||||||
#include "cmGeneratorTarget.h"
|
#include "cmGeneratorTarget.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmInstallGenerator.h"
|
#include "cmInstallGenerator.h"
|
||||||
#include "cmInstallTargetGenerator.h"
|
#include "cmInstallTargetGenerator.h"
|
||||||
|
#include "cmJsonObjectDictionary.h"
|
||||||
|
#include "cmJsonObjects.h"
|
||||||
#include "cmLinkLineComputer.h"
|
#include "cmLinkLineComputer.h"
|
||||||
#include "cmLocalGenerator.h"
|
#include "cmLocalGenerator.h"
|
||||||
#include "cmMakefile.h"
|
#include "cmMakefile.h"
|
||||||
@@ -66,11 +69,14 @@ Json::Value fromStringList(const T& in)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir,
|
} // namespace
|
||||||
const std::string& buildDir,
|
|
||||||
std::vector<std::string>* internalFiles,
|
void cmGetCMakeInputs(const cmGlobalGenerator* gg,
|
||||||
std::vector<std::string>* explicitFiles,
|
const std::string& sourceDir,
|
||||||
std::vector<std::string>* tmpFiles)
|
const std::string& buildDir,
|
||||||
|
std::vector<std::string>* internalFiles,
|
||||||
|
std::vector<std::string>* explicitFiles,
|
||||||
|
std::vector<std::string>* tmpFiles)
|
||||||
{
|
{
|
||||||
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
|
const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/';
|
||||||
std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
|
std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles();
|
||||||
@@ -109,9 +115,7 @@ void getCMakeInputs(const cmGlobalGenerator* gg, const std::string& sourceDir,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
Json::Value cmDumpCMakeInputs(const cmake* cm)
|
||||||
|
|
||||||
static Json::Value DumpCMakeInputs(const cmake* cm)
|
|
||||||
{
|
{
|
||||||
const cmGlobalGenerator* gg = cm->GetGlobalGenerator();
|
const cmGlobalGenerator* gg = cm->GetGlobalGenerator();
|
||||||
const std::string& buildDir = cm->GetHomeOutputDirectory();
|
const std::string& buildDir = cm->GetHomeOutputDirectory();
|
||||||
@@ -120,8 +124,8 @@ static Json::Value DumpCMakeInputs(const cmake* cm)
|
|||||||
std::vector<std::string> internalFiles;
|
std::vector<std::string> internalFiles;
|
||||||
std::vector<std::string> explicitFiles;
|
std::vector<std::string> explicitFiles;
|
||||||
std::vector<std::string> tmpFiles;
|
std::vector<std::string> tmpFiles;
|
||||||
getCMakeInputs(gg, sourceDir, buildDir, &internalFiles, &explicitFiles,
|
cmGetCMakeInputs(gg, sourceDir, buildDir, &internalFiles, &explicitFiles,
|
||||||
&tmpFiles);
|
&tmpFiles);
|
||||||
|
|
||||||
Json::Value array = Json::arrayValue;
|
Json::Value array = Json::arrayValue;
|
||||||
|
|
||||||
@@ -506,7 +510,7 @@ static Json::Value DumpCTestConfigurationsList(const cmake* cm)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Json::Value DumpCTestInfo(const cmake* cm)
|
Json::Value cmDumpCTestInfo(const cmake* cm)
|
||||||
{
|
{
|
||||||
Json::Value result = Json::objectValue;
|
Json::Value result = Json::objectValue;
|
||||||
result[kCONFIGURATIONS_KEY] = DumpCTestConfigurationsList(cm);
|
result[kCONFIGURATIONS_KEY] = DumpCTestConfigurationsList(cm);
|
||||||
@@ -811,7 +815,7 @@ static Json::Value DumpConfigurationsList(const cmake* cm)
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
static Json::Value DumpCodeModel(const cmake* cm)
|
Json::Value cmDumpCodeModel(const cmake* cm)
|
||||||
{
|
{
|
||||||
Json::Value result = Json::objectValue;
|
Json::Value result = Json::objectValue;
|
||||||
result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(cm);
|
result[kCONFIGURATIONS_KEY] = DumpConfigurationsList(cm);
|
||||||
|
|||||||
27
Source/cmJsonObjects.h
Normal file
27
Source/cmJsonObjects.h
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
|
||||||
|
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||||
|
#ifndef cmJsonObjects_h
|
||||||
|
#define cmJsonObjects_h
|
||||||
|
|
||||||
|
#include "cmConfigure.h" // IWYU pragma: keep
|
||||||
|
|
||||||
|
#include "cm_jsoncpp_value.h"
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
class cmake;
|
||||||
|
class cmGlobalGenerator;
|
||||||
|
|
||||||
|
extern void cmGetCMakeInputs(const cmGlobalGenerator* gg,
|
||||||
|
const std::string& sourceDir,
|
||||||
|
const std::string& buildDir,
|
||||||
|
std::vector<std::string>* internalFiles,
|
||||||
|
std::vector<std::string>* explicitFiles,
|
||||||
|
std::vector<std::string>* tmpFiles);
|
||||||
|
|
||||||
|
extern Json::Value cmDumpCodeModel(const cmake* cm);
|
||||||
|
extern Json::Value cmDumpCTestInfo(const cmake* cm);
|
||||||
|
extern Json::Value cmDumpCMakeInputs(const cmake* cm);
|
||||||
|
|
||||||
|
#endif
|
||||||
@@ -7,6 +7,7 @@
|
|||||||
#include "cmFileMonitor.h"
|
#include "cmFileMonitor.h"
|
||||||
#include "cmGlobalGenerator.h"
|
#include "cmGlobalGenerator.h"
|
||||||
#include "cmJsonObjectDictionary.h"
|
#include "cmJsonObjectDictionary.h"
|
||||||
|
#include "cmJsonObjects.h"
|
||||||
#include "cmServer.h"
|
#include "cmServer.h"
|
||||||
#include "cmServerDictionary.h"
|
#include "cmServerDictionary.h"
|
||||||
#include "cmState.h"
|
#include "cmState.h"
|
||||||
@@ -37,8 +38,6 @@ std::vector<std::string> toStringList(const Json::Value& in)
|
|||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
#include "cmJsonObjects.cxx"
|
|
||||||
|
|
||||||
cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection,
|
cmServerRequest::cmServerRequest(cmServer* server, cmConnection* connection,
|
||||||
const std::string& t, const std::string& c,
|
const std::string& t, const std::string& c,
|
||||||
const Json::Value& d)
|
const Json::Value& d)
|
||||||
@@ -473,7 +472,7 @@ cmServerResponse cmServerProtocol1::ProcessCMakeInputs(
|
|||||||
Json::Value result = Json::objectValue;
|
Json::Value result = Json::objectValue;
|
||||||
result[kSOURCE_DIRECTORY_KEY] = sourceDir;
|
result[kSOURCE_DIRECTORY_KEY] = sourceDir;
|
||||||
result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir;
|
result[kCMAKE_ROOT_DIRECTORY_KEY] = cmakeRootDir;
|
||||||
result[kBUILD_FILES_KEY] = DumpCMakeInputs(cm);
|
result[kBUILD_FILES_KEY] = cmDumpCMakeInputs(cm);
|
||||||
return request.Reply(result);
|
return request.Reply(result);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -484,7 +483,7 @@ cmServerResponse cmServerProtocol1::ProcessCodeModel(
|
|||||||
return request.ReportError("No build system was generated yet.");
|
return request.ReportError("No build system was generated yet.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.Reply(DumpCodeModel(this->CMakeInstance()));
|
return request.Reply(cmDumpCodeModel(this->CMakeInstance()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmServerResponse cmServerProtocol1::ProcessCompute(
|
cmServerResponse cmServerProtocol1::ProcessCompute(
|
||||||
@@ -601,7 +600,8 @@ cmServerResponse cmServerProtocol1::ProcessConfigure(
|
|||||||
}
|
}
|
||||||
|
|
||||||
std::vector<std::string> toWatchList;
|
std::vector<std::string> toWatchList;
|
||||||
getCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList, nullptr);
|
cmGetCMakeInputs(gg, std::string(), buildDir, nullptr, &toWatchList,
|
||||||
|
nullptr);
|
||||||
|
|
||||||
FileMonitor()->MonitorPaths(toWatchList,
|
FileMonitor()->MonitorPaths(toWatchList,
|
||||||
[this](const std::string& p, int e, int s) {
|
[this](const std::string& p, int e, int s) {
|
||||||
@@ -707,7 +707,7 @@ cmServerResponse cmServerProtocol1::ProcessCTests(
|
|||||||
return request.ReportError("This instance was not yet computed.");
|
return request.ReportError("This instance was not yet computed.");
|
||||||
}
|
}
|
||||||
|
|
||||||
return request.Reply(DumpCTestInfo(this->CMakeInstance()));
|
return request.Reply(cmDumpCTestInfo(this->CMakeInstance()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cmServerProtocol1::GeneratorInformation::GeneratorInformation(
|
cmServerProtocol1::GeneratorInformation::GeneratorInformation(
|
||||||
|
|||||||
Reference in New Issue
Block a user