cmCustomCommandGenerator.h 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <functional>
  6. #include <set>
  7. #include <string>
  8. #include <utility>
  9. #include <vector>
  10. #include <cm/optional>
  11. #include "cmCustomCommandLines.h"
  12. #include "cmListFileCache.h"
  13. class cmCustomCommand;
  14. class cmLocalGenerator;
  15. class cmCustomCommandGenerator
  16. {
  17. std::string GetInternalDepfileName(const std::string&, const std::string&);
  18. cmCustomCommand const* CC;
  19. std::string OutputConfig;
  20. std::string CommandConfig;
  21. cmLocalGenerator* LG;
  22. bool OldStyle;
  23. bool MakeVars;
  24. cmCustomCommandLines CommandLines;
  25. std::vector<std::vector<std::string>> EmulatorsWithArguments;
  26. std::vector<std::string> Outputs;
  27. std::vector<std::string> Byproducts;
  28. std::vector<std::string> Depends;
  29. std::string WorkingDirectory;
  30. std::set<BT<std::pair<std::string, bool>>> Utilities;
  31. std::function<std::string(const std::string&, const std::string&)>
  32. ComputeInternalDepfile;
  33. void FillEmulatorsWithArguments();
  34. std::vector<std::string> GetCrossCompilingEmulator(unsigned int c) const;
  35. const char* GetArgv0Location(unsigned int c) const;
  36. public:
  37. cmCustomCommandGenerator(
  38. cmCustomCommand const& cc, std::string config, cmLocalGenerator* lg,
  39. bool transformDepfile = true, cm::optional<std::string> crossConfig = {},
  40. std::function<std::string(const std::string&, const std::string&)>
  41. computeInternalDepfile = {});
  42. cmCustomCommandGenerator(const cmCustomCommandGenerator&) = delete;
  43. cmCustomCommandGenerator(cmCustomCommandGenerator&&) = default;
  44. cmCustomCommandGenerator& operator=(const cmCustomCommandGenerator&) =
  45. delete;
  46. cmCustomCommandGenerator& operator=(cmCustomCommandGenerator&&) = default;
  47. cmCustomCommand const& GetCC() const { return *(this->CC); }
  48. unsigned int GetNumberOfCommands() const;
  49. std::string GetCommand(unsigned int c) const;
  50. void AppendArguments(unsigned int c, std::string& cmd) const;
  51. const char* GetComment() const;
  52. std::string GetWorkingDirectory() const;
  53. std::vector<std::string> const& GetOutputs() const;
  54. std::vector<std::string> const& GetByproducts() const;
  55. std::vector<std::string> const& GetDepends() const;
  56. std::set<BT<std::pair<std::string, bool>>> const& GetUtilities() const;
  57. bool HasOnlyEmptyCommandLines() const;
  58. std::string GetDepfile() const;
  59. std::string GetFullDepfile() const;
  60. std::string GetInternalDepfile() const;
  61. const std::string& GetOutputConfig() const { return this->OutputConfig; }
  62. const std::string& GetCommandConfig() const { return this->CommandConfig; }
  63. };