cmCustomCommand.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  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 cmCustomCommand_h
  11. #define cmCustomCommand_h
  12. #include "cmStandardIncludes.h"
  13. #include "cmListFileCache.h"
  14. class cmMakefile;
  15. /** \class cmCustomCommand
  16. * \brief A class to encapsulate a custom command
  17. *
  18. * cmCustomCommand encapsulates the properties of a custom command
  19. */
  20. class cmCustomCommand
  21. {
  22. public:
  23. /** Default and copy constructors for STL containers. */
  24. cmCustomCommand();
  25. /** Main constructor specifies all information for the command. */
  26. cmCustomCommand(cmMakefile const* mf,
  27. const std::vector<std::string>& outputs,
  28. const std::vector<std::string>& byproducts,
  29. const std::vector<std::string>& depends,
  30. const cmCustomCommandLines& commandLines,
  31. const char* comment, const char* workingDirectory);
  32. /** Get the output file produced by the command. */
  33. const std::vector<std::string>& GetOutputs() const;
  34. /** Get the extra files produced by the command. */
  35. const std::vector<std::string>& GetByproducts() const;
  36. /** Get the vector that holds the list of dependencies. */
  37. const std::vector<std::string>& GetDepends() const;
  38. /** Get the working directory. */
  39. std::string const& GetWorkingDirectory() const
  40. {
  41. return this->WorkingDirectory;
  42. }
  43. /** Get the list of command lines. */
  44. const cmCustomCommandLines& GetCommandLines() const;
  45. /** Get the comment string for the command. */
  46. const char* GetComment() const;
  47. /** Append to the list of command lines. */
  48. void AppendCommands(const cmCustomCommandLines& commandLines);
  49. /** Append to the list of dependencies. */
  50. void AppendDepends(const std::vector<std::string>& depends);
  51. /** Set/Get whether old-style escaping should be used. */
  52. bool GetEscapeOldStyle() const;
  53. void SetEscapeOldStyle(bool b);
  54. /** Set/Get whether the build tool can replace variables in
  55. arguments to the command. */
  56. bool GetEscapeAllowMakeVars() const;
  57. void SetEscapeAllowMakeVars(bool b);
  58. /** Backtrace of the command that created this custom command. */
  59. cmListFileBacktrace const& GetBacktrace() const;
  60. typedef std::pair<std::string, std::string> ImplicitDependsPair;
  61. class ImplicitDependsList : public std::vector<ImplicitDependsPair>
  62. {
  63. };
  64. void SetImplicitDepends(ImplicitDependsList const&);
  65. void AppendImplicitDepends(ImplicitDependsList const&);
  66. ImplicitDependsList const& GetImplicitDepends() const;
  67. /** Set/Get whether this custom command should be given access to the
  68. real console (if possible). */
  69. bool GetUsesTerminal() const;
  70. void SetUsesTerminal(bool b);
  71. /** Set/Get the depfile (used by the Ninja generator) */
  72. const std::string& GetDepfile() const;
  73. void SetDepfile(const std::string& depfile);
  74. private:
  75. std::vector<std::string> Outputs;
  76. std::vector<std::string> Byproducts;
  77. std::vector<std::string> Depends;
  78. cmCustomCommandLines CommandLines;
  79. cmListFileBacktrace Backtrace;
  80. ImplicitDependsList ImplicitDepends;
  81. std::string Comment;
  82. std::string WorkingDirectory;
  83. std::string Depfile;
  84. bool HaveComment;
  85. bool EscapeAllowMakeVars;
  86. bool EscapeOldStyle;
  87. bool UsesTerminal;
  88. };
  89. #endif