CQtDeployer/Deploy/configparser.h

132 lines
3.4 KiB
C
Raw Normal View History

2019-09-23 16:46:57 +03:00
//#
//# Copyright (C) 2018-2019 QuasarApp.
//# Distributed under the lgplv3 software license, see the accompanying
//# Everyone is permitted to copy and distribute verbatim copies
//# of this license document, but changing it is not allowed.
//#
2019-09-04 21:27:29 +03:00
#ifndef CQT_H
#define CQT_H
2019-09-15 17:38:47 +03:00
#include "distrostruct.h"
2019-09-07 12:36:20 +03:00
#include "envirement.h"
2019-09-23 10:06:22 +03:00
#include "ignorerule.h"
2019-09-07 12:36:20 +03:00
2019-09-04 21:27:29 +03:00
#include <QJsonObject>
#include <QJsonDocument>
#include <QJsonArray>
2019-09-07 12:01:20 +03:00
#include <QStringList>
#include <QMap>
#include <QDir>
2019-09-09 21:19:44 +03:00
#include "deploy_global.h"
2019-09-04 21:27:29 +03:00
2019-09-16 09:44:19 +03:00
#define DISTRO_DIR QString("DistributionKit")
2019-09-09 21:19:44 +03:00
class FileManager;
2019-11-13 18:18:44 +03:00
class DependenciesScanner;
2019-09-04 21:27:29 +03:00
2019-11-01 15:12:03 +03:00
struct DEPLOYSHARED_EXPORT QtDir {
QString libs;
QString bins;
QString libexecs;
QString plugins;
QString qmls;
QString translations;
QString resources;
Platform qtPlatform;
bool isQt(const QString &path) const;
};
2019-11-05 13:17:52 +03:00
struct DEPLOYSHARED_EXPORT Extra {
QSet<QString> extraPaths;
QSet<QString> extraPathsMasks;
QSet<QString> extraNamesMasks;
bool contains(const QString &path) const;
};
2019-09-09 21:19:44 +03:00
struct DEPLOYSHARED_EXPORT DeployConfig {
2019-09-07 12:01:20 +03:00
QString targetDir = "";
int depchLimit = 0;
bool deployQml = false;
2019-09-23 10:06:22 +03:00
IgnoreRule ignoreList;
2019-09-07 12:01:20 +03:00
QStringList extraPlugins;
QString appDir;
2019-11-01 15:12:03 +03:00
QtDir qtDir;
2019-11-05 13:17:52 +03:00
Extra extraPaths;
// QStringList extraPaths;
2019-09-07 12:01:20 +03:00
/**
* @brief targets
* key - path
* value - create wrapper
*/
2019-11-13 18:18:44 +03:00
QHash<QString, LibInfo> targets;
2019-09-07 12:36:20 +03:00
Envirement envirement;
2019-09-15 17:38:47 +03:00
DistroStruct distroStruct;
2019-09-08 19:30:01 +03:00
2019-09-28 16:44:39 +03:00
/**
* @brief reset config file to default
*/
void reset();
2019-09-07 12:01:20 +03:00
};
2019-09-14 13:59:11 +03:00
class DEPLOYSHARED_EXPORT ConfigParser
2019-09-04 21:27:29 +03:00
{
private:
2019-09-07 12:01:20 +03:00
DeployConfig _config;
2019-09-08 13:37:33 +03:00
FileManager *_fileManager;
2019-11-13 18:18:44 +03:00
DependenciesScanner *_scaner;
2019-09-10 15:40:12 +03:00
bool createFromDeploy(const QString& file) const;
bool loadFromFile(const QString& file);
2019-09-07 12:01:20 +03:00
bool parseQtDeployMode();
bool parseQtInfoMode();
bool parseQtClearMode();
2019-11-14 17:35:21 +03:00
QSet<QString> getQtPathesFromTargets();
2019-09-07 12:36:20 +03:00
void setTargetDir(const QString &target = "");
2019-09-07 12:01:20 +03:00
bool setTargets(const QStringList &value);
bool setTargetsRecursive(const QString &dir);
2019-09-07 12:36:20 +03:00
bool setBinDir(const QString &dir, bool recursive = false);
2019-09-07 12:01:20 +03:00
void initIgnoreList();
void initIgnoreEnvList();
2019-11-02 01:00:05 +03:00
QString getPathFrmoQmakeLine(const QString& in) const;
2019-11-14 17:35:21 +03:00
bool initQmakePrivate(const QString& qmake);
bool initQmake();
2019-11-01 15:12:03 +03:00
bool setQmake(const QString &value);
bool setQtDir(const QString &value);
2019-09-07 12:01:20 +03:00
void setExtraPath(const QStringList &value);
2019-11-05 13:17:52 +03:00
void setExtraNames(const QStringList &value);
2019-09-07 12:01:20 +03:00
void setExtraPlugins(const QStringList &value);
2019-09-24 15:11:30 +03:00
QString recursiveInvairement(QDir &dir, int depch = 0, int depchLimit = -1);
QString recursiveInvairement(const QString &dir, int depch);
2019-09-07 12:01:20 +03:00
void initEnvirement();
2019-09-04 21:27:29 +03:00
2019-09-14 15:51:23 +03:00
QStringList getDirsRecursive(const QString &path, int maxDepch = -1, int depch = 0);
2019-11-05 13:17:52 +03:00
QSet<QString> getSetDirsRecursive(const QString &path, int maxDepch = -1, int depch = 0);
2019-09-08 13:37:33 +03:00
QString getRelativeLink(const QString& from, const QString& to);
void writeKey(const QString &key, QJsonObject &, const QString &confFileDir) const;
void readKey(const QString &key, const QJsonObject &obj, const QString &confFileDir) const;
2019-11-13 18:18:44 +03:00
QHash<QString, LibInfo> prepareTarget(const QString &target);
2019-09-04 21:27:29 +03:00
public:
2019-11-13 18:18:44 +03:00
ConfigParser(FileManager *filemanager, DependenciesScanner *scaner);
2019-09-07 12:01:20 +03:00
bool parseParams();
bool smartMoveTargets();
2019-09-04 21:27:29 +03:00
2019-09-08 13:37:33 +03:00
const DeployConfig* config() const;
2019-09-08 19:30:01 +03:00
friend class deploytest;
2019-09-04 21:27:29 +03:00
};
#endif // CQT_H