mirror of
https://github.com/Kitware/CMake.git
synced 2026-04-28 01:49:23 -05:00
Merge topic 'genex-SHELL_PATH'
ca6ba3feGenex: Add a SHELL_PATH expression7de868c4Tests: Simplify GeneratorExpression check implementation
This commit is contained in:
@@ -13,6 +13,7 @@
|
||||
#include "cmGeneratorExpressionNode.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmAlgorithms.h"
|
||||
#include "cmOutputConverter.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmGeneratorExpressionNode::EvaluateDependentExpression(
|
||||
@@ -1791,6 +1792,27 @@ TargetFilesystemArtifactNodeGroup<ArtifactSonameTag> targetSoNameNodeGroup;
|
||||
static const
|
||||
TargetFilesystemArtifactNodeGroup<ArtifactPdbTag> targetPdbNodeGroup;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
static const struct ShellPathNode : public cmGeneratorExpressionNode
|
||||
{
|
||||
ShellPathNode() {}
|
||||
|
||||
std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||
cmGeneratorExpressionContext *context,
|
||||
const GeneratorExpressionContent *content,
|
||||
cmGeneratorExpressionDAGChecker *) const
|
||||
{
|
||||
if (!cmSystemTools::FileIsFullPath(parameters.front()))
|
||||
{
|
||||
reportError(context, content->GetOriginalExpression(),
|
||||
"\"" + parameters.front() + "\" is not an absolute path.");
|
||||
return std::string();
|
||||
}
|
||||
cmOutputConverter converter(context->Makefile->GetStateSnapshot());
|
||||
return converter.ConvertDirectorySeparatorsForShell(parameters.front());
|
||||
}
|
||||
} shellPathNode;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const cmGeneratorExpressionNode*
|
||||
cmGeneratorExpressionNode::GetNode(const std::string &identifier)
|
||||
@@ -1846,6 +1868,7 @@ cmGeneratorExpressionNode::GetNode(const std::string &identifier)
|
||||
nodeMap["JOIN"] = &joinNode;
|
||||
nodeMap["LINK_ONLY"] = &linkOnlyNode;
|
||||
nodeMap["COMPILE_LANGUAGE"] = &languageNode;
|
||||
nodeMap["SHELL_PATH"] = &shellPathNode;
|
||||
}
|
||||
NodeMap::const_iterator i = nodeMap.find(identifier);
|
||||
if (i == nodeMap.end())
|
||||
|
||||
@@ -142,21 +142,7 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source,
|
||||
}
|
||||
else if(output == SHELL || output == WATCOMQUOTE)
|
||||
{
|
||||
// For the MSYS shell convert drive letters to posix paths, so
|
||||
// that c:/some/path becomes /c/some/path. This is needed to
|
||||
// avoid problems with the shell path translation.
|
||||
if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell)
|
||||
{
|
||||
if(result.size() > 2 && result[1] == ':')
|
||||
{
|
||||
result[1] = result[0];
|
||||
result[0] = '/';
|
||||
}
|
||||
}
|
||||
if(this->GetState()->UseWindowsShell())
|
||||
{
|
||||
std::replace(result.begin(), result.end(), '/', '\\');
|
||||
}
|
||||
result = this->ConvertDirectorySeparatorsForShell(source);
|
||||
result = this->EscapeForShell(result, true, false, output == WATCOMQUOTE);
|
||||
}
|
||||
else if(output == RESPONSE)
|
||||
@@ -166,6 +152,29 @@ std::string cmOutputConverter::ConvertToOutputFormat(const std::string& source,
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmOutputConverter::ConvertDirectorySeparatorsForShell(
|
||||
const std::string& source) const
|
||||
{
|
||||
std::string result = source;
|
||||
// For the MSYS shell convert drive letters to posix paths, so
|
||||
// that c:/some/path becomes /c/some/path. This is needed to
|
||||
// avoid problems with the shell path translation.
|
||||
if(this->GetState()->UseMSYSShell() && !this->LinkScriptShell)
|
||||
{
|
||||
if(result.size() > 2 && result[1] == ':')
|
||||
{
|
||||
result[1] = result[0];
|
||||
result[0] = '/';
|
||||
}
|
||||
}
|
||||
if(this->GetState()->UseWindowsShell())
|
||||
{
|
||||
std::replace(result.begin(), result.end(), '/', '\\');
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
std::string cmOutputConverter::Convert(RelativeRoot remote,
|
||||
const std::string& local,
|
||||
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
std::string Convert(RelativeRoot remote, const std::string& local,
|
||||
OutputFormat output = UNCHANGED,
|
||||
bool optional = false) const;
|
||||
std::string ConvertDirectorySeparatorsForShell(
|
||||
const std::string& source) const;
|
||||
|
||||
/**
|
||||
* Get path for the specified relative root.
|
||||
|
||||
Reference in New Issue
Block a user