1 /*============================================================================
2 CMake - Cross Platform Makefile Generator
3 Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
5 Distributed under the OSI-approved BSD License (the "License");
6 see accompanying file Copyright.txt for details.
8 This software is distributed WITHOUT ANY WARRANTY; without even the
9 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
10 See the License for more information.
11 ============================================================================*/
12 #include "cmVisualStudioWCEPlatformParser.h"
13 #include "cmGlobalVisualStudioGenerator.h"
14 #include "cmXMLParser.h"
16 int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
18 const std::string registryBase =
19 cmGlobalVisualStudioGenerator::GetRegistryBase(version);
20 const std::string vckey = registryBase + "\\Setup\\VC;ProductDir";
21 const std::string vskey = registryBase + "\\Setup\\VS;ProductDir";
23 if(!cmSystemTools::ReadRegistryValue(vckey.c_str(),
25 cmSystemTools::KeyWOW64_32) ||
26 !cmSystemTools::ReadRegistryValue(vskey.c_str(),
28 cmSystemTools::KeyWOW64_32))
32 cmSystemTools::ConvertToUnixSlashes(this->VcInstallDir);
33 cmSystemTools::ConvertToUnixSlashes(this->VsInstallDir);
34 this->VcInstallDir.append("/");
35 this->VsInstallDir.append("/");
37 const std::string configFilename =
38 this->VcInstallDir + "vcpackages/WCE.VCPlatform.config";
40 return this->ParseFile(configFilename.c_str());
43 std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
45 if (this->OSMinorVersion.empty())
47 return OSMajorVersion;
50 return OSMajorVersion + "." + OSMinorVersion;
53 const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
55 std::map<std::string, std::string>::const_iterator it =
56 this->Macros.find("ARCHFAM");
57 if (it != this->Macros.end())
59 return it->second.c_str();
65 void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
66 const char** attributes)
68 if(this->FoundRequiredName)
73 this->CharacterData = "";
75 if(strcmp(name, "PlatformData") == 0)
77 this->PlatformName = "";
78 this->OSMajorVersion = "";
79 this->OSMinorVersion = "";
83 if(strcmp(name, "Macro") == 0)
85 std::string macroName;
86 std::string macroValue;
88 for(const char** attr = attributes; *attr; attr += 2)
90 if(strcmp(attr[0], "Name") == 0)
94 else if(strcmp(attr[0], "Value") == 0)
100 if(!macroName.empty())
102 this->Macros[macroName] = macroValue;
105 else if(strcmp(name, "Directories") == 0)
107 for(const char** attr = attributes; *attr; attr += 2)
109 if(strcmp(attr[0], "Include") == 0)
111 this->Include = attr[1];
113 else if(strcmp(attr[0], "Library") == 0)
115 this->Library = attr[1];
117 else if(strcmp(attr[0], "Path") == 0)
119 this->Path = attr[1];
125 void cmVisualStudioWCEPlatformParser::EndElement(const char* name)
127 if(!this->RequiredName)
129 if(strcmp(name, "PlatformName") == 0)
131 this->AvailablePlatforms.push_back(this->CharacterData);
136 if(this->FoundRequiredName)
141 if(strcmp(name, "PlatformName") == 0)
143 this->PlatformName = this->CharacterData;
145 else if(strcmp(name, "OSMajorVersion") == 0)
147 this->OSMajorVersion = this->CharacterData;
149 else if(strcmp(name, "OSMinorVersion") == 0)
151 this->OSMinorVersion = this->CharacterData;
153 else if(strcmp(name, "Platform") == 0)
155 if(this->PlatformName == this->RequiredName)
157 this->FoundRequiredName = true;
162 void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
165 this->CharacterData.append(data, length);
168 std::string cmVisualStudioWCEPlatformParser::FixPaths(
169 const std::string& paths) const
171 std::string ret = paths;
172 cmSystemTools::ReplaceString(ret, "$(PATH)", "%PATH%");
173 cmSystemTools::ReplaceString(ret, "$(VCInstallDir)", VcInstallDir.c_str());
174 cmSystemTools::ReplaceString(ret, "$(VSInstallDir)", VsInstallDir.c_str());
175 cmSystemTools::ReplaceString(ret, "\\", "/");
176 cmSystemTools::ReplaceString(ret, "//", "/");
177 cmSystemTools::ReplaceString(ret, "/", "\\");