cmRulePlaceholderExpander.h 2.5 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. RuleVariables();
  24. const char* CMTargetName;
  25. const char* CMTargetType;
  26. const char* TargetPDB;
  27. const char* TargetCompilePDB;
  28. const char* TargetVersionMajor;
  29. const char* TargetVersionMinor;
  30. const char* Language;
  31. const char* AIXExports;
  32. const char* Objects;
  33. const char* Target;
  34. const char* LinkLibraries;
  35. const char* Source;
  36. const char* AssemblySource;
  37. const char* PreprocessedSource;
  38. const char* Output;
  39. const char* Object;
  40. const char* ObjectDir;
  41. const char* ObjectFileDir;
  42. const char* Flags;
  43. const char* ObjectsQuoted;
  44. const char* SONameFlag;
  45. const char* TargetSOName;
  46. const char* TargetInstallNameDir;
  47. const char* LinkFlags;
  48. const char* Manifests;
  49. const char* LanguageCompileFlags;
  50. const char* Defines;
  51. const char* Includes;
  52. const char* DependencyFile;
  53. const char* FilterPrefix;
  54. const char* SwiftLibraryName;
  55. const char* SwiftModule;
  56. const char* SwiftModuleName;
  57. const char* SwiftOutputFileMap;
  58. const char* SwiftSources;
  59. const char* ISPCHeader;
  60. const char* Fatbinary;
  61. const char* RegisterFile;
  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. };