diff options
Diffstat (limited to 'Source/cmServerProtocol.cxx')
-rw-r--r-- | Source/cmServerProtocol.cxx | 75 |
1 files changed, 47 insertions, 28 deletions
diff --git a/Source/cmServerProtocol.cxx b/Source/cmServerProtocol.cxx index 8317018..a5c1a23 100644 --- a/Source/cmServerProtocol.cxx +++ b/Source/cmServerProtocol.cxx @@ -2,11 +2,11 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmServerProtocol.h" -#include "cmCacheManager.h" #include "cmExternalMakefileProjectGenerator.h" #include "cmFileMonitor.h" #include "cmGeneratorTarget.h" #include "cmGlobalGenerator.h" +#include "cmLinkLineComputer.h" #include "cmListFileCache.h" #include "cmLocalGenerator.h" #include "cmMakefile.h" @@ -32,7 +32,7 @@ namespace { -static std::vector<std::string> getConfigurations(const cmake* cm) +std::vector<std::string> getConfigurations(const cmake* cm) { std::vector<std::string> configurations; auto makefiles = cm->GetGlobalGenerator()->GetMakefiles(); @@ -41,12 +41,13 @@ static std::vector<std::string> getConfigurations(const cmake* cm) } makefiles[0]->GetConfigurations(configurations); - if (configurations.empty()) + if (configurations.empty()) { configurations.push_back(""); + } return configurations; } -static bool hasString(const Json::Value& v, const std::string& s) +bool hasString(const Json::Value& v, const std::string& s) { return !v.isNull() && std::find_if(v.begin(), v.end(), [s](const Json::Value& i) { @@ -55,7 +56,7 @@ static bool hasString(const Json::Value& v, const std::string& s) } template <class T> -static Json::Value fromStringList(const T& in) +Json::Value fromStringList(const T& in) { Json::Value result = Json::arrayValue; for (const std::string& i : in) { @@ -64,7 +65,7 @@ static Json::Value fromStringList(const T& in) return result; } -static std::vector<std::string> toStringList(const Json::Value& in) +std::vector<std::string> toStringList(const Json::Value& in) { std::vector<std::string> result; for (const auto& it : in) { @@ -73,15 +74,14 @@ static std::vector<std::string> toStringList(const Json::Value& in) return result; } -static void getCMakeInputs(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) +void getCMakeInputs(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) { const std::string cmakeRootDir = cmSystemTools::GetCMakeRoot() + '/'; - const std::vector<cmMakefile*> makefiles = gg->GetMakefiles(); + std::vector<cmMakefile*> const& makefiles = gg->GetMakefiles(); for (auto it = makefiles.begin(); it != makefiles.end(); ++it) { const std::vector<std::string> listFiles = (*it)->GetListFiles(); @@ -95,20 +95,24 @@ static void getCMakeInputs(const cmGlobalGenerator* gg, if (!sourceDir.empty()) { const std::string& relative = cmSystemTools::RelativePath(sourceDir.c_str(), jt->c_str()); - if (toAdd.size() > relative.size()) + if (toAdd.size() > relative.size()) { toAdd = relative; + } } if (isInternal) { - if (internalFiles) + if (internalFiles) { internalFiles->push_back(toAdd); + } } else { if (isTemporary) { - if (tmpFiles) + if (tmpFiles) { tmpFiles->push_back(toAdd); + } } else { - if (explicitFiles) + if (explicitFiles) { explicitFiles->push_back(toAdd); + } } } } @@ -685,7 +689,13 @@ static Json::Value DumpSourceFilesList( cmLocalGenerator* lg = target->GetLocalGenerator(); std::string compileFlags = ld.Flags; - lg->AppendFlags(compileFlags, file->GetProperty("COMPILE_FLAGS")); + if (const char* cflags = file->GetProperty("COMPILE_FLAGS")) { + cmGeneratorExpression ge; + auto cge = ge.Parse(cflags); + const char* processed = + cge->Evaluate(target->GetLocalGenerator(), config); + lg->AppendFlags(compileFlags, processed); + } fileData.Flags = compileFlags; fileData.IncludePathList = ld.IncludePathList; @@ -709,8 +719,9 @@ static Json::Value DumpSourceFilesList( Json::Value result = Json::arrayValue; for (auto it = fileGroups.begin(); it != fileGroups.end(); ++it) { Json::Value group = DumpSourceFileGroup(it->first, it->second, baseDir); - if (!group.isNull()) + if (!group.isNull()) { result.append(group); + } } return result; @@ -722,7 +733,7 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, cmLocalGenerator* lg = target->GetLocalGenerator(); const cmState* state = lg->GetState(); - const cmState::TargetType type = target->GetType(); + const cmStateEnums::TargetType type = target->GetType(); const std::string typeName = state->GetTargetTypeName(type); Json::Value ttl = Json::arrayValue; @@ -740,12 +751,16 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, Json::Value result = Json::objectValue; result[kNAME_KEY] = target->GetName(); - result[kTYPE_KEY] = typeName; - result[kFULL_NAME_KEY] = target->GetFullName(config); result[kSOURCE_DIRECTORY_KEY] = lg->GetCurrentSourceDirectory(); result[kBUILD_DIRECTORY_KEY] = lg->GetCurrentBinaryDirectory(); + if (type == cmStateEnums::INTERFACE_LIBRARY) { + return result; + } + + result[kFULL_NAME_KEY] = target->GetFullName(config); + if (target->HaveWellDefinedOutputFiles()) { Json::Value artifacts = Json::arrayValue; artifacts.append(target->GetFullPath(config, false)); @@ -766,8 +781,10 @@ static Json::Value DumpTarget(cmGeneratorTarget* target, std::string linkLanguageFlags; std::string frameworkPath; std::string linkPath; - lg->GetTargetFlags(config, linkLibs, linkLanguageFlags, linkFlags, - frameworkPath, linkPath, target, false); + cmLinkLineComputer linkLineComputer(lg, + lg->GetStateSnapshot().GetDirectory()); + lg->GetTargetFlags(&linkLineComputer, config, linkLibs, linkLanguageFlags, + linkFlags, frameworkPath, linkPath, target); linkLibs = cmSystemTools::TrimWhitespace(linkLibs); linkFlags = cmSystemTools::TrimWhitespace(linkFlags); @@ -846,7 +863,7 @@ static Json::Value DumpTargetsList( return result; } -static Json::Value DumpProjectList(const cmake* cm, const std::string config) +static Json::Value DumpProjectList(const cmake* cm, std::string const& config) { Json::Value result = Json::arrayValue; @@ -856,8 +873,8 @@ static Json::Value DumpProjectList(const cmake* cm, const std::string config) Json::Value pObj = Json::objectValue; pObj[kNAME_KEY] = projectIt.first; - assert(projectIt.second.size() > - 0); // All Projects must have at least one local generator + // All Projects must have at least one local generator + assert(!projectIt.second.empty()); const cmLocalGenerator* lg = projectIt.second.at(0); // Project structure information: @@ -1004,6 +1021,8 @@ cmServerResponse cmServerProtocol1_0::ProcessConfigure( } } + cmSystemTools::ResetErrorOccuredFlag(); // Reset error state + if (cm->AddCMakePaths() != 1) { return request.ReportError("Failed to set CMake paths."); } @@ -1058,7 +1077,7 @@ cmServerResponse cmServerProtocol1_0::ProcessGlobalSettings( } static void setBool(const cmServerRequest& request, const std::string& key, - std::function<void(bool)> setter) + std::function<void(bool)> const& setter) { if (request.Data[key].isNull()) { return; |