diff options
author | Stephen Kelly <steveire@gmail.com> | 2015-04-12 13:15:51 +0200 |
---|---|---|
committer | Stephen Kelly <steveire@gmail.com> | 2015-06-06 09:15:55 +0200 |
commit | 6d7abb6326d422dabdf72e8486b492ac20f8b347 (patch) | |
tree | 0a174867b9a74cba8032edbe5ee4df4a0b4d57fd /Source/cmOutputConverter.h | |
parent | a82441572493e4f420fca24041b594da9d3c14e6 (diff) | |
download | cmake-6d7abb6326d422dabdf72e8486b492ac20f8b347.tar.gz |
cmOutputConverter: Extract from cmLocalGenerator.
The Convert methods never belonged to the local generator concept, so
split them out now. The cmOutputConverter is cheap to construct and
destroy, so it can be instantiated where needed to perform
conversions. This will allow further decoupling of cmLocalGenerator
from the configure step.
Inherit cmLocalGenerator from cmOutputConverter for the purpose of
source compatibility.
Diffstat (limited to 'Source/cmOutputConverter.h')
-rw-r--r-- | Source/cmOutputConverter.h | 106 |
1 files changed, 106 insertions, 0 deletions
diff --git a/Source/cmOutputConverter.h b/Source/cmOutputConverter.h new file mode 100644 index 0000000000..1d3f8c75f0 --- /dev/null +++ b/Source/cmOutputConverter.h @@ -0,0 +1,106 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc., Insight Software Consortium + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ +#ifndef cmOutputConverter_h +#define cmOutputConverter_h + +#include "cmStandardIncludes.h" + +#include "cmGlobalGenerator.h" +#include "cmState.h" + +class cmOutputConverter +{ +public: + cmOutputConverter(cmState::Snapshot snapshot); + + /** + * Convert something to something else. This is a centralized conversion + * routine used by the generators to handle relative paths and the like. + * The flags determine what is actually done. + * + * relative: treat the argument as a directory and convert it to make it + * relative or full or unchanged. If relative (HOME, START etc) then that + * specifies what it should be relative to. + * + * output: make the result suitable for output to a... + * + * optional: should any relative path operation be controlled by the rel + * path setting + */ + enum RelativeRoot { NONE, FULL, HOME, START, HOME_OUTPUT, START_OUTPUT }; + enum OutputFormat { UNCHANGED, MAKERULE, SHELL, WATCOMQUOTE, RESPONSE }; + std::string ConvertToOutputFormat(const std::string& source, + OutputFormat output); + std::string Convert(const std::string& remote, RelativeRoot local, + OutputFormat output = UNCHANGED); + std::string Convert(RelativeRoot remote, const std::string& local, + OutputFormat output = UNCHANGED, + bool optional = false); + + /** + * Get path for the specified relative root. + */ + const char* GetRelativeRootPath(RelativeRoot relroot); + + ///! for existing files convert to output path and short path if spaces + std::string ConvertToOutputForExisting(const std::string& remote, + RelativeRoot local = START_OUTPUT, + OutputFormat format = SHELL); + + /** For existing path identified by RelativeRoot convert to output + path and short path if spaces. */ + std::string ConvertToOutputForExisting(RelativeRoot remote, + const std::string& local = "", + OutputFormat format = SHELL); + + void SetLinkScriptShell(bool linkScriptShell); + + std::string EscapeForShell(const std::string& str, + bool makeVars = false, + bool forEcho = false, + bool useWatcomQuote = false); + + static std::string EscapeForCMake(const std::string& str); + + enum FortranFormat + { + FortranFormatNone, + FortranFormatFixed, + FortranFormatFree + }; + static FortranFormat GetFortranFormat(const char* value); + + /** + * Convert the given remote path to a relative path with respect to + * the given local path. The local path must be given in component + * form (see SystemTools::SplitPath) without a trailing slash. The + * remote path must use forward slashes and not already be escaped + * or quoted. + */ + std::string ConvertToRelativePath(const std::vector<std::string>& local, + const std::string& in_remote, + bool force = false); + +private: + cmState* GetState() const; + + std::string ConvertToOutputForExistingCommon(const std::string& remote, + std::string const& result, + OutputFormat format); + +private: + cmState::Snapshot StateSnapshot; + + bool LinkScriptShell; +}; + +#endif |