2009-09-28 15:43:28 +00:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2001-08-28 22:28:31 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2001-08-28 22:28:31 +00:00
|
|
|
|
2009-09-28 15:43:28 +00:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2001-08-28 22:28:31 +00:00
|
|
|
#ifndef cmListFileCache_h
|
|
|
|
#define cmListFileCache_h
|
|
|
|
|
|
|
|
#include "cmStandardIncludes.h"
|
|
|
|
|
2015-06-04 18:00:14 +00:00
|
|
|
#include "cmState.h"
|
2014-03-12 21:59:42 +00:00
|
|
|
|
2001-08-28 22:28:31 +00:00
|
|
|
/** \class cmListFileCache
|
|
|
|
* \brief A class to cache list file contents.
|
|
|
|
*
|
|
|
|
* cmListFileCache is a class used to cache the contents of parsed
|
|
|
|
* cmake list files.
|
|
|
|
*/
|
|
|
|
|
2008-03-06 15:57:59 +00:00
|
|
|
class cmMakefile;
|
2012-08-13 17:42:58 +00:00
|
|
|
|
2015-07-04 11:12:50 +00:00
|
|
|
struct cmCommandContext
|
|
|
|
{
|
|
|
|
std::string Name;
|
|
|
|
long Line;
|
|
|
|
cmCommandContext(): Name(), Line(0) {}
|
|
|
|
};
|
|
|
|
|
2002-12-11 23:13:33 +00:00
|
|
|
struct cmListFileArgument
|
|
|
|
{
|
2012-08-06 14:07:58 +00:00
|
|
|
enum Delimiter
|
|
|
|
{
|
|
|
|
Unquoted,
|
2013-08-06 19:58:22 +00:00
|
|
|
Quoted,
|
|
|
|
Bracket
|
2012-08-06 14:07:58 +00:00
|
|
|
};
|
2015-05-23 21:43:37 +00:00
|
|
|
cmListFileArgument(): Value(), Delim(Unquoted), Line(0) {}
|
|
|
|
cmListFileArgument(const cmListFileArgument& r)
|
|
|
|
: Value(r.Value), Delim(r.Delim), Line(r.Line) {}
|
|
|
|
cmListFileArgument(const std::string& v, Delimiter d, long line)
|
|
|
|
: Value(v), Delim(d), Line(line) {}
|
2002-12-11 23:13:33 +00:00
|
|
|
bool operator == (const cmListFileArgument& r) const
|
|
|
|
{
|
2012-08-06 14:07:58 +00:00
|
|
|
return (this->Value == r.Value) && (this->Delim == r.Delim);
|
2002-12-11 23:13:33 +00:00
|
|
|
}
|
2002-12-17 19:55:31 +00:00
|
|
|
bool operator != (const cmListFileArgument& r) const
|
|
|
|
{
|
|
|
|
return !(*this == r);
|
|
|
|
}
|
2002-12-11 23:13:33 +00:00
|
|
|
std::string Value;
|
2012-08-06 14:07:58 +00:00
|
|
|
Delimiter Delim;
|
2004-08-04 14:45:11 +00:00
|
|
|
long Line;
|
2002-12-11 23:13:33 +00:00
|
|
|
};
|
|
|
|
|
2008-03-07 13:40:36 +00:00
|
|
|
struct cmListFileContext
|
2001-08-28 22:28:31 +00:00
|
|
|
{
|
2006-03-15 16:02:08 +00:00
|
|
|
std::string Name;
|
2007-05-11 12:36:05 +00:00
|
|
|
std::string FilePath;
|
2006-03-15 16:02:08 +00:00
|
|
|
long Line;
|
2008-10-11 16:02:50 +00:00
|
|
|
cmListFileContext(): Name(), FilePath(), Line(0) {}
|
2015-07-04 11:12:50 +00:00
|
|
|
|
|
|
|
static cmListFileContext FromCommandContext(cmCommandContext const& lfcc,
|
|
|
|
std::string const& fileName)
|
|
|
|
{
|
|
|
|
cmListFileContext lfc;
|
|
|
|
lfc.FilePath = fileName;
|
|
|
|
lfc.Line = lfcc.Line;
|
|
|
|
lfc.Name = lfcc.Name;
|
|
|
|
return lfc;
|
|
|
|
}
|
2001-08-28 22:28:31 +00:00
|
|
|
};
|
|
|
|
|
2008-03-13 17:48:57 +00:00
|
|
|
std::ostream& operator<<(std::ostream&, cmListFileContext const&);
|
2015-05-18 19:44:14 +00:00
|
|
|
bool operator<(const cmListFileContext& lhs, const cmListFileContext& rhs);
|
2015-05-18 19:51:42 +00:00
|
|
|
bool operator==(cmListFileContext const& lhs, cmListFileContext const& rhs);
|
|
|
|
bool operator!=(cmListFileContext const& lhs, cmListFileContext const& rhs);
|
2008-03-13 17:48:57 +00:00
|
|
|
|
2015-07-04 11:12:50 +00:00
|
|
|
struct cmListFileFunction: public cmCommandContext
|
2008-03-07 13:40:36 +00:00
|
|
|
{
|
|
|
|
std::vector<cmListFileArgument> Arguments;
|
|
|
|
};
|
|
|
|
|
2015-05-29 20:37:59 +00:00
|
|
|
class cmListFileBacktrace
|
2014-03-12 21:59:42 +00:00
|
|
|
{
|
|
|
|
public:
|
2015-05-29 20:37:59 +00:00
|
|
|
cmListFileBacktrace(cmState::Snapshot snapshot = cmState::Snapshot(),
|
|
|
|
cmCommandContext const& cc = cmCommandContext())
|
|
|
|
: Context(cc), Snapshot(snapshot)
|
2014-03-12 21:59:42 +00:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2015-07-09 20:26:51 +00:00
|
|
|
void PrintTitle(std::ostream& out) const;
|
|
|
|
void PrintCallStack(std::ostream& out) const;
|
2014-03-12 21:59:42 +00:00
|
|
|
private:
|
2015-05-29 20:37:59 +00:00
|
|
|
cmCommandContext Context;
|
2015-06-04 18:00:14 +00:00
|
|
|
cmState::Snapshot Snapshot;
|
2014-03-12 21:59:42 +00:00
|
|
|
};
|
2008-03-13 17:48:57 +00:00
|
|
|
|
2001-08-28 22:28:31 +00:00
|
|
|
struct cmListFile
|
|
|
|
{
|
2012-08-13 17:42:58 +00:00
|
|
|
bool ParseFile(const char* path,
|
2008-03-06 15:57:59 +00:00
|
|
|
bool topLevel,
|
|
|
|
cmMakefile *mf);
|
2006-03-15 16:02:08 +00:00
|
|
|
|
|
|
|
std::vector<cmListFileFunction> Functions;
|
2001-08-28 22:28:31 +00:00
|
|
|
};
|
|
|
|
|
2013-02-12 09:35:28 +00:00
|
|
|
struct cmValueWithOrigin {
|
|
|
|
cmValueWithOrigin(const std::string &value,
|
|
|
|
const cmListFileBacktrace &bt)
|
|
|
|
: Value(value), Backtrace(bt)
|
|
|
|
{}
|
|
|
|
std::string Value;
|
|
|
|
cmListFileBacktrace Backtrace;
|
|
|
|
};
|
|
|
|
|
2001-08-28 22:28:31 +00:00
|
|
|
#endif
|