Skip to content

Commit

Permalink
Merge pull request #195 from QuasarApp/v1.3.1
Browse files Browse the repository at this point in the history
[WIP] Version 1.3.1 fixes]
  • Loading branch information
EndrII authored Oct 17, 2019
2 parents d5f8b00 + f2d43df commit fa62f06
Show file tree
Hide file tree
Showing 13 changed files with 240 additions and 34 deletions.
2 changes: 1 addition & 1 deletion Deploy/Deploy.pro
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ TEMPLATE = lib

DEFINES += DEPLOY_LIBRARY

VERSION = 1.3.0.8
VERSION = 1.3.1.0

DEFINES += APP_VERSION='\\"$$VERSION\\"'

Expand Down
34 changes: 27 additions & 7 deletions Deploy/configparser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
bool ConfigParser::parseParams() {

auto path = QuasarAppUtils::Params::getStrArg("confFile");
bool createFile = !path.isEmpty();
bool createFile = !(path.isEmpty() || QFile::exists(path));
if (path.isEmpty()) {
path = QFileInfo("./").absoluteFilePath();
}
Expand Down Expand Up @@ -65,8 +65,9 @@ bool ConfigParser::parseParams() {

}

if (createFile) {
createFromDeploy(path);
if (createFile && !createFromDeploy(path)) {
QuasarAppUtils::Params::verboseLog("Do not create a deploy config file in " + path,
QuasarAppUtils::Error);
}

return true;
Expand Down Expand Up @@ -129,8 +130,15 @@ void ConfigParser::readKey(const QString& key, const QJsonObject& obj,

if (!val.isEmpty()) {
if (PathUtils::isPath(val)) {
list.push_back(
QFileInfo(confFileDir + '/' + val).absoluteFilePath());
QString path;

if (PathUtils::isAbsalutPath(val)) {
path = QFileInfo(val).absoluteFilePath();
} else {
path = QFileInfo(confFileDir + '/' + val).absoluteFilePath();
}

list.push_back(path);

} else {
list.push_back(val);
Expand All @@ -145,7 +153,12 @@ void ConfigParser::readKey(const QString& key, const QJsonObject& obj,
if (!val.isEmpty()) {

if (PathUtils::isPath(val)) {
val = QFileInfo(confFileDir + '/' + val).absoluteFilePath();

if (PathUtils::isAbsalutPath(val)) {
val = QFileInfo(val).absoluteFilePath();
} else {
val = QFileInfo(confFileDir + '/' + val).absoluteFilePath();
}
}

QuasarAppUtils::Params::setArg(key, val);
Expand All @@ -161,8 +174,15 @@ void ConfigParser::readKey(const QString& key, const QJsonObject& obj,
bool ConfigParser::createFromDeploy(const QString& confFile) const {
QJsonObject obj;

auto info = QFileInfo(confFile);

for (auto &key :DeployCore::helpKeys()) {
writeKey(key, obj, QFileInfo(confFile).absolutePath());
writeKey(key, obj, info.absolutePath());
}

if (!QFile::exists(info.absolutePath()) &&
!QDir("/").mkpath(info.absolutePath())) {
return false;
}

QJsonDocument doc(obj);
Expand Down
4 changes: 3 additions & 1 deletion Deploy/deploycore.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@ enum Platform {
Win32 = 0x1,
Win64 = 0x2,
Unix32 = 0x4,
Unix64 = 0x8
Unix64 = 0x8,
GeneralFile = 0xf
};

enum LibPriority : int {
QtLib = 0x0,
ExtraLib,
SystemLib,
ExtraFile,
NotFile = 0xF,
};

Expand Down
4 changes: 2 additions & 2 deletions Deploy/extracter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ void Extracter::copyExtraPlugins() {
}

void Extracter::copyPlugins(const QStringList &list) {
for (auto plugin : list) {
for (auto plugin : list) {
if (!copyPlugin(plugin)) {
qWarning() << plugin << " not copied!";
}
Expand Down Expand Up @@ -292,7 +292,7 @@ bool Extracter::extractQmlAll() {

if (!_fileManager->copyFolder(DeployCore::_config->qmlDir,
DeployCore::_config->targetDir + DeployCore::_config->distroStruct.getQmlOutDir(),
QStringList() << ".so.debug" << "d.dll",
QStringList() << ".so.debug" << "d.dll" << ".pdb",
&listItems)) {
return false;
}
Expand Down
14 changes: 14 additions & 0 deletions Deploy/filemanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,20 @@ bool FileManager::copyFolder(const QString &from, const QString &to, const QStri
QuasarAppUtils::VerboseLvl::Info);
continue;
}
auto config = DeployCore::_config;

LibInfo info;
info.setName(item.fileName());
info.setPath(item.absolutePath());
info.setPlatform(GeneralFile);

if (config)
if (auto rule = config->ignoreList.isIgnore(info)) {
QuasarAppUtils::Params::verboseLog(
item.absoluteFilePath() + " ignored by rule " + rule->label,
QuasarAppUtils::VerboseLvl::Info);
continue;
}

if (!copyFile(item.absoluteFilePath(), to , mask)) {
QuasarAppUtils::Params::verboseLog(
Expand Down
6 changes: 3 additions & 3 deletions Deploy/ignorerule.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ bool IgnoreRule::check(const LibInfo &info, const QString& ignoreLabel) const {
return false;
}

bool IgnoreRule::isIgnore(const LibInfo &info) const {
const IgnoreData* IgnoreRule::isIgnore(const LibInfo &info) const {

for (auto &ignore : _data) {

Expand All @@ -44,12 +44,12 @@ bool IgnoreRule::isIgnore(const LibInfo &info) const {
bool checkEnvirement = !ignore.enfirement.size() || ignore.enfirement.inThisEnvirement(info.fullPath());

if (checkPlatform && checkPriority && checkEnvirement && check(info, ignore.label)) {
return true;
return &ignore;
}

}

return false;
return nullptr;
}

IgnoreData::IgnoreData(const QString &label) {
Expand Down
8 changes: 7 additions & 1 deletion Deploy/ignorerule.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,13 @@ class IgnoreRule
public:
IgnoreRule();
void addRule(const IgnoreData& rule);
bool isIgnore(const LibInfo& info) const;

/**
* @brief isIgnore
* @param info
* @return const ptr to ignore data
*/
const IgnoreData *isIgnore(const LibInfo& info) const;
};

#endif // IGNORERULE_H
37 changes: 28 additions & 9 deletions Deploy/pathutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ QString PathUtils::toFullPath(QString path) {

QString PathUtils::getRelativeLink(QString from, QString to) {

auto mainDrive = getDrive(from);

if (mainDrive != getDrive(to) && !mainDrive.isNull()) {
return to;
}

bool isFile = QFileInfo(to).isFile();
from = toFullPath(from);
to = toFullPath(to);
Expand Down Expand Up @@ -63,6 +69,25 @@ bool PathUtils::isPath(const QString &path) {
return path.contains('/') || path.contains('\\') || path == ".";
}

QChar PathUtils::getDrive(QString path) {

path = stripPath(path);

if (path.size() > 1 && path[1] == ':') {
return path[0];
}

return 0;
}

bool PathUtils::isAbsalutPath(const QString &path) {
if (getDrive(path).isNull()) {
return path.size() && (path.at(0) == "/" || path.at(0) == "\\");
}

return true;
}

QString PathUtils::getReleativePath(QString path) {
path = toFullPath(path);

Expand All @@ -81,19 +106,13 @@ QString PathUtils::getReleativePath(QString path) {
}

QString PathUtils::stripPath(QString path) {
path.replace('\\', '/');

int index = -1;
do {
path.replace("//", "/");
} while ((index = path.indexOf("//")) >= 0);

path = toFullPath(path);
if (path.left(1) == '/') {
path = path.right(path.size() - 1);
path.remove(0, 1);
}

if (path.right(1) == '/') {
path = path.left(path.size() - 1);
return path.remove(path.size() - 1, 1);
}

return path;
Expand Down
47 changes: 46 additions & 1 deletion Deploy/pathutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,56 @@ class DEPLOYSHARED_EXPORT PathUtils
{
public:
PathUtils();
/**
* @brief toFullPath remove all dublicate separators and insert separators into begin and end
* @param path
* @return return full path
*/
static QString toFullPath(QString path);

/**
* @brief getReleativePath
* @param path
* @return return releative path from "path" to root dir
*/
static QString getReleativePath(QString path);
static QString stripPath(QString path) ;

/**
* @brief stripPath remove all dublicate separators and remove separators from begin and end
* @param path
* @return return strip patth
*/
static QString stripPath(QString path);

/**
* @brief getRelativeLink return releative path
* @param from
* @param to
* @return releative path
*/
static QString getRelativeLink(QString from, QString to);

/**
* @brief isPath
* @param path
* @return return true if imput value is path
*/
static bool isPath(const QString &path);

/**
* @brief getDrive
* @param path
* @return char of drive in windows systems
*/
static QChar getDrive(QString path);

/**
* @brief isAbsalutPath
* @param path
* @return return true if path is absolute
*/
static bool isAbsalutPath(const QString &path);

};

#endif // PATHUTILS_H
2 changes: 0 additions & 2 deletions UnitTests/modules.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -228,8 +228,6 @@ QSet<QString> Modules::qmlLibs() {
"./" + DISTRO_DIR + "/Qt5VirtualKeyboard.dll",
"./" + DISTRO_DIR + "/Qt5WebSockets.dll",
"./" + DISTRO_DIR + "/Qt5Widgets.dll",
"./" + DISTRO_DIR + "/QtWidgetsProject.exe",
"./" + DISTRO_DIR + "/TestOnlyC.exe",
"./" + DISTRO_DIR + "/TestQMLWidgets.exe",
"./" + DISTRO_DIR + "/libgcc_s_seh-1.dll",
"./" + DISTRO_DIR + "/libstdc++-6.dll",
Expand Down
Loading

0 comments on commit fa62f06

Please sign in to comment.