CQtDeployer/Deploy/deploycore.h

230 lines
7.5 KiB
C
Raw Normal View History

2019-01-26 07:54:56 +03:00
/*
2019-12-08 13:57:20 +03:00
* Copyright (C) 2018-2020 QuasarApp.
2019-01-26 07:54:56 +03:00
* 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.
*/
2018-12-09 17:35:07 +03:00
#ifndef DEPLOYUTILS_H
#define DEPLOYUTILS_H
#include <QStringList>
2018-12-15 20:51:25 +03:00
#include <QDebug>
2019-09-08 13:37:33 +03:00
#include <QFileInfo>
2019-01-27 15:37:19 +03:00
#include "deploy_global.h"
2019-03-28 10:32:46 +03:00
enum MSVCVersion: int {
MSVC_Unknown = 0x0,
MSVC_x64 = 0x01,
MSVC_x32 = 0x02,
MSVC_13 = 0x10,
MSVC_15 = 0x20,
MSVC_17 = 0x40,
MSVC_19 = 0x80,
};
2019-01-27 15:37:19 +03:00
struct DEPLOYSHARED_EXPORT QtModuleEntry {
quint64 module;
const char *option;
const char *libraryName;
const char *translation;
};
2018-12-09 17:35:07 +03:00
2019-03-25 20:13:30 +03:00
enum Platform {
UnknownPlatform = 0x0000,
2020-07-02 16:00:34 +03:00
// Windows
Win32 = 0x0001,
Win64 = 0x0002,
2019-11-01 15:12:03 +03:00
Win = Win32 | Win64,
2020-07-02 16:00:34 +03:00
// Unix
Unix_x86_32 = 0x0004,
Unix_x86_64 = 0x0008,
2020-07-02 16:00:34 +03:00
Unix_x86 = Unix_x86_32 | Unix_x86_64,
Unix_ARM_32 = 0x0010,
Unix_ARM_64 = 0x0020,
2020-07-02 16:00:34 +03:00
Unix_ARM = Unix_x86_32 | Unix_x86_64,
Unix = Unix_x86 | Unix_ARM,
// Other
// Web
WebGl = 0x0040,
WebRemote = 0x0080,
GeneralFile = 0x0100
2019-03-25 20:13:30 +03:00
};
/**
* @brief The LibPriority enum This is library priority.
* The lower the priority of the topics, the library is the most suitable for distribution.
*/
2019-08-24 17:56:42 +03:00
enum LibPriority : int {
// ================= General Libraryes
/// This is qt libraryes.
2019-04-04 18:11:38 +03:00
QtLib = 0x0,
/// This is user libraryes.
2019-03-25 21:27:26 +03:00
ExtraLib,
/// This is qt 3dParty and user libraryes. (distribution-safe libraries)
AllowedLib,
// ================= System Libraryes
/// This is rest of all libraryes (frm system and another).
2019-04-04 18:11:38 +03:00
SystemLib,
/// This is libraryes from another proggram distributions.
2020-02-25 15:18:14 +03:00
AlienLib,
/// This is General Files.
2019-04-04 18:11:38 +03:00
NotFile = 0xF,
2019-03-25 21:27:26 +03:00
};
2019-12-24 11:46:11 +03:00
enum class WinAPI : quint8 {
NoWinAPI = 0x00,
Other = 0x01,
Core = 0x02,
Devices = 0x04,
Eventing = 0x08,
Crt = 0x10,
Security = 0x20,
Base = 0x40
};
uint qHash (WinAPI i);
2019-08-24 17:56:42 +03:00
enum class RunMode: int {
Info,
Deploy,
2020-01-24 13:57:55 +03:00
Clear,
Init
2019-08-24 17:56:42 +03:00
};
2019-09-08 13:37:33 +03:00
class Extracter;
class DeployConfig;
2018-12-09 17:35:07 +03:00
2019-09-03 18:15:05 +03:00
class DEPLOYSHARED_EXPORT DeployCore
2018-12-09 17:35:07 +03:00
{
2019-01-27 15:37:19 +03:00
2019-03-28 12:36:21 +03:00
private:
static QString getMSVCName(MSVCVersion msvc);
static QString getMSVCVersion(MSVCVersion msvc);
2018-12-09 17:35:07 +03:00
public:
2019-01-27 15:37:19 +03:00
enum QtModule : quint64
{
2019-08-31 22:22:26 +03:00
NONE = 0x0000000000000000,
2019-01-27 15:37:19 +03:00
QtBluetoothModule = 0x0000000000000001,
QtConcurrentModule = 0x0000000000000002,
QtCoreModule = 0x0000000000000004,
QtDeclarativeModule = 0x0000000000000008,
QtDesignerComponents = 0x0000000000000010,
QtDesignerModule = 0x0000000000000020,
QtGuiModule = 0x0000000000000040,
QtHelpModule = 0x0000000000000080,
QtMultimediaModule = 0x0000000000000100,
QtMultimediaWidgetsModule = 0x0000000000000200,
QtMultimediaQuickModule = 0x0000000000000400,
QtNetworkModule = 0x0000000000000800,
QtNfcModule = 0x0000000000001000,
QtOpenGLModule = 0x0000000000002000,
QtPositioningModule = 0x0000000000004000,
QtPrintSupportModule = 0x0000000000008000,
QtQmlModule = 0x0000000000010000,
QtQuickModule = 0x0000000000020000,
QtQuickParticlesModule = 0x0000000000040000,
QtScriptModule = 0x0000000000080000,
QtScriptToolsModule = 0x0000000000100000,
QtSensorsModule = 0x0000000000200000,
QtSerialPortModule = 0x0000000000400000,
QtSqlModule = 0x0000000000800000,
QtSvgModule = 0x0000000001000000,
QtTestModule = 0x0000000002000000,
QtWidgetsModule = 0x0000000004000000,
QtWinExtrasModule = 0x0000000008000000,
QtXmlModule = 0x0000000010000000,
QtXmlPatternsModule = 0x0000000020000000,
QtWebKitModule = 0x0000000040000000,
QtWebKitWidgetsModule = 0x0000000080000000,
QtQuickWidgetsModule = 0x0000000100000000,
QtWebSocketsModule = 0x0000000200000000,
QtEnginioModule = 0x0000000400000000,
QtWebEngineCoreModule = 0x0000000800000000,
QtWebEngineModule = 0x0000001000000000,
QtWebEngineWidgetsModule = 0x0000002000000000,
QtQmlToolingModule = 0x0000004000000000,
Qt3DCoreModule = 0x0000008000000000,
Qt3DRendererModule = 0x0000010000000000,
Qt3DQuickModule = 0x0000020000000000,
Qt3DQuickRendererModule = 0x0000040000000000,
Qt3DInputModule = 0x0000080000000000,
QtLocationModule = 0x0000100000000000,
QtWebChannelModule = 0x0000200000000000,
QtTextToSpeechModule = 0x0000400000000000,
QtSerialBusModule = 0x0000800000000000,
QtGamePadModule = 0x0001000000000000,
Qt3DAnimationModule = 0x0002000000000000,
QtWebViewModule = 0x0004000000000000,
Qt3DExtrasModule = 0x0008000000000000
};
2019-09-03 18:15:05 +03:00
DeployCore() = delete;
2018-12-09 17:35:07 +03:00
2019-01-27 15:37:19 +03:00
static QtModuleEntry qtModuleEntries[];
2019-09-08 13:37:33 +03:00
static const DeployConfig * _config;
2018-12-09 17:35:07 +03:00
2019-11-01 15:12:03 +03:00
static MSVCVersion getMSVC(const QString & _qtBin);
static QString getVCredist(const QString & _qtBin);
2019-03-28 10:32:46 +03:00
2018-12-09 17:35:07 +03:00
static bool isQtLib(const QString &lib);
static bool isExtraLib(const QString &lib);
static QChar getSeparator(int lvl);
2020-02-25 15:18:14 +03:00
static bool isAlienLib(const QString &lib);
/**
* @brief isAllowedLib This method checks the library if the library is allowed or not, allowet libraryes is added with extraLibs method.
* @param lib This is library fuul path
* @return true if lirary is allowed
*/
static bool isAllowedLib(const QString &lib);
/**
* @brief QtThreethepartyLibs This method return list of 3rdparty libraryes of qt for selected platform.
* @param platform This is OS name.
* @return list of 3rdparty libs.
* @note This method is hardcode.
* @note See Task https://github.com/QuasarApp/CQtDeployer/issues/422 of the CQtDeployer project.
*/
static QStringList Qt3rdpartyLibs(Platform platform);
2020-01-16 11:10:16 +03:00
static char getEnvSeparator();
2019-08-24 17:56:42 +03:00
static LibPriority getLibPriority(const QString &lib);
2019-09-03 18:15:05 +03:00
static DeployCore::QtModule getQtModule(const QString& path);
static void addQtModule(DeployCore::QtModule& module, const QString& path);
2019-08-31 22:22:26 +03:00
2019-08-24 17:56:42 +03:00
static RunMode getMode();
2020-02-20 11:02:01 +03:00
static void help();
2019-09-10 15:40:12 +03:00
static QStringList helpKeys();
2019-12-15 18:30:24 +03:00
static QStringList extractTranslation(const QSet<QString> &libs);
2019-08-12 18:05:28 +03:00
static QString getAppVersion();
2020-03-22 11:52:08 +03:00
static QString getAppVersionName();
2019-08-12 18:05:28 +03:00
static QString getQtVersion();
static void printVersion();
2019-09-08 13:37:33 +03:00
static int find(const QString &str, const QStringList &list);
static bool isLib(const QFileInfo &file);
2019-08-28 17:23:49 +03:00
static bool isExecutable(const QFileInfo &file);
2020-01-02 19:27:40 +03:00
static bool isContainsArraySeparators(const QString& val,
int lastLvl = 2);
2020-01-28 13:51:00 +03:00
static QString findProcess(const QString& env, const QString& proc);
2019-01-27 15:37:19 +03:00
2020-07-28 23:56:34 +03:00
static bool isSnap();
static QString snapRootFS();
static QString transportPathToSnapRoot(const QString &path);
2020-07-30 10:55:15 +03:00
static bool checkSystemBakupSnapInterface();
2018-12-09 17:35:07 +03:00
};
#endif // DEPLOYUTILS_H