2015-04-12 14:15:51 +03:00
|
|
|
/*============================================================================
|
|
|
|
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,
|
2015-06-14 21:27:37 +03:00
|
|
|
OutputFormat output) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
std::string Convert(const std::string& remote, RelativeRoot local,
|
2015-06-14 21:27:37 +03:00
|
|
|
OutputFormat output = UNCHANGED) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
std::string Convert(RelativeRoot remote, const std::string& local,
|
|
|
|
OutputFormat output = UNCHANGED,
|
2015-06-14 21:27:37 +03:00
|
|
|
bool optional = false) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get path for the specified relative root.
|
|
|
|
*/
|
2015-06-14 21:27:37 +03:00
|
|
|
const char* GetRelativeRootPath(RelativeRoot relroot) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
///! for existing files convert to output path and short path if spaces
|
|
|
|
std::string ConvertToOutputForExisting(const std::string& remote,
|
|
|
|
RelativeRoot local = START_OUTPUT,
|
2015-06-14 21:27:37 +03:00
|
|
|
OutputFormat format = SHELL) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
/** For existing path identified by RelativeRoot convert to output
|
|
|
|
path and short path if spaces. */
|
|
|
|
std::string ConvertToOutputForExisting(RelativeRoot remote,
|
|
|
|
const std::string& local = "",
|
2015-06-14 21:27:37 +03:00
|
|
|
OutputFormat format = SHELL) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
void SetLinkScriptShell(bool linkScriptShell);
|
|
|
|
|
|
|
|
std::string EscapeForShell(const std::string& str,
|
|
|
|
bool makeVars = false,
|
|
|
|
bool forEcho = false,
|
2015-06-14 21:27:37 +03:00
|
|
|
bool useWatcomQuote = false) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
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,
|
2015-06-14 21:27:37 +03:00
|
|
|
bool force = false) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
cmState* GetState() const;
|
|
|
|
|
|
|
|
std::string ConvertToOutputForExistingCommon(const std::string& remote,
|
|
|
|
std::string const& result,
|
2015-06-14 21:27:37 +03:00
|
|
|
OutputFormat format) const;
|
2015-04-12 14:15:51 +03:00
|
|
|
|
|
|
|
private:
|
|
|
|
cmState::Snapshot StateSnapshot;
|
|
|
|
|
|
|
|
bool LinkScriptShell;
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|