cmRulePlaceholderExpander.h 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file LICENSE.rst or https://cmake.org/licensing for details. */
  3. #pragma once
  4. #include "cmConfigure.h" // IWYU pragma: keep
  5. #include <map>
  6. #include <string>
  7. #include "cmGeneratorOptions.h"
  8. #include "cmPlaceholderExpander.h"
  9. class cmOutputConverter;
  10. class cmRulePlaceholderExpander : public cmPlaceholderExpander
  11. {
  12. public:
  13. cmRulePlaceholderExpander(
  14. cmBuildStep buildStep, std::map<std::string, std::string> compilers,
  15. std::map<std::string, std::string> variableMappings,
  16. std::string compilerSysroot, std::string linkerSysroot);
  17. void SetTargetImpLib(std::string const& targetImpLib)
  18. {
  19. this->TargetImpLib = targetImpLib;
  20. }
  21. // Create a struct to hold the variables passed into
  22. // ExpandRuleVariables
  23. struct RuleVariables
  24. {
  25. char const* CMTargetName = nullptr;
  26. char const* CMTargetType = nullptr;
  27. char const* TargetPDB = nullptr;
  28. char const* TargetCompilePDB = nullptr;
  29. char const* TargetVersionMajor = nullptr;
  30. char const* TargetVersionMinor = nullptr;
  31. char const* Language = nullptr;
  32. char const* AIXExports = nullptr;
  33. char const* Objects = nullptr;
  34. char const* Target = nullptr;
  35. char const* LinkLibraries = nullptr;
  36. char const* Source = nullptr;
  37. char const* AssemblySource = nullptr;
  38. char const* PreprocessedSource = nullptr;
  39. char const* DynDepFile = nullptr;
  40. char const* Output = nullptr;
  41. char const* Object = nullptr;
  42. char const* TargetSupportDir = nullptr;
  43. char const* ObjectDir = nullptr;
  44. char const* ObjectFileDir = nullptr;
  45. char const* Flags = nullptr;
  46. char const* ObjectsQuoted = nullptr;
  47. char const* SONameFlag = nullptr;
  48. char const* TargetSOName = nullptr;
  49. char const* TargetInstallNameDir = nullptr;
  50. char const* Linker = nullptr;
  51. char const* LinkFlags = nullptr;
  52. char const* Manifests = nullptr;
  53. char const* LanguageCompileFlags = nullptr;
  54. char const* Defines = nullptr;
  55. char const* Includes = nullptr;
  56. char const* DependencyFile = nullptr;
  57. char const* DependencyTarget = nullptr;
  58. char const* FilterPrefix = nullptr;
  59. char const* SwiftLibraryName = nullptr;
  60. char const* SwiftModule = nullptr;
  61. char const* SwiftModuleName = nullptr;
  62. char const* SwiftOutputFileMapOption = nullptr;
  63. char const* SwiftSources = nullptr;
  64. char const* ISPCHeader = nullptr;
  65. char const* CudaCompileMode = nullptr;
  66. char const* Fatbinary = nullptr;
  67. char const* RegisterFile = nullptr;
  68. char const* Launcher = nullptr;
  69. char const* Role = nullptr;
  70. char const* Config = nullptr;
  71. };
  72. // Expand rule variables in CMake of the type found in language rules
  73. void ExpandRuleVariables(cmOutputConverter* outputConverter,
  74. std::string& string,
  75. RuleVariables const& replaceValues);
  76. private:
  77. std::string ExpandVariable(std::string const& variable) override;
  78. std::string TargetImpLib;
  79. cmBuildStep BuildStep = cmBuildStep::Compile;
  80. std::map<std::string, std::string> Compilers;
  81. std::map<std::string, std::string> VariableMappings;
  82. std::string CompilerSysroot;
  83. std::string LinkerSysroot;
  84. cmOutputConverter* OutputConverter = nullptr;
  85. RuleVariables const* ReplaceValues = nullptr;
  86. };