VS: Add parser for WCE.VCPlatform.config to read WinCE platforms

Parse the WCE.VCPlatform.config file, which contains the installed
WindowsCE SDKs in XML format, and add possibility to generate
Visual Studio generators for them.
This commit is contained in:
Patrick Gansterer 2012-11-20 13:12:27 +01:00 committed by Brad King
parent 2118a2016f
commit 6fe4fcba78
7 changed files with 297 additions and 24 deletions

View File

@ -353,6 +353,8 @@ if (WIN32)
cmLocalVisualStudio7Generator.h
cmLocalVisualStudioGenerator.cxx
cmLocalVisualStudioGenerator.h
cmVisualStudioWCEPlatformParser.h
cmVisualStudioWCEPlatformParser.cxx
cmWin32ProcessExecution.cxx
cmWin32ProcessExecution.h
)

View File

@ -13,32 +13,57 @@
#include "cmGlobalVisualStudio8Generator.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
#include "cmVisualStudioWCEPlatformParser.h"
#include "cmake.h"
#include "cmGeneratedFileStream.h"
static const char vs8Win32generatorName[] = "Visual Studio 8 2005";
static const char vs8Win64generatorName[] = "Visual Studio 8 2005 Win64";
static const char vs8generatorName[] = "Visual Studio 8 2005";
class cmGlobalVisualStudio8Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
if(!strcmp(name, vs8Win32generatorName))
if(strstr(name, vs8generatorName) != name)
{
return 0;
}
const char* p = name + sizeof(vs8generatorName) - 1;
if(p[0] == '\0')
{
return new cmGlobalVisualStudio8Generator(
vs8Win32generatorName, NULL, NULL);
name, NULL, NULL);
}
if(!strcmp(name, vs8Win64generatorName))
if(p[0] != ' ')
{
return 0;
}
++p;
if(!strcmp(p, "Win64"))
{
return new cmGlobalVisualStudio8Generator(
vs8Win64generatorName, "x64", "CMAKE_FORCE_WIN64");
name, "x64", "CMAKE_FORCE_WIN64");
}
return 0;
cmVisualStudioWCEPlatformParser parser(p);
parser.ParseVersion("8.0");
if (!parser.Found())
{
return 0;
}
cmGlobalVisualStudio8Generator* ret = new cmGlobalVisualStudio8Generator(
name, parser.GetArchitectureFamily(), NULL);
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
entry.Name = "Visual Studio 8 2005";
entry.Name = vs8generatorName;
entry.Brief = "Generates Visual Studio 8 2005 project files.";
entry.Full =
"It is possible to append a space followed by the platform name "
@ -48,8 +73,18 @@ public:
}
virtual void GetGenerators(std::vector<std::string>& names) const {
names.push_back(vs8Win32generatorName);
names.push_back(vs8Win64generatorName); }
names.push_back(vs8generatorName);
names.push_back(vs8generatorName + std::string(" Win64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("8.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for(std::vector<std::string>::const_iterator i =
availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
{
names.push_back("Visual Studio 8 2005 " + *i);
}
}
};
//----------------------------------------------------------------------------

View File

@ -64,6 +64,10 @@ public:
LinkLibraryDependencies and link to .sln dependencies. */
virtual bool NeedLinkLibraryDependencies(cmTarget& target);
/** Return true if building for Windows CE */
virtual bool TargetsWindowsCE() const {
return !this->WindowsCEVersion.empty(); }
protected:
virtual const char* GetIDEVersion() { return "8.0"; }
@ -83,8 +87,10 @@ protected:
const char* path, cmTarget &t);
std::string Name;
std::string WindowsCEVersion;
private:
class Factory;
friend class Factory;
};
#endif

View File

@ -13,37 +13,62 @@
#include "cmGlobalVisualStudio9Generator.h"
#include "cmLocalVisualStudio7Generator.h"
#include "cmMakefile.h"
#include "cmVisualStudioWCEPlatformParser.h"
#include "cmake.h"
static const char vs9Win32generatorName[] = "Visual Studio 9 2008";
static const char vs9Win64generatorName[] = "Visual Studio 8 2005 Win64";
static const char vs9IA64generatorName[] = "Visual Studio 9 2008 IA64";
static const char vs9generatorName[] = "Visual Studio 9 2008";
class cmGlobalVisualStudio9Generator::Factory
: public cmGlobalGeneratorFactory
{
public:
virtual cmGlobalGenerator* CreateGlobalGenerator(const char* name) const {
if(!strcmp(name, vs9Win32generatorName))
if(strstr(name, vs9generatorName) != name)
{
return 0;
}
const char* p = name + sizeof(vs9generatorName) - 1;
if(p[0] == '\0')
{
return new cmGlobalVisualStudio9Generator(
vs9Win32generatorName, NULL, NULL);
name, NULL, NULL);
}
if(!strcmp(name, vs9Win64generatorName))
if(p[0] != ' ')
{
return 0;
}
++p;
if(!strcmp(p, "IA64"))
{
return new cmGlobalVisualStudio9Generator(
vs9Win64generatorName, "x64", "CMAKE_FORCE_WIN64");
name, "Itanium", "CMAKE_FORCE_IA64");
}
if(!strcmp(name, vs9IA64generatorName))
if(!strcmp(p, "Win64"))
{
return new cmGlobalVisualStudio9Generator(
vs9IA64generatorName, "Itanium", "CMAKE_FORCE_IA64");
name, "x64", "CMAKE_FORCE_WIN64");
}
return 0;
cmVisualStudioWCEPlatformParser parser(p);
parser.ParseVersion("9.0");
if (!parser.Found())
{
return 0;
}
cmGlobalVisualStudio9Generator* ret = new cmGlobalVisualStudio9Generator(
name, parser.GetArchitectureFamily(), NULL);
ret->WindowsCEVersion = parser.GetOSVersion();
return ret;
}
virtual void GetDocumentation(cmDocumentationEntry& entry) const {
entry.Name = "Visual Studio 9 2008";
entry.Name = vs9generatorName;
entry.Brief = "Generates Visual Studio 9 2008 project files.";
entry.Full =
"It is possible to append a space followed by the platform name "
@ -53,9 +78,19 @@ public:
}
virtual void GetGenerators(std::vector<std::string>& names) const {
names.push_back(vs9Win32generatorName);
names.push_back(vs9Win64generatorName);
names.push_back(vs9IA64generatorName); }
names.push_back(vs9generatorName);
names.push_back(vs9generatorName + std::string(" Win64"));
names.push_back(vs9generatorName + std::string(" IA64"));
cmVisualStudioWCEPlatformParser parser;
parser.ParseVersion("9.0");
const std::vector<std::string>& availablePlatforms =
parser.GetAvailablePlatforms();
for(std::vector<std::string>::const_iterator i =
availablePlatforms.begin(); i != availablePlatforms.end(); ++i)
{
names.push_back("Visual Studio 9 2008 " + *i);
}
}
};
//----------------------------------------------------------------------------

View File

@ -55,5 +55,6 @@ protected:
virtual const char* GetIDEVersion() { return "9.0"; }
private:
class Factory;
friend class Factory;
};
#endif

View File

@ -0,0 +1,139 @@
/*============================================================================
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"
#include "cmGlobalVisualStudioGenerator.h"
#include "cmXMLParser.h"
int cmVisualStudioWCEPlatformParser::ParseVersion(const char* version)
{
std::string vskey = cmGlobalVisualStudioGenerator::GetRegistryBase(version);
vskey += "\\Setup\\VS;ProductDir";
std::string vsInstallPath;
if(!cmSystemTools::ReadRegistryValue(vskey.c_str(), vsInstallPath))
{
return 0;
}
cmSystemTools::ConvertToUnixSlashes(vsInstallPath);
const std::string configFilename =
vsInstallPath + "/VC/vcpackages/WCE.VCPlatform.config";
return this->ParseFile(configFilename.c_str());
}
std::string cmVisualStudioWCEPlatformParser::GetOSVersion() const
{
if (this->OSMinorVersion.empty())
{
return OSMajorVersion;
}
return OSMajorVersion + "." + OSMinorVersion;
}
const char* cmVisualStudioWCEPlatformParser::GetArchitectureFamily() const
{
std::map<std::string, std::string>::const_iterator it =
this->Macros.find("ARCHFAM");
if (it != this->Macros.end())
{
return it->second.c_str();
}
return 0;
}
void cmVisualStudioWCEPlatformParser::StartElement(const char* name,
const char** attributes)
{
if(this->FoundRequiredName)
{
return;
}
this->CharacterData = "";
if(strcmp(name, "PlatformData") == 0)
{
this->PlatformName = "";
this->OSMajorVersion = "";
this->OSMinorVersion = "";
this->Macros.clear();
}
if(strcmp(name, "Macro") == 0)
{
std::string macroName;
std::string macroValue;
for(const char** attr = attributes; *attr; attr += 2)
{
if(strcmp(attr[0], "Name") == 0)
{
macroName = attr[1];
}
else if(strcmp(attr[0], "Value") == 0)
{
macroValue = attr[1];
}
}
if(!macroName.empty())
{
this->Macros[macroName] = macroValue;
}
}
}
void cmVisualStudioWCEPlatformParser::EndElement(const char* name)
{
if(!this->RequiredName)
{
if(strcmp(name, "PlatformName") == 0)
{
this->AvailablePlatforms.push_back(this->CharacterData);
}
return;
}
if(this->FoundRequiredName)
{
return;
}
if(strcmp(name, "PlatformName") == 0)
{
this->PlatformName = this->CharacterData;
}
else if(strcmp(name, "OSMajorVersion") == 0)
{
this->OSMajorVersion = this->CharacterData;
}
else if(strcmp(name, "OSMinorVersion") == 0)
{
this->OSMinorVersion = this->CharacterData;
}
else if(strcmp(name, "Platform") == 0)
{
if(this->PlatformName == this->RequiredName)
{
this->FoundRequiredName = true;
}
}
}
void cmVisualStudioWCEPlatformParser::CharacterDataHandler(const char* data,
int length)
{
this->CharacterData.append(data, length);
}

View File

@ -0,0 +1,55 @@
/*============================================================================
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.
============================================================================*/
#ifndef cmVisualStudioWCEPlatformParser_h
#define cmVisualStudioWCEPlatformParser_h
#include "cmStandardIncludes.h"
#include "cmXMLParser.h"
// This class is used to parse XML with configuration
// of installed SDKs in system
class cmVisualStudioWCEPlatformParser : public cmXMLParser
{
public:
cmVisualStudioWCEPlatformParser(const char* name = NULL)
: RequiredName(name)
, FoundRequiredName(false)
{
}
int ParseVersion(const char* version);
bool Found() const {return this->FoundRequiredName;}
const char* GetArchitectureFamily() const;
std::string GetOSVersion() const;
const std::vector<std::string>& GetAvailablePlatforms() const {
return this->AvailablePlatforms; }
protected:
virtual void StartElement(const char* name, const char** attributes);
void EndElement(const char* name);
void CharacterDataHandler(const char* data, int length);
private:
std::string CharacterData;
std::string PlatformName;
std::string OSMajorVersion;
std::string OSMinorVersion;
std::map<std::string, std::string> Macros;
std::vector<std::string> AvailablePlatforms;
const char* RequiredName;
bool FoundRequiredName;
};
#endif