cmGeneratorExpression.h 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #ifndef cmGeneratorExpression_h
  11. #define cmGeneratorExpression_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmListFileCache.h"
  14. #include <stack>
  15. #include <cmsys/RegularExpression.hxx>
  16. #include <cmsys/auto_ptr.hxx>
  17. class cmTarget;
  18. class cmMakefile;
  19. class cmListFileBacktrace;
  20. struct cmGeneratorExpressionEvaluator;
  21. struct cmGeneratorExpressionDAGChecker;
  22. class cmCompiledGeneratorExpression;
  23. /** \class cmGeneratorExpression
  24. * \brief Evaluate generate-time query expression syntax.
  25. *
  26. * cmGeneratorExpression instances are used by build system generator
  27. * implementations to evaluate the $<> generator expression syntax.
  28. * Generator expressions are evaluated just before the generate step
  29. * writes strings into the build system. They have knowledge of the
  30. * build configuration which is not available at configure time.
  31. */
  32. class cmGeneratorExpression
  33. {
  34. public:
  35. /** Construct. */
  36. cmGeneratorExpression(cmListFileBacktrace const& backtrace);
  37. ~cmGeneratorExpression();
  38. cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(
  39. std::string const& input);
  40. cmsys::auto_ptr<cmCompiledGeneratorExpression> Parse(const char* input);
  41. enum PreprocessContext {
  42. StripAllGeneratorExpressions
  43. };
  44. static std::string Preprocess(const std::string &input,
  45. PreprocessContext context);
  46. private:
  47. cmGeneratorExpression(const cmGeneratorExpression &);
  48. void operator=(const cmGeneratorExpression &);
  49. cmListFileBacktrace const& Backtrace;
  50. };
  51. class cmCompiledGeneratorExpression
  52. {
  53. public:
  54. const char* Evaluate(cmMakefile* mf, const char* config,
  55. bool quiet = false,
  56. cmTarget *target = 0,
  57. cmGeneratorExpressionDAGChecker *dagChecker = 0) const;
  58. /** Get set of targets found during evaluations. */
  59. std::set<cmTarget*> const& GetTargets() const
  60. { return this->Targets; }
  61. ~cmCompiledGeneratorExpression();
  62. std::string GetInput() const
  63. {
  64. return this->Input;
  65. }
  66. private:
  67. cmCompiledGeneratorExpression(cmListFileBacktrace const& backtrace,
  68. const char *input);
  69. friend class cmGeneratorExpression;
  70. cmCompiledGeneratorExpression(const cmCompiledGeneratorExpression &);
  71. void operator=(const cmCompiledGeneratorExpression &);
  72. cmListFileBacktrace Backtrace;
  73. std::vector<cmGeneratorExpressionEvaluator*> Evaluators;
  74. const std::string Input;
  75. bool NeedsParsing;
  76. mutable std::set<cmTarget*> Targets;
  77. mutable std::string Output;
  78. };
  79. #endif