2012-11-20 16:12:27 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2012 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
#include "cmVisualStudioWCEPlatformParser.h"
|
2016-04-29 16:40:20 +03:00
|
|
|
|
2012-11-20 16:12:27 +04:00
|
|
|
#include "cmGlobalVisualStudioGenerator.h"
|
|
|
|
#include "cmXMLParser.h"
|
|
|
|
|
|
|
|
int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
|
|
|
|
{
|
2012-11-29 19:36:20 +04:00
|
|
|
const std::string registryBase =
|
|
|
|
cmGlobalVisualStudioGenerator::GetRegistryBase(version);
|
|
|
|
const std::string vckey = registryBase + "\\Setup\\VC;ProductDir";
|
|
|
|
const std::string vskey = registryBase + "\\Setup\\VS;ProductDir";
|
2012-11-20 16:12:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::ReadRegistryValue(vckey.c_str(), this->VcInstallDir,
|
|
|
|
cmSystemTools::KeyWOW64_32) ||
|
|
|
|
!cmSystemTools::ReadRegistryValue(vskey.c_str(), this->VsInstallDir,
|
|
|
|
cmSystemTools::KeyWOW64_32)) {
|
2012-11-20 16:12:27 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-29 19:36:20 +04:00
|
|
|
cmSystemTools::ConvertToUnixSlashes(this->VcInstallDir);
|
|
|
|
cmSystemTools::ConvertToUnixSlashes(this->VsInstallDir);
|
|
|
|
this->VcInstallDir.append("/");
|
|
|
|
this->VsInstallDir.append("/");
|
2012-11-20 16:12:27 +04:00
|
|
|
|
|
|
|
const std::string configFilename =
|
2012-11-29 19:36:20 +04:00
|
|
|
this->VcInstallDir + "vcpackages/WCE.VCPlatform.config";
|
2012-11-20 16:12:27 +04:00
|
|
|
|
|
|
|
return this->ParseFile(configFilename.c_str());
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->OSMinorVersion.empty()) {
|
2012-11-20 16:12:27 +04:00
|
|
|
return OSMajorVersion;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
|
|
|
return OSMajorVersion + "." + OSMinorVersion;
|
|
|
|
}
|
|
|
|
|
|
|
|
const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
|
|
|
|
{
|
|
|
|
std::map<std::string, std::string>::const_iterator it =
|
|
|
|
this->Macros.find("ARCHFAM");
|
2016-05-16 17:34:04 +03:00
|
|
|
if (it != this->Macros.end()) {
|
2012-11-20 16:12:27 +04:00
|
|
|
return it->second.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2014-02-22 04:05:55 +04:00
|
|
|
void cmVisualStudioWCEPlatformParser::StartElement(const std::string& name,
|
2012-11-20 16:12:27 +04:00
|
|
|
const char** attributes)
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FoundRequiredName) {
|
2012-11-20 16:12:27 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
|
|
|
this->CharacterData = "";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "PlatformData") {
|
2012-11-20 16:12:27 +04:00
|
|
|
this->PlatformName = "";
|
|
|
|
this->OSMajorVersion = "";
|
|
|
|
this->OSMinorVersion = "";
|
|
|
|
this->Macros.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "Macro") {
|
2012-11-20 16:12:27 +04:00
|
|
|
std::string macroName;
|
|
|
|
std::string macroValue;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (const char** attr = attributes; *attr; attr += 2) {
|
|
|
|
if (strcmp(attr[0], "Name") == 0) {
|
2012-11-20 16:12:27 +04:00
|
|
|
macroName = attr[1];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(attr[0], "Value") == 0) {
|
2012-11-20 16:12:27 +04:00
|
|
|
macroValue = attr[1];
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!macroName.empty()) {
|
2012-11-20 16:12:27 +04:00
|
|
|
this->Macros[macroName] = macroValue;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "Directories") {
|
|
|
|
for (const char** attr = attributes; *attr; attr += 2) {
|
|
|
|
if (strcmp(attr[0], "Include") == 0) {
|
2012-11-29 19:36:20 +04:00
|
|
|
this->Include = attr[1];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(attr[0], "Library") == 0) {
|
2012-11-29 19:36:20 +04:00
|
|
|
this->Library = attr[1];
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (strcmp(attr[0], "Path") == 0) {
|
2012-11-29 19:36:20 +04:00
|
|
|
this->Path = attr[1];
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
}
|
|
|
|
|
2014-02-22 04:05:55 +04:00
|
|
|
void cmVisualStudioWCEPlatformParser::EndElement(const std::string& name)
|
2012-11-20 16:12:27 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->RequiredName) {
|
|
|
|
if (name == "PlatformName") {
|
2012-11-20 16:12:27 +04:00
|
|
|
this->AvailablePlatforms.push_back(this->CharacterData);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return;
|
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->FoundRequiredName) {
|
2012-11-20 16:12:27 +04:00
|
|
|
return;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (name == "PlatformName") {
|
2012-11-20 16:12:27 +04:00
|
|
|
this->PlatformName = this->CharacterData;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "OSMajorVersion") {
|
2012-11-20 16:12:27 +04:00
|
|
|
this->OSMajorVersion = this->CharacterData;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (name == "OSMinorVersion") {
|
|
|
|
this->OSMinorVersion = this->CharacterData;
|
|
|
|
} else if (name == "Platform") {
|
|
|
|
if (this->PlatformName == this->RequiredName) {
|
2012-11-20 16:12:27 +04:00
|
|
|
this->FoundRequiredName = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-11-20 16:12:27 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
|
|
|
|
int length)
|
|
|
|
{
|
|
|
|
this->CharacterData.append(data, length);
|
|
|
|
}
|
2012-11-29 19:36:20 +04:00
|
|
|
|
|
|
|
std::string cmVisualStudioWCEPlatformParser::FixPaths(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& paths) const
|
2012-11-29 19:36:20 +04:00
|
|
|
{
|
|
|
|
std::string ret = paths;
|
|
|
|
cmSystemTools::ReplaceString(ret, "$(PATH)", "%PATH%");
|
|
|
|
cmSystemTools::ReplaceString(ret, "$(VCInstallDir)", VcInstallDir.c_str());
|
|
|
|
cmSystemTools::ReplaceString(ret, "$(VSInstallDir)", VsInstallDir.c_str());
|
Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and
`with` are string literals with a size of one.
Automate with:
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
2016-05-24 23:58:11 +03:00
|
|
|
std::replace(ret.begin(), ret.end(), '\\', '/');
|
2012-11-29 19:36:20 +04:00
|
|
|
cmSystemTools::ReplaceString(ret, "//", "/");
|
Use std::replace for replacing chars in strings.
Find uses of `cmSystemTools::ReplaceString` where both `replace` and
`with` are string literals with a size of one.
Automate with:
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\2', '\3');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\(.\)\", \"\\\\\\\\\");|std::replace(\1.begin(), \1.end(), '\2', '\\\\\\\\');|g"
git grep -l ReplaceString | xargs sed -i "s|cmSystemTools::ReplaceString(\([^,]*\), \"\\\\\\\\\", \"\(.\)\");|std::replace(\1.begin(), \1.end(), '\\\\\\\\', '\2');|g"
2016-05-24 23:58:11 +03:00
|
|
|
std::replace(ret.begin(), ret.end(), '/', '\\');
|
2012-11-29 19:36:20 +04:00
|
|
|
return ret;
|
|
|
|
}
|