1
0

cmCustomCommand.h 3.5 KB

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