diff options
-rw-r--r-- | Source/CMakeLists.txt | 17 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWCommon.cxx | 86 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWCommon.h | 65 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.cxx | 113 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.h | 30 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.cxx | 72 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.h | 17 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.cxx | 93 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.h | 20 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWRepository.cxx | 48 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWRepository.h | 16 |
11 files changed, 251 insertions, 326 deletions
diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 1ea75bf..40403ca 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -867,10 +867,6 @@ set(CPACK_SRCS CPack/cmCPackGenerator.cxx CPack/cmCPackLog.cxx CPack/cmCPackNSISGenerator.cxx - CPack/IFW/cmCPackIFWPackage.cxx - CPack/IFW/cmCPackIFWInstaller.cxx - CPack/IFW/cmCPackIFWRepository.cxx - CPack/IFW/cmCPackIFWGenerator.cxx CPack/cmCPackSTGZGenerator.cxx CPack/cmCPackTGZGenerator.cxx CPack/cmCPackTXZGenerator.cxx @@ -879,6 +875,19 @@ set(CPACK_SRCS CPack/cmCPackZIPGenerator.cxx CPack/cmCPack7zGenerator.cxx ) +# CPack IFW generator +set(CPACK_SRCS ${CPACK_SRCS} + CPack/IFW/cmCPackIFWCommon.cxx + CPack/IFW/cmCPackIFWCommon.h + CPack/IFW/cmCPackIFWGenerator.cxx + CPack/IFW/cmCPackIFWGenerator.h + CPack/IFW/cmCPackIFWInstaller.cxx + CPack/IFW/cmCPackIFWInstaller.h + CPack/IFW/cmCPackIFWPackage.cxx + CPack/IFW/cmCPackIFWPackage.h + CPack/IFW/cmCPackIFWRepository.cxx + CPack/IFW/cmCPackIFWRepository.h + ) if(CYGWIN) set(CPACK_SRCS ${CPACK_SRCS} diff --git a/Source/CPack/IFW/cmCPackIFWCommon.cxx b/Source/CPack/IFW/cmCPackIFWCommon.cxx new file mode 100644 index 0000000..60954ea --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWCommon.cxx @@ -0,0 +1,86 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#include "cmCPackIFWCommon.h" + +#include "cmCPackGenerator.h" +#include "cmCPackIFWGenerator.h" +#include "cmCPackLog.h" // IWYU pragma: keep +#include "cmSystemTools.h" +#include "cmTimestamp.h" +#include "cmVersionConfig.h" +#include "cmXMLWriter.h" + +#include <sstream> + +cmCPackIFWCommon::cmCPackIFWCommon() + : Generator(CM_NULLPTR) +{ +} + +const char* cmCPackIFWCommon::GetOption(const std::string& op) const +{ + return Generator ? Generator->cmCPackGenerator::GetOption(op) : CM_NULLPTR; +} + +bool cmCPackIFWCommon::IsOn(const std::string& op) const +{ + return Generator ? Generator->cmCPackGenerator::IsOn(op) : false; +} + +bool cmCPackIFWCommon::IsSetToOff(const std::string& op) const +{ + return Generator ? Generator->cmCPackGenerator::IsSetToOff(op) : false; +} + +bool cmCPackIFWCommon::IsSetToEmpty(const std::string& op) const +{ + return Generator ? Generator->cmCPackGenerator::IsSetToEmpty(op) : false; +} + +bool cmCPackIFWCommon::IsVersionLess(const char* version) +{ + if (!Generator) { + return false; + } + + return cmSystemTools::VersionCompare( + cmSystemTools::OP_LESS, Generator->FrameworkVersion.data(), version); +} + +bool cmCPackIFWCommon::IsVersionGreater(const char* version) +{ + if (!Generator) { + return false; + } + + return cmSystemTools::VersionCompare( + cmSystemTools::OP_GREATER, Generator->FrameworkVersion.data(), version); +} + +bool cmCPackIFWCommon::IsVersionEqual(const char* version) +{ + if (!Generator) { + return false; + } + + return cmSystemTools::VersionCompare( + cmSystemTools::OP_EQUAL, Generator->FrameworkVersion.data(), version); +} + +void cmCPackIFWCommon::WriteGeneratedByToStrim(cmXMLWriter& xout) +{ + if (!Generator) { + return; + } + + std::ostringstream comment; + comment << "Generated by CPack " << CMake_VERSION << " IFW generator " + << "for QtIFW "; + if (IsVersionEqual("1.9.9")) { + comment << "less 2.0"; + } else { + comment << Generator->FrameworkVersion; + } + comment << " tools at " << cmTimestamp().CurrentTime("", true); + xout.Comment(comment.str().c_str()); +} diff --git a/Source/CPack/IFW/cmCPackIFWCommon.h b/Source/CPack/IFW/cmCPackIFWCommon.h new file mode 100644 index 0000000..66b6e89 --- /dev/null +++ b/Source/CPack/IFW/cmCPackIFWCommon.h @@ -0,0 +1,65 @@ +/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying + file Copyright.txt or https://cmake.org/licensing for details. */ +#ifndef cmCPackIFWCommon_h +#define cmCPackIFWCommon_h + +#include "cmConfigure.h" // IWYU pragma: keep + +#include <string> + +class cmCPackIFWGenerator; +class cmXMLWriter; + +/** \class cmCPackIFWCommon + * \brief A base class for CPack IFW generator implementation subclasses + */ +class cmCPackIFWCommon +{ +public: + // Constructor + + /** + * Construct Part + */ + cmCPackIFWCommon(); + +public: + // Internal implementation + + const char* GetOption(const std::string& op) const; + bool IsOn(const std::string& op) const; + bool IsSetToOff(const std::string& op) const; + bool IsSetToEmpty(const std::string& op) const; + + /** + * Compare \a version with QtIFW framework version + */ + bool IsVersionLess(const char* version); + + /** + * Compare \a version with QtIFW framework version + */ + bool IsVersionGreater(const char* version); + + /** + * Compare \a version with QtIFW framework version + */ + bool IsVersionEqual(const char* version); + + cmCPackIFWGenerator* Generator; + +protected: + void WriteGeneratedByToStrim(cmXMLWriter& xout); +}; + +#define cmCPackIFWLogger(logType, msg) \ + do { \ + std::ostringstream cmCPackLog_msg; \ + cmCPackLog_msg << msg; \ + if (Generator) { \ + Generator->Logger->Log(cmCPackLog::LOG_##logType, __FILE__, __LINE__, \ + cmCPackLog_msg.str().c_str()); \ + } \ + } while (false) + +#endif // cmCPackIFWCommon_h diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index fa8982f..a9628d6 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -4,48 +4,29 @@ #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" +#include "cmCPackIFWCommon.h" #include "cmCPackIFWInstaller.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" -#include "cmCPackLog.h" +#include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" -#include "cmTimestamp.h" -#include "cmVersionConfig.h" -#include "cmXMLWriter.h" #include <sstream> #include <utility> cmCPackIFWGenerator::cmCPackIFWGenerator() { + Generator = this; } cmCPackIFWGenerator::~cmCPackIFWGenerator() { } -bool cmCPackIFWGenerator::IsVersionLess(const char* version) -{ - return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - FrameworkVersion.data(), version); -} - -bool cmCPackIFWGenerator::IsVersionGreater(const char* version) -{ - return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER, - FrameworkVersion.data(), version); -} - -bool cmCPackIFWGenerator::IsVersionEqual(const char* version) -{ - return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, - FrameworkVersion.data(), version); -} - int cmCPackIFWGenerator::PackageFiles() { - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Configuration" << std::endl); + cmCPackIFWLogger(OUTPUT, "- Configuration" << std::endl); // Installer configuragion Installer.GenerateInstallerFile(); @@ -85,11 +66,10 @@ int cmCPackIFWGenerator::PackageFiles() } } ifwCmd += " " + this->toplevel + "/repository"; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl); + cmCPackIFWLogger(VERBOSE, "Execute: " << ifwCmd << std::endl); std::string output; int retVal = 1; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository" - << std::endl); + cmCPackIFWLogger(OUTPUT, "- Generate repository" << std::endl); bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output, &output, &retVal, CM_NULLPTR, this->GeneratorVerbose, 0); @@ -98,22 +78,24 @@ int cmCPackIFWGenerator::PackageFiles() ofs << "# Run command: " << ifwCmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: " - << ifwCmd << std::endl - << "Please check " << ifwTmpFile << " for errors" - << std::endl); + cmCPackIFWLogger(ERROR, "Problem running IFW command: " + << ifwCmd << std::endl + << "Please check " << ifwTmpFile << " for errors" + << std::endl); return 0; } if (!Repository.RepositoryUpdate.empty() && !Repository.PatchUpdatesXml()) { - cmCPackLogger(cmCPackLog::LOG_WARNING, "Problem patch IFW \"Updates\" " - << "file: " << this->toplevel + "/repository/Updates.xml" - << std::endl); + cmCPackIFWLogger(WARNING, "Problem patch IFW \"Updates\" " + << "file: " + << this->toplevel + "/repository/Updates.xml" + << std::endl); } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " - << this->toplevel << "/repository generated" << std::endl); + cmCPackIFWLogger(OUTPUT, "- repository: " << this->toplevel + << "/repository generated" + << std::endl); } // Run binary creator @@ -177,10 +159,10 @@ int cmCPackIFWGenerator::PackageFiles() } else { ifwCmd += " installer"; } - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl); + cmCPackIFWLogger(VERBOSE, "Execute: " << ifwCmd << std::endl); std::string output; int retVal = 1; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl); + cmCPackIFWLogger(OUTPUT, "- Generate package" << std::endl); bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output, &output, &retVal, CM_NULLPTR, this->GeneratorVerbose, 0); @@ -189,10 +171,10 @@ int cmCPackIFWGenerator::PackageFiles() ofs << "# Run command: " << ifwCmd << std::endl << "# Output:" << std::endl << output << std::endl; - cmCPackLogger(cmCPackLog::LOG_ERROR, "Problem running IFW command: " - << ifwCmd << std::endl - << "Please check " << ifwTmpFile << " for errors" - << std::endl); + cmCPackIFWLogger(ERROR, "Problem running IFW command: " + << ifwCmd << std::endl + << "Please check " << ifwTmpFile << " for errors" + << std::endl); return 0; } } @@ -243,10 +225,9 @@ int cmCPackIFWGenerator::InitializeInternal() } if (BinCreator.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot find QtIFW compiler \"binarycreator\": " - "likely it is not installed, or not in your PATH" - << std::endl); + cmCPackIFWLogger(ERROR, "Cannot find QtIFW compiler \"binarycreator\": " + "likely it is not installed, or not in your PATH" + << std::endl); return 0; } @@ -309,10 +290,10 @@ int cmCPackIFWGenerator::InitializeInternal() } if (!Installer.RemoteRepositories.empty() && RepoGen.empty()) { - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot find QtIFW repository generator \"repogen\": " - "likely it is not installed, or not in your PATH" - << std::endl); + cmCPackIFWLogger(ERROR, + "Cannot find QtIFW repository generator \"repogen\": " + "likely it is not installed, or not in your PATH" + << std::endl); return 0; } @@ -381,9 +362,9 @@ cmCPackComponent* cmCPackIFWGenerator::GetComponent( } } else { Packages.erase(name); - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \"" - << name << "\" for component \"" << component->Name << "\"" - << std::endl); + cmCPackIFWLogger(ERROR, "Cannot configure package \"" + << name << "\" for component \"" << component->Name + << "\"" << std::endl); } return component; @@ -416,9 +397,9 @@ cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup( BinaryPackages.insert(package); } else { Packages.erase(name); - cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \"" - << name << "\" for component group \"" << group->Name - << "\"" << std::endl); + cmCPackIFWLogger(ERROR, "Cannot configure package \"" + << name << "\" for component group \"" << group->Name + << "\"" << std::endl); } return group; } @@ -561,24 +542,10 @@ cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository( } else { Repositories.erase(repositoryName); repository = CM_NULLPTR; - cmCPackLogger(cmCPackLog::LOG_WARNING, "Invalid repository \"" - << repositoryName << "\"" - << " configuration. Repository will be skipped." - << std::endl); + cmCPackIFWLogger(WARNING, "Invalid repository \"" + << repositoryName << "\"" + << " configuration. Repository will be skipped." + << std::endl); } return repository; } - -void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout) -{ - std::ostringstream comment; - comment << "Generated by CPack " << CMake_VERSION << " IFW generator " - << "for QtIFW "; - if (IsVersionLess("2.0")) { - comment << "less 2.0"; - } else { - comment << FrameworkVersion; - } - comment << " tools at " << cmTimestamp().CurrentTime("", true); - xout.Comment(comment.str().c_str()); -} diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.h b/Source/CPack/IFW/cmCPackIFWGenerator.h index 688db4b..8348cee 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -3,10 +3,11 @@ #ifndef cmCPackIFWGenerator_h #define cmCPackIFWGenerator_h -#include "cmConfigure.h" +#include "cmConfigure.h" // IWYU pragma: keep #include "cmCPackComponentGroup.h" #include "cmCPackGenerator.h" +#include "cmCPackIFWCommon.h" #include "cmCPackIFWInstaller.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" @@ -16,14 +17,12 @@ #include <string> #include <vector> -class cmXMLWriter; - /** \class cmCPackIFWGenerator * \brief A generator for Qt Installer Framework tools * * http://qt-project.org/doc/qtinstallerframework/index.html */ -class cmCPackIFWGenerator : public cmCPackGenerator +class cmCPackIFWGenerator : public cmCPackGenerator, public cmCPackIFWCommon { public: cmCPackTypeMacro(cmCPackIFWGenerator, cmCPackGenerator); @@ -35,6 +34,11 @@ public: typedef std::map<std::string, cmCPackIFWPackage::DependenceStruct> DependenceMap; + using cmCPackIFWCommon::GetOption; + using cmCPackIFWCommon::IsOn; + using cmCPackIFWCommon::IsSetToOff; + using cmCPackIFWCommon::IsSetToEmpty; + /** * Construct IFW generator */ @@ -45,21 +49,6 @@ public: */ ~cmCPackIFWGenerator() CM_OVERRIDE; - /** - * Compare \a version with QtIFW framework version - */ - bool IsVersionLess(const char* version); - - /** - * Compare \a version with QtIFW framework version - */ - bool IsVersionGreater(const char* version); - - /** - * Compare \a version with QtIFW framework version - */ - bool IsVersionEqual(const char* version); - protected: // cmCPackGenerator reimplementation @@ -124,12 +113,11 @@ protected: cmCPackIFWRepository* GetRepository(const std::string& repositoryName); - void WriteGeneratedByToStrim(cmXMLWriter& xout); - protected: // Data friend class cmCPackIFWPackage; + friend class cmCPackIFWCommon; friend class cmCPackIFWInstaller; friend class cmCPackIFWRepository; diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index 5e5f066..317137f 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -2,69 +2,29 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWInstaller.h" -#include "cmConfigure.h" -#include <sstream> -#include <stddef.h> -#include <utility> - -#include "cmCPackGenerator.h" +#include "cmCPackIFWCommon.h" #include "cmCPackIFWGenerator.h" #include "cmCPackIFWPackage.h" #include "cmCPackIFWRepository.h" -#include "cmCPackLog.h" +#include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmXMLParser.h" #include "cmXMLWriter.h" -#ifdef cmCPackLogger -#undef cmCPackLogger -#endif -#define cmCPackLogger(logType, msg) \ - do { \ - std::ostringstream cmCPackLog_msg; \ - cmCPackLog_msg << msg; \ - if (Generator) { \ - Generator->Logger->Log(logType, __FILE__, __LINE__, \ - cmCPackLog_msg.str().c_str()); \ - } \ - } while (false) +#include <sstream> +#include <stddef.h> +#include <utility> cmCPackIFWInstaller::cmCPackIFWInstaller() - : Generator(CM_NULLPTR) -{ -} - -const char* cmCPackIFWInstaller::GetOption(const std::string& op) const -{ - return Generator ? Generator->GetOption(op) : CM_NULLPTR; -} - -bool cmCPackIFWInstaller::IsOn(const std::string& op) const { - return Generator ? Generator->IsOn(op) : false; -} - -bool cmCPackIFWInstaller::IsVersionLess(const char* version) -{ - return Generator ? Generator->IsVersionLess(version) : false; -} - -bool cmCPackIFWInstaller::IsVersionGreater(const char* version) -{ - return Generator ? Generator->IsVersionGreater(version) : false; -} - -bool cmCPackIFWInstaller::IsVersionEqual(const char* version) -{ - return Generator ? Generator->IsVersionEqual(version) : false; } void cmCPackIFWInstaller::printSkippedOptionWarning( const std::string& optionName, const std::string& optionValue) { - cmCPackLogger( - cmCPackLog::LOG_WARNING, "Option " + cmCPackIFWLogger( + WARNING, "Option " << optionName << " is set to \"" << optionValue << "\" but will be skipped because the specified file does not exist." << std::endl); @@ -176,9 +136,8 @@ void cmCPackIFWInstaller::ConfigureFromOptions() // Check known values if (WizardStyle != "Modern" && WizardStyle != "Aero" && WizardStyle != "Mac" && WizardStyle != "Classic") { - cmCPackLogger( - cmCPackLog::LOG_WARNING, - "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \"" + cmCPackIFWLogger( + WARNING, "Option CPACK_IFW_PACKAGE_WIZARD_STYLE has unknown value \"" << option << "\". Expected values are: Modern, Aero, Mac, Classic." << std::endl); } @@ -493,9 +452,9 @@ void cmCPackIFWInstaller::GenerateInstallerFile() cmsys::SystemTools::CopyFileIfDifferent(Resources[i], path); resources.push_back(name); } else { - cmCPackLogger(cmCPackLog::LOG_WARNING, "Can't copy resources from \"" - << Resources[i] << "\". Resource will be skipped." - << std::endl); + cmCPackIFWLogger(WARNING, "Can't copy resources from \"" + << Resources[i] << "\". Resource will be skipped." + << std::endl); } } Resources = resources; @@ -534,10 +493,3 @@ void cmCPackIFWInstaller::GeneratePackageFiles() package->GeneratePackageFile(); } } - -void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout) -{ - if (Generator) { - Generator->WriteGeneratedByToStrim(xout); - } -} diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index 64239cf..b635f42 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -5,19 +5,19 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCPackIFWCommon.h" + #include <map> #include <string> #include <vector> -class cmCPackIFWGenerator; class cmCPackIFWPackage; class cmCPackIFWRepository; -class cmXMLWriter; /** \class cmCPackIFWInstaller * \brief A binary installer to be created CPack IFW generator */ -class cmCPackIFWInstaller +class cmCPackIFWInstaller : public cmCPackIFWCommon { public: // Types @@ -111,28 +111,17 @@ public: public: // Internal implementation - const char* GetOption(const std::string& op) const; - bool IsOn(const std::string& op) const; - - bool IsVersionLess(const char* version); - bool IsVersionGreater(const char* version); - bool IsVersionEqual(const char* version); - void ConfigureFromOptions(); void GenerateInstallerFile(); void GeneratePackageFiles(); - cmCPackIFWGenerator* Generator; PackagesMap Packages; RepositoriesVector RemoteRepositories; std::string Directory; protected: - void WriteGeneratedByToStrim(cmXMLWriter& xout); - -private: void printSkippedOptionWarning(const std::string& optionName, const std::string& optionValue); }; diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index eda383f..7a0a00c 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -3,34 +3,19 @@ #include "cmCPackIFWPackage.h" #include "cmCPackComponentGroup.h" -#include "cmCPackGenerator.h" +#include "cmCPackIFWCommon.h" #include "cmCPackIFWGenerator.h" #include "cmCPackIFWInstaller.h" -#include "cmCPackLog.h" +#include "cmCPackLog.h" // IWYU pragma: keep #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmTimestamp.h" #include "cmXMLWriter.h" -#include "cmConfigure.h" #include <map> #include <sstream> #include <stddef.h> -//----------------------------------------------------------------- Logger --- -#ifdef cmCPackLogger -#undef cmCPackLogger -#endif -#define cmCPackLogger(logType, msg) \ - do { \ - std::ostringstream cmCPackLog_msg; \ - cmCPackLog_msg << msg; \ - if (Generator) { \ - Generator->Logger->Log(logType, __FILE__, __LINE__, \ - cmCPackLog_msg.str().c_str()); \ - } \ - } while (false) - //---------------------------------------------------------- CompareStruct --- cmCPackIFWPackage::CompareStruct::CompareStruct() : Type(CompareNone) @@ -104,45 +89,8 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const //------------------------------------------------------ cmCPackIFWPackage --- cmCPackIFWPackage::cmCPackIFWPackage() - : Generator(CM_NULLPTR) - , Installer(CM_NULLPTR) -{ -} - -const char* cmCPackIFWPackage::GetOption(const std::string& op) const -{ - const char* option = Generator ? Generator->GetOption(op) : CM_NULLPTR; - return option && *option ? option : CM_NULLPTR; -} - -bool cmCPackIFWPackage::IsOn(const std::string& op) const + : Installer(CM_NULLPTR) { - return Generator ? Generator->IsOn(op) : false; -} - -bool cmCPackIFWPackage::IsSetToOff(const std::string& op) const -{ - return Generator ? Generator->IsSetToOff(op) : false; -} - -bool cmCPackIFWPackage::IsSetToEmpty(const std::string& op) const -{ - return Generator ? Generator->IsSetToEmpty(op) : false; -} - -bool cmCPackIFWPackage::IsVersionLess(const char* version) -{ - return Generator ? Generator->IsVersionLess(version) : false; -} - -bool cmCPackIFWPackage::IsVersionGreater(const char* version) -{ - return Generator ? Generator->IsVersionGreater(version) : false; -} - -bool cmCPackIFWPackage::IsVersionEqual(const char* version) -{ - return Generator ? Generator->IsVersionEqual(version) : false; } std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component) @@ -264,11 +212,11 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) Licenses.clear(); cmSystemTools::ExpandListArgument(option, Licenses); if (Licenses.size() % 2 != 0) { - cmCPackLogger( - cmCPackLog::LOG_WARNING, prefix - << "LICENSES" - << " should contain pairs of <display_name> and <file_path>." - << std::endl); + cmCPackIFWLogger( + WARNING, + prefix << "LICENSES" + << " should contain pairs of <display_name> and <file_path>." + << std::endl); Licenses.clear(); } } @@ -276,8 +224,8 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) // Priority if (const char* option = this->GetOption(prefix + "PRIORITY")) { SortingPriority = option; - cmCPackLogger( - cmCPackLog::LOG_WARNING, "The \"PRIORITY\" option is set " + cmCPackIFWLogger( + WARNING, "The \"PRIORITY\" option is set " << "for component \"" << component->Name << "\", but there option is " << "deprecated. Please use \"SORTING_PRIORITY\" option instead." << std::endl); @@ -341,11 +289,11 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) Licenses.clear(); cmSystemTools::ExpandListArgument(option, Licenses); if (Licenses.size() % 2 != 0) { - cmCPackLogger( - cmCPackLog::LOG_WARNING, prefix - << "LICENSES" - << " should contain pairs of <display_name> and <file_path>." - << std::endl); + cmCPackIFWLogger( + WARNING, + prefix << "LICENSES" + << " should contain pairs of <display_name> and <file_path>." + << std::endl); Licenses.clear(); } } @@ -353,8 +301,8 @@ int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) // Priority if (const char* option = this->GetOption(prefix + "PRIORITY")) { SortingPriority = option; - cmCPackLogger( - cmCPackLog::LOG_WARNING, "The \"PRIORITY\" option is set " + cmCPackIFWLogger( + WARNING, "The \"PRIORITY\" option is set " << "for component group \"" << group->Name << "\", but there option is " << "deprecated. Please use \"SORTING_PRIORITY\" option instead." @@ -714,10 +662,3 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.EndElement(); xout.EndDocument(); } - -void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout) -{ - if (Generator) { - Generator->WriteGeneratedByToStrim(xout); - } -} diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index 025a03e..f9e577a 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -5,20 +5,20 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCPackIFWCommon.h" + #include <set> #include <string> #include <vector> class cmCPackComponent; class cmCPackComponentGroup; -class cmCPackIFWGenerator; class cmCPackIFWInstaller; -class cmXMLWriter; /** \class cmCPackIFWPackage * \brief A single component to be installed by CPack IFW generator */ -class cmCPackIFWPackage +class cmCPackIFWPackage : public cmCPackIFWCommon { public: // Types @@ -119,15 +119,6 @@ public: public: // Internal implementation - const char* GetOption(const std::string& op) const; - bool IsOn(const std::string& op) const; - bool IsSetToOff(const std::string& op) const; - bool IsSetToEmpty(const std::string& op) const; - - bool IsVersionLess(const char* version); - bool IsVersionGreater(const char* version); - bool IsVersionEqual(const char* version); - std::string GetComponentName(cmCPackComponent* component); void DefaultConfiguration(); @@ -140,8 +131,6 @@ public: void GeneratePackageFile(); - // Pointer to generator - cmCPackIFWGenerator* Generator; // Pointer to installer cmCPackIFWInstaller* Installer; // Collection of dependencies @@ -152,9 +141,6 @@ public: std::set<DependenceStruct*> AlienAutoDependOn; // Patch to package directory std::string Directory; - -protected: - void WriteGeneratedByToStrim(cmXMLWriter& xout); }; #endif // cmCPackIFWPackage_h diff --git a/Source/CPack/IFW/cmCPackIFWRepository.cxx b/Source/CPack/IFW/cmCPackIFWRepository.cxx index 8ce375e..9190596 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.cxx +++ b/Source/CPack/IFW/cmCPackIFWRepository.cxx @@ -2,32 +2,16 @@ file Copyright.txt or https://cmake.org/licensing for details. */ #include "cmCPackIFWRepository.h" -#include "cmCPackGenerator.h" #include "cmCPackIFWGenerator.h" #include "cmGeneratedFileStream.h" #include "cmSystemTools.h" #include "cmXMLParser.h" #include "cmXMLWriter.h" -#include "cmConfigure.h" #include <stddef.h> -#ifdef cmCPackLogger -#undef cmCPackLogger -#endif -#define cmCPackLogger(logType, msg) \ - do { \ - std::ostringstream cmCPackLog_msg; \ - cmCPackLog_msg << msg; \ - if (Generator) { \ - Generator->Logger->Log(logType, __FILE__, __LINE__, \ - cmCPackLog_msg.str().c_str()); \ - } \ - } while (false) - cmCPackIFWRepository::cmCPackIFWRepository() : Update(None) - , Generator(CM_NULLPTR) { } @@ -53,31 +37,6 @@ bool cmCPackIFWRepository::IsValid() const return valid; } -const char* cmCPackIFWRepository::GetOption(const std::string& op) const -{ - return Generator ? Generator->GetOption(op) : CM_NULLPTR; -} - -bool cmCPackIFWRepository::IsOn(const std::string& op) const -{ - return Generator ? Generator->IsOn(op) : false; -} - -bool cmCPackIFWRepository::IsVersionLess(const char* version) -{ - return Generator ? Generator->IsVersionLess(version) : false; -} - -bool cmCPackIFWRepository::IsVersionGreater(const char* version) -{ - return Generator ? Generator->IsVersionGreater(version) : false; -} - -bool cmCPackIFWRepository::IsVersionEqual(const char* version) -{ - return Generator ? Generator->IsVersionEqual(version) : false; -} - bool cmCPackIFWRepository::ConfigureFromOptions() { // Name; @@ -325,10 +284,3 @@ void cmCPackIFWRepository::WriteRepositoryUpdates(cmXMLWriter& xout) xout.EndElement(); } } - -void cmCPackIFWRepository::WriteGeneratedByToStrim(cmXMLWriter& xout) -{ - if (Generator) { - Generator->WriteGeneratedByToStrim(xout); - } -} diff --git a/Source/CPack/IFW/cmCPackIFWRepository.h b/Source/CPack/IFW/cmCPackIFWRepository.h index c09a158..227cfae 100644 --- a/Source/CPack/IFW/cmCPackIFWRepository.h +++ b/Source/CPack/IFW/cmCPackIFWRepository.h @@ -5,16 +5,17 @@ #include "cmConfigure.h" // IWYU pragma: keep +#include "cmCPackIFWCommon.h" + #include <string> #include <vector> -class cmCPackIFWGenerator; class cmXMLWriter; /** \class cmCPackIFWRepository * \brief A remote repository to be created CPack IFW generator */ -class cmCPackIFWRepository +class cmCPackIFWRepository : public cmCPackIFWCommon { public: // Types @@ -72,13 +73,6 @@ public: bool IsValid() const; - const char* GetOption(const std::string& op) const; - bool IsOn(const std::string& op) const; - - bool IsVersionLess(const char* version); - bool IsVersionGreater(const char* version); - bool IsVersionEqual(const char* version); - bool ConfigureFromOptions(); bool PatchUpdatesXml(); @@ -87,12 +81,8 @@ public: void WriteRepositoryUpdate(cmXMLWriter& xout); void WriteRepositoryUpdates(cmXMLWriter& xout); - cmCPackIFWGenerator* Generator; RepositoriesVector RepositoryUpdate; std::string Directory; - -protected: - void WriteGeneratedByToStrim(cmXMLWriter& xout); }; #endif // cmCPackIFWRepository_h |