1 /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
2 file Copyright.txt or https://cmake.org/licensing for details. */
3 #include "cmVisualStudioWCEPlatformParser.h"
9 #include "cmGlobalVisualStudioGenerator.h"
10 #include "cmSystemTools.h"
12 int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
14 const std::string registryBase =
15 cmGlobalVisualStudioGenerator::GetRegistryBase(version);
16 const std::string vckey = registryBase + "\\Setup\\VC;ProductDir";
17 const std::string vskey = registryBase + "\\Setup\\VS;ProductDir";
19 if (!cmSystemTools::ReadRegistryValue(vckey.c_str(), this->VcInstallDir,
20 cmSystemTools::KeyWOW64_32) ||
21 !cmSystemTools::ReadRegistryValue(vskey.c_str(), this->VsInstallDir,
22 cmSystemTools::KeyWOW64_32)) {
25 cmSystemTools::ConvertToUnixSlashes(this->VcInstallDir);
26 cmSystemTools::ConvertToUnixSlashes(this->VsInstallDir);
27 this->VcInstallDir.append("/");
28 this->VsInstallDir.append("/");
30 const std::string configFilename =
31 this->VcInstallDir + "vcpackages/WCE.VCPlatform.config";
33 return this->ParseFile(configFilename.c_str());
36 std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
38 if (this->OSMinorVersion.empty()) {
39 return OSMajorVersion;
42 return OSMajorVersion + "." + OSMinorVersion;
45 const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
47 std::map<std::string, std::string>::const_iterator it =
48 this->Macros.find("ARCHFAM");
49 if (it != this->Macros.end()) {
50 return it->second.c_str();
56 void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
57 const char** attributes)
59 if (this->FoundRequiredName) {
63 this->CharacterData.clear();
65 if (name == "PlatformData") {
66 this->PlatformName.clear();
67 this->OSMajorVersion.clear();
68 this->OSMinorVersion.clear();
72 if (name == "Macro") {
73 std::string macroName;
74 std::string macroValue;
76 for (const char** attr = attributes; *attr; attr += 2) {
77 if (strcmp(attr[0], "Name") == 0) {
79 } else if (strcmp(attr[0], "Value") == 0) {
84 if (!macroName.empty()) {
85 this->Macros[macroName] = macroValue;
87 } else if (name == "Directories") {
88 for (const char** attr = attributes; *attr; attr += 2) {
89 if (strcmp(attr[0], "Include") == 0) {
90 this->Include = attr[1];
91 } else if (strcmp(attr[0], "Library") == 0) {
92 this->Library = attr[1];
93 } else if (strcmp(attr[0], "Path") == 0) {
100 void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
102 if (!this->RequiredName) {
103 if (name == "PlatformName") {
104 this->AvailablePlatforms.push_back(this->CharacterData);
109 if (this->FoundRequiredName) {
113 if (name == "PlatformName") {
114 this->PlatformName = this->CharacterData;
115 } else if (name == "OSMajorVersion") {
116 this->OSMajorVersion = this->CharacterData;
117 } else if (name == "OSMinorVersion") {
118 this->OSMinorVersion = this->CharacterData;
119 } else if (name == "Platform") {
120 if (this->PlatformName == this->RequiredName) {
121 this->FoundRequiredName = true;
126 void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
129 this->CharacterData.append(data, length);
132 std::string cmVisualStudioWCEPlatformParser::FixPaths(
133 const std::string& paths) const
135 std::string ret = paths;
136 cmSystemTools::ReplaceString(ret, "$(PATH)", "%PATH%");
137 cmSystemTools::ReplaceString(ret, "$(VCInstallDir)", VcInstallDir.c_str());
138 cmSystemTools::ReplaceString(ret, "$(VSInstallDir)", VsInstallDir.c_str());
139 std::replace(ret.begin(), ret.end(), '\\', '/');
140 cmSystemTools::ReplaceString(ret, "//", "/");
141 std::replace(ret.begin(), ret.end(), '/', '\\');