4
1
mirror of https://github.com/QuasarApp/CQtDeployer.git synced 2025-05-05 14:09:35 +00:00

added the deploy base template of qif

This commit is contained in:
Andrei Yankovich 2020-01-14 15:48:35 +03:00
parent 986064c77f
commit 2675e16f66
14 changed files with 253 additions and 34 deletions

@ -1,3 +1,2 @@
{
"":"",
}

@ -9,7 +9,9 @@ QString DefaultDistro::getConfig() const{
return ":/Distro/Distributions/configures/C and C++.json";
}
void DefaultDistro::deployTemplate() const {}
bool DefaultDistro::deployTemplate() const {
return true;
}
Envirement DefaultDistro::toolKitLocation() const {
return {};

@ -11,7 +11,7 @@ public:
// iDistribution interface
public:
QString getConfig() const;
void deployTemplate() const;
bool deployTemplate() const;
Envirement toolKitLocation() const;
QString runCmd() const;
QStringList runArg() const;

@ -2,6 +2,7 @@
#include <typeinfo>
#include <QFile>
#include <QTextStream>
#include <QDir>
iDistribution::iDistribution() = default;
iDistribution::~iDistribution() = default;
@ -18,10 +19,10 @@ void iDistribution::setLocation(const QString &location) {
_location = location;
}
bool iDistribution::unpack(const QString &resource,
const QString &target,
const TemplateInfo &info) const {
QFile file(resource);
bool iDistribution::unpackFile(const QFileInfo &resource,
const QString &target,
const TemplateInfo &info) const {
QFile file(resource.absoluteFilePath());
if (!file.open(QIODevice::ReadOnly)) {
return false;
}
@ -29,7 +30,10 @@ bool iDistribution::unpack(const QString &resource,
QString inputData = file.readAll();
file.close();
file.setFileName(target);
if (!QDir().mkpath(target))
return false;
file.setFileName(target + "/" + resource.fileName());
if (!file.open(QIODevice::WriteOnly | QIODevice::Truncate)) {
return false;
@ -52,3 +56,30 @@ bool iDistribution::unpack(const QString &resource,
return true;
}
bool iDistribution::unpackDir(const QString &resource,
const QString &target,
const TemplateInfo &info) const {
QDir res(resource);
auto list = res.entryInfoList();
for (const auto & item :list) {
if (item.isFile()) {
if (!unpackFile(item, target, info)) {
return false;
}
} else {
if (!unpackDir(item.absoluteFilePath(),
target + "/" + item.fileName(),
info)) {
return false;
}
}
}
return true;
}

@ -5,6 +5,8 @@
#include "envirement.h"
#include "templateinfo.h"
#include <QFileInfo>
class DEPLOYSHARED_EXPORT iDistribution
{
public:
@ -12,7 +14,7 @@ public:
virtual ~iDistribution();
virtual QString getConfig() const = 0;
virtual void deployTemplate() const = 0;
virtual bool deployTemplate() const = 0;
virtual Envirement toolKitLocation() const = 0;
virtual QString runCmd() const = 0;
virtual QStringList runArg() const = 0;
@ -22,9 +24,13 @@ public:
protected:
QString getLocation() const;
void setLocation(const QString &location);
bool unpack(const QString& resource,
const QString& target,
const TemplateInfo& info) const;
bool unpackFile(const QFileInfo& resource,
const QString& target,
const TemplateInfo& info) const;
bool unpackDir(const QString& resource,
const QString& target,
const TemplateInfo& info) const;
private:
QString _location = "packageTemplate";

@ -3,6 +3,8 @@
#include "deploycore.h"
#include "deployconfig.h"
#include <QDateTime>
QIF::QIF()= default;
Envirement QIF::toolKitLocation() const {
@ -26,7 +28,7 @@ QString QIF::runCmd() const {
return "binarycreator";
}
void QIF::deployTemplate() const {
bool QIF::deployTemplate() const {
auto customTemplate = QuasarAppUtils::Params::getStrArg("qif", "");
const DeployConfig *cfg = DeployCore::_config;
@ -34,14 +36,42 @@ void QIF::deployTemplate() const {
// default template
for (auto it = cfg->prefixes().cbegin(); it != cfg->prefixes().cend(); ++it) {
auto location = cfg->getTargetDir() + "/" + it.key();
auto location = cfg->getTargetDir() + "/" + getLocation() + "/" + it.key();
auto package = it.value();
TemplateInfo info;
info.Name = it.key();
if (!package.name().isEmpty())
info.Name = package.name();
info.Description = "This package contains the " + info.Name;
if (!package.description().isEmpty())
info.Description = package.description();
info.Version = "1.0";
if (!package.version().isEmpty())
info.Version = package.version();
info.ReleaseData = QDate::currentDate().toString();
if (!package.releaseData().isEmpty())
info.ReleaseData = package.releaseData();
info.Icon = "";
if (!package.icon().isEmpty())
info.Icon = package.icon();
if (!unpackDir(":/Templates/QIF/Distributions/Templates/qif", location, info)) {
return false;
}
}
} else {
return true;
}
// custom template
return true;
}
QStringList QIF::runArg() const {

@ -14,7 +14,7 @@ public:
Envirement toolKitLocation() const;
QString getConfig() const;
QString runCmd() const;
void deployTemplate() const;
bool deployTemplate() const;
QStringList runArg() const;
};

@ -317,6 +317,17 @@ bool ConfigParser::initDistroStruct() {
auto recOut = QuasarAppUtils::Params::getStrArg("recOut").
split(DeployCore::getSeparator(0), QString::SkipEmptyParts);
auto name = QuasarAppUtils::Params::getStrArg("name").
split(DeployCore::getSeparator(0), QString::SkipEmptyParts);
auto description = QuasarAppUtils::Params::getStrArg("description").
split(DeployCore::getSeparator(0), QString::SkipEmptyParts);
auto deployVersion = QuasarAppUtils::Params::getStrArg("deployVersion").
split(DeployCore::getSeparator(0), QString::SkipEmptyParts);
auto releaseDate = QuasarAppUtils::Params::getStrArg("releaseDate").
split(DeployCore::getSeparator(0), QString::SkipEmptyParts);
auto icon = QuasarAppUtils::Params::getStrArg("icon").
split(DeployCore::getSeparator(0), QString::SkipEmptyParts);
auto erroLog = [](const QString &flag){
QuasarAppUtils::Params::verboseLog(QString("Set %0 fail, becouse you try set %0 for not inited prefix."
" Use 'targetPrefix' flag for init the prefixes").arg(flag),
@ -354,6 +365,31 @@ bool ConfigParser::initDistroStruct() {
return false;
}
if (name.size() && !parsePrefixesPrivate(mainDistro, name, &DistroModule::setName)) {
erroLog("name");
return false;
}
if (description.size() && !parsePrefixesPrivate(mainDistro, description, &DistroModule::setDescription)) {
erroLog("description");
return false;
}
if (deployVersion.size() && !parsePrefixesPrivate(mainDistro, deployVersion, &DistroModule::setVersion)) {
erroLog("deployVersion");
return false;
}
if (releaseDate.size() && !parsePrefixesPrivate(mainDistro, releaseDate, &DistroModule::setReleaseData)) {
erroLog("releaseDate");
return false;
}
if (icon.size() && !parsePrefixesPrivate(mainDistro, icon, &DistroModule::setIcon)) {
erroLog("icon");
return false;
}
return true;
}
@ -1006,8 +1042,6 @@ bool ConfigParser::configureDistribution(iDistribution *distro) {
return false;
}
distro->deployTemplate();
_packing->setDistribution(distro);
return true;

@ -174,7 +174,7 @@ QString DeployCore::help() {
{ " | Use '-bin' flag if you want to deploy linux binary files" },
{ " -qmlDir [prefix;path,path]: Qml data dir. For example -qmlDir ~/my/project/qml" },
{ " deploySystem : Deploys all libs" },
{ " deploySystem-with-libc : Skip Deploys system core libs libs" },
{ " deploySystem-with-libc : Skip Deploys system core libs libs" },
{ " -qmake [params] : Qmake path." },
{ " | For example -qmake ~/Qt/5.14.0/gcc_64/bin/qmake" },
{ " -ignore [list,params] : The list of libs to ignore." },
@ -203,12 +203,18 @@ QString DeployCore::help() {
{ " noTranslations : Skips the translations files." },
{ " | It doesn't work without qmake and inside a snap package" },
{ " -noAutoCheckQmake : Disables automatic search of paths to qmake in executable files." },
{ " -qmlOut [path;prefix;target,path] : Sets path to qml out directory" },
{ " -libOut [path;prefix;target,path] : Sets path to libraries out directory" },
{ " -trOut [path;prefix;target,path] : Sets path to translations out directory" },
{ " -pluginOut [path;prefix;target,path]: Sets path to plugins out directory" },
{ " -binOut [path;prefix;target,path] : Sets path to binary out directory" },
{ " -recOut [path;prefix;target,path] : Sets path to recurses out directory" },
{ " -qmlOut [prefix;val,val] : Sets path to qml out directory" },
{ " -libOut [prefix;val,val] : Sets path to libraries out directory" },
{ " -trOut [prefix;val,val] : Sets path to translations out directory" },
{ " -pluginOut [prefix;val,val]: Sets path to plugins out directory" },
{ " -binOut [prefix;val,val] : Sets path to binary out directory" },
{ " -recOut [prefix;val,val] : Sets path to recurses out directory" },
{ " -name [prefix;val,val] : Sets name for prefix. If this if you do not specify a prefix, the value will be assigned to the default prefix ("")" },
{ " -description [prefix;val,val] : Sets description for prefix" },
{ " -deployVersion [prefix;val,val] : Sets version for prefix" },
{ " -releaseDate [prefix;val,val] : Sets release date for prefix" },
{ " -icon [prefix;val,val] : Sets path to icon for prefix" },
{ " -qif [params] : Create the QIF installer for deployement programm" },
{ " : By default params value is 'Default'" },
@ -262,7 +268,12 @@ QStringList DeployCore::helpKeys() {
"version",
"verbose",
"qif",
"noAutoCheckQmake"
"noAutoCheckQmake",
"name",
"description",
"deployVersion",
"releaseDate",
"icon"
};
}

@ -27,3 +27,53 @@ void DistroModule::setQmlInput(const QSet<QString> &qmlInput) {
void DistroModule::addQmlInput(const QString &target) {
_qmlInput.insert(target);
}
QString DistroModule::name() const
{
return _name;
}
void DistroModule::setName(const QString &name)
{
_name = name;
}
QString DistroModule::description() const
{
return _description;
}
void DistroModule::setDescription(const QString &description)
{
_description = description;
}
QString DistroModule::version() const
{
return _version;
}
void DistroModule::setVersion(const QString &version)
{
_version = version;
}
QString DistroModule::releaseData() const
{
return _releaseData;
}
void DistroModule::setReleaseData(const QString &releaseData)
{
_releaseData = releaseData;
}
QString DistroModule::icon() const
{
return _icon;
}
void DistroModule::setIcon(const QString &icon)
{
_icon = icon;
}

@ -18,7 +18,27 @@ public:
void addQmlInput(const QString& target);
QString name() const;
void setName(const QString &name);
QString description() const;
void setDescription(const QString &description);
QString version() const;
void setVersion(const QString &version);
QString releaseData() const;
void setReleaseData(const QString &releaseData);
QString icon() const;
void setIcon(const QString &icon);
private:
QString _name;
QString _description;
QString _version;
QString _releaseData;
QString _icon;
QSet<QString> _targets;
QSet<QString> _qmlInput;

@ -35,6 +35,9 @@ bool Packing::create() {
if (!_pakage)
return false;
if (!_pakage->deployTemplate())
return false;
if (!_pakage->runCmd().size())
return true;

@ -128,6 +128,9 @@ private slots:
// extractPlugins flags
void testExtractPlugins();
// qif flags
void testQIF();
void testDependencyMap();
};
@ -561,6 +564,26 @@ void deploytest::testExtractPlugins() {
}
}
void deploytest::testQIF() {
TestUtils utils;
#ifdef Q_OS_UNIX
QString bin = TestBinDir + "TestQMLWidgets";
QString qmake = TestQtDir + "bin/qmake";
#else
QString bin = TestBinDir + "TestQMLWidgets.exe";
QString qmake = TestQtDir + "bin/qmake.exe";
#endif
auto comapareTree = Modules::qmlLibs();
runTestParams({"-bin", bin, "clear" ,
"-qmake", qmake,
"-qmlDir", TestBinDir + "/../TestQMLWidgets",
"qif"}, &comapareTree);
}
void deploytest::testDependencyMap() {
DependencyMap dep1, dep2, dep3;

@ -38,12 +38,17 @@ cqtdeployer -option1 value1 -option2 list, of, values flag1 flag2 flag3
| -targetDir [params] | Sets target directory(by default it is the path to the first deployable file)|
| -targetPrefix [prefix;tar1,prefix;tar2]| Sets prefix for target( by default it is empty value) |
| -verbose [0-3] | Shows debug log |
| -qmlOut [prefix;path,path]| Sets path to qml out directory |
| -libOut [prefix;path,path]| Sets path to libraries out directory |
| -trOut [prefix;path,path] | Sets path to translations out directory |
| -pluginOut [prefix;path,path]| Sets path to plugins out directory |
| -binOut [prefix;path,path]| Sets path to binary out directory |
| -recOut [prefix;path,path]| Sets path to recurses out directory |
| -qmlOut [prefix;path,path] | Sets path to qml out directory |
| -libOut [prefix;path,path] | Sets path to libraries out directory |
| -trOut [prefix;path,path] | Sets path to translations out directory |
| -pluginOut [prefix;path,path]| Sets path to plugins out directory |
| -binOut [prefix;path,path] | Sets path to binary out directory |
| -recOut [prefix;path,path] | Sets path to recurses out directory |
| -name [prefix;val,val] | Sets name for prefix. If this if you do not specify a prefix, the value will be assigned to the default prefix ("")|
| -description [prefix;val,val] | Sets description for prefix |
| -deployVersion [prefix;val,val] | Sets version for prefix |
| -releaseDate [prefix;val,val] | Sets release date for prefix |
| -icon [prefix;val,val] | Sets path to icon for prefix |
| -qif [params] | Create the QIF installer for deployement programm" |
| | if skip the [params] then installer weel be created by default'" |
| | Examples:" },
@ -113,6 +118,11 @@ cqtdeployer -option1 value1 -option2 list,of,values flag1 flag2 flag3
| -pluginOut [prefix;path,path]| Установит путь к папке с плагинами |
| -binOut [prefix;path,path]| Установит путь к папке с исполняемыми файлами |
| -recOut [prefix;path,path]| Установит путь к папке с ресурсами |
| -name [prefix;val,val] | Установит имя префиксу. Если указать значение без префикса, то значение будет установленно префиксу по умолчанию. |
| -description [prefix;val,val] | Установит описание префиксу |
| -deployVersion [prefix;val,val] | Установит версию префиксу |
| -releaseDate [prefix;val,val] | Установит дату выпуска префиксу |
| -icon [prefix;val,val] | Установит путь к иконке или логотипу префиксу |
| -qif [params] | Создать установщик QIF для развертываемой программы"|
| | если оставить параметр пустым то будет создан инсталлер По умолчанию|
| | Примеры:" },