diff options
Diffstat (limited to 'Source/CPack/IFW')
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.cxx | 499 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWGenerator.h | 22 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.cxx | 451 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWInstaller.h | 6 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.cxx | 389 | ||||
-rw-r--r-- | Source/CPack/IFW/cmCPackIFWPackage.h | 32 |
6 files changed, 569 insertions, 830 deletions
diff --git a/Source/CPack/IFW/cmCPackIFWGenerator.cxx b/Source/CPack/IFW/cmCPackIFWGenerator.cxx index cf8587c..2c25f43 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.cxx +++ b/Source/CPack/IFW/cmCPackIFWGenerator.cxx @@ -39,22 +39,22 @@ cmCPackIFWGenerator::~cmCPackIFWGenerator() { } -bool cmCPackIFWGenerator::IsVersionLess(const char *version) +bool cmCPackIFWGenerator::IsVersionLess(const char* version) { return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS, - FrameworkVersion.data(), version); + FrameworkVersion.data(), version); } -bool cmCPackIFWGenerator::IsVersionGreater(const char *version) +bool cmCPackIFWGenerator::IsVersionGreater(const char* version) { return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER, - FrameworkVersion.data(), version); + FrameworkVersion.data(), version); } -bool cmCPackIFWGenerator::IsVersionEqual(const char *version) +bool cmCPackIFWGenerator::IsVersionEqual(const char* version) { return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL, - FrameworkVersion.data(), version); + FrameworkVersion.data(), version); } int cmCPackIFWGenerator::PackageFiles() @@ -72,168 +72,141 @@ int cmCPackIFWGenerator::PackageFiles() ifwTmpFile += "/IFWOutput.log"; // Run repogen - if (!Installer.Repositories.empty()) - { + if (!Installer.Repositories.empty()) { std::string ifwCmd = RepoGen; - if(IsVersionLess("2.0.0")) - { + if (IsVersionLess("2.0.0")) { ifwCmd += " -c " + this->toplevel + "/config/config.xml"; - } + } ifwCmd += " -p " + this->toplevel + "/packages"; - if(!PkgsDirsVector.empty()) - { - for(std::vector<std::string>::iterator it = PkgsDirsVector.begin(); - it != PkgsDirsVector.end(); ++it) - { + if (!PkgsDirsVector.empty()) { + for (std::vector<std::string>::iterator it = PkgsDirsVector.begin(); + it != PkgsDirsVector.end(); ++it) { ifwCmd += " -p " + *it; - } } + } - if (!OnlineOnly && !DownloadedPackages.empty()) - { + if (!OnlineOnly && !DownloadedPackages.empty()) { ifwCmd += " -i "; - std::set<cmCPackIFWPackage*>::iterator it - = DownloadedPackages.begin(); + std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin(); ifwCmd += (*it)->Name; ++it; - while(it != DownloadedPackages.end()) - { + while (it != DownloadedPackages.end()) { ifwCmd += "," + (*it)->Name; ++it; - } } + } ifwCmd += " " + this->toplevel + "/repository"; - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd - << std::endl); + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl); std::string output; int retVal = 1; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, - "- Generate repository" << std::endl); + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository" + << std::endl); bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &output, - &retVal, 0, this->GeneratorVerbose, 0); - if ( !res || retVal ) - { + ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0); + if (!res || retVal) { cmGeneratedFileStream ofs(ifwTmpFile.c_str()); 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); + << ifwCmd << std::endl + << "Please check " << ifwTmpFile << " for errors" + << std::endl); return 0; - } - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " << this->toplevel - << "/repository generated" << std::endl); } + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: " + << this->toplevel << "/repository generated" << std::endl); + } // Run binary creator { - std::string ifwCmd = BinCreator; - ifwCmd += " -c " + this->toplevel + "/config/config.xml"; - ifwCmd += " -p " + this->toplevel + "/packages"; - - if(!PkgsDirsVector.empty()) - { - for(std::vector<std::string>::iterator it = PkgsDirsVector.begin(); - it != PkgsDirsVector.end(); ++it) - { - ifwCmd += " -p " + *it; + std::string ifwCmd = BinCreator; + ifwCmd += " -c " + this->toplevel + "/config/config.xml"; + ifwCmd += " -p " + this->toplevel + "/packages"; + + if (!PkgsDirsVector.empty()) { + for (std::vector<std::string>::iterator it = PkgsDirsVector.begin(); + it != PkgsDirsVector.end(); ++it) { + ifwCmd += " -p " + *it; } } - if (OnlineOnly) - { - ifwCmd += " --online-only"; - } - else if (!DownloadedPackages.empty() && !Installer.Repositories.empty()) - { - ifwCmd += " -e "; - std::set<cmCPackIFWPackage*>::iterator it - = DownloadedPackages.begin(); - ifwCmd += (*it)->Name; - ++it; - while(it != DownloadedPackages.end()) - { - ifwCmd += "," + (*it)->Name; + if (OnlineOnly) { + ifwCmd += " --online-only"; + } else if (!DownloadedPackages.empty() && + !Installer.Repositories.empty()) { + ifwCmd += " -e "; + std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin(); + ifwCmd += (*it)->Name; ++it; + while (it != DownloadedPackages.end()) { + ifwCmd += "," + (*it)->Name; + ++it; } - } - else if (!DependentPackages.empty()) - { - ifwCmd += " -i "; - // Binary - std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin(); - while(bit != BinaryPackages.end()) - { - ifwCmd += (*bit)->Name + ","; - ++bit; + } else if (!DependentPackages.empty()) { + ifwCmd += " -i "; + // Binary + std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin(); + while (bit != BinaryPackages.end()) { + ifwCmd += (*bit)->Name + ","; + ++bit; } - // Depend - DependenceMap::iterator it = DependentPackages.begin(); - ifwCmd += it->second.Name; - ++it; - while(it != DependentPackages.end()) - { - ifwCmd += "," + it->second.Name; + // Depend + DependenceMap::iterator it = DependentPackages.begin(); + ifwCmd += it->second.Name; ++it; + while (it != DependentPackages.end()) { + ifwCmd += "," + it->second.Name; + ++it; } } - // TODO: set correct name for multipackages - if (!this->packageFileNames.empty()) - { - ifwCmd += " " + packageFileNames[0]; - } - else - { - ifwCmd += " installer"; + // TODO: set correct name for multipackages + if (!this->packageFileNames.empty()) { + ifwCmd += " " + packageFileNames[0]; + } else { + ifwCmd += " installer"; } - cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd - << std::endl); - std::string output; - int retVal = 1; - cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl); - bool res = cmSystemTools::RunSingleCommand( - ifwCmd.c_str(), &output, &output, - &retVal, 0, this->GeneratorVerbose, 0); - if ( !res || retVal ) - { - cmGeneratedFileStream ofs(ifwTmpFile.c_str()); - 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); - return 0; + cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl); + std::string output; + int retVal = 1; + cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl); + bool res = cmSystemTools::RunSingleCommand( + ifwCmd.c_str(), &output, &output, &retVal, 0, this->GeneratorVerbose, 0); + if (!res || retVal) { + cmGeneratedFileStream ofs(ifwTmpFile.c_str()); + 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); + return 0; } } return 1; } -const char *cmCPackIFWGenerator::GetPackagingInstallPrefix() +const char* cmCPackIFWGenerator::GetPackagingInstallPrefix() { - const char *defPrefix = cmCPackGenerator::GetPackagingInstallPrefix(); + const char* defPrefix = cmCPackGenerator::GetPackagingInstallPrefix(); std::string tmpPref = defPrefix ? defPrefix : ""; - if(this->Components.empty()) - { + if (this->Components.empty()) { tmpPref += "packages/" + GetRootPackageName() + "/data"; - } + } this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str()); return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX"); } -const char *cmCPackIFWGenerator::GetOutputExtension() +const char* cmCPackIFWGenerator::GetOutputExtension() { return ExecutableSuffix.c_str(); } @@ -246,56 +219,43 @@ int cmCPackIFWGenerator::InitializeInternal() const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE"; const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION"; - if(!this->IsSet(BinCreatorOpt) || - !this->IsSet(RepoGenOpt) || - !this->IsSet(FrameworkVersionOpt)) - { + if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) || + !this->IsSet(FrameworkVersionOpt)) { this->ReadListFile("CPackIFW.cmake"); - } + } // Look 'binarycreator' executable (needs) - const char *BinCreatorStr = this->GetOption(BinCreatorOpt); - if(!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) - { + const char* BinCreatorStr = this->GetOption(BinCreatorOpt); + if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) { BinCreator = ""; - } - else - { + } else { BinCreator = BinCreatorStr; - } + } - if (BinCreator.empty()) - { + if (BinCreator.empty()) { cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot find QtIFW compiler \"binarycreator\": " "likely it is not installed, or not in your PATH" - << std::endl); + << std::endl); return 0; - } + } // Look 'repogen' executable (optional) - const char *RepoGenStr = this->GetOption(RepoGenOpt); - if(!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) - { + const char* RepoGenStr = this->GetOption(RepoGenOpt); + if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) { RepoGen = ""; - } - else - { + } else { RepoGen = RepoGenStr; - } + } // Framework version - if(const char* FrameworkVersionSrt = - this->GetOption(FrameworkVersionOpt)) - { + if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) { FrameworkVersion = FrameworkVersionSrt; - } - else - { + } else { FrameworkVersion = "1.9.9"; - } + } // Variables that Change Behavior @@ -304,158 +264,130 @@ int cmCPackIFWGenerator::InitializeInternal() // Additional packages dirs PkgsDirsVector.clear(); - if(const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) - { - cmSystemTools::ExpandListArgument(dirs, - PkgsDirsVector); - } + if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) { + cmSystemTools::ExpandListArgument(dirs, PkgsDirsVector); + } // Installer Installer.Generator = this; Installer.ConfigureFromOptions(); - if (const char* ifwDownloadAll = - this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) - { + if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) { OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll); - } - else if (const char* cpackDownloadAll = - this->GetOption("CPACK_DOWNLOAD_ALL")) - { + } else if (const char* cpackDownloadAll = + this->GetOption("CPACK_DOWNLOAD_ALL")) { OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll); - } - else - { + } else { OnlineOnly = false; - } + } if (!Installer.Repositories.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); - return 0; + cmCPackLogger(cmCPackLog::LOG_ERROR, + "Cannot find QtIFW repository generator \"repogen\": " + "likely it is not installed, or not in your PATH" + << std::endl); + return 0; } // Executable suffix - if(const char *optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) - { + if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) { ExecutableSuffix = optExeSuffix; - if(ExecutableSuffix.empty()) - { + if (ExecutableSuffix.empty()) { std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME")); - if(sysName == "Linux") - { + if (sysName == "Linux") { ExecutableSuffix = ".run"; - } } } - else - { + } else { ExecutableSuffix = cmCPackGenerator::GetOutputExtension(); - } + } return this->Superclass::InitializeInternal(); } -std::string -cmCPackIFWGenerator::GetComponentInstallDirNameSuffix( +std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix( const std::string& componentName) { const std::string prefix = "packages/"; const std::string suffix = "/data"; if (componentPackageMethod == ONE_PACKAGE) { - return std::string(prefix + GetRootPackageName() + suffix); + return std::string(prefix + GetRootPackageName() + suffix); } - return prefix - + GetComponentPackageName(&Components[componentName]) - + suffix; + return prefix + GetComponentPackageName(&Components[componentName]) + suffix; } -cmCPackComponent* -cmCPackIFWGenerator::GetComponent(const std::string &projectName, - const std::string &componentName) +cmCPackComponent* cmCPackIFWGenerator::GetComponent( + const std::string& projectName, const std::string& componentName) { ComponentsMap::iterator cit = Components.find(componentName); - if ( cit != Components.end() ) return &(cit->second); + if (cit != Components.end()) + return &(cit->second); - cmCPackComponent* component - = cmCPackGenerator::GetComponent(projectName, componentName); - if(!component) return component; + cmCPackComponent* component = + cmCPackGenerator::GetComponent(projectName, componentName); + if (!component) + return component; std::string name = GetComponentPackageName(component); PackagesMap::iterator pit = Packages.find(name); - if(pit != Packages.end()) return component; + if (pit != Packages.end()) + return component; - cmCPackIFWPackage *package = &Packages[name]; + cmCPackIFWPackage* package = &Packages[name]; package->Name = name; package->Generator = this; - if(package->ConfigureFromComponent(component)) - { + if (package->ConfigureFromComponent(component)) { package->Installer = &Installer; Installer.Packages.insert( - std::pair<std::string, cmCPackIFWPackage*>( - name, package)); + std::pair<std::string, cmCPackIFWPackage*>(name, package)); ComponentPackages.insert( - std::pair<cmCPackComponent*, cmCPackIFWPackage*>( - component, package)); - if(component->IsDownloaded) - { + std::pair<cmCPackComponent*, cmCPackIFWPackage*>(component, package)); + if (component->IsDownloaded) { DownloadedPackages.insert(package); - } - else - { + } else { BinaryPackages.insert(package); - } } - else - { + } else { Packages.erase(name); - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot configure package \"" << name << - "\" for component \"" << component->Name << "\"" - << std::endl); - } + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \"" + << name << "\" for component \"" << component->Name << "\"" + << std::endl); + } return component; } -cmCPackComponentGroup* -cmCPackIFWGenerator::GetComponentGroup(const std::string &projectName, - const std::string &groupName) +cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup( + const std::string& projectName, const std::string& groupName) { - cmCPackComponentGroup* group - = cmCPackGenerator::GetComponentGroup(projectName, groupName); - if(!group) return group; + cmCPackComponentGroup* group = + cmCPackGenerator::GetComponentGroup(projectName, groupName); + if (!group) + return group; std::string name = GetGroupPackageName(group); PackagesMap::iterator pit = Packages.find(name); - if(pit != Packages.end()) return group; + if (pit != Packages.end()) + return group; - cmCPackIFWPackage *package = &Packages[name]; + cmCPackIFWPackage* package = &Packages[name]; package->Name = name; package->Generator = this; - if(package->ConfigureFromGroup(group)) - { + if (package->ConfigureFromGroup(group)) { package->Installer = &Installer; Installer.Packages.insert( - std::pair<std::string, cmCPackIFWPackage*>( - name, package)); + std::pair<std::string, cmCPackIFWPackage*>(name, package)); GroupPackages.insert( - std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>( - group, package)); + std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(group, package)); BinaryPackages.insert(package); - } - else - { + } else { Packages.erase(name); - cmCPackLogger(cmCPackLog::LOG_ERROR, - "Cannot configure package \"" << name << - "\" for component group \"" << group->Name << "\"" - << std::endl); - } + cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \"" + << name << "\" for component group \"" << group->Name + << "\"" << std::endl); + } return group; } @@ -485,123 +417,106 @@ std::string cmCPackIFWGenerator::GetRootPackageName() // Default value std::string name = "root"; if (const char* optIFW_PACKAGE_GROUP = - this->GetOption("CPACK_IFW_PACKAGE_GROUP")) - { + this->GetOption("CPACK_IFW_PACKAGE_GROUP")) { // Configure from root group cmCPackIFWPackage package; package.Generator = this; package.ConfigureFromGroup(optIFW_PACKAGE_GROUP); name = package.Name; - } - else if (const char* optIFW_PACKAGE_NAME = - this->GetOption("CPACK_IFW_PACKAGE_NAME")) - { + } else if (const char* optIFW_PACKAGE_NAME = + this->GetOption("CPACK_IFW_PACKAGE_NAME")) { // Configure from root package name name = optIFW_PACKAGE_NAME; - } - else if (const char* optPACKAGE_NAME = - this->GetOption("CPACK_PACKAGE_NAME")) - { + } else if (const char* optPACKAGE_NAME = + this->GetOption("CPACK_PACKAGE_NAME")) { // Configure from package name name = optPACKAGE_NAME; - } + } return name; } -std::string -cmCPackIFWGenerator::GetGroupPackageName(cmCPackComponentGroup *group) const +std::string cmCPackIFWGenerator::GetGroupPackageName( + cmCPackComponentGroup* group) const { std::string name; - if (!group) return name; - if (cmCPackIFWPackage* package = GetGroupPackage(group)) - { + if (!group) + return name; + if (cmCPackIFWPackage* package = GetGroupPackage(group)) { return package->Name; - } - const char* option = GetOption( - "CPACK_IFW_COMPONENT_GROUP_" - + cmsys::SystemTools::UpperCase(group->Name) - + "_NAME"); + } + const char* option = + GetOption("CPACK_IFW_COMPONENT_GROUP_" + + cmsys::SystemTools::UpperCase(group->Name) + "_NAME"); name = option ? option : group->Name; - if(group->ParentGroup) - { + if (group->ParentGroup) { cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup); bool dot = !ResolveDuplicateNames; - if(dot && name.substr(0, package->Name.size()) == package->Name) - { + if (dot && name.substr(0, package->Name.size()) == package->Name) { dot = false; - } - if(dot) - { + } + if (dot) { name = package->Name + "." + name; - } } + } return name; } std::string cmCPackIFWGenerator::GetComponentPackageName( - cmCPackComponent *component) const + cmCPackComponent* component) const { std::string name; - if (!component) return name; - if (cmCPackIFWPackage* package = GetComponentPackage(component)) - { + if (!component) + return name; + if (cmCPackIFWPackage* package = GetComponentPackage(component)) { return package->Name; - } - std::string prefix = "CPACK_IFW_COMPONENT_" - + cmsys::SystemTools::UpperCase(component->Name) - + "_"; + } + std::string prefix = "CPACK_IFW_COMPONENT_" + + cmsys::SystemTools::UpperCase(component->Name) + "_"; const char* option = GetOption(prefix + "NAME"); name = option ? option : component->Name; - if(component->Group) - { + if (component->Group) { cmCPackIFWPackage* package = GetGroupPackage(component->Group); - if((componentPackageMethod == ONE_PACKAGE_PER_GROUP) - || IsOn(prefix + "COMMON")) - { + if ((componentPackageMethod == ONE_PACKAGE_PER_GROUP) || + IsOn(prefix + "COMMON")) { return package->Name; - } + } bool dot = !ResolveDuplicateNames; - if(dot && name.substr(0, package->Name.size()) == package->Name) - { + if (dot && name.substr(0, package->Name.size()) == package->Name) { dot = false; - } - if(dot) - { + } + if (dot) { name = package->Name + "." + name; - } } + } return name; } cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage( - cmCPackComponentGroup *group) const + cmCPackComponentGroup* group) const { - std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit - = GroupPackages.find(group); + std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit = + GroupPackages.find(group); return pit != GroupPackages.end() ? pit->second : 0; } cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage( - cmCPackComponent *component) const + cmCPackComponent* component) const { - std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit - = ComponentPackages.find(component); + std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit = + ComponentPackages.find(component); return pit != ComponentPackages.end() ? pit->second : 0; } -void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter &xout) +void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout) { std::stringstream comment; comment << "Generated by CPack " << CMake_VERSION << " IFW generator " - << "for QtIFW "; - if(IsVersionLess("2.0")) - { + << "for QtIFW "; + if (IsVersionLess("2.0")) { comment << "less 2.0"; - } - else - { + } 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 d02f9d2..d8cc562 100644 --- a/Source/CPack/IFW/cmCPackIFWGenerator.h +++ b/Source/CPack/IFW/cmCPackIFWGenerator.h @@ -49,17 +49,17 @@ public: /** * Compare \a version with QtIFW framework version */ - bool IsVersionLess(const char *version); + bool IsVersionLess(const char* version); /** * Compare \a version with QtIFW framework version */ - bool IsVersionGreater(const char *version); + bool IsVersionGreater(const char* version); /** * Compare \a version with QtIFW framework version */ - bool IsVersionEqual(const char *version); + bool IsVersionEqual(const char* version); protected: // cmCPackGenerator reimplementation @@ -90,9 +90,8 @@ protected: * * @return Pointer to component */ - virtual cmCPackComponent* GetComponent( - const std::string& projectName, - const std::string& componentName); + virtual cmCPackComponent* GetComponent(const std::string& projectName, + const std::string& componentName); /** * @brief Get group of component @@ -104,8 +103,7 @@ protected: * @return Pointer to component group */ virtual cmCPackComponentGroup* GetComponentGroup( - const std::string& projectName, - const std::string& groupName); + const std::string& projectName, const std::string& groupName); enum cmCPackGenerator::CPackSetDestdirSupport SupportsSetDestdir() const; virtual bool SupportsAbsoluteDestination() const; @@ -118,11 +116,11 @@ protected: std::string GetRootPackageName(); - std::string GetGroupPackageName(cmCPackComponentGroup *group) const; - std::string GetComponentPackageName(cmCPackComponent *component) const; + std::string GetGroupPackageName(cmCPackComponentGroup* group) const; + std::string GetComponentPackageName(cmCPackComponent* component) const; - cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup *group) const; - cmCPackIFWPackage* GetComponentPackage(cmCPackComponent *component) const; + cmCPackIFWPackage* GetGroupPackage(cmCPackComponentGroup* group) const; + cmCPackIFWPackage* GetComponentPackage(cmCPackComponent* component) const; void WriteGeneratedByToStrim(cmXMLWriter& xout); diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.cxx b/Source/CPack/IFW/cmCPackIFWInstaller.cxx index dfb336c..b9a9861 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.cxx +++ b/Source/CPack/IFW/cmCPackIFWInstaller.cxx @@ -20,310 +20,239 @@ #include <cmXMLWriter.h> #ifdef cmCPackLogger -# undef 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 ( 0 ) - -cmCPackIFWInstaller::cmCPackIFWInstaller() : - Generator(0) +#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 (0) + +cmCPackIFWInstaller::cmCPackIFWInstaller() + : Generator(0) { } -const char *cmCPackIFWInstaller::GetOption(const std::string &op) const +const char* cmCPackIFWInstaller::GetOption(const std::string& op) const { return Generator ? Generator->GetOption(op) : 0; } -bool cmCPackIFWInstaller::IsOn(const std::string &op) const +bool cmCPackIFWInstaller::IsOn(const std::string& op) const { return Generator ? Generator->IsOn(op) : false; } -bool cmCPackIFWInstaller::IsVersionLess(const char *version) +bool cmCPackIFWInstaller::IsVersionLess(const char* version) { return Generator ? Generator->IsVersionLess(version) : false; } -bool cmCPackIFWInstaller::IsVersionGreater(const char *version) +bool cmCPackIFWInstaller::IsVersionGreater(const char* version) { return Generator ? Generator->IsVersionGreater(version) : false; } -bool cmCPackIFWInstaller::IsVersionEqual(const char *version) +bool cmCPackIFWInstaller::IsVersionEqual(const char* version) { return Generator ? Generator->IsVersionEqual(version) : false; } - void cmCPackIFWInstaller::ConfigureFromOptions() { // Name; if (const char* optIFW_PACKAGE_NAME = - this->GetOption("CPACK_IFW_PACKAGE_NAME")) - { + this->GetOption("CPACK_IFW_PACKAGE_NAME")) { Name = optIFW_PACKAGE_NAME; - } - else if (const char* optPACKAGE_NAME = - this->GetOption("CPACK_PACKAGE_NAME")) - { + } else if (const char* optPACKAGE_NAME = + this->GetOption("CPACK_PACKAGE_NAME")) { Name = optPACKAGE_NAME; - } - else - { + } else { Name = "Your package"; - } + } // Title; if (const char* optIFW_PACKAGE_TITLE = - GetOption("CPACK_IFW_PACKAGE_TITLE")) - { + GetOption("CPACK_IFW_PACKAGE_TITLE")) { Title = optIFW_PACKAGE_TITLE; - } - else if (const char* optPACKAGE_DESCRIPTION_SUMMARY = - GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) - { + } else if (const char* optPACKAGE_DESCRIPTION_SUMMARY = + GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) { Title = optPACKAGE_DESCRIPTION_SUMMARY; - } - else - { + } else { Title = "Your package description"; - } + } // Version; - if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) - { + if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) { Version = option; - } - else - { + } else { Version = "1.0.0"; - } + } // Publisher - if(const char* optIFW_PACKAGE_PUBLISHER = - GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) - { + if (const char* optIFW_PACKAGE_PUBLISHER = + GetOption("CPACK_IFW_PACKAGE_PUBLISHER")) { Publisher = optIFW_PACKAGE_PUBLISHER; - } - else if(const char* optPACKAGE_VENDOR = GetOption("CPACK_PACKAGE_VENDOR")) - { + } else if (const char* optPACKAGE_VENDOR = + GetOption("CPACK_PACKAGE_VENDOR")) { Publisher = optPACKAGE_VENDOR; - } + } // ProductUrl - if(const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) - { + if (const char* option = GetOption("CPACK_IFW_PRODUCT_URL")) { ProductUrl = option; - } + } // ApplicationIcon - if(const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) - { - if(cmSystemTools::FileExists(option)) - { + if (const char* option = GetOption("CPACK_IFW_PACKAGE_ICON")) { + if (cmSystemTools::FileExists(option)) { InstallerApplicationIcon = option; - } - else - { + } else { // TODO: implement warning - } } + } // WindowIcon - if(const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) - { - if(cmSystemTools::FileExists(option)) - { + if (const char* option = GetOption("CPACK_IFW_PACKAGE_WINDOW_ICON")) { + if (cmSystemTools::FileExists(option)) { InstallerWindowIcon = option; - } - else - { + } else { // TODO: implement warning - } } + } // Logo - if(const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) - { - if(cmSystemTools::FileExists(option)) - { + if (const char* option = GetOption("CPACK_IFW_PACKAGE_LOGO")) { + if (cmSystemTools::FileExists(option)) { Logo = option; - } - else - { + } else { // TODO: implement warning - } } + } // Start menu if (const char* optIFW_START_MENU_DIR = - this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) - { + this->GetOption("CPACK_IFW_PACKAGE_START_MENU_DIRECTORY")) { StartMenuDir = optIFW_START_MENU_DIR; - } - else - { + } else { StartMenuDir = Name; - } + } // Default target directory for installation if (const char* optIFW_TARGET_DIRECTORY = - GetOption("CPACK_IFW_TARGET_DIRECTORY")) - { + GetOption("CPACK_IFW_TARGET_DIRECTORY")) { TargetDir = optIFW_TARGET_DIRECTORY; - } - else if (const char *optPACKAGE_INSTALL_DIRECTORY = - GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) - { + } else if (const char* optPACKAGE_INSTALL_DIRECTORY = + GetOption("CPACK_PACKAGE_INSTALL_DIRECTORY")) { TargetDir = "@ApplicationsDir@/"; TargetDir += optPACKAGE_INSTALL_DIRECTORY; - } - else - { + } else { TargetDir = "@RootDir@/usr/local"; - } + } // Default target directory for installation with administrator rights - if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) - { + if (const char* option = GetOption("CPACK_IFW_ADMIN_TARGET_DIRECTORY")) { AdminTargetDir = option; - } + } // Repositories Repositories.clear(); RepositoryStruct Repo; - if(const char *site = this->GetOption("CPACK_DOWNLOAD_SITE")) - { + if (const char* site = this->GetOption("CPACK_DOWNLOAD_SITE")) { Repo.Url = site; Repositories.push_back(Repo); - } - if(const char *RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) - { + } + if (const char* RepoAllStr = this->GetOption("CPACK_IFW_REPOSITORIES_ALL")) { std::vector<std::string> RepoAllVector; - cmSystemTools::ExpandListArgument(RepoAllStr, - RepoAllVector); - for(std::vector<std::string>::iterator - rit = RepoAllVector.begin(); rit != RepoAllVector.end(); ++rit) - { - std::string prefix = "CPACK_IFW_REPOSITORY_" - + cmsys::SystemTools::UpperCase(*rit) - + "_"; - // Url - if (const char* url = GetOption(prefix + "URL")) - { - Repo.Url = url; - } - else - { - Repo.Url = ""; - } - // Enabled - if (IsOn(prefix + "DISABLED")) - { - Repo.Enabled = "0"; - } - else - { - Repo.Enabled = ""; - } - // Username - if (const char* username = GetOption(prefix + "USERNAME")) - { - Repo.Username = username; - } - else - { - Repo.Username = ""; - } - // Password - if (const char* password = GetOption(prefix + "PASSWORD")) - { - Repo.Password = password; - } - else - { - Repo.Password = ""; - } - // DisplayName - if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) - { - Repo.DisplayName = displayName; - } - else - { - Repo.DisplayName = ""; - } - - if(!Repo.Url.empty()) - { - Repositories.push_back(Repo); - } + cmSystemTools::ExpandListArgument(RepoAllStr, RepoAllVector); + for (std::vector<std::string>::iterator rit = RepoAllVector.begin(); + rit != RepoAllVector.end(); ++rit) { + std::string prefix = + "CPACK_IFW_REPOSITORY_" + cmsys::SystemTools::UpperCase(*rit) + "_"; + // Url + if (const char* url = GetOption(prefix + "URL")) { + Repo.Url = url; + } else { + Repo.Url = ""; + } + // Enabled + if (IsOn(prefix + "DISABLED")) { + Repo.Enabled = "0"; + } else { + Repo.Enabled = ""; + } + // Username + if (const char* username = GetOption(prefix + "USERNAME")) { + Repo.Username = username; + } else { + Repo.Username = ""; + } + // Password + if (const char* password = GetOption(prefix + "PASSWORD")) { + Repo.Password = password; + } else { + Repo.Password = ""; + } + // DisplayName + if (const char* displayName = GetOption(prefix + "DISPLAY_NAME")) { + Repo.DisplayName = displayName; + } else { + Repo.DisplayName = ""; + } + + if (!Repo.Url.empty()) { + Repositories.push_back(Repo); } } + } // Maintenance tool - if(const char* optIFW_MAINTENANCE_TOOL = - this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) - { + if (const char* optIFW_MAINTENANCE_TOOL = + this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_NAME")) { MaintenanceToolName = optIFW_MAINTENANCE_TOOL; - } + } // Maintenance tool ini file - if(const char* optIFW_MAINTENANCE_TOOL_INI = - this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) - { + if (const char* optIFW_MAINTENANCE_TOOL_INI = + this->GetOption("CPACK_IFW_PACKAGE_MAINTENANCE_TOOL_INI_FILE")) { MaintenanceToolIniFile = optIFW_MAINTENANCE_TOOL_INI; - } + } // Allow non-ASCII characters - if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) - { - if(IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) - { + if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) { + if (IsOn("CPACK_IFW_PACKAGE_ALLOW_NON_ASCII_CHARACTERS")) { AllowNonAsciiCharacters = "true"; - } - else - { + } else { AllowNonAsciiCharacters = "false"; - } } + } // Space in path - if(this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) - { - if(IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) - { + if (this->GetOption("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) { + if (IsOn("CPACK_IFW_PACKAGE_ALLOW_SPACE_IN_PATH")) { AllowSpaceInPath = "true"; - } - else - { + } else { AllowSpaceInPath = "false"; - } } + } // Control script - if(const char* optIFW_CONTROL_SCRIPT = - this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) - { + if (const char* optIFW_CONTROL_SCRIPT = + this->GetOption("CPACK_IFW_PACKAGE_CONTROL_SCRIPT")) { ControlScript = optIFW_CONTROL_SCRIPT; - } + } } void cmCPackIFWInstaller::GenerateInstallerFile() { // Lazy directory initialization - if(Directory.empty() && Generator) - { + if (Directory.empty() && Generator) { Directory = Generator->toplevel; - } + } // Output stream cmGeneratedFileStream fout((Directory + "/config/config.xml").data()); @@ -339,140 +268,118 @@ void cmCPackIFWInstaller::GenerateInstallerFile() xout.Element("Version", Version); xout.Element("Title", Title); - if(!Publisher.empty()) - { + if (!Publisher.empty()) { xout.Element("Publisher", Publisher); - } + } - if(!ProductUrl.empty()) - { + if (!ProductUrl.empty()) { xout.Element("ProductUrl", ProductUrl); - } + } // ApplicationIcon - if(!InstallerApplicationIcon.empty()) - { + if (!InstallerApplicationIcon.empty()) { std::string name = cmSystemTools::GetFilenameName(InstallerApplicationIcon); std::string path = Directory + "/config/" + name; name = cmSystemTools::GetFilenameWithoutExtension(name); - cmsys::SystemTools::CopyFileIfDifferent( - InstallerApplicationIcon.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(InstallerApplicationIcon.data(), + path.data()); xout.Element("InstallerApplicationIcon", name); - } + } // WindowIcon - if(!InstallerWindowIcon.empty()) - { + if (!InstallerWindowIcon.empty()) { std::string name = cmSystemTools::GetFilenameName(InstallerWindowIcon); std::string path = Directory + "/config/" + name; - cmsys::SystemTools::CopyFileIfDifferent( - InstallerWindowIcon.data(), path.data()); + cmsys::SystemTools::CopyFileIfDifferent(InstallerWindowIcon.data(), + path.data()); xout.Element("InstallerWindowIcon", name); - } + } // Logo - if(!Logo.empty()) - { + if (!Logo.empty()) { std::string name = cmSystemTools::GetFilenameName(Logo); std::string path = Directory + "/config/" + name; cmsys::SystemTools::CopyFileIfDifferent(Logo.data(), path.data()); xout.Element("Logo", name); - } + } // Start menu - if(!IsVersionLess("2.0")) - { + if (!IsVersionLess("2.0")) { xout.Element("StartMenuDir", StartMenuDir); - } + } // Target dir - if(!TargetDir.empty()) - { + if (!TargetDir.empty()) { xout.Element("TargetDir", TargetDir); - } + } // Admin target dir - if(!AdminTargetDir.empty()) - { + if (!AdminTargetDir.empty()) { xout.Element("AdminTargetDir", AdminTargetDir); - } + } // Remote repositories - if (!Repositories.empty()) - { + if (!Repositories.empty()) { xout.StartElement("RemoteRepositories"); - for(std::vector<RepositoryStruct>::iterator - rit = Repositories.begin(); rit != Repositories.end(); ++rit) - { + for (std::vector<RepositoryStruct>::iterator rit = Repositories.begin(); + rit != Repositories.end(); ++rit) { xout.StartElement("Repository"); // Url xout.Element("Url", rit->Url); // Enabled - if(!rit->Enabled.empty()) - { + if (!rit->Enabled.empty()) { xout.Element("Enabled", rit->Enabled); - } + } // Username - if(!rit->Username.empty()) - { + if (!rit->Username.empty()) { xout.Element("Username", rit->Username); - } + } // Password - if(!rit->Password.empty()) - { + if (!rit->Password.empty()) { xout.Element("Password", rit->Password); - } + } // DisplayName - if(!rit->DisplayName.empty()) - { + if (!rit->DisplayName.empty()) { xout.Element("DisplayName", rit->DisplayName); - } - xout.EndElement(); } - xout.EndElement(); + xout.EndElement(); } + xout.EndElement(); + } // Maintenance tool - if(!IsVersionLess("2.0") && !MaintenanceToolName.empty()) - { + if (!IsVersionLess("2.0") && !MaintenanceToolName.empty()) { xout.Element("MaintenanceToolName", MaintenanceToolName); - } + } // Maintenance tool ini file - if(!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) - { + if (!IsVersionLess("2.0") && !MaintenanceToolIniFile.empty()) { xout.Element("MaintenanceToolIniFile", MaintenanceToolIniFile); - } + } // Different allows - if(IsVersionLess("2.0")) - { + if (IsVersionLess("2.0")) { // CPack IFW default policy xout.Comment("CPack IFW default policy for QtIFW less 2.0"); xout.Element("AllowNonAsciiCharacters", "true"); xout.Element("AllowSpaceInPath", "true"); + } else { + if (!AllowNonAsciiCharacters.empty()) { + xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters); } - else - { - if(!AllowNonAsciiCharacters.empty()) - { - xout.Element("AllowNonAsciiCharacters", AllowNonAsciiCharacters); - } - if(!AllowSpaceInPath.empty()) - { - xout.Element("AllowSpaceInPath", AllowSpaceInPath); - } + if (!AllowSpaceInPath.empty()) { + xout.Element("AllowSpaceInPath", AllowSpaceInPath); } + } // Control script (copy to config dir) - if(!IsVersionLess("2.0") && !ControlScript.empty()) - { + if (!IsVersionLess("2.0") && !ControlScript.empty()) { std::string name = cmSystemTools::GetFilenameName(ControlScript); std::string path = Directory + "/config/" + name; cmsys::SystemTools::CopyFileIfDifferent(ControlScript.data(), path.data()); xout.Element("ControlScript", name); - } + } xout.EndElement(); xout.EndDocument(); @@ -480,36 +387,32 @@ void cmCPackIFWInstaller::GenerateInstallerFile() void cmCPackIFWInstaller::GeneratePackageFiles() { - if (Packages.empty() || Generator->IsOnePackage()) - { + if (Packages.empty() || Generator->IsOnePackage()) { // Generate default package cmCPackIFWPackage package; package.Generator = Generator; package.Installer = this; // Check package group - if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) - { + if (const char* option = GetOption("CPACK_IFW_PACKAGE_GROUP")) { package.ConfigureFromGroup(option); package.ForcedInstallation = "true"; - } - else - { + } else { package.ConfigureFromOptions(); - } + } package.GeneratePackageFile(); return; - } + } // Generate packages meta information - for(PackagesMap::iterator pit = Packages.begin(); - pit != Packages.end(); ++pit) - { + for (PackagesMap::iterator pit = Packages.begin(); pit != Packages.end(); + ++pit) { cmCPackIFWPackage* package = pit->second; package->GeneratePackageFile(); } } -void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter &xout) +void cmCPackIFWInstaller::WriteGeneratedByToStrim(cmXMLWriter& xout) { - if(Generator) Generator->WriteGeneratedByToStrim(xout); + if (Generator) + Generator->WriteGeneratedByToStrim(xout); } diff --git a/Source/CPack/IFW/cmCPackIFWInstaller.h b/Source/CPack/IFW/cmCPackIFWInstaller.h index 9cb7d5b..84a789e 100644 --- a/Source/CPack/IFW/cmCPackIFWInstaller.h +++ b/Source/CPack/IFW/cmCPackIFWInstaller.h @@ -103,9 +103,9 @@ public: 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 IsVersionLess(const char* version); + bool IsVersionGreater(const char* version); + bool IsVersionEqual(const char* version); void ConfigureFromOptions(); diff --git a/Source/CPack/IFW/cmCPackIFWPackage.cxx b/Source/CPack/IFW/cmCPackIFWPackage.cxx index a22c0b9..5bc1a0b 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.cxx +++ b/Source/CPack/IFW/cmCPackIFWPackage.cxx @@ -22,21 +22,21 @@ //----------------------------------------------------------------- Logger --- #ifdef cmCPackLogger -# undef 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 ( 0 ) +#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 (0) //---------------------------------------------------------- CompareStruct --- -cmCPackIFWPackage::CompareStruct::CompareStruct() : - Type(CompareNone) +cmCPackIFWPackage::CompareStruct::CompareStruct() + : Type(CompareNone) { } @@ -46,64 +46,47 @@ cmCPackIFWPackage::DependenceStruct::DependenceStruct() } cmCPackIFWPackage::DependenceStruct::DependenceStruct( - const std::string &dependence) + const std::string& dependence) { // Search compare section size_t pos = std::string::npos; - if((pos = dependence.find("<=")) != std::string::npos) - { + if ((pos = dependence.find("<=")) != std::string::npos) { Compare.Type = CompareLessOrEqual; Compare.Value = dependence.substr(pos + 2); - } - else if((pos = dependence.find(">=")) != std::string::npos) - { + } else if ((pos = dependence.find(">=")) != std::string::npos) { Compare.Type = CompareGreaterOrEqual; Compare.Value = dependence.substr(pos + 2); - } - else if((pos = dependence.find("<")) != std::string::npos) - { + } else if ((pos = dependence.find("<")) != std::string::npos) { Compare.Type = CompareLess; Compare.Value = dependence.substr(pos + 1); - } - else if((pos = dependence.find("=")) != std::string::npos) - { + } else if ((pos = dependence.find("=")) != std::string::npos) { Compare.Type = CompareEqual; Compare.Value = dependence.substr(pos + 1); - } - else if((pos = dependence.find(">")) != std::string::npos) - { + } else if ((pos = dependence.find(">")) != std::string::npos) { Compare.Type = CompareGreater; Compare.Value = dependence.substr(pos + 1); - } + } Name = pos == std::string::npos ? dependence : dependence.substr(0, pos); } std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const { - if (Compare.Type == CompareNone) return Name; + if (Compare.Type == CompareNone) + return Name; std::string result = Name; - if (Compare.Type == CompareLessOrEqual) - { + if (Compare.Type == CompareLessOrEqual) { result += "<="; - } - else if (Compare.Type == CompareGreaterOrEqual) - { + } else if (Compare.Type == CompareGreaterOrEqual) { result += ">="; - } - else if (Compare.Type == CompareLess) - { + } else if (Compare.Type == CompareLess) { result += "<"; - } - else if (Compare.Type == CompareEqual) - { + } else if (Compare.Type == CompareEqual) { result += "="; - } - else if (Compare.Type == CompareGreater) - { + } else if (Compare.Type == CompareGreater) { result += ">"; - } + } result += Compare.Value; @@ -111,45 +94,45 @@ std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const } //------------------------------------------------------ cmCPackIFWPackage --- -cmCPackIFWPackage::cmCPackIFWPackage() : - Generator(0), - Installer(0) +cmCPackIFWPackage::cmCPackIFWPackage() + : Generator(0) + , Installer(0) { } -const char *cmCPackIFWPackage::GetOption(const std::string &op) const +const char* cmCPackIFWPackage::GetOption(const std::string& op) const { - const char *option = Generator ? Generator->GetOption(op) : 0; + const char* option = Generator ? Generator->GetOption(op) : 0; return option && *option ? option : 0; } -bool cmCPackIFWPackage::IsOn(const std::string &op) const +bool cmCPackIFWPackage::IsOn(const std::string& op) const { return Generator ? Generator->IsOn(op) : false; } -bool cmCPackIFWPackage::IsVersionLess(const char *version) +bool cmCPackIFWPackage::IsVersionLess(const char* version) { return Generator ? Generator->IsVersionLess(version) : false; } -bool cmCPackIFWPackage::IsVersionGreater(const char *version) +bool cmCPackIFWPackage::IsVersionGreater(const char* version) { return Generator ? Generator->IsVersionGreater(version) : false; } -bool cmCPackIFWPackage::IsVersionEqual(const char *version) +bool cmCPackIFWPackage::IsVersionEqual(const char* version) { return Generator ? Generator->IsVersionEqual(version) : false; } -std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent *component) +std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component) { - if (!component) return ""; - const char* option = GetOption( - "CPACK_IFW_COMPONENT_" - + cmsys::SystemTools::UpperCase(component->Name) - + "_NAME"); + if (!component) + return ""; + const char* option = + GetOption("CPACK_IFW_COMPONENT_" + + cmsys::SystemTools::UpperCase(component->Name) + "_NAME"); return option ? option : component->Name; } @@ -177,51 +160,42 @@ int cmCPackIFWPackage::ConfigureFromOptions() Name = Generator->GetRootPackageName(); // Display name - if (const char *option = this->GetOption("CPACK_PACKAGE_NAME")) - { + if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) { DisplayName = option; - } - else - { + } else { DisplayName = "Your package"; - } + } // Description if (const char* option = - this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) - { + this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) { Description = option; - } - else - { + } else { Description = "Your package description"; - } + } // Version - if(const char* option = GetOption("CPACK_PACKAGE_VERSION")) - { + if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) { Version = option; - } - else - { + } else { Version = "1.0.0"; - } + } ForcedInstallation = "true"; return 1; } -int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component) +int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component) { - if(!component) return 0; + if (!component) + return 0; // Restore defaul configuration DefaultConfiguration(); - std::string prefix = "CPACK_IFW_COMPONENT_" - + cmsys::SystemTools::UpperCase(component->Name) - + "_"; + std::string prefix = "CPACK_IFW_COMPONENT_" + + cmsys::SystemTools::UpperCase(component->Name) + "_"; // Display name DisplayName = component->DisplayName; @@ -230,81 +204,65 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component) Description = component->Description; // Version - if(const char* optVERSION = GetOption(prefix + "VERSION")) - { + if (const char* optVERSION = GetOption(prefix + "VERSION")) { Version = optVERSION; - } - else if(const char* optPACKAGE_VERSION = - GetOption("CPACK_PACKAGE_VERSION")) - { + } else if (const char* optPACKAGE_VERSION = + GetOption("CPACK_PACKAGE_VERSION")) { Version = optPACKAGE_VERSION; - } - else - { + } else { Version = "1.0.0"; - } + } // Script - if (const char* option = GetOption(prefix + "SCRIPT")) - { + if (const char* option = GetOption(prefix + "SCRIPT")) { Script = option; - } + } // CMake dependencies - if (!component->Dependencies.empty()) - { + if (!component->Dependencies.empty()) { std::vector<cmCPackComponent*>::iterator dit; - for(dit = component->Dependencies.begin(); - dit != component->Dependencies.end(); - ++dit) - { + for (dit = component->Dependencies.begin(); + dit != component->Dependencies.end(); ++dit) { Dependencies.insert(Generator->ComponentPackages[*dit]); - } } + } // QtIFW dependencies - if(const char* option = this->GetOption(prefix + "DEPENDS")) - { + if (const char* option = this->GetOption(prefix + "DEPENDS")) { std::vector<std::string> deps; - cmSystemTools::ExpandListArgument(option, - deps); - for(std::vector<std::string>::iterator - dit = deps.begin(); dit != deps.end(); ++dit) - { + cmSystemTools::ExpandListArgument(option, deps); + for (std::vector<std::string>::iterator dit = deps.begin(); + dit != deps.end(); ++dit) { DependenceStruct dep(*dit); - if (!Generator->Packages.count(dep.Name)) - { + if (!Generator->Packages.count(dep.Name)) { bool hasDep = Generator->DependentPackages.count(dep.Name) > 0; - DependenceStruct &depRef = - Generator->DependentPackages[dep.Name]; - if(!hasDep) - { + DependenceStruct& depRef = Generator->DependentPackages[dep.Name]; + if (!hasDep) { depRef = dep; - } - AlienDependencies.insert(&depRef); } + AlienDependencies.insert(&depRef); } } + } // Licenses - if (const char* option = this->GetOption(prefix + "LICENSES")) - { + if (const char* option = this->GetOption(prefix + "LICENSES")) { 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); + 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); Licenses.clear(); - } } + } // Priority - if(const char* option = this->GetOption(prefix + "PRIORITY")) - { + if (const char* option = this->GetOption(prefix + "PRIORITY")) { SortingPriority = option; - } + } // Default Default = component->IsDisabledByDefault ? "false" : "true"; @@ -318,87 +276,74 @@ int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent *component) return 1; } -int -cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup *group) +int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group) { - if(!group) return 0; + if (!group) + return 0; // Restore defaul configuration DefaultConfiguration(); - std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" - + cmsys::SystemTools::UpperCase(group->Name) - + "_"; + std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" + + cmsys::SystemTools::UpperCase(group->Name) + "_"; DisplayName = group->DisplayName; Description = group->Description; // Version - if(const char* optVERSION = GetOption(prefix + "VERSION")) - { + if (const char* optVERSION = GetOption(prefix + "VERSION")) { Version = optVERSION; - } - else if(const char* optPACKAGE_VERSION = - GetOption("CPACK_PACKAGE_VERSION")) - { + } else if (const char* optPACKAGE_VERSION = + GetOption("CPACK_PACKAGE_VERSION")) { Version = optPACKAGE_VERSION; - } - else - { + } else { Version = "1.0.0"; - } + } // Script - if (const char* option = GetOption(prefix + "SCRIPT")) - { + if (const char* option = GetOption(prefix + "SCRIPT")) { Script = option; - } + } // Licenses - if (const char* option = this->GetOption(prefix + "LICENSES")) - { + if (const char* option = this->GetOption(prefix + "LICENSES")) { 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); + 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); Licenses.clear(); - } } + } // Priority - if(const char* option = this->GetOption(prefix + "PRIORITY")) - { + if (const char* option = this->GetOption(prefix + "PRIORITY")) { SortingPriority = option; - } + } return 1; } -int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName) +int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName) { // Group configuration cmCPackComponentGroup group; - std::string prefix = "CPACK_COMPONENT_GROUP_" - + cmsys::SystemTools::UpperCase(groupName) - + "_"; + std::string prefix = + "CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_"; - if (const char *option = GetOption(prefix + "DISPLAY_NAME")) - { + if (const char* option = GetOption(prefix + "DISPLAY_NAME")) { group.DisplayName = option; - } - else - { + } else { group.DisplayName = group.Name; - } + } - if (const char* option = GetOption(prefix + "DESCRIPTION")) - { + if (const char* option = GetOption(prefix + "DESCRIPTION")) { group.Description = option; - } + } group.IsBold = IsOn(prefix + "BOLD_TITLE"); group.IsExpandedByDefault = IsOn(prefix + "EXPANDED"); @@ -406,14 +351,11 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName) group.Name = groupName; - if(Generator) - { + if (Generator) { Name = Generator->GetGroupPackageName(&group); - } - else - { + } else { Name = group.Name; - } + } return ConfigureFromGroup(&group); } @@ -421,17 +363,13 @@ int cmCPackIFWPackage::ConfigureFromGroup(const std::string &groupName) void cmCPackIFWPackage::GeneratePackageFile() { // Lazy directory initialization - if (Directory.empty()) - { - if(Installer) - { + if (Directory.empty()) { + if (Installer) { Directory = Installer->Directory + "/packages/" + Name; - } - else if (Generator) - { + } else if (Generator) { Directory = Generator->toplevel + "/packages/" + Name; - } } + } // Output stream cmGeneratedFileStream fout((Directory + "/meta/package.xml").data()); @@ -448,98 +386,83 @@ void cmCPackIFWPackage::GeneratePackageFile() xout.Element("Name", Name); xout.Element("Version", Version); - if (!ReleaseDate.empty()) - { + if (!ReleaseDate.empty()) { xout.Element("ReleaseDate", ReleaseDate); - } - else - { + } else { xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true)); - } + } // Script (copy to meta dir) - if(!Script.empty()) - { + if (!Script.empty()) { std::string name = cmSystemTools::GetFilenameName(Script); std::string path = Directory + "/meta/" + name; cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data()); xout.Element("Script", name); - } + } // Dependencies std::set<DependenceStruct> compDepSet; - for(std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin(); - ait != AlienDependencies.end(); ++ait) - { + for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin(); + ait != AlienDependencies.end(); ++ait) { compDepSet.insert(*(*ait)); - } - for(std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin(); - it != Dependencies.end(); ++it) - { + } + for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin(); + it != Dependencies.end(); ++it) { compDepSet.insert(DependenceStruct((*it)->Name)); - } + } // Write dependencies - if (!compDepSet.empty()) - { + if (!compDepSet.empty()) { std::stringstream dependencies; std::set<DependenceStruct>::iterator it = compDepSet.begin(); dependencies << it->NameWithCompare(); ++it; - while(it != compDepSet.end()) - { + while (it != compDepSet.end()) { dependencies << "," << it->NameWithCompare(); ++it; - } - xout.Element("Dependencies", dependencies.str()); } + xout.Element("Dependencies", dependencies.str()); + } // Licenses (copy to meta dir) std::vector<std::string> licenses = Licenses; - for(size_t i = 1; i < licenses.size(); i += 2) - { + for (size_t i = 1; i < licenses.size(); i += 2) { std::string name = cmSystemTools::GetFilenameName(licenses[i]); std::string path = Directory + "/meta/" + name; cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data()); licenses[i] = name; - } - if(!licenses.empty()) - { + } + if (!licenses.empty()) { xout.StartElement("Licenses"); - for(size_t i = 0; i < licenses.size(); i += 2) - { + for (size_t i = 0; i < licenses.size(); i += 2) { xout.StartElement("License"); xout.Attribute("name", licenses[i]); xout.Attribute("file", licenses[i + 1]); xout.EndElement(); - } - xout.EndElement(); } + xout.EndElement(); + } - if (!ForcedInstallation.empty()) - { + if (!ForcedInstallation.empty()) { xout.Element("ForcedInstallation", ForcedInstallation); - } + } - if (!Virtual.empty()) - { + if (!Virtual.empty()) { xout.Element("Virtual", Virtual); - } - else if (!Default.empty()) - { + } else if (!Default.empty()) { xout.Element("Default", Default); - } + } // Priority - if(!SortingPriority.empty()) - { + if (!SortingPriority.empty()) { xout.Element("SortingPriority", SortingPriority); - } + } xout.EndElement(); xout.EndDocument(); } -void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter &xout) +void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout) { - if(Generator) Generator->WriteGeneratedByToStrim(xout); + if (Generator) + Generator->WriteGeneratedByToStrim(xout); } diff --git a/Source/CPack/IFW/cmCPackIFWPackage.h b/Source/CPack/IFW/cmCPackIFWPackage.h index 4f3f40b..8a566cb 100644 --- a/Source/CPack/IFW/cmCPackIFWPackage.h +++ b/Source/CPack/IFW/cmCPackIFWPackage.h @@ -31,11 +31,11 @@ public: enum CompareTypes { - CompareNone = 0x0, - CompareEqual = 0x1, - CompareLess = 0x2, - CompareLessOrEqual = 0x3, - CompareGreater = 0x4, + CompareNone = 0x0, + CompareEqual = 0x1, + CompareLess = 0x2, + CompareLessOrEqual = 0x3, + CompareGreater = 0x4, CompareGreaterOrEqual = 0x5 }; @@ -50,17 +50,17 @@ public: struct DependenceStruct { DependenceStruct(); - DependenceStruct(const std::string &dependence); + DependenceStruct(const std::string& dependence); std::string Name; CompareStruct Compare; std::string NameWithCompare() const; - bool operator < (const DependenceStruct &other) const - { + bool operator<(const DependenceStruct& other) const + { return Name < other.Name; - } + } }; public: @@ -113,18 +113,18 @@ public: 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 IsVersionLess(const char* version); + bool IsVersionGreater(const char* version); + bool IsVersionEqual(const char* version); - std::string GetComponentName(cmCPackComponent *component); + std::string GetComponentName(cmCPackComponent* component); void DefaultConfiguration(); int ConfigureFromOptions(); - int ConfigureFromComponent(cmCPackComponent *component); - int ConfigureFromGroup(cmCPackComponentGroup *group); - int ConfigureFromGroup(const std::string &groupName); + int ConfigureFromComponent(cmCPackComponent* component); + int ConfigureFromGroup(cmCPackComponentGroup* group); + int ConfigureFromGroup(const std::string& groupName); void GeneratePackageFile(); |