1
0
mirror of https://github.com/VCMP-SqMod/SqMod.git synced 2025-06-24 19:17:12 +02:00

Update POCO library.

This commit is contained in:
Sandu Liviu Catalin
2023-03-23 20:19:11 +02:00
parent 8d15f4b6e9
commit 233fc103f9
2521 changed files with 257092 additions and 72789 deletions

View File

@ -3,7 +3,7 @@
//
// Visual Studio project file generator.
//
// Copyright (c) 2010, Applied Informatics Software Engineering GmbH.
// Copyright (c) 2010-2022, Applied Informatics Software Engineering GmbH.
// and Contributors.
//
// SPDX-License-Identifier: BSL-1.0
@ -60,19 +60,19 @@ using Poco::StringTokenizer;
class ProGenApp: public Application
{
public:
ProGenApp():
ProGenApp():
_helpRequested(false),
_outputDir(Poco::Path::current())
{
}
protected:
protected:
void initialize(Application& self)
{
loadConfiguration(); // load default configuration files, if present
Application::initialize(self);
}
void defineOptions(OptionSet& options)
{
Application::defineOptions(options);
@ -84,7 +84,7 @@ protected:
.callback(OptionCallback<ProGenApp>(this, &ProGenApp::handleHelp)));
options.addOption(
Option("define", "D",
Option("define", "D",
"Define a configuration property. A configuration property "
"defined with this option can be referenced in the project "
"properties file, using the following syntax: ${<name>}.")
@ -92,7 +92,7 @@ protected:
.repeatable(true)
.argument("<name>=<value>")
.callback(OptionCallback<ProGenApp>(this, &ProGenApp::handleDefine)));
options.addOption(
Option("output-dir", "o", "Write project files to directory <dir>.")
.required(false)
@ -114,23 +114,23 @@ protected:
.argument("<tool>{,<tool>}")
.callback(OptionCallback<ProGenApp>(this, &ProGenApp::handleTool)));
}
void handleHelp(const std::string& name, const std::string& value)
{
_helpRequested = true;
stopOptionsProcessing();
}
void handleDefine(const std::string& name, const std::string& value)
{
defineProperty(value);
}
void handleOutputDir(const std::string& name, const std::string& value)
{
_outputDir = value;
}
void handlePlatform(const std::string& name, const std::string& value)
{
Poco::StringTokenizer tok(value, ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
@ -151,19 +151,19 @@ protected:
helpFormatter.setHeader(
"\n"
"The POCO C++ Libraries Visual Studio Project File Generator.\n"
"Copyright (c) 2010-2020 by Applied Informatics Software Engineering GmbH.\n"
"Copyright (c) 2010-2022 by Applied Informatics Software Engineering GmbH.\n"
"All rights reserved.\n\n"
"This program generates project and solution files "
"for Visual Studio .NET 2003, 2005, 2008 and 2010, 2012, 2013 and 2015 from "
"global project templates and project-specific property files."
"for Visual Studio 2010 - 2022 from global project "
"templates and project-specific property files."
);
helpFormatter.setFooter(
"For more information, please see the POCO C++ Libraries "
"documentation at <http://pocoproject.org/docs/>."
"documentation at <https://pocoproject.org/docs/>."
);
helpFormatter.format(std::cout);
}
void defineProperty(const std::string& def)
{
std::string name;
@ -177,7 +177,7 @@ protected:
else name = def;
config().setString(name, value);
}
Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> loadProjectConfig(const Poco::Path& configPath)
{
Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> pConfig = new Poco::Util::PropertyFileConfiguration(configPath.toString());
@ -188,7 +188,7 @@ protected:
pConfig->setString("vc.project.guidFromName", Poco::toUpper(nameUUID.toString()));
return pConfig;
}
void expandAttributes(Poco::XML::Element* pRootElement, Poco::Util::AbstractConfiguration& properties)
{
Poco::XML::TreeWalker walker(pRootElement, Poco::XML::NodeFilter::SHOW_ELEMENT);
@ -205,7 +205,7 @@ protected:
pNode = walker.nextNode();
}
}
void setProperty(Poco::Util::AbstractConfiguration& properties, const std::string& name, const Poco::Util::AbstractConfiguration& projectConfig, const std::string& projectConfigName, const std::string& platformName, const std::string& archName, const std::string& configName, const std::string& delim = ";")
{
std::string value = projectConfig.getString(projectConfigName, "");
@ -247,7 +247,7 @@ protected:
properties.setString(name, value);
}
void fixFileConfigurations(Poco::XML::Node* pFilesElem, const std::string& configs, const std::set<std::string>& archs)
{
Poco::AutoPtr<Poco::XML::NodeList> pFileElems = static_cast<Poco::XML::Element*>(pFilesElem)->getElementsByTagName("File");
@ -281,7 +281,7 @@ protected:
}
}
}
void replaceFiles(Poco::XML::Node* pFilesElem, const std::string& replacements)
{
Poco::StringTokenizer replacementsTok(replacements, ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
@ -304,11 +304,11 @@ protected:
}
}
}
void generateSolution(const Poco::Path& solutionPath, const Poco::Util::AbstractConfiguration& projectConfig, const Poco::Util::AbstractConfiguration& templateProps, const std::string& platform, const std::string& tool)
{
std::string solutionGUID(config().getString("progen.solution.applicationGUID"));
Poco::File solutionFile(solutionPath.toString());
if (solutionFile.exists())
{
@ -330,8 +330,13 @@ protected:
solutionStream << "Microsoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio Version 16\r\n";
generateSolution80(solutionStream, solutionPath, solutionGUID, projectConfig, templateProps, platform, tool);
}
else if (tool == "vs170")
{
solutionStream << "Microsoft Visual Studio Solution File, Format Version 12.00\r\n# Visual Studio Version 17\r\n";
generateSolution80(solutionStream, solutionPath, solutionGUID, projectConfig, templateProps, platform, tool);
}
}
void generateSolution80(std::ostream& solutionStream, const Poco::Path& solutionPath, const std::string& solutionGUID, const Poco::Util::AbstractConfiguration& projectConfig, const Poco::Util::AbstractConfiguration& templateProps, const std::string& platform, const std::string& tool)
{
std::vector<std::string> dependencies;
@ -346,7 +351,7 @@ protected:
solutionStream << "EndProject\r\n";
dependencies.push_back(projectGUID);
includesHaveDependencies = true;
}
}
std::string includes = projectConfig.getString("vc.solution.include", "");
Poco::StringTokenizer includesTokenizer(includes, ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
for (const auto& incl: includesTokenizer)
@ -370,10 +375,10 @@ protected:
solutionStream << "EndProject\r\n";
dependencies.push_back(projectGUID);
}
solutionStream << "Global\r\n";
solutionStream << "\tGlobalSection(SolutionConfigurationPlatforms) = preSolution\r\n";
Poco::StringTokenizer archTok(templateProps.getString("project.architectures"), ";,", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
std::set<std::string> archs(archTok.begin(), archTok.end());
@ -404,7 +409,7 @@ protected:
solutionStream << "\tGlobalSection(SolutionProperties) = preSolution\r\n";
solutionStream << "\t\tHideSolutionNode = FALSE\r\n";
solutionStream << "\tEndGlobalSection\r\n";
solutionStream << "EndGlobal\r\n";
solutionStream << "EndGlobal\r\n";
}
void fix2010Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
@ -492,7 +497,7 @@ protected:
pClCompileElem->appendChild(pMultiProcessorCompilationElem);
}
}
void fix2012Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
{
fix2010Project(pProjectDoc, configSet, platform, projectProps, templateProps);
@ -545,7 +550,7 @@ protected:
}
}
void fix2013Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
void fix20XXProject(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps, const std::string& platformToolset)
{
fix2010Project(pProjectDoc, configSet, platform, projectProps, templateProps);
Poco::AutoPtr<Poco::XML::NodeList> pConfigurationTypeList = pProjectDoc->getElementsByTagName("ConfigurationType");
@ -553,43 +558,43 @@ protected:
{
Poco::XML::Element* pConfigurationTypeElem = static_cast<Poco::XML::Element*>(pConfigurationTypeList->item(i));
removeElement(pConfigurationTypeElem->parentNode(), "PlatformToolset");
appendElement(pConfigurationTypeElem->parentNode(), "PlatformToolset", "v120");
appendElement(pConfigurationTypeElem->parentNode(), "PlatformToolset", platformToolset);
}
}
void fix2013Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
{
fix20XXProject(pProjectDoc, configSet, platform, projectProps, templateProps, "v120");
}
void fix2015Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
{
fix2010Project(pProjectDoc, configSet, platform, projectProps, templateProps);
Poco::AutoPtr<Poco::XML::NodeList> pConfigurationTypeList = pProjectDoc->getElementsByTagName("ConfigurationType");
for (unsigned long i = 0; i < pConfigurationTypeList->length(); i++)
{
Poco::XML::Element* pConfigurationTypeElem = static_cast<Poco::XML::Element*>(pConfigurationTypeList->item(i));
removeElement(pConfigurationTypeElem->parentNode(), "PlatformToolset");
appendElement(pConfigurationTypeElem->parentNode(), "PlatformToolset", "v140");
}
fix20XXProject(pProjectDoc, configSet, platform, projectProps, templateProps, "v140");
}
void fix2017Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
{
fix2010Project(pProjectDoc, configSet, platform, projectProps, templateProps);
Poco::AutoPtr<Poco::XML::NodeList> pConfigurationTypeList = pProjectDoc->getElementsByTagName("ConfigurationType");
for (unsigned long i = 0; i < pConfigurationTypeList->length(); i++)
{
Poco::XML::Element* pConfigurationTypeElem = static_cast<Poco::XML::Element*>(pConfigurationTypeList->item(i));
removeElement(pConfigurationTypeElem->parentNode(), "PlatformToolset");
appendElement(pConfigurationTypeElem->parentNode(), "PlatformToolset", "v141");
}
fix20XXProject(pProjectDoc, configSet, platform, projectProps, templateProps, "v141");
}
void fix2019Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
{
fix2010Project(pProjectDoc, configSet, platform, projectProps, templateProps);
Poco::AutoPtr<Poco::XML::NodeList> pConfigurationTypeList = pProjectDoc->getElementsByTagName("ConfigurationType");
for (unsigned long i = 0; i < pConfigurationTypeList->length(); i++)
fix20XXProject(pProjectDoc, configSet, platform, projectProps, templateProps, "v142");
}
void fix2022Project(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::set<std::string>& configSet, const std::string& platform, const Poco::Util::AbstractConfiguration& projectProps, const Poco::Util::AbstractConfiguration& templateProps)
{
fix20XXProject(pProjectDoc, configSet, platform, projectProps, templateProps, "v143");
Poco::AutoPtr<Poco::XML::NodeList> pLinkList = pProjectDoc->getElementsByTagName("Link");
for (unsigned long i = 0; i < pLinkList->length(); i++)
{
Poco::XML::Element* pConfigurationTypeElem = static_cast<Poco::XML::Element*>(pConfigurationTypeList->item(i));
removeElement(pConfigurationTypeElem->parentNode(), "PlatformToolset");
appendElement(pConfigurationTypeElem->parentNode(), "PlatformToolset", "v142");
Poco::XML::Element* pLinkElem = static_cast<Poco::XML::Element*>(pLinkList->item(i));
Poco::XML::Element* pItemDefinitionGroupElem = static_cast<Poco::XML::Element*>(pLinkElem->parentNode());
Poco::XML::XMLString condition = pItemDefinitionGroupElem->getAttribute("Condition");
if (Poco::endsWith(condition, Poco::XML::XMLString("ARM64'")))
{
appendElement(pLinkElem, "TargetMachine", "MachineARM64");
}
}
}
@ -609,7 +614,7 @@ protected:
pParentNode->removeChild(pNode);
}
}
void writeProject(Poco::AutoPtr<Poco::XML::Document> pProjectDoc, const std::string& path)
{
Poco::XML::DOMWriter writer;
@ -618,21 +623,21 @@ protected:
writer.setIndent(" ");
writer.writeNode(path, pProjectDoc);
}
void generateProject(const Poco::Util::AbstractConfiguration& projectConfig, const Poco::Path& projectPath, const Poco::Path& templatePath, const std::string& platform, const std::string& tool)
{
Poco::File templateDir(templatePath);
if (templateDir.exists())
{
logger().information("Generating using templates from: " + templatePath.toString());
Poco::Path projectTemplatePath(templatePath);
projectTemplatePath.setFileName("project.template");
Poco::Path templatePropsPath(templatePath);
templatePropsPath.setFileName("project.properties");
Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> pTemplateProps = new Poco::Util::PropertyFileConfiguration(templatePropsPath.toString());
if (projectConfig.hasProperty("vc.project.name"))
{
Poco::StringTokenizer archTok(pTemplateProps->getString("project.architectures"), ";,", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
@ -647,7 +652,7 @@ protected:
domParser.setFeature(Poco::XML::DOMParser::FEATURE_FILTER_WHITESPACE, true);
Poco::AutoPtr<Poco::XML::Document> pPrototypeDoc = domParser.parse(prototypePath.toString());
Poco::AutoPtr<Poco::XML::Document> pProjectDoc = domParser.parse(projectTemplatePath.toString());
Poco::AutoPtr<Poco::Util::MapConfiguration> pProps = new Poco::Util::MapConfiguration;
pProps->setString("project.guid", projectConfig.getString("vc.project.guid"));
pProps->setString("project.name", projectConfig.getString("vc.project.name"));
@ -657,22 +662,22 @@ protected:
pProps->setString("project.platform", pTemplateProps->getString("project.platform", platform));
pProps->setString("project.targetPlatform", pTemplateProps->getString("project.targetPlatform", "WINDOWS_NT"));
expandAttributes(pProjectDoc->documentElement(), *pProps);
Poco::XML::Node* pFilesElement = pPrototypeDoc->getNodeByPath("//Files");
Poco::XML::Node* pFilesElement = pPrototypeDoc->getNodeByPath("//Files");
if (!pFilesElement) throw Poco::NotFoundException("No Files element found in prototype document");
pFilesElement = pProjectDoc->importNode(pFilesElement, true);
fixFileConfigurations(pFilesElement, projectConfig.getString("vc.project.configurations", ""), archs);
replaceFiles(pFilesElement, pTemplateProps->getString("project.replaceSourceFiles", ""));
Poco::XML::Node* pOldFilesElement = pProjectDoc->getNodeByPath("//Files");
Poco::XML::Node* pOldFilesElement = pProjectDoc->getNodeByPath("//Files");
if (!pOldFilesElement) throw Poco::NotFoundException("No Files element found in project document template");
Poco::XML::Node* pConfigurationsElement = pProjectDoc->getNodeByPath("//Configurations");
Poco::XML::Node* pConfigurationsElement = pProjectDoc->getNodeByPath("//Configurations");
if (!pConfigurationsElement) throw Poco::NotFoundException("No Configurations element found in project document template");
pProjectDoc->documentElement()->replaceChild(pFilesElement, pOldFilesElement);
std::set<std::string> configSet;
Poco::StringTokenizer configs(projectConfig.getString("vc.project.configurations", ""), ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
for (const auto& arch: archs)
@ -705,13 +710,13 @@ protected:
expandedDependencies += lib;
}
pProps->setString("configuration.linker.dependencies", expandedDependencies);
Poco::Path configPath(templatePath);
configPath.setBaseName(config + "-" + arch);
configPath.setExtension("template");
Poco::AutoPtr<Poco::XML::Document> pConfigDoc = domParser.parse(configPath.toString());
Poco::XML::Element* pConfigElem = pConfigDoc->documentElement();
std::string prebuild = pProps->getString("configuration.prebuild", "");
if (!prebuild.empty())
{
@ -731,13 +736,13 @@ protected:
static_cast<Poco::XML::Element*>(pPostBuildNode)->setAttribute("CommandLine", postbuild);
}
}
expandAttributes(pConfigElem, *pProps);
pConfigElem = static_cast<Poco::XML::Element*>(pProjectDoc->importNode(pConfigElem, true));
pConfigurationsElement->appendChild(pConfigElem);
}
}
std::string vcprojName = projectConfig.getString("vc.project.name");
vcprojName.append(pTemplateProps->getString("project.suffix", ""));
Poco::Path vcprojPath(projectPath);
@ -765,7 +770,7 @@ protected:
serializer.setContentHandler(&writer);
serializer.serialize(pProjectDoc);
vcprojStream.close();
std::string postprocess = pTemplateProps->getString("project.postprocess", "");
if (!postprocess.empty())
{
@ -871,6 +876,16 @@ protected:
writeProject(pProjectDoc, vcxprojPath.toString());
}
}
if (config().getBool("progen.postprocess." + postprocess + ".fix2022ProjectFile", false))
{
if (projectFile.exists())
{
logger().information("Fixing Visual Studio 2022 project file: " + vcxprojPath.toString());
Poco::AutoPtr<Poco::XML::Document> pProjectDoc = domParser.parse(vcxprojPath.toString());
fix2022Project(pProjectDoc, configSet, pTemplateProps->getString("project.platform", platform), *pProps, *pTemplateProps);
writeProject(pProjectDoc, vcxprojPath.toString());
}
}
if (config().getBool("progen.postprocess." + postprocess + ".deleteOriginalFile", false))
{
Poco::File projectFile(vcprojPath.toString());
@ -917,21 +932,21 @@ protected:
logger().information("Template directory missing: " + templatePath.toString());
}
}
void process(const std::string& configPath)
{
Poco::Path projectPath(configPath);
Poco::AutoPtr<Poco::Util::PropertyFileConfiguration> pProjectConfig = loadProjectConfig(projectPath);
Poco::StringTokenizer platforms(pProjectConfig->getString("vc.project.platforms", ""), ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY);
Poco::Path templateBasePath(config().getString("progen.templatePath"));
templateBasePath.makeDirectory();
Poco::File templateDir(templateBasePath);
std::vector<std::string> tools;
templateDir.list(tools);
for (const auto& tool: tools)
{
if (_tools.empty() || _tools.find(tool) != _tools.end())

View File

@ -25,7 +25,7 @@ VSXMLWriter::~VSXMLWriter()
{
}
void VSXMLWriter::setDocumentLocator(const Poco::XML::Locator* loc)
{
}
@ -87,7 +87,7 @@ void VSXMLWriter::startElement(const Poco::XML::XMLString& namespaceURI, const P
if (attributes.getQName(i) != "Name")
{
std::string value = attributes.getValue(i);
if (_convertBool && (value == "true" || value == "false"))
if (_convertBool && (value == "true" || value == "false"))
value = Poco::toUpper(value);
sortedAttributes.addAttribute(attributes.getURI(i), attributes.getLocalName(i), attributes.getQName(i), attributes.getType(i), value);
}

View File

@ -28,7 +28,7 @@ class VSXMLWriter: public Poco::XML::ContentHandler
public:
VSXMLWriter(std::ostream& ostr, bool convertBool);
~VSXMLWriter();
// ContentHandler
void setDocumentLocator(const Poco::XML::Locator* loc);
void startDocument();