cmVisualStudioWCEPlatformParser.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmVisualStudioWCEPlatformParser.h"
  11. #include "cmGlobalVisualStudioGenerator.h"
  12. #include "cmXMLParser.h"
  13. int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
  14. {
  15. std::string vskey = cmGlobalVisualStudioGenerator::GetRegistryBase(version);
  16. vskey += "\\Setup\\VS;ProductDir";
  17. std::string vsInstallPath;
  18. if(!cmSystemTools::ReadRegistryValue(vskey.c_str(), vsInstallPath))
  19. {
  20. return 0;
  21. }
  22. cmSystemTools::ConvertToUnixSlashes(vsInstallPath);
  23. const std::string configFilename =
  24. vsInstallPath + "/VC/vcpackages/WCE.VCPlatform.config";
  25. return this->ParseFile(configFilename.c_str());
  26. }
  27. std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
  28. {
  29. if (this->OSMinorVersion.empty())
  30. {
  31. return OSMajorVersion;
  32. }
  33. return OSMajorVersion + "." + OSMinorVersion;
  34. }
  35. const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
  36. {
  37. std::map<std::string, std::string>::const_iterator it =
  38. this->Macros.find("ARCHFAM");
  39. if (it != this->Macros.end())
  40. {
  41. return it->second.c_str();
  42. }
  43. return 0;
  44. }
  45. void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
  46. const char** attributes)
  47. {
  48. if(this->FoundRequiredName)
  49. {
  50. return;
  51. }
  52. this->CharacterData = "";
  53. if(strcmp(name, "PlatformData") == 0)
  54. {
  55. this->PlatformName = "";
  56. this->OSMajorVersion = "";
  57. this->OSMinorVersion = "";
  58. this->Macros.clear();
  59. }
  60. if(strcmp(name, "Macro") == 0)
  61. {
  62. std::string macroName;
  63. std::string macroValue;
  64. for(const char** attr = attributes; *attr; attr += 2)
  65. {
  66. if(strcmp(attr[0], "Name") == 0)
  67. {
  68. macroName = attr[1];
  69. }
  70. else if(strcmp(attr[0], "Value") == 0)
  71. {
  72. macroValue = attr[1];
  73. }
  74. }
  75. if(!macroName.empty())
  76. {
  77. this->Macros[macroName] = macroValue;
  78. }
  79. }
  80. }
  81. void cmVisualStudioWCEPlatformParser::EndElement(const char* name)
  82. {
  83. if(!this->RequiredName)
  84. {
  85. if(strcmp(name, "PlatformName") == 0)
  86. {
  87. this->AvailablePlatforms.push_back(this->CharacterData);
  88. }
  89. return;
  90. }
  91. if(this->FoundRequiredName)
  92. {
  93. return;
  94. }
  95. if(strcmp(name, "PlatformName") == 0)
  96. {
  97. this->PlatformName = this->CharacterData;
  98. }
  99. else if(strcmp(name, "OSMajorVersion") == 0)
  100. {
  101. this->OSMajorVersion = this->CharacterData;
  102. }
  103. else if(strcmp(name, "OSMinorVersion") == 0)
  104. {
  105. this->OSMinorVersion = this->CharacterData;
  106. }
  107. else if(strcmp(name, "Platform") == 0)
  108. {
  109. if(this->PlatformName == this->RequiredName)
  110. {
  111. this->FoundRequiredName = true;
  112. }
  113. }
  114. }
  115. void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
  116. int length)
  117. {
  118. this->CharacterData.append(data, length);
  119. }