cmCustomCommand.h 3.8 KB

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