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 "cmCPackIFWPackage.h"
|
|
|
|
|
|
|
|
#include "cmCPackIFWGenerator.h"
|
|
|
|
|
|
|
|
#include <CPack/cmCPackLog.h>
|
|
|
|
|
|
|
|
#include <cmGeneratedFileStream.h>
|
|
|
|
#include <cmTimestamp.h>
|
2015-07-16 22:53:57 +03:00
|
|
|
#include <cmXMLWriter.h>
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
//----------------------------------------------------------------- Logger ---
|
|
|
|
#ifdef cmCPackLogger
|
2016-05-16 17:34:04 +03:00
|
|
|
#undef cmCPackLogger
|
2014-08-06 19:23:00 +04:00
|
|
|
#endif
|
2016-05-16 17:34:04 +03:00
|
|
|
#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)
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
//---------------------------------------------------------- CompareStruct ---
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackIFWPackage::CompareStruct::CompareStruct()
|
|
|
|
: Type(CompareNone)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------- DependenceStruct ---
|
|
|
|
cmCPackIFWPackage::DependenceStruct::DependenceStruct()
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
cmCPackIFWPackage::DependenceStruct::DependenceStruct(
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::string& dependence)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
|
|
|
// Search compare section
|
|
|
|
size_t pos = std::string::npos;
|
2016-05-16 17:34:04 +03:00
|
|
|
if ((pos = dependence.find("<=")) != std::string::npos) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Compare.Type = CompareLessOrEqual;
|
|
|
|
Compare.Value = dependence.substr(pos + 2);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if ((pos = dependence.find(">=")) != std::string::npos) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Compare.Type = CompareGreaterOrEqual;
|
|
|
|
Compare.Value = dependence.substr(pos + 2);
|
2016-05-24 22:24:10 +03:00
|
|
|
} else if ((pos = dependence.find('<')) != std::string::npos) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Compare.Type = CompareLess;
|
|
|
|
Compare.Value = dependence.substr(pos + 1);
|
2016-05-24 22:24:10 +03:00
|
|
|
} else if ((pos = dependence.find('=')) != std::string::npos) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Compare.Type = CompareEqual;
|
|
|
|
Compare.Value = dependence.substr(pos + 1);
|
2016-05-24 22:24:10 +03:00
|
|
|
} else if ((pos = dependence.find('>')) != std::string::npos) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Compare.Type = CompareGreater;
|
|
|
|
Compare.Value = dependence.substr(pos + 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
Name = pos == std::string::npos ? dependence : dependence.substr(0, pos);
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string cmCPackIFWPackage::DependenceStruct::NameWithCompare() const
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (Compare.Type == CompareNone)
|
|
|
|
return Name;
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
std::string result = Name;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (Compare.Type == CompareLessOrEqual) {
|
2014-08-06 19:23:00 +04:00
|
|
|
result += "<=";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (Compare.Type == CompareGreaterOrEqual) {
|
2014-08-06 19:23:00 +04:00
|
|
|
result += ">=";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (Compare.Type == CompareLess) {
|
2014-08-06 19:23:00 +04:00
|
|
|
result += "<";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (Compare.Type == CompareEqual) {
|
2014-08-06 19:23:00 +04:00
|
|
|
result += "=";
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (Compare.Type == CompareGreater) {
|
2014-08-06 19:23:00 +04:00
|
|
|
result += ">";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
result += Compare.Value;
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
//------------------------------------------------------ cmCPackIFWPackage ---
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCPackIFWPackage::cmCPackIFWPackage()
|
|
|
|
: Generator(0)
|
|
|
|
, Installer(0)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* cmCPackIFWPackage::GetOption(const std::string& op) const
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* option = Generator ? Generator->GetOption(op) : 0;
|
2014-08-12 22:44:02 +04:00
|
|
|
return option && *option ? option : 0;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWPackage::IsOn(const std::string& op) const
|
2014-08-12 22:44:02 +04:00
|
|
|
{
|
|
|
|
return Generator ? Generator->IsOn(op) : false;
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWPackage::IsVersionLess(const char* version)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
|
|
|
return Generator ? Generator->IsVersionLess(version) : false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWPackage::IsVersionGreater(const char* version)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
|
|
|
return Generator ? Generator->IsVersionGreater(version) : false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCPackIFWPackage::IsVersionEqual(const char* version)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
|
|
|
return Generator ? Generator->IsVersionEqual(version) : false;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string cmCPackIFWPackage::GetComponentName(cmCPackComponent* component)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!component)
|
|
|
|
return "";
|
|
|
|
const char* option =
|
|
|
|
GetOption("CPACK_IFW_COMPONENT_" +
|
|
|
|
cmsys::SystemTools::UpperCase(component->Name) + "_NAME");
|
2014-08-06 19:23:00 +04:00
|
|
|
return option ? option : component->Name;
|
|
|
|
}
|
|
|
|
|
|
|
|
void cmCPackIFWPackage::DefaultConfiguration()
|
|
|
|
{
|
|
|
|
DisplayName = "";
|
|
|
|
Description = "";
|
|
|
|
Version = "";
|
|
|
|
ReleaseDate = "";
|
|
|
|
Script = "";
|
|
|
|
Licenses.clear();
|
|
|
|
SortingPriority = "";
|
|
|
|
Default = "";
|
2016-05-23 15:32:22 +03:00
|
|
|
Essential = "";
|
2014-08-06 19:23:00 +04:00
|
|
|
Virtual = "";
|
|
|
|
ForcedInstallation = "";
|
|
|
|
}
|
|
|
|
|
|
|
|
// Defaul configuration (all in one package)
|
|
|
|
int cmCPackIFWPackage::ConfigureFromOptions()
|
|
|
|
{
|
|
|
|
// Restore defaul configuration
|
|
|
|
DefaultConfiguration();
|
|
|
|
|
|
|
|
// Name
|
|
|
|
Name = Generator->GetRootPackageName();
|
|
|
|
|
|
|
|
// Display name
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = this->GetOption("CPACK_PACKAGE_NAME")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
DisplayName = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
DisplayName = "Your package";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Description
|
|
|
|
if (const char* option =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->GetOption("CPACK_PACKAGE_DESCRIPTION_SUMMARY")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Description = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
Description = "Your package description";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Version
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = GetOption("CPACK_PACKAGE_VERSION")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = "1.0.0";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
ForcedInstallation = "true";
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int cmCPackIFWPackage::ConfigureFromComponent(cmCPackComponent* component)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!component)
|
|
|
|
return 0;
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Restore defaul configuration
|
|
|
|
DefaultConfiguration();
|
|
|
|
|
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
|
|
|
|
|
|
|
// Display name
|
|
|
|
DisplayName = component->DisplayName;
|
|
|
|
|
|
|
|
// Description
|
|
|
|
Description = component->Description;
|
|
|
|
|
|
|
|
// Version
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* optVERSION = GetOption(prefix + "VERSION")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = optVERSION;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* optPACKAGE_VERSION =
|
|
|
|
GetOption("CPACK_PACKAGE_VERSION")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = optPACKAGE_VERSION;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = "1.0.0";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Script
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = GetOption(prefix + "SCRIPT")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Script = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// CMake dependencies
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!component->Dependencies.empty()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
std::vector<cmCPackComponent*>::iterator dit;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (dit = component->Dependencies.begin();
|
|
|
|
dit != component->Dependencies.end(); ++dit) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Dependencies.insert(Generator->ComponentPackages[*dit]);
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// QtIFW dependencies
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = this->GetOption(prefix + "DEPENDS")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
std::vector<std::string> deps;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(option, deps);
|
|
|
|
for (std::vector<std::string>::iterator dit = deps.begin();
|
|
|
|
dit != deps.end(); ++dit) {
|
2014-08-06 19:23:00 +04:00
|
|
|
DependenceStruct dep(*dit);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!Generator->Packages.count(dep.Name)) {
|
2014-08-06 19:23:00 +04:00
|
|
|
bool hasDep = Generator->DependentPackages.count(dep.Name) > 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
DependenceStruct& depRef = Generator->DependentPackages[dep.Name];
|
|
|
|
if (!hasDep) {
|
2014-08-06 19:23:00 +04:00
|
|
|
depRef = dep;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
AlienDependencies.insert(&depRef);
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Licenses
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = this->GetOption(prefix + "LICENSES")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Licenses.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
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);
|
2014-08-06 19:23:00 +04:00
|
|
|
Licenses.clear();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Priority
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = this->GetOption(prefix + "PRIORITY")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
SortingPriority = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Default
|
|
|
|
Default = component->IsDisabledByDefault ? "false" : "true";
|
|
|
|
|
2016-05-23 15:32:22 +03:00
|
|
|
// Essential
|
|
|
|
if (this->IsOn(prefix + "ESSENTIAL")) {
|
|
|
|
Essential = "true";
|
|
|
|
}
|
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
// Virtual
|
|
|
|
Virtual = component->IsHidden ? "true" : "";
|
|
|
|
|
|
|
|
// ForcedInstallation
|
|
|
|
ForcedInstallation = component->IsRequired ? "true" : "false";
|
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int cmCPackIFWPackage::ConfigureFromGroup(cmCPackComponentGroup* group)
|
2014-08-06 19:23:00 +04:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!group)
|
|
|
|
return 0;
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Restore defaul configuration
|
|
|
|
DefaultConfiguration();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string prefix = "CPACK_IFW_COMPONENT_GROUP_" +
|
|
|
|
cmsys::SystemTools::UpperCase(group->Name) + "_";
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
DisplayName = group->DisplayName;
|
|
|
|
Description = group->Description;
|
|
|
|
|
|
|
|
// Version
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* optVERSION = GetOption(prefix + "VERSION")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = optVERSION;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (const char* optPACKAGE_VERSION =
|
|
|
|
GetOption("CPACK_PACKAGE_VERSION")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = optPACKAGE_VERSION;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-06 19:23:00 +04:00
|
|
|
Version = "1.0.0";
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2014-08-12 22:44:02 +04:00
|
|
|
// Script
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = GetOption(prefix + "SCRIPT")) {
|
2014-08-12 22:44:02 +04:00
|
|
|
Script = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-12 22:44:02 +04:00
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
// Licenses
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = this->GetOption(prefix + "LICENSES")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Licenses.clear();
|
2016-05-16 17:34:04 +03:00
|
|
|
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);
|
2014-08-06 19:23:00 +04:00
|
|
|
Licenses.clear();
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Priority
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = this->GetOption(prefix + "PRIORITY")) {
|
2014-08-06 19:23:00 +04:00
|
|
|
SortingPriority = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
int cmCPackIFWPackage::ConfigureFromGroup(const std::string& groupName)
|
2014-08-12 22:44:02 +04:00
|
|
|
{
|
|
|
|
// Group configuration
|
|
|
|
|
|
|
|
cmCPackComponentGroup group;
|
2016-05-16 17:34:04 +03:00
|
|
|
std::string prefix =
|
|
|
|
"CPACK_COMPONENT_GROUP_" + cmsys::SystemTools::UpperCase(groupName) + "_";
|
2014-08-12 22:44:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = GetOption(prefix + "DISPLAY_NAME")) {
|
2014-08-12 22:44:02 +04:00
|
|
|
group.DisplayName = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-12 22:44:02 +04:00
|
|
|
group.DisplayName = group.Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-12 22:44:02 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (const char* option = GetOption(prefix + "DESCRIPTION")) {
|
2014-08-12 22:44:02 +04:00
|
|
|
group.Description = option;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-12 22:44:02 +04:00
|
|
|
group.IsBold = IsOn(prefix + "BOLD_TITLE");
|
|
|
|
group.IsExpandedByDefault = IsOn(prefix + "EXPANDED");
|
|
|
|
|
|
|
|
// Package configuration
|
|
|
|
|
|
|
|
group.Name = groupName;
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (Generator) {
|
2014-08-12 22:44:02 +04:00
|
|
|
Name = Generator->GetGroupPackageName(&group);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2014-08-12 22:44:02 +04:00
|
|
|
Name = group.Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-12 22:44:02 +04:00
|
|
|
|
|
|
|
return ConfigureFromGroup(&group);
|
|
|
|
}
|
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
void cmCPackIFWPackage::GeneratePackageFile()
|
|
|
|
{
|
|
|
|
// Lazy directory initialization
|
2016-05-16 17:34:04 +03:00
|
|
|
if (Directory.empty()) {
|
|
|
|
if (Installer) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Directory = Installer->Directory + "/packages/" + Name;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (Generator) {
|
2014-08-06 19:23:00 +04:00
|
|
|
Directory = Generator->toplevel + "/packages/" + Name;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Output stream
|
2015-07-16 22:53:57 +03:00
|
|
|
cmGeneratedFileStream fout((Directory + "/meta/package.xml").data());
|
|
|
|
cmXMLWriter xout(fout);
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.StartDocument();
|
2015-04-27 17:02:49 +03:00
|
|
|
|
|
|
|
WriteGeneratedByToStrim(xout);
|
|
|
|
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.StartElement("Package");
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("DisplayName", DisplayName);
|
|
|
|
xout.Element("Description", Description);
|
|
|
|
xout.Element("Name", Name);
|
|
|
|
xout.Element("Version", Version);
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ReleaseDate.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("ReleaseDate", ReleaseDate);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("ReleaseDate", cmTimestamp().CurrentTime("%Y-%m-%d", true));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Script (copy to meta dir)
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!Script.empty()) {
|
2014-08-06 19:23:00 +04:00
|
|
|
std::string name = cmSystemTools::GetFilenameName(Script);
|
|
|
|
std::string path = Directory + "/meta/" + name;
|
|
|
|
cmsys::SystemTools::CopyFileIfDifferent(Script.data(), path.data());
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("Script", name);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Dependencies
|
|
|
|
std::set<DependenceStruct> compDepSet;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::set<DependenceStruct*>::iterator ait = AlienDependencies.begin();
|
|
|
|
ait != AlienDependencies.end(); ++ait) {
|
2014-08-06 19:23:00 +04:00
|
|
|
compDepSet.insert(*(*ait));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
for (std::set<cmCPackIFWPackage*>::iterator it = Dependencies.begin();
|
|
|
|
it != Dependencies.end(); ++it) {
|
2014-08-06 19:23:00 +04:00
|
|
|
compDepSet.insert(DependenceStruct((*it)->Name));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
// Write dependencies
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!compDepSet.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
std::stringstream dependencies;
|
2014-08-06 19:23:00 +04:00
|
|
|
std::set<DependenceStruct>::iterator it = compDepSet.begin();
|
2015-07-16 22:53:57 +03:00
|
|
|
dependencies << it->NameWithCompare();
|
2014-08-06 19:23:00 +04:00
|
|
|
++it;
|
2016-05-16 17:34:04 +03:00
|
|
|
while (it != compDepSet.end()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
dependencies << "," << it->NameWithCompare();
|
2014-08-06 19:23:00 +04:00
|
|
|
++it;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
xout.Element("Dependencies", dependencies.str());
|
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
|
|
|
// Licenses (copy to meta dir)
|
|
|
|
std::vector<std::string> licenses = Licenses;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 1; i < licenses.size(); i += 2) {
|
2014-08-06 19:23:00 +04:00
|
|
|
std::string name = cmSystemTools::GetFilenameName(licenses[i]);
|
|
|
|
std::string path = Directory + "/meta/" + name;
|
|
|
|
cmsys::SystemTools::CopyFileIfDifferent(licenses[i].data(), path.data());
|
|
|
|
licenses[i] = name;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!licenses.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.StartElement("Licenses");
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < licenses.size(); i += 2) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.StartElement("License");
|
|
|
|
xout.Attribute("name", licenses[i]);
|
|
|
|
xout.Attribute("file", licenses[i + 1]);
|
|
|
|
xout.EndElement();
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
xout.EndElement();
|
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ForcedInstallation.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("ForcedInstallation", ForcedInstallation);
|
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 (!Virtual.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("Virtual", Virtual);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (!Default.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("Default", Default);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2016-05-23 15:32:22 +03:00
|
|
|
// Essential
|
|
|
|
if (!Essential.empty()) {
|
|
|
|
xout.Element("Essential", Essential);
|
|
|
|
}
|
|
|
|
|
2014-08-06 19:23:00 +04:00
|
|
|
// Priority
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!SortingPriority.empty()) {
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.Element("SortingPriority", SortingPriority);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-08-06 19:23:00 +04:00
|
|
|
|
2015-07-16 22:53:57 +03:00
|
|
|
xout.EndElement();
|
|
|
|
xout.EndDocument();
|
2014-08-06 19:23:00 +04:00
|
|
|
}
|
2015-04-27 17:02:49 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCPackIFWPackage::WriteGeneratedByToStrim(cmXMLWriter& xout)
|
2015-04-27 17:02:49 +03:00
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (Generator)
|
|
|
|
Generator->WriteGeneratedByToStrim(xout);
|
2015-04-27 17:02:49 +03:00
|
|
|
}
|