2014-08-06 19:23:00 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
|
|
|
|
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
|
|
|
|
|
|
|
This software is distributed WITHOUT ANY WARRANTY; without even the
|
|
|
|
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
See the License for more information.
|
|
|
|
============================================================================*/
|
|
|
|
|
|
|
|
#include "cmCPackIFWGenerator.h"
|
|
|
|
|
2016-09-07 01:21:35 +03:00
|
|
|
#include "CPack/cmCPackComponentGroup.h"
|
|
|
|
#include "CPack/cmCPackGenerator.h"
|
|
|
|
#include "CPack/cmCPackLog.h"
|
|
|
|
#include "cmCPackIFWInstaller.h"
|
|
|
|
#include "cmCPackIFWPackage.h"
|
|
|
|
#include "cmCPackIFWRepository.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
|
|
|
#include "cmSystemTools.h"
|
|
|
|
#include "cmTimestamp.h"
|
|
|
|
#include "cmVersionConfig.h"
|
|
|
|
#include "cmXMLWriter.h"
|
|
|
|
|
|
|
|
#include <sstream>
|
|
|
|
#include <utility>
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
cmCPackIFWGenerator::cmCPackIFWGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCPackIFWGenerator::~cmCPackIFWGenerator()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWGenerator::IsVersionLess(const char* version)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_LESS,
|
2016-05-16 17:34:04 +03:00
|
|
|
FrameworkVersion.data(), version);
|
2015-04-27 17:02:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWGenerator::IsVersionGreater(const char* version)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_GREATER,
|
2016-05-16 17:34:04 +03:00
|
|
|
FrameworkVersion.data(), version);
|
2015-04-27 17:02:49 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWGenerator::IsVersionEqual(const char* version)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
|
|
|
return cmSystemTools::VersionCompare(cmSystemTools::OP_EQUAL,
|
2016-05-16 17:34:04 +03:00
|
|
|
FrameworkVersion.data(), version);
|
2015-04-27 17:02:49 +03:00
|
|
|
}
|
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
int cmCPackIFWGenerator::PackageFiles()
|
|
|
|
{
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Configuration" << std::endl);
|
|
|
|
|
|
|
|
// Installer configuragion
|
|
|
|
Installer.GenerateInstallerFile();
|
|
|
|
|
|
|
|
// Packages configuration
|
|
|
|
Installer.GeneratePackageFiles();
|
|
|
|
|
|
|
|
std::string ifwTLD = this->GetOption("CPACK_TOPLEVEL_DIRECTORY");
|
|
|
|
std::string ifwTmpFile = ifwTLD;
|
|
|
|
ifwTmpFile += "/IFWOutput.log";
|
|
|
|
|
|
|
|
// Run repogen
|
2016-05-17 17:00:29 +03:00
|
|
|
if (!Installer.RemoteRepositories.empty()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
std::string ifwCmd = RepoGen;
|
2015-04-27 17:02:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (IsVersionLess("2.0.0")) {
|
2015-04-27 17:02:49 +03:00
|
|
|
ifwCmd += " -c " + this->toplevel + "/config/config.xml";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-27 17:02:49 +03:00
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
ifwCmd += " -p " + this->toplevel + "/packages";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!PkgsDirsVector.empty()) {
|
|
|
|
for (std::vector<std::string>::iterator it = PkgsDirsVector.begin();
|
|
|
|
it != PkgsDirsVector.end(); ++it) {
|
2014-08-06 19:23:00 +04:00
|
|
|
ifwCmd += " -p " + *it;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!OnlineOnly && !DownloadedPackages.empty()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
ifwCmd += " -i ";
|
2016-05-16 17:34:04 +03:00
|
|
|
std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
|
2014-08-06 19:23:00 +04:00
|
|
|
ifwCmd += (*it)->Name;
|
|
|
|
++it;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (it != DownloadedPackages.end()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
ifwCmd += "," + (*it)->Name;
|
|
|
|
++it;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
ifwCmd += " " + this->toplevel + "/repository";
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
|
2014-08-06 19:23:00 +04:00
|
|
|
std::string output;
|
|
|
|
int retVal = 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate repository"
|
|
|
|
<< std::endl);
|
2016-06-27 23:44:16 +03:00
|
|
|
bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output,
|
|
|
|
&output, &retVal, CM_NULLPTR,
|
|
|
|
this->GeneratorVerbose, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!res || retVal) {
|
2014-08-06 19:23:00 +04:00
|
|
|
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: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< ifwCmd << std::endl
|
|
|
|
<< "Please check " << ifwTmpFile << " for errors"
|
|
|
|
<< std::endl);
|
2014-08-06 19:23:00 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2016-05-17 17:00:29 +03:00
|
|
|
|
|
|
|
if (!Repository.RepositoryUpdate.empty() &&
|
|
|
|
!Repository.PatchUpdatesXml()) {
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING, "Problem patch IFW \"Updates\" "
|
|
|
|
<< "file: " << this->toplevel + "/repository/Updates.xml"
|
|
|
|
<< std::endl);
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- repository: "
|
|
|
|
<< this->toplevel << "/repository generated" << std::endl);
|
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Run binary creator
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
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;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (OnlineOnly) {
|
|
|
|
ifwCmd += " --online-only";
|
|
|
|
} else if (!DownloadedPackages.empty() &&
|
2016-05-17 17:00:29 +03:00
|
|
|
!Installer.RemoteRepositories.empty()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
ifwCmd += " -e ";
|
|
|
|
std::set<cmCPackIFWPackage*>::iterator it = DownloadedPackages.begin();
|
|
|
|
ifwCmd += (*it)->Name;
|
2014-08-06 19:23:00 +04:00
|
|
|
++it;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (it != DownloadedPackages.end()) {
|
|
|
|
ifwCmd += "," + (*it)->Name;
|
|
|
|
++it;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!DependentPackages.empty()) {
|
|
|
|
ifwCmd += " -i ";
|
|
|
|
// Binary
|
|
|
|
std::set<cmCPackIFWPackage*>::iterator bit = BinaryPackages.begin();
|
|
|
|
while (bit != BinaryPackages.end()) {
|
|
|
|
ifwCmd += (*bit)->Name + ",";
|
|
|
|
++bit;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
// Depend
|
|
|
|
DependenceMap::iterator it = DependentPackages.begin();
|
|
|
|
ifwCmd += it->second.Name;
|
2014-08-06 19:23:00 +04:00
|
|
|
++it;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (it != DependentPackages.end()) {
|
|
|
|
ifwCmd += "," + it->second.Name;
|
|
|
|
++it;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
// TODO: set correct name for multipackages
|
|
|
|
if (!this->packageFileNames.empty()) {
|
|
|
|
ifwCmd += " " + packageFileNames[0];
|
|
|
|
} else {
|
|
|
|
ifwCmd += " installer";
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_VERBOSE, "Execute: " << ifwCmd << std::endl);
|
|
|
|
std::string output;
|
|
|
|
int retVal = 1;
|
|
|
|
cmCPackLogger(cmCPackLog::LOG_OUTPUT, "- Generate package" << std::endl);
|
2016-06-27 23:44:16 +03:00
|
|
|
bool res = cmSystemTools::RunSingleCommand(ifwCmd.c_str(), &output,
|
|
|
|
&output, &retVal, CM_NULLPTR,
|
|
|
|
this->GeneratorVerbose, 0);
|
2016-05-16 17:34:04 +03:00
|
|
|
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;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmCPackIFWGenerator::GetPackagingInstallPrefix()
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* defPrefix = cmCPackGenerator::GetPackagingInstallPrefix();
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
std::string tmpPref = defPrefix ? defPrefix : "";
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Components.empty()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
tmpPref += "packages/" + GetRootPackageName() + "/data";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
this->SetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX", tmpPref.c_str());
|
|
|
|
|
|
|
|
return this->GetOption("CPACK_IFW_PACKAGING_INSTALL_PREFIX");
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmCPackIFWGenerator::GetOutputExtension()
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2015-04-27 17:02:49 +03:00
|
|
|
return ExecutableSuffix.c_str();
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
int cmCPackIFWGenerator::InitializeInternal()
|
|
|
|
{
|
|
|
|
// Search Qt Installer Framework tools
|
|
|
|
|
2014-10-04 22:55:43 +04:00
|
|
|
const std::string BinCreatorOpt = "CPACK_IFW_BINARYCREATOR_EXECUTABLE";
|
|
|
|
const std::string RepoGenOpt = "CPACK_IFW_REPOGEN_EXECUTABLE";
|
2015-07-08 20:23:34 +03:00
|
|
|
const std::string FrameworkVersionOpt = "CPACK_IFW_FRAMEWORK_VERSION";
|
2014-10-04 22:55:43 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->IsSet(BinCreatorOpt) || !this->IsSet(RepoGenOpt) ||
|
|
|
|
!this->IsSet(FrameworkVersionOpt)) {
|
2014-08-06 19:23:00 +04:00
|
|
|
this->ReadListFile("CPackIFW.cmake");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Look 'binarycreator' executable (needs)
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* BinCreatorStr = this->GetOption(BinCreatorOpt);
|
|
|
|
if (!BinCreatorStr || cmSystemTools::IsNOTFOUND(BinCreatorStr)) {
|
2014-10-04 22:55:43 +04:00
|
|
|
BinCreator = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-04 22:55:43 +04:00
|
|
|
BinCreator = BinCreatorStr;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (BinCreator.empty()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"Cannot find QtIFW compiler \"binarycreator\": "
|
|
|
|
"likely it is not installed, or not in your PATH"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2014-08-06 19:23:00 +04:00
|
|
|
return 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Look 'repogen' executable (optional)
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* RepoGenStr = this->GetOption(RepoGenOpt);
|
|
|
|
if (!RepoGenStr || cmSystemTools::IsNOTFOUND(RepoGenStr)) {
|
2014-10-04 22:55:43 +04:00
|
|
|
RepoGen = "";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-04 22:55:43 +04:00
|
|
|
RepoGen = RepoGenStr;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2015-04-27 17:02:49 +03:00
|
|
|
// Framework version
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* FrameworkVersionSrt = this->GetOption(FrameworkVersionOpt)) {
|
2015-04-27 17:02:49 +03:00
|
|
|
FrameworkVersion = FrameworkVersionSrt;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-27 17:02:49 +03:00
|
|
|
FrameworkVersion = "1.9.9";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-27 17:02:49 +03:00
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
// Variables that Change Behavior
|
|
|
|
|
|
|
|
// Resolve duplicate names
|
|
|
|
ResolveDuplicateNames = this->IsOn("CPACK_IFW_RESOLVE_DUPLICATE_NAMES");
|
|
|
|
|
|
|
|
// Additional packages dirs
|
|
|
|
PkgsDirsVector.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* dirs = this->GetOption("CPACK_IFW_PACKAGES_DIRECTORIES")) {
|
|
|
|
cmSystemTools::ExpandListArgument(dirs, PkgsDirsVector);
|
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2014-10-05 12:52:57 +04:00
|
|
|
// Installer
|
|
|
|
Installer.Generator = this;
|
|
|
|
Installer.ConfigureFromOptions();
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-17 17:00:29 +03:00
|
|
|
// Repository
|
|
|
|
Repository.Generator = this;
|
|
|
|
Repository.Name = "Unspecified";
|
|
|
|
if (const char* site = this->GetOption("CPACK_DOWNLOAD_SITE")) {
|
|
|
|
Repository.Url = site;
|
|
|
|
Installer.RemoteRepositories.push_back(&Repository);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Repositories
|
|
|
|
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) {
|
|
|
|
GetRepository(*rit);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* ifwDownloadAll = this->GetOption("CPACK_IFW_DOWNLOAD_ALL")) {
|
2014-10-05 12:52:57 +04:00
|
|
|
OnlineOnly = cmSystemTools::IsOn(ifwDownloadAll);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* cpackDownloadAll =
|
|
|
|
this->GetOption("CPACK_DOWNLOAD_ALL")) {
|
2014-10-05 12:52:57 +04:00
|
|
|
OnlineOnly = cmSystemTools::IsOn(cpackDownloadAll);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-10-05 12:52:57 +04:00
|
|
|
OnlineOnly = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-17 17:00:29 +03:00
|
|
|
if (!Installer.RemoteRepositories.empty() && RepoGen.empty()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR,
|
|
|
|
"Cannot find QtIFW repository generator \"repogen\": "
|
|
|
|
"likely it is not installed, or not in your PATH"
|
|
|
|
<< std::endl);
|
|
|
|
return 0;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
|
2015-04-27 17:02:49 +03:00
|
|
|
// Executable suffix
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* optExeSuffix = this->GetOption("CMAKE_EXECUTABLE_SUFFIX")) {
|
2015-04-27 17:02:49 +03:00
|
|
|
ExecutableSuffix = optExeSuffix;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (ExecutableSuffix.empty()) {
|
2015-04-27 17:02:49 +03:00
|
|
|
std::string sysName(this->GetOption("CMAKE_SYSTEM_NAME"));
|
2016-05-16 17:34:04 +03:00
|
|
|
if (sysName == "Linux") {
|
2015-04-27 17:02:49 +03:00
|
|
|
ExecutableSuffix = ".run";
|
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-04-27 17:02:49 +03:00
|
|
|
ExecutableSuffix = cmCPackGenerator::GetOutputExtension();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-04-27 17:02:49 +03:00
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
return this->Superclass::InitializeInternal();
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmCPackIFWGenerator::GetComponentInstallDirNameSuffix(
|
2014-08-06 19:23:00 +04:00
|
|
|
const std::string& componentName)
|
|
|
|
{
|
|
|
|
const std::string prefix = "packages/";
|
|
|
|
const std::string suffix = "/data";
|
|
|
|
|
|
|
|
if (componentPackageMethod == ONE_PACKAGE) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return std::string(prefix + GetRootPackageName() + suffix);
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
return prefix + GetComponentPackageName(&Components[componentName]) + suffix;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponent* cmCPackIFWGenerator::GetComponent(
|
|
|
|
const std::string& projectName, const std::string& componentName)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
|
|
|
ComponentsMap::iterator cit = Components.find(componentName);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (cit != Components.end()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return &(cit->second);
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponent* component =
|
|
|
|
cmCPackGenerator::GetComponent(projectName, componentName);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!component) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return component;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
std::string name = GetComponentPackageName(component);
|
|
|
|
PackagesMap::iterator pit = Packages.find(name);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (pit != Packages.end()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return component;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackIFWPackage* package = &Packages[name];
|
2014-08-06 19:23:00 +04:00
|
|
|
package->Name = name;
|
|
|
|
package->Generator = this;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (package->ConfigureFromComponent(component)) {
|
2014-08-06 19:23:00 +04:00
|
|
|
package->Installer = &Installer;
|
|
|
|
Installer.Packages.insert(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::pair<std::string, cmCPackIFWPackage*>(name, package));
|
2014-08-06 19:23:00 +04:00
|
|
|
ComponentPackages.insert(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::pair<cmCPackComponent*, cmCPackIFWPackage*>(component, package));
|
|
|
|
if (component->IsDownloaded) {
|
2014-08-06 19:23:00 +04:00
|
|
|
DownloadedPackages.insert(package);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
BinaryPackages.insert(package);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
Packages.erase(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
|
|
|
|
<< name << "\" for component \"" << component->Name << "\""
|
|
|
|
<< std::endl);
|
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
return component;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponentGroup* cmCPackIFWGenerator::GetComponentGroup(
|
|
|
|
const std::string& projectName, const std::string& groupName)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponentGroup* group =
|
|
|
|
cmCPackGenerator::GetComponentGroup(projectName, groupName);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!group) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return group;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
std::string name = GetGroupPackageName(group);
|
|
|
|
PackagesMap::iterator pit = Packages.find(name);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (pit != Packages.end()) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return group;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackIFWPackage* package = &Packages[name];
|
2014-08-06 19:23:00 +04:00
|
|
|
package->Name = name;
|
|
|
|
package->Generator = this;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (package->ConfigureFromGroup(group)) {
|
2014-08-06 19:23:00 +04:00
|
|
|
package->Installer = &Installer;
|
|
|
|
Installer.Packages.insert(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::pair<std::string, cmCPackIFWPackage*>(name, package));
|
2014-08-06 19:23:00 +04:00
|
|
|
GroupPackages.insert(
|
2016-05-16 17:34:04 +03:00
|
|
|
std::pair<cmCPackComponentGroup*, cmCPackIFWPackage*>(group, package));
|
2014-08-06 19:23:00 +04:00
|
|
|
BinaryPackages.insert(package);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
Packages.erase(name);
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_ERROR, "Cannot configure package \""
|
|
|
|
<< name << "\" for component group \"" << group->Name
|
|
|
|
<< "\"" << std::endl);
|
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
return group;
|
|
|
|
}
|
|
|
|
|
|
|
|
enum cmCPackGenerator::CPackSetDestdirSupport
|
|
|
|
cmCPackIFWGenerator::SupportsSetDestdir() const
|
|
|
|
{
|
|
|
|
return cmCPackGenerator::SETDESTDIR_SHOULD_NOT_BE_USED;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCPackIFWGenerator::SupportsAbsoluteDestination() const
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCPackIFWGenerator::SupportsComponentInstallation() const
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCPackIFWGenerator::IsOnePackage() const
|
|
|
|
{
|
|
|
|
return componentPackageMethod == ONE_PACKAGE;
|
|
|
|
}
|
|
|
|
|
2014-08-12 22:44:02 +04:00
|
|
|
std::string cmCPackIFWGenerator::GetRootPackageName()
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2014-08-12 22:44:02 +04:00
|
|
|
// Default value
|
2014-08-06 19:23:00 +04:00
|
|
|
std::string name = "root";
|
2014-08-12 22:44:02 +04:00
|
|
|
if (const char* optIFW_PACKAGE_GROUP =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("CPACK_IFW_PACKAGE_GROUP")) {
|
2014-08-12 22:44:02 +04:00
|
|
|
// Configure from root group
|
|
|
|
cmCPackIFWPackage package;
|
|
|
|
package.Generator = this;
|
|
|
|
package.ConfigureFromGroup(optIFW_PACKAGE_GROUP);
|
|
|
|
name = package.Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* optIFW_PACKAGE_NAME =
|
|
|
|
this->GetOption("CPACK_IFW_PACKAGE_NAME")) {
|
2014-08-12 22:44:02 +04:00
|
|
|
// Configure from root package name
|
|
|
|
name = optIFW_PACKAGE_NAME;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* optPACKAGE_NAME =
|
|
|
|
this->GetOption("CPACK_PACKAGE_NAME")) {
|
2014-08-12 22:44:02 +04:00
|
|
|
// Configure from package name
|
2014-08-06 19:23:00 +04:00
|
|
|
name = optPACKAGE_NAME;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmCPackIFWGenerator::GetGroupPackageName(
|
|
|
|
cmCPackComponentGroup* group) const
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
|
|
|
std::string name;
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!group) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return name;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmCPackIFWPackage* package = GetGroupPackage(group)) {
|
2014-08-06 19:23:00 +04:00
|
|
|
return package->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
const char* option =
|
|
|
|
GetOption("CPACK_IFW_COMPONENT_GROUP_" +
|
|
|
|
cmsys::SystemTools::UpperCase(group->Name) + "_NAME");
|
2014-08-06 19:23:00 +04:00
|
|
|
name = option ? option : group->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (group->ParentGroup) {
|
2014-08-06 19:23:00 +04:00
|
|
|
cmCPackIFWPackage* package = GetGroupPackage(group->ParentGroup);
|
|
|
|
bool dot = !ResolveDuplicateNames;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dot && name.substr(0, package->Name.size()) == package->Name) {
|
2014-08-06 19:23:00 +04:00
|
|
|
dot = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (dot) {
|
2014-08-06 19:23:00 +04:00
|
|
|
name = package->Name + "." + name;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmCPackIFWGenerator::GetComponentPackageName(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponent* component) const
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
|
|
|
std::string name;
|
2016-06-10 19:36:24 +03:00
|
|
|
if (!component) {
|
2016-05-16 17:34:04 +03:00
|
|
|
return name;
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmCPackIFWPackage* package = GetComponentPackage(component)) {
|
2014-08-06 19:23:00 +04:00
|
|
|
return package->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
std::string prefix = "CPACK_IFW_COMPONENT_" +
|
|
|
|
cmsys::SystemTools::UpperCase(component->Name) + "_";
|
2014-08-06 19:23:00 +04:00
|
|
|
const char* option = GetOption(prefix + "NAME");
|
|
|
|
name = option ? option : component->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (component->Group) {
|
2014-08-06 19:23:00 +04:00
|
|
|
cmCPackIFWPackage* package = GetGroupPackage(component->Group);
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((componentPackageMethod == ONE_PACKAGE_PER_GROUP) ||
|
|
|
|
IsOn(prefix + "COMMON")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
return package->Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
bool dot = !ResolveDuplicateNames;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (dot && name.substr(0, package->Name.size()) == package->Name) {
|
2014-08-06 19:23:00 +04:00
|
|
|
dot = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (dot) {
|
2014-08-06 19:23:00 +04:00
|
|
|
name = package->Name + "." + name;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
return name;
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCPackIFWPackage* cmCPackIFWGenerator::GetGroupPackage(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponentGroup* group) const
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<cmCPackComponentGroup*, cmCPackIFWPackage*>::const_iterator pit =
|
|
|
|
GroupPackages.find(group);
|
2016-06-27 23:44:16 +03:00
|
|
|
return pit != GroupPackages.end() ? pit->second : CM_NULLPTR;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
cmCPackIFWPackage* cmCPackIFWGenerator::GetComponentPackage(
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackComponent* component) const
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
std::map<cmCPackComponent*, cmCPackIFWPackage*>::const_iterator pit =
|
|
|
|
ComponentPackages.find(component);
|
2016-06-27 23:44:16 +03:00
|
|
|
return pit != ComponentPackages.end() ? pit->second : CM_NULLPTR;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
2015-04-27 17:02:49 +03:00
|
|
|
|
2016-05-17 17:00:29 +03:00
|
|
|
cmCPackIFWRepository* cmCPackIFWGenerator::GetRepository(
|
|
|
|
const std::string& repositoryName)
|
|
|
|
{
|
|
|
|
RepositoriesMap::iterator rit = Repositories.find(repositoryName);
|
2016-06-10 19:36:24 +03:00
|
|
|
if (rit != Repositories.end()) {
|
2016-05-17 17:00:29 +03:00
|
|
|
return &(rit->second);
|
2016-06-10 19:36:24 +03:00
|
|
|
}
|
2016-05-17 17:00:29 +03:00
|
|
|
|
|
|
|
cmCPackIFWRepository* repository = &Repositories[repositoryName];
|
|
|
|
repository->Name = repositoryName;
|
|
|
|
repository->Generator = this;
|
|
|
|
if (repository->ConfigureFromOptions()) {
|
|
|
|
if (repository->Update == cmCPackIFWRepository::None) {
|
|
|
|
Installer.RemoteRepositories.push_back(repository);
|
|
|
|
} else {
|
|
|
|
Repository.RepositoryUpdate.push_back(repository);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
Repositories.erase(repositoryName);
|
2016-06-27 23:44:16 +03:00
|
|
|
repository = CM_NULLPTR;
|
2016-05-17 17:00:29 +03:00
|
|
|
cmCPackLogger(cmCPackLog::LOG_WARNING, "Invalid repository \""
|
|
|
|
<< repositoryName << "\""
|
|
|
|
<< " configuration. Repository will be skipped."
|
|
|
|
<< std::endl);
|
|
|
|
}
|
|
|
|
return repository;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCPackIFWGenerator::WriteGeneratedByToStrim(cmXMLWriter& xout)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
2016-06-14 23:37:36 +03:00
|
|
|
std::ostringstream comment;
|
2015-07-16 22:53:57 +03:00
|
|
|
comment << "Generated by CPack " << CMake_VERSION << " IFW generator "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< "for QtIFW ";
|
|
|
|
if (IsVersionLess("2.0")) {
|
2015-07-16 22:53:57 +03:00
|
|
|
comment << "less 2.0";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-07-16 22:53:57 +03:00
|
|
|
comment << FrameworkVersion;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2015-07-16 22:53:57 +03:00
|
|
|
comment << " tools at " << cmTimestamp().CurrentTime("", true);
|
|
|
|
xout.Comment(comment.str().c_str());
|
2015-04-27 17:02:49 +03:00
|
|
|
}
|