// // ProGen.cpp // // Visual Studio project file generator. // // Copyright (c) 2010, Applied Informatics Software Engineering GmbH. // and Contributors. // // SPDX-License-Identifier: BSL-1.0 // #include "Poco/Util/Application.h" #include "Poco/Util/Option.h" #include "Poco/Util/OptionSet.h" #include "Poco/Util/HelpFormatter.h" #include "Poco/Util/AbstractConfiguration.h" #include "Poco/Util/MapConfiguration.h" #include "Poco/Util/PropertyFileConfiguration.h" #include "Poco/DOM/Document.h" #include "Poco/DOM/Element.h" #include "Poco/DOM/NamedNodeMap.h" #include "Poco/DOM/Attr.h" #include "Poco/DOM/Text.h" #include "Poco/DOM/DOMParser.h" #include "Poco/DOM/DOMSerializer.h" #include "Poco/DOM/DOMWriter.h" #include "Poco/DOM/TreeWalker.h" #include "Poco/DOM/NodeFilter.h" #include "Poco/DOM/NodeList.h" #include "Poco/XML/XMLWriter.h" #include "Poco/Windows1252Encoding.h" #include "Poco/AutoPtr.h" #include "Poco/FileStream.h" #include "Poco/Path.h" #include "Poco/File.h" #include "Poco/StringTokenizer.h" #include "Poco/UUIDGenerator.h" #include "Poco/UUID.h" #include "Poco/String.h" #include "Poco/Process.h" #include "VSXMLWriter.h" #include #include using Poco::Util::Application; using Poco::Util::Option; using Poco::Util::OptionSet; using Poco::Util::HelpFormatter; using Poco::Util::AbstractConfiguration; using Poco::Util::OptionCallback; using Poco::AutoPtr; using Poco::FileInputStream; using Poco::FileOutputStream; using Poco::Path; using Poco::StringTokenizer; class ProGenApp: public Application { public: ProGenApp(): _helpRequested(false), _outputDir(Poco::Path::current()) { } protected: void initialize(Application& self) { loadConfiguration(); // load default configuration files, if present Application::initialize(self); } void defineOptions(OptionSet& options) { Application::defineOptions(options); options.addOption( Option("help", "h", "Display help information on command line arguments.") .required(false) .repeatable(false) .callback(OptionCallback(this, &ProGenApp::handleHelp))); options.addOption( 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: ${}.") .required(false) .repeatable(true) .argument("=") .callback(OptionCallback(this, &ProGenApp::handleDefine))); options.addOption( Option("output-dir", "o", "Write project files to directory .") .required(false) .repeatable(false) .argument("") .callback(OptionCallback(this, &ProGenApp::handleOutputDir))); options.addOption( Option("platform", "p", "Generate project files for specified platforms only.") .required(false) .repeatable(true) .argument("{,}") .callback(OptionCallback(this, &ProGenApp::handlePlatform))); options.addOption( Option("tool", "t", "Generate project files for specified tools only.") .required(false) .repeatable(true) .argument("{,}") .callback(OptionCallback(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); _platforms.insert(tok.begin(), tok.end()); } void handleTool(const std::string& name, const std::string& value) { Poco::StringTokenizer tok(value, ",;", Poco::StringTokenizer::TOK_TRIM | Poco::StringTokenizer::TOK_IGNORE_EMPTY); _tools.insert(tok.begin(), tok.end()); } void displayHelp() { HelpFormatter helpFormatter(options()); helpFormatter.setCommand(commandName()); helpFormatter.setUsage("[