cmRulePlaceholderExpander.h 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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 <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. const char* CMTargetName = nullptr;
  26. const char* CMTargetType = nullptr;
  27. const char* TargetPDB = nullptr;
  28. const char* TargetCompilePDB = nullptr;
  29. const char* TargetVersionMajor = nullptr;
  30. const char* TargetVersionMinor = nullptr;
  31. const char* Language = nullptr;
  32. const char* AIXExports = nullptr;
  33. const char* Objects = nullptr;
  34. const char* Target = nullptr;
  35. const char* LinkLibraries = nullptr;
  36. const char* Source = nullptr;
  37. const char* AssemblySource = nullptr;
  38. const char* PreprocessedSource = nullptr;
  39. const char* DynDepFile = nullptr;
  40. const char* Output = nullptr;
  41. const char* Object = nullptr;
  42. const char* ObjectDir = nullptr;
  43. const char* ObjectFileDir = nullptr;
  44. const char* Flags = nullptr;
  45. const char* ObjectsQuoted = nullptr;
  46. const char* SONameFlag = nullptr;
  47. const char* TargetSOName = nullptr;
  48. const char* TargetInstallNameDir = nullptr;
  49. const char* Linker = nullptr;
  50. const char* LinkFlags = nullptr;
  51. const char* Manifests = nullptr;
  52. const char* LanguageCompileFlags = nullptr;
  53. const char* Defines = nullptr;
  54. const char* Includes = nullptr;
  55. const char* DependencyFile = nullptr;
  56. const char* DependencyTarget = nullptr;
  57. const char* FilterPrefix = nullptr;
  58. const char* SwiftLibraryName = nullptr;
  59. const char* SwiftModule = nullptr;
  60. const char* SwiftModuleName = nullptr;
  61. const char* SwiftOutputFileMapOption = nullptr;
  62. const char* SwiftSources = nullptr;
  63. const char* ISPCHeader = nullptr;
  64. const char* CudaCompileMode = nullptr;
  65. const char* Fatbinary = nullptr;
  66. const char* RegisterFile = nullptr;
  67. const char* Launcher = nullptr;
  68. const char* Role = nullptr;
  69. };
  70. // Expand rule variables in CMake of the type found in language rules
  71. void ExpandRuleVariables(cmOutputConverter* outputConverter,
  72. std::string& string,
  73. const RuleVariables& replaceValues);
  74. private:
  75. std::string ExpandVariable(std::string const& variable) override;
  76. std::string TargetImpLib;
  77. cmBuildStep BuildStep = cmBuildStep::Compile;
  78. std::map<std::string, std::string> Compilers;
  79. std::map<std::string, std::string> VariableMappings;
  80. std::string CompilerSysroot;
  81. std::string LinkerSysroot;
  82. cmOutputConverter* OutputConverter = nullptr;
  83. RuleVariables const* ReplaceValues = nullptr;
  84. };