Merge topic 'refactor-cmGeneratorExpression'
ec428faf
Genex: Extend cmGeneratorExpressionContext constructor.082b6a9d
Genex: Split cmGeneratorExpressionContext into own file.9df1f0fc
Genex: Split cmGeneratorExpressionNode into own file.80b9f0cb
Genex: Extract an evaluateWithContext method.642048ce
Help: Move docs of $<0:...> and $<1:...> to output section.
This commit is contained in:
commit
6390d5f5cb
|
@ -40,10 +40,6 @@ otherwise expands to nothing.
|
|||
|
||||
Available logical expressions are:
|
||||
|
||||
``$<0:...>``
|
||||
Empty string (ignores ``...``)
|
||||
``$<1:...>``
|
||||
Content of ``...``
|
||||
``$<BOOL:...>``
|
||||
``1`` if the ``...`` is true, else ``0``
|
||||
``$<AND:?[,?]...>``
|
||||
|
@ -241,6 +237,10 @@ where ``${prop}`` refers to a helper variable::
|
|||
|
||||
Available output expressions are:
|
||||
|
||||
``$<0:...>``
|
||||
Empty string (ignores ``...``)
|
||||
``$<1:...>``
|
||||
Content of ``...``
|
||||
``$<JOIN:list,...>``
|
||||
Joins the list with the content of ``...``
|
||||
``$<ANGLE-R>``
|
||||
|
|
|
@ -238,12 +238,16 @@ set(SRCS
|
|||
cmFileTimeComparison.cxx
|
||||
cmFileTimeComparison.h
|
||||
cmGeneratedFileStream.cxx
|
||||
cmGeneratorExpressionContext.cxx
|
||||
cmGeneratorExpressionContext.h
|
||||
cmGeneratorExpressionDAGChecker.cxx
|
||||
cmGeneratorExpressionDAGChecker.h
|
||||
cmGeneratorExpressionEvaluator.cxx
|
||||
cmGeneratorExpressionEvaluator.h
|
||||
cmGeneratorExpressionLexer.cxx
|
||||
cmGeneratorExpressionLexer.h
|
||||
cmGeneratorExpressionNode.cxx
|
||||
cmGeneratorExpressionNode.h
|
||||
cmGeneratorExpressionParser.cxx
|
||||
cmGeneratorExpressionParser.h
|
||||
cmGeneratorExpression.cxx
|
||||
|
|
|
@ -72,6 +72,19 @@ const char *cmCompiledGeneratorExpression::Evaluate(
|
|||
cmTarget const* currentTarget,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker,
|
||||
std::string const& language) const
|
||||
{
|
||||
cmGeneratorExpressionContext context(mf, config, quiet, headTarget,
|
||||
currentTarget ? currentTarget : headTarget,
|
||||
this->EvaluateForBuildsystem,
|
||||
this->Backtrace, language);
|
||||
|
||||
return this->EvaluateWithContext(context, dagChecker);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
const char* cmCompiledGeneratorExpression::EvaluateWithContext(
|
||||
cmGeneratorExpressionContext& context,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker) const
|
||||
{
|
||||
if (!this->NeedsEvaluation)
|
||||
{
|
||||
|
@ -85,20 +98,6 @@ const char *cmCompiledGeneratorExpression::Evaluate(
|
|||
const std::vector<cmGeneratorExpressionEvaluator*>::const_iterator end
|
||||
= this->Evaluators.end();
|
||||
|
||||
cmGeneratorExpressionContext context;
|
||||
context.Makefile = mf;
|
||||
context.Config = config;
|
||||
context.Quiet = quiet;
|
||||
context.HadError = false;
|
||||
context.HadContextSensitiveCondition = false;
|
||||
context.HadHeadSensitiveCondition = false;
|
||||
context.SourceSensitiveTargets.clear();
|
||||
context.HeadTarget = headTarget;
|
||||
context.EvaluateForBuildsystem = this->EvaluateForBuildsystem;
|
||||
context.CurrentTarget = currentTarget ? currentTarget : headTarget;
|
||||
context.Backtrace = this->Backtrace;
|
||||
context.Language = language;
|
||||
|
||||
for ( ; it != end; ++it)
|
||||
{
|
||||
this->Output += (*it)->Evaluate(&context, dagChecker);
|
||||
|
|
|
@ -24,6 +24,7 @@ class cmMakefile;
|
|||
class cmListFileBacktrace;
|
||||
|
||||
struct cmGeneratorExpressionEvaluator;
|
||||
struct cmGeneratorExpressionContext;
|
||||
struct cmGeneratorExpressionDAGChecker;
|
||||
|
||||
class cmCompiledGeneratorExpression;
|
||||
|
@ -131,6 +132,9 @@ public:
|
|||
std::map<std::string, std::string>& mapping);
|
||||
|
||||
private:
|
||||
const char* EvaluateWithContext(cmGeneratorExpressionContext& context,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker) const;
|
||||
|
||||
cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
|
||||
const std::string& input);
|
||||
|
||||
|
|
|
@ -0,0 +1,34 @@
|
|||
/*============================================================================
|
||||
CMake - Cross Platform Makefile Generator
|
||||
Copyright 2012 Stephen Kelly <steveire@gmail.com>
|
||||
|
||||
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.
|
||||
============================================================================*/
|
||||
|
||||
#include "cmGeneratorExpressionContext.h"
|
||||
|
||||
cmGeneratorExpressionContext::cmGeneratorExpressionContext(
|
||||
cmMakefile* mf, std::string const& config,
|
||||
bool quiet, cmTarget const* headTarget,
|
||||
cmTarget const* currentTarget,
|
||||
bool evaluateForBuildsystem,
|
||||
cmListFileBacktrace const& backtrace,
|
||||
std::string const& language)
|
||||
: Backtrace(backtrace),
|
||||
Makefile(mf),
|
||||
Config(config),
|
||||
Language(language),
|
||||
HeadTarget(headTarget),
|
||||
CurrentTarget(currentTarget),
|
||||
Quiet(quiet),
|
||||
HadError(false),
|
||||
HadContextSensitiveCondition(false),
|
||||
HadHeadSensitiveCondition(false),
|
||||
EvaluateForBuildsystem(evaluateForBuildsystem)
|
||||
{
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
/*============================================================================
|
||||
CMake - Cross Platform Makefile Generator
|
||||
Copyright 2012 Stephen Kelly <steveire@gmail.com>
|
||||
|
||||
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 cmGeneratorExpressionContext_h
|
||||
#define cmGeneratorExpressionContext_h
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
|
||||
#include <set>
|
||||
#include <map>
|
||||
#include <string>
|
||||
|
||||
class cmTarget;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct cmGeneratorExpressionContext
|
||||
{
|
||||
cmGeneratorExpressionContext(cmMakefile* mf, std::string const& config,
|
||||
bool quiet, cmTarget const* headTarget,
|
||||
cmTarget const* currentTarget,
|
||||
bool evaluateForBuildsystem,
|
||||
cmListFileBacktrace const& backtrace,
|
||||
std::string const& language);
|
||||
|
||||
|
||||
cmListFileBacktrace Backtrace;
|
||||
std::set<cmTarget*> DependTargets;
|
||||
std::set<cmTarget const*> AllTargets;
|
||||
std::set<std::string> SeenTargetProperties;
|
||||
std::set<cmTarget const*> SourceSensitiveTargets;
|
||||
std::map<cmTarget const*, std::map<std::string, std::string> >
|
||||
MaxLanguageStandard;
|
||||
cmMakefile *Makefile;
|
||||
std::string Config;
|
||||
std::string Language;
|
||||
cmTarget const* HeadTarget; // The target whose property is being evaluated.
|
||||
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
|
||||
// directly or indirectly in the property.
|
||||
bool Quiet;
|
||||
bool HadError;
|
||||
bool HadContextSensitiveCondition;
|
||||
bool HadHeadSensitiveCondition;
|
||||
bool EvaluateForBuildsystem;
|
||||
};
|
||||
|
||||
#endif
|
File diff suppressed because it is too large
Load Diff
|
@ -16,37 +16,10 @@
|
|||
#include <string>
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
#include "cmGeneratorExpressionContext.h"
|
||||
|
||||
class cmTarget;
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct cmGeneratorExpressionContext
|
||||
{
|
||||
cmGeneratorExpressionContext()
|
||||
: Backtrace(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
cmListFileBacktrace Backtrace;
|
||||
std::set<cmTarget*> DependTargets;
|
||||
std::set<cmTarget const*> AllTargets;
|
||||
std::set<std::string> SeenTargetProperties;
|
||||
std::set<cmTarget const*> SourceSensitiveTargets;
|
||||
std::map<cmTarget const*, std::map<std::string, std::string> >
|
||||
MaxLanguageStandard;
|
||||
cmMakefile *Makefile;
|
||||
std::string Config;
|
||||
std::string Language;
|
||||
cmTarget const* HeadTarget; // The target whose property is being evaluated.
|
||||
cmTarget const* CurrentTarget; // The dependent of HeadTarget which appears
|
||||
// directly or indirectly in the property.
|
||||
bool Quiet;
|
||||
bool HadError;
|
||||
bool HadContextSensitiveCondition;
|
||||
bool HadHeadSensitiveCondition;
|
||||
bool EvaluateForBuildsystem;
|
||||
};
|
||||
|
||||
struct cmGeneratorExpressionDAGChecker;
|
||||
struct cmGeneratorExpressionNode;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,70 @@
|
|||
/*============================================================================
|
||||
CMake - Cross Platform Makefile Generator
|
||||
Copyright 2012 Stephen Kelly <steveire@gmail.com>
|
||||
|
||||
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 cmGeneratorExpressionNode_h
|
||||
#define cmGeneratorExpressionNode_h
|
||||
|
||||
#include "cmMakefile.h"
|
||||
|
||||
#include "cmGeneratorExpressionEvaluator.h"
|
||||
#include "cmGeneratorExpressionParser.h"
|
||||
#include "cmGeneratorExpressionDAGChecker.h"
|
||||
#include "cmGeneratorExpression.h"
|
||||
#include "cmLocalGenerator.h"
|
||||
#include "cmSourceFile.h"
|
||||
|
||||
#include <cmsys/String.h>
|
||||
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
|
||||
#include "cmListFileCache.h"
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
struct cmGeneratorExpressionNode
|
||||
{
|
||||
enum {
|
||||
DynamicParameters = 0,
|
||||
OneOrMoreParameters = -1,
|
||||
OneOrZeroParameters = -2
|
||||
};
|
||||
virtual ~cmGeneratorExpressionNode() {}
|
||||
|
||||
virtual bool GeneratesContent() const { return true; }
|
||||
|
||||
virtual bool RequiresLiteralInput() const { return false; }
|
||||
|
||||
virtual bool AcceptsArbitraryContentParameter() const
|
||||
{ return false; }
|
||||
|
||||
virtual int NumExpectedParameters() const { return 1; }
|
||||
|
||||
virtual std::string Evaluate(const std::vector<std::string> ¶meters,
|
||||
cmGeneratorExpressionContext *context,
|
||||
const GeneratorExpressionContent *content,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker
|
||||
) const = 0;
|
||||
|
||||
static std::string EvaluateDependentExpression(
|
||||
std::string const& prop, cmMakefile *makefile,
|
||||
cmGeneratorExpressionContext *context,
|
||||
cmTarget const* headTarget, cmTarget const* currentTarget,
|
||||
cmGeneratorExpressionDAGChecker *dagChecker);
|
||||
|
||||
static const cmGeneratorExpressionNode* GetNode(
|
||||
const std::string &identifier);
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------
|
||||
void reportError(cmGeneratorExpressionContext *context,
|
||||
const std::string &expr, const std::string &result);
|
||||
|
||||
#endif
|
|
@ -267,9 +267,11 @@ CMAKE_CXX_SOURCES="\
|
|||
cmInstallDirectoryGenerator \
|
||||
cmGeneratedFileStream \
|
||||
cmGeneratorTarget \
|
||||
cmGeneratorExpressionContext \
|
||||
cmGeneratorExpressionDAGChecker \
|
||||
cmGeneratorExpressionEvaluator \
|
||||
cmGeneratorExpressionLexer \
|
||||
cmGeneratorExpressionNode \
|
||||
cmGeneratorExpressionParser \
|
||||
cmGeneratorExpression \
|
||||
cmGlobalGenerator \
|
||||
|
|
Loading…
Reference in New Issue