cmRulePlaceholderExpander.h 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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. class cmOutputConverter;
  8. class cmRulePlaceholderExpander
  9. {
  10. public:
  11. cmRulePlaceholderExpander(
  12. std::map<std::string, std::string> compilers,
  13. std::map<std::string, std::string> variableMappings,
  14. std::string compilerSysroot, std::string linkerSysroot);
  15. void SetTargetImpLib(std::string const& targetImpLib)
  16. {
  17. this->TargetImpLib = targetImpLib;
  18. }
  19. // Create a struct to hold the variables passed into
  20. // ExpandRuleVariables
  21. struct RuleVariables
  22. {
  23. const char* CMTargetName = nullptr;
  24. const char* CMTargetType = nullptr;
  25. const char* TargetPDB = nullptr;
  26. const char* TargetCompilePDB = nullptr;
  27. const char* TargetVersionMajor = nullptr;
  28. const char* TargetVersionMinor = nullptr;
  29. const char* Language = nullptr;
  30. const char* AIXExports = nullptr;
  31. const char* Objects = nullptr;
  32. const char* Target = nullptr;
  33. const char* LinkLibraries = nullptr;
  34. const char* Source = nullptr;
  35. const char* AssemblySource = nullptr;
  36. const char* PreprocessedSource = nullptr;
  37. const char* Output = nullptr;
  38. const char* Object = nullptr;
  39. const char* ObjectDir = nullptr;
  40. const char* ObjectFileDir = nullptr;
  41. const char* Flags = nullptr;
  42. const char* ObjectsQuoted = nullptr;
  43. const char* SONameFlag = nullptr;
  44. const char* TargetSOName = nullptr;
  45. const char* TargetInstallNameDir = nullptr;
  46. const char* LinkFlags = nullptr;
  47. const char* Manifests = nullptr;
  48. const char* LanguageCompileFlags = nullptr;
  49. const char* Defines = nullptr;
  50. const char* Includes = nullptr;
  51. const char* DependencyFile = nullptr;
  52. const char* DependencyTarget = nullptr;
  53. const char* FilterPrefix = nullptr;
  54. const char* SwiftLibraryName = nullptr;
  55. const char* SwiftModule = nullptr;
  56. const char* SwiftModuleName = nullptr;
  57. const char* SwiftOutputFileMap = nullptr;
  58. const char* SwiftSources = nullptr;
  59. const char* ISPCHeader = nullptr;
  60. const char* Fatbinary = nullptr;
  61. const char* RegisterFile = nullptr;
  62. };
  63. // Expand rule variables in CMake of the type found in language rules
  64. void ExpandRuleVariables(cmOutputConverter* outputConverter,
  65. std::string& string,
  66. const RuleVariables& replaceValues);
  67. // Expand rule variables in a single string
  68. std::string ExpandRuleVariable(cmOutputConverter* outputConverter,
  69. std::string const& variable,
  70. const RuleVariables& replaceValues);
  71. private:
  72. std::string TargetImpLib;
  73. std::map<std::string, std::string> Compilers;
  74. std::map<std::string, std::string> VariableMappings;
  75. std::string CompilerSysroot;
  76. std::string LinkerSysroot;
  77. };