2019-09-08 13:37:33 +03:00
|
|
|
/*
|
2019-12-08 13:57:20 +03:00
|
|
|
* Copyright (C) 2018-2020 QuasarApp.
|
2019-09-08 13:37:33 +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.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "extracter.h"
|
|
|
|
#include "deploycore.h"
|
|
|
|
#include "pluginsparser.h"
|
2019-09-14 13:59:11 +03:00
|
|
|
#include "configparser.h"
|
2019-09-15 17:38:47 +03:00
|
|
|
#include "metafilemanager.h"
|
2019-09-29 18:14:41 +03:00
|
|
|
#include "pathutils.h"
|
2019-09-08 13:37:33 +03:00
|
|
|
#include <QCoreApplication>
|
|
|
|
#include <QDebug>
|
|
|
|
#include <QDir>
|
|
|
|
#include <QDirIterator>
|
|
|
|
#include <QFile>
|
|
|
|
#include <QFileInfo>
|
|
|
|
#include <QProcess>
|
|
|
|
#include <QRegularExpression>
|
|
|
|
#include <quasarapp.h>
|
2020-01-12 16:43:03 +03:00
|
|
|
#include <cstdio>
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
#include <cassert>
|
2019-09-08 13:37:33 +03:00
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
|
|
|
bool Extracter::deployMSVC() {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("try deploy msvc",
|
|
|
|
QuasarAppUtils::Info);
|
2019-12-20 17:25:20 +03:00
|
|
|
auto msvcInstaller = DeployCore::getVCredist(DeployCore::_config->qtDir.getBins());
|
2019-09-08 13:37:33 +03:00
|
|
|
|
|
|
|
if (msvcInstaller.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2019-12-14 17:38:43 +03:00
|
|
|
return _fileManager->copyFile(msvcInstaller, DeployCore::_config->getTargetDir());
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
bool Extracter::isWebEngine(const QString &package) const {
|
|
|
|
auto qtModules = _packageDependencyes.value(package).qtModules();
|
2019-09-15 20:31:31 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
return static_cast<quint64>(qtModules) & static_cast<quint64>(DeployCore::QtModule::QtWebEngineModule);
|
|
|
|
}
|
2019-09-15 20:31:31 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
bool Extracter::extractWebEngine() {
|
2019-11-01 15:12:03 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
auto cnf = DeployCore::_config;
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) {
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
const auto &package = i.key();
|
|
|
|
if (isWebEngine(package)) {
|
2020-04-04 16:21:44 +03:00
|
|
|
auto webEngeneBin = cnf->qtDir.getLibexecs();
|
|
|
|
if (cnf->qtDir.getQtPlatform() & Platform::Unix) {
|
2019-12-15 18:30:24 +03:00
|
|
|
webEngeneBin += "/QtWebEngineProcess";
|
|
|
|
} else {
|
|
|
|
webEngeneBin += "/QtWebEngineProcess.exe";
|
|
|
|
}
|
|
|
|
|
2020-04-04 16:21:44 +03:00
|
|
|
auto destWebEngine = cnf->getTargetDir() + "/" + package + cnf->packages()[package].getBinOutDir();
|
|
|
|
auto resOut = cnf->getTargetDir() + "/" + package + cnf->packages()[package].getResOutDir();
|
|
|
|
auto res = cnf->qtDir.getResources();
|
2019-12-15 18:30:24 +03:00
|
|
|
|
|
|
|
if (!_fileManager->copyFile(webEngeneBin, destWebEngine)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!_fileManager->copyFolder(res, resOut)) {
|
|
|
|
return false;
|
|
|
|
}
|
2019-09-15 20:31:31 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2019-09-14 15:51:23 +03:00
|
|
|
void Extracter::extractAllTargets() {
|
2019-12-15 18:30:24 +03:00
|
|
|
auto cfg = DeployCore::_config;
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cfg->packages().cbegin(); i != cfg->packages().cend(); ++i) {
|
|
|
|
_packageDependencyes[i.key()] = {};
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &target : i.value().targets()) {
|
2020-01-27 20:02:25 +03:00
|
|
|
extract(target, &_packageDependencyes[i.key()]);
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-09-14 15:51:23 +03:00
|
|
|
void Extracter::clear() {
|
2019-09-08 13:37:33 +03:00
|
|
|
if (QuasarAppUtils::Params::isEndable("clear") ||
|
|
|
|
QuasarAppUtils::Params::isEndable("force-clear")) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("clear old data",
|
|
|
|
QuasarAppUtils::Info);
|
2019-12-15 18:30:24 +03:00
|
|
|
_fileManager->clear(DeployCore::_config->getTargetDir(),
|
2019-09-08 13:37:33 +03:00
|
|
|
QuasarAppUtils::Params::isEndable("force-clear"));
|
|
|
|
}
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-07-04 18:13:32 +03:00
|
|
|
void Extracter::copyExtraPlugins(const QString& package) {
|
2020-07-04 23:08:41 +03:00
|
|
|
|
|
|
|
|
2020-07-04 18:13:32 +03:00
|
|
|
QFileInfo info;
|
2020-07-02 16:10:11 +03:00
|
|
|
|
|
|
|
auto cnf = DeployCore::_config;
|
2020-07-04 18:13:32 +03:00
|
|
|
auto targetPath = cnf->getTargetDir() + "/" + package;
|
2020-07-02 16:10:11 +03:00
|
|
|
auto distro = cnf->getDistroFromPackage(package);
|
|
|
|
|
2020-07-04 18:13:32 +03:00
|
|
|
for (auto extraPlugin : distro.extraPlugins()) {
|
|
|
|
|
|
|
|
info.setFile(extraPlugin);
|
2020-07-07 11:05:27 +03:00
|
|
|
|
|
|
|
if (info.isFile()) {
|
|
|
|
if (!_fileManager->copyFile(info.absoluteFilePath(),
|
|
|
|
targetPath + distro.getPluginsOutDir())) {
|
|
|
|
|
|
|
|
QuasarAppUtils::Params::log("fail to copy extra plugin from:" + info.absoluteFilePath() +
|
|
|
|
" to: " + targetPath + distro.getPluginsOutDir(),
|
|
|
|
QuasarAppUtils::Warning);
|
|
|
|
}
|
2020-07-02 16:10:11 +03:00
|
|
|
|
2020-07-04 18:13:32 +03:00
|
|
|
extractPluginLib(info.absoluteFilePath(), package);
|
2020-07-07 11:05:27 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (info.isDir()) {
|
|
|
|
QStringList plugins;
|
|
|
|
if (!_fileManager->copyFolder(info.absoluteFilePath(),
|
|
|
|
targetPath + distro.getPluginsOutDir() + info.fileName()
|
|
|
|
, {}, &plugins)) {
|
|
|
|
|
|
|
|
QuasarAppUtils::Params::log("fail to copy extra plugin from:" + info.absoluteFilePath() +
|
|
|
|
" to: " + targetPath + distro.getPluginsOutDir(),
|
|
|
|
QuasarAppUtils::Warning);
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto& plugin : plugins) {
|
|
|
|
extractPluginLib(plugin, package);
|
|
|
|
}
|
2020-07-04 18:13:32 +03:00
|
|
|
}
|
2020-07-02 16:10:11 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
void Extracter::extractPlugins() {
|
|
|
|
auto cnf = DeployCore::_config;
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-07-05 13:53:15 +03:00
|
|
|
_pluginsParser->initDeployPluginsList();
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) {
|
2020-07-04 18:13:32 +03:00
|
|
|
auto targetPath = cnf->getTargetDir() + "/" + i.key();
|
2020-01-27 20:02:25 +03:00
|
|
|
auto distro = cnf->getDistroFromPackage(i.key());
|
2019-12-15 18:30:24 +03:00
|
|
|
|
|
|
|
QStringList plugins;
|
2020-07-04 18:13:32 +03:00
|
|
|
QStringList listItems;
|
2020-07-02 16:00:34 +03:00
|
|
|
|
2020-07-04 18:13:32 +03:00
|
|
|
_pluginsParser->scan(cnf->qtDir.getPlugins(), plugins, _packageDependencyes[i.key()].qtModules(), i.key());
|
|
|
|
|
|
|
|
_fileManager->copyFiles(plugins, targetPath + distro.getPluginsOutDir(), 1,
|
|
|
|
QStringList() << ".so.debug" << "d.dll" << ".pdb", &listItems);
|
|
|
|
|
|
|
|
for (const auto &item : listItems) {
|
|
|
|
extractPluginLib(item, i.key());
|
2020-07-02 16:00:34 +03:00
|
|
|
}
|
2020-07-04 18:13:32 +03:00
|
|
|
|
|
|
|
copyExtraPlugins(i.key());
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
2020-07-04 18:13:32 +03:00
|
|
|
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
void Extracter::copyLibs(const QSet<QString> &files, const QString& package) {
|
2019-12-15 18:30:24 +03:00
|
|
|
auto cnf = DeployCore::_config;
|
2020-02-27 10:50:11 +03:00
|
|
|
auto targetPath = cnf->getTargetDir() + "/" + package;
|
2020-01-27 20:02:25 +03:00
|
|
|
auto distro = cnf->getDistroFromPackage(package);
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &file : files) {
|
2019-12-15 18:30:24 +03:00
|
|
|
if (!_fileManager->smartCopyFile(file, targetPath + distro.getLibOutDir())) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log(file + " not copied");
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
void Extracter::copyFiles() {
|
|
|
|
auto cnf = DeployCore::_config;
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) {
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
copyLibs(_packageDependencyes[i.key()].neadedLibs(), i.key());
|
2019-12-15 18:30:24 +03:00
|
|
|
|
|
|
|
if (QuasarAppUtils::Params::isEndable("deploySystem")) {
|
2020-01-27 20:02:25 +03:00
|
|
|
copyLibs(_packageDependencyes[i.key()].systemLibs(), i.key());
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (!QuasarAppUtils::Params::isEndable("noStrip") && !_fileManager->strip(cnf->getTargetDir())) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("strip failed!");
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
void Extracter::copyTr() {
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
if (!QuasarAppUtils::Params::isEndable("noTranslations")) {
|
2019-12-15 18:30:24 +03:00
|
|
|
|
|
|
|
auto cnf = DeployCore::_config;
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) {
|
|
|
|
if (!copyTranslations(DeployCore::extractTranslation(_packageDependencyes[i.key()].neadedLibs()),
|
2019-12-15 18:30:24 +03:00
|
|
|
i.key())) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("Failed to copy standard Qt translations",
|
2019-12-15 18:30:24 +03:00
|
|
|
QuasarAppUtils::Warning);
|
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-09-14 15:51:23 +03:00
|
|
|
void Extracter::deploy() {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("target deploy started!!",
|
|
|
|
QuasarAppUtils::Info);
|
2019-09-14 15:51:23 +03:00
|
|
|
clear();
|
|
|
|
_cqt->smartMoveTargets();
|
2020-02-26 14:29:04 +03:00
|
|
|
_scaner->setEnvironment(DeployCore::_config->envirement.environmentList());
|
2019-09-14 15:51:23 +03:00
|
|
|
extractAllTargets();
|
|
|
|
|
|
|
|
if (DeployCore::_config->deployQml && !extractQml()) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("qml not extacted!",
|
|
|
|
QuasarAppUtils::Error);
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
extractPlugins();
|
|
|
|
|
|
|
|
copyFiles();
|
|
|
|
|
|
|
|
copyTr();
|
|
|
|
|
2019-09-15 20:31:31 +03:00
|
|
|
if (!extractWebEngine()) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("deploy webEngine failed", QuasarAppUtils::Error);
|
2019-09-15 20:31:31 +03:00
|
|
|
}
|
|
|
|
|
2019-09-14 15:51:23 +03:00
|
|
|
if (!deployMSVC()) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("deploy msvc failed");
|
2019-09-14 15:51:23 +03:00
|
|
|
}
|
|
|
|
|
2019-09-15 17:38:47 +03:00
|
|
|
_metaFileManager->createRunMetaFiles();
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("deploy done!",
|
|
|
|
QuasarAppUtils::Info);
|
2019-09-08 13:37:33 +03:00
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
bool Extracter::copyTranslations(const QStringList &list, const QString& package) {
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
auto cnf = DeployCore::_config;
|
|
|
|
|
2019-12-23 10:12:23 +03:00
|
|
|
QDir dir(cnf->qtDir.getTranslations());
|
2019-09-08 13:37:33 +03:00
|
|
|
if (!dir.exists() || list.isEmpty()) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
QStringList filters;
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &i: list) {
|
2019-09-08 13:37:33 +03:00
|
|
|
filters.push_back("*" + i + "*");
|
|
|
|
}
|
|
|
|
|
|
|
|
auto listItems = dir.entryInfoList(filters, QDir::Files | QDir::NoDotAndDotDot);
|
|
|
|
|
2020-02-27 10:50:11 +03:00
|
|
|
auto targetPath = cnf->getTargetDir() + "/" + package;
|
2020-01-27 20:02:25 +03:00
|
|
|
auto distro = cnf->getDistroFromPackage(package);
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &i: listItems) {
|
2019-12-15 18:30:24 +03:00
|
|
|
_fileManager->copyFile(i.absoluteFilePath(), targetPath + distro.getTrOutDir());
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
if (isWebEngine(package)) {
|
2019-12-15 18:30:24 +03:00
|
|
|
auto trOut = targetPath + distro.getTrOutDir();
|
2020-04-04 16:21:44 +03:00
|
|
|
auto tr = cnf->qtDir.getTranslations() + "/qtwebengine_locales";
|
2019-09-17 14:35:40 +03:00
|
|
|
_fileManager->copyFolder(tr, trOut + "/qtwebengine_locales");
|
|
|
|
}
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
QFileInfoList Extracter::findFilesInsideDir(const QString &name,
|
|
|
|
const QString &dirpath) {
|
|
|
|
QFileInfoList files;
|
|
|
|
|
|
|
|
QDir dir(dirpath);
|
|
|
|
|
|
|
|
auto list = dir.entryInfoList( QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot);
|
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto & item :list) {
|
2019-09-08 13:37:33 +03:00
|
|
|
if (item.isFile()) {
|
|
|
|
if (item.fileName().contains(name)) {
|
|
|
|
files += item;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
files += findFilesInsideDir(name, item.absoluteFilePath());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return files;
|
|
|
|
}
|
|
|
|
|
2019-12-08 13:57:20 +03:00
|
|
|
void Extracter::extractLib(const QString &file,
|
|
|
|
DependencyMap* depMap,
|
|
|
|
const QString& mask) {
|
|
|
|
|
|
|
|
assert(depMap);
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("extract lib :" + file,
|
|
|
|
QuasarAppUtils::Info);
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-11-13 18:18:44 +03:00
|
|
|
auto data = _scaner->scan(file);
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &line : data) {
|
2019-11-05 14:33:14 +03:00
|
|
|
|
2019-12-20 17:25:20 +03:00
|
|
|
if (mask.size() && !line.getName().contains(mask, ONLY_WIN_CASE_INSENSIATIVE)) {
|
2019-11-05 14:33:14 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2019-09-23 10:06:22 +03:00
|
|
|
if (DeployCore::_config->ignoreList.isIgnore(line)) {
|
2019-09-08 13:37:33 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2020-02-25 15:18:14 +03:00
|
|
|
if (line.getPriority() < LibPriority::SystemLib && !depMap->containsNeadedLib(line.fullPath())) {
|
2019-12-08 13:57:20 +03:00
|
|
|
depMap->addNeadedLib(line.fullPath());
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
} else if (QuasarAppUtils::Params::isEndable("deploySystem") &&
|
2020-02-25 15:18:14 +03:00
|
|
|
line.getPriority() >= LibPriority::SystemLib &&
|
2019-12-08 13:57:20 +03:00
|
|
|
!depMap->containsSysLib(line.fullPath())) {
|
|
|
|
|
|
|
|
depMap->addSystemLib(line.fullPath());
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2020-02-29 16:42:18 +03:00
|
|
|
void Extracter::extractPluginLib(const QString& item, const QString& package) {
|
|
|
|
if (QuasarAppUtils::Params::isEndable("extractPlugins")) {
|
|
|
|
extract(item, &_packageDependencyes[package]);
|
|
|
|
} else {
|
|
|
|
extract(item, &_packageDependencyes[package], "Qt");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
bool Extracter::extractQmlAll() {
|
2020-04-04 16:21:44 +03:00
|
|
|
auto cnf = DeployCore::_config;
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-04-04 16:21:44 +03:00
|
|
|
if (!QFileInfo::exists(cnf->qtDir.getQmls())) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("qml dir wrong!",
|
|
|
|
QuasarAppUtils::Warning);
|
2019-09-08 13:37:33 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) {
|
2020-02-27 10:50:11 +03:00
|
|
|
auto targetPath = cnf->getTargetDir() + "/" + i.key();
|
2020-01-27 20:02:25 +03:00
|
|
|
auto distro = cnf->getDistroFromPackage(i.key());
|
2019-12-15 18:30:24 +03:00
|
|
|
|
|
|
|
QStringList listItems;
|
|
|
|
|
2019-12-23 10:12:23 +03:00
|
|
|
if (!_fileManager->copyFolder(cnf->qtDir.getQmls(), targetPath + distro.getQmlOutDir(),
|
2019-12-15 18:30:24 +03:00
|
|
|
QStringList() << ".so.debug" << "d.dll" << ".pdb",
|
|
|
|
&listItems)) {
|
|
|
|
return false;
|
2019-11-05 18:24:55 +03:00
|
|
|
}
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &item : listItems) {
|
2020-02-29 16:42:18 +03:00
|
|
|
extractPluginLib(item, i.key());
|
2019-12-15 18:30:24 +03:00
|
|
|
}
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2020-02-25 17:42:10 +03:00
|
|
|
bool Extracter::extractQmlFromSource() {
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-12-15 18:30:24 +03:00
|
|
|
auto cnf = DeployCore::_config;
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-27 20:02:25 +03:00
|
|
|
for (auto i = cnf->packages().cbegin(); i != cnf->packages().cend(); ++i) {
|
2020-02-27 10:50:11 +03:00
|
|
|
auto targetPath = cnf->getTargetDir() + "/" + i.key();
|
2020-01-27 20:02:25 +03:00
|
|
|
auto distro = cnf->getDistroFromPackage(i.key());
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-02 19:27:40 +03:00
|
|
|
QStringList plugins;
|
|
|
|
QStringList listItems;
|
|
|
|
QStringList filter;
|
|
|
|
filter << ".so.debug" << "d.dll" << ".pdb";
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &qmlInput: distro.qmlInput()) {
|
2020-01-02 19:27:40 +03:00
|
|
|
QFileInfo info(qmlInput);
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-02 19:27:40 +03:00
|
|
|
if (!info.isDir()) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("extract qml fail! qml source dir not exits or is not dir " + qmlInput,
|
|
|
|
QuasarAppUtils::Error);
|
2020-01-02 19:27:40 +03:00
|
|
|
continue;
|
|
|
|
}
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("extractQmlFromSource " + info.absoluteFilePath());
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-02 19:27:40 +03:00
|
|
|
if (!QFileInfo::exists(cnf->qtDir.getQmls())) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("qml dir wrong!",
|
|
|
|
QuasarAppUtils::Warning);
|
2020-01-02 19:27:40 +03:00
|
|
|
continue;
|
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-02 19:27:40 +03:00
|
|
|
QML ownQmlScaner(cnf->qtDir.getQmls());
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2020-01-02 19:27:40 +03:00
|
|
|
if (!ownQmlScaner.scan(plugins, info.absoluteFilePath())) {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("qml scaner run failed!",
|
2020-02-25 17:42:10 +03:00
|
|
|
QuasarAppUtils::Error);
|
2020-01-02 19:27:40 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-12-23 10:12:23 +03:00
|
|
|
if (!_fileManager->copyFolder(cnf->qtDir.getQmls(),
|
2019-12-15 18:30:24 +03:00
|
|
|
targetPath + distro.getQmlOutDir(),
|
|
|
|
filter , &listItems, &plugins)) {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2020-01-12 16:43:03 +03:00
|
|
|
for (const auto &item : listItems) {
|
2020-02-29 16:42:18 +03:00
|
|
|
extractPluginLib(item, i.key());
|
2019-11-05 18:24:55 +03:00
|
|
|
}
|
2019-12-15 18:30:24 +03:00
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool Extracter::extractQml() {
|
|
|
|
|
|
|
|
if (QuasarAppUtils::Params::isEndable("qmlDir")) {
|
2020-02-25 17:42:10 +03:00
|
|
|
return extractQmlFromSource();
|
2019-09-08 13:37:33 +03:00
|
|
|
|
|
|
|
} else if (QuasarAppUtils::Params::isEndable("allQmlDependes")) {
|
|
|
|
return extractQmlAll();
|
|
|
|
|
|
|
|
}
|
2020-01-12 16:43:03 +03:00
|
|
|
return false;
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|
2019-12-08 13:57:20 +03:00
|
|
|
void Extracter::extract(const QString &file,
|
|
|
|
DependencyMap *depMap,
|
|
|
|
const QString &mask) {
|
|
|
|
|
|
|
|
assert(depMap);
|
|
|
|
|
2019-09-08 13:37:33 +03:00
|
|
|
QFileInfo info(file);
|
|
|
|
|
|
|
|
auto sufix = info.completeSuffix();
|
|
|
|
|
2019-09-14 13:59:11 +03:00
|
|
|
if (sufix.compare("dll", Qt::CaseSensitive) == 0 ||
|
|
|
|
sufix.compare("exe", Qt::CaseSensitive) == 0 ||
|
2019-09-08 13:37:33 +03:00
|
|
|
sufix.isEmpty() || sufix.contains("so", Qt::CaseSensitive)) {
|
|
|
|
|
2019-12-08 13:57:20 +03:00
|
|
|
extractLib(file, depMap, mask);
|
2019-09-08 13:37:33 +03:00
|
|
|
} else {
|
2020-04-04 15:43:46 +03:00
|
|
|
QuasarAppUtils::Params::log("file with sufix " + sufix + " not supported!");
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2020-07-04 18:13:32 +03:00
|
|
|
Extracter::Extracter(FileManager *fileManager, PluginsParser *pluginsParser, ConfigParser *cqt,
|
2019-11-13 18:18:44 +03:00
|
|
|
DependenciesScanner *scaner):
|
|
|
|
_scaner(scaner),
|
2019-09-11 13:09:09 +03:00
|
|
|
_fileManager(fileManager),
|
2020-07-04 18:13:32 +03:00
|
|
|
_pluginsParser(pluginsParser),
|
2019-11-13 18:18:44 +03:00
|
|
|
_cqt(cqt)
|
|
|
|
{
|
2019-09-08 13:37:33 +03:00
|
|
|
|
2019-09-11 13:09:09 +03:00
|
|
|
assert(_cqt);
|
2019-09-08 13:37:33 +03:00
|
|
|
assert(_fileManager);
|
2020-07-04 18:13:32 +03:00
|
|
|
assert(_pluginsParser);
|
2019-09-08 13:37:33 +03:00
|
|
|
assert(DeployCore::_config);
|
2019-09-15 17:38:47 +03:00
|
|
|
|
|
|
|
_metaFileManager = new MetaFileManager(_fileManager);
|
2019-09-08 13:37:33 +03:00
|
|
|
}
|
|
|
|
|