diff --git a/CQtDeployer.pro b/CQtDeployer.pro index bb080d2..ebb4e05 100644 --- a/CQtDeployer.pro +++ b/CQtDeployer.pro @@ -9,7 +9,10 @@ TEMPLATE = subdirs CONFIG += ordered SUBDIRS += QuasarAppLib \ - CQtDeployer + Deploy \ + CQtDeployer \ + UnitTests + contains(DEFINES, WITH_TESTS) { SUBDIRS += \ @@ -19,7 +22,18 @@ contains(DEFINES, WITH_TESTS) { } CQtDeployer.depends=QuasarAppLib +CQtDeployer.depends=Deploy QuasarAppLib.file = $$PWD/QuasarAppLib/QuasarApp.pro win32:include('$$PWD/CQtDeployerWinBuild.pri') + +DISTFILES += \ + snapBuild.sh \ + staticBuild.sh \ + snap/snapcraft.yaml \ + README.md \ + sharedBuild.sh \ + README.md \ + staticBuildCrossWin.sh \ + sharedBuild.bat diff --git a/CQtDeployer/CQtDeployer.pro b/CQtDeployer/CQtDeployer.pro index 2739188..83d1c57 100644 --- a/CQtDeployer/CQtDeployer.pro +++ b/CQtDeployer/CQtDeployer.pro @@ -22,51 +22,18 @@ DEFINES += QT_DEPRECATED_WARNINGS #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 CONFIG(release, debug|release): { - DESTDIR="$$PWD/../build/release" + DESTDIR="$$PWD/build/release" } else { - DESTDIR="$$PWD/../build/debug" + DESTDIR="$$PWD/build/debug" } -isEmpty(PREFIX){ - PREFIX=$$PWD/../distro -} include('$$PWD/../QuasarAppLib/QuasarLib.pri') -include('$$PWD/../QuasarAppLib/Etalons/qmake/install_prefix.pri') -win32:include('$$PWD/CQtDeployerWinBuild.pri') - -install_data.files += $$DESTDIR/$$runfiletype -install_data.files += $$QUASARAPP_LIB_OUTPUT_DIR/$$libfiletype - +include('$$PWD/../Deploy/Deploy.pri') TARGET = cqtdeployer SOURCES += \ main.cpp \ - deploy.cpp \ - deployutils.cpp \ - windependenciesscanner.cpp \ - ../qtTools/src/windeployqt/elfreader.cpp \ - ../qtTools/src/windeployqt/utils.cpp - -HEADERS += \ - deploy.h \ - deployutils.h \ - windependenciesscanner.h \ - ../qtTools/src/windeployqt/elfreader.h \ - ../qtTools/src/windeployqt/utils.h -DISTFILES += \ - ../snapBuild.sh \ - ../staticBuild.sh \ - ../snap/snapcraft.yaml \ - ../README.md \ - ../sharedBuild.sh \ - ../README.md \ - ../staticBuildCrossWin.sh \ - ../sharedBuild.bat - - - -win32: LIBS += -lshlwapi win32: RC_ICONS = $$PWD/../res/icon.ico diff --git a/Deploy/Deploy.pri b/Deploy/Deploy.pri new file mode 100644 index 0000000..66621dd --- /dev/null +++ b/Deploy/Deploy.pri @@ -0,0 +1,23 @@ +# +# 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. +# + +!isEmpty(DEPLOY_LIB):error("Deploy.pri already included") +DEPLOY_LIB = 1 + +#DEPENDS +CONFIG(release, debug|release): { + DEPLOY_LIB_OUTPUT_DIR="$$PWD/build/release" +} else { + DEPLOY_LIB_OUTPUT_DIR="$$PWD/build/debug" +} + +LIBS += -L$$DEPLOY_LIB_OUTPUT_DIR -lDeploy + +INCLUDEPATH += "$$PWD/" + + + diff --git a/Deploy/Deploy.pro b/Deploy/Deploy.pro new file mode 100644 index 0000000..ca64505 --- /dev/null +++ b/Deploy/Deploy.pro @@ -0,0 +1,57 @@ +# +# 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. +# + + +#------------------------------------------------- +# +# Project created by QtCreator 2019-01-26T13:55:47 +# +#------------------------------------------------- + +QT -= gui + +TARGET = Deploy +TEMPLATE = lib + +DEFINES += DEPLOY_LIBRARY + +# The following define makes your compiler emit warnings if you use +# any feature of Qt which has been marked as deprecated (the exact warnings +# depend on your compiler). Please consult the documentation of the +# deprecated API in order to know how to port your code away from it. +DEFINES += QT_DEPRECATED_WARNINGS + +# You can also make your code fail to compile if you use deprecated APIs. +# In order to do so, uncomment the following line. +# You can also select to disable deprecated APIs only up to a certain version of Qt. +#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 + +CONFIG(release, debug|release): { + DESTDIR="$$PWD/build/release" +} else { + DESTDIR="$$PWD/build/debug" +} + +include('$$PWD/../QuasarAppLib/QuasarLib.pri') + + +SOURCES += \ + deploy.cpp \ + deployutils.cpp \ + windependenciesscanner.cpp \ + ../qtTools/src/windeployqt/elfreader.cpp \ + ../qtTools/src/windeployqt/utils.cpp + +HEADERS += \ + deploy.h \ + deploy_global.h \ + deployutils.h \ + windependenciesscanner.h\ + ../qtTools/src/windeployqt/elfreader.h \ + ../qtTools/src/windeployqt/utils.h + +win32: LIBS += -lshlwapi diff --git a/CQtDeployer/deploy.cpp b/Deploy/deploy.cpp similarity index 100% rename from CQtDeployer/deploy.cpp rename to Deploy/deploy.cpp diff --git a/CQtDeployer/deploy.h b/Deploy/deploy.h similarity index 100% rename from CQtDeployer/deploy.h rename to Deploy/deploy.h diff --git a/Deploy/deploy_global.h b/Deploy/deploy_global.h new file mode 100644 index 0000000..58246cb --- /dev/null +++ b/Deploy/deploy_global.h @@ -0,0 +1,19 @@ +/* + * 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. + */ + +#ifndef DEPLOY_GLOBAL_H +#define DEPLOY_GLOBAL_H + +#include <QtCore/qglobal.h> + +#if defined(DEPLOY_LIBRARY) +# define DEPLOYSHARED_EXPORT Q_DECL_EXPORT +#else +# define DEPLOYSHARED_EXPORT Q_DECL_IMPORT +#endif + +#endif // DEPLOY_GLOBAL_H diff --git a/CQtDeployer/deployutils.cpp b/Deploy/deployutils.cpp similarity index 97% rename from CQtDeployer/deployutils.cpp rename to Deploy/deployutils.cpp index 96d6d2e..3225fda 100644 --- a/CQtDeployer/deployutils.cpp +++ b/Deploy/deployutils.cpp @@ -165,7 +165,7 @@ bool DeployUtils::parseQt(Deploy *deploy) { bool DeployUtils::isQtLib(const QString &lib) { QFileInfo info(lib); - return !qtDir.isEmpty() && info.absolutePath().contains(qtDir); + return !qtDir.isEmpty() && info.absoluteFilePath().contains(qtDir); } @@ -173,7 +173,7 @@ bool DeployUtils::isExtraLib(const QString &lib) { QFileInfo info(lib); for (auto i : extraPaths) { - if (info.absolutePath().contains(i)) { + if (info.absoluteFilePath().contains(i)) { return true; } } diff --git a/CQtDeployer/deployutils.h b/Deploy/deployutils.h similarity index 100% rename from CQtDeployer/deployutils.h rename to Deploy/deployutils.h diff --git a/CQtDeployer/windependenciesscanner.cpp b/Deploy/windependenciesscanner.cpp similarity index 100% rename from CQtDeployer/windependenciesscanner.cpp rename to Deploy/windependenciesscanner.cpp diff --git a/CQtDeployer/windependenciesscanner.h b/Deploy/windependenciesscanner.h similarity index 100% rename from CQtDeployer/windependenciesscanner.h rename to Deploy/windependenciesscanner.h diff --git a/UnitTests/.gitignore b/UnitTests/.gitignore new file mode 100644 index 0000000..fab7372 --- /dev/null +++ b/UnitTests/.gitignore @@ -0,0 +1,73 @@ +# This file is used to ignore files which are generated +# ---------------------------------------------------------------------------- + +*~ +*.autosave +*.a +*.core +*.moc +*.o +*.obj +*.orig +*.rej +*.so +*.so.* +*_pch.h.cpp +*_resource.rc +*.qm +.#* +*.*# +core +!core/ +tags +.DS_Store +.directory +*.debug +Makefile* +*.prl +*.app +moc_*.cpp +ui_*.h +qrc_*.cpp +Thumbs.db +*.res +*.rc +/.qmake.cache +/.qmake.stash + +# qtcreator generated files +*.pro.user* + +# xemacs temporary files +*.flc + +# Vim temporary files +.*.swp + +# Visual Studio generated files +*.ib_pdb_index +*.idb +*.ilk +*.pdb +*.sln +*.suo +*.vcproj +*vcproj.*.*.user +*.ncb +*.sdf +*.opensdf +*.vcxproj +*vcxproj.* + +# MinGW generated files +*.Debug +*.Release + +# Python byte code +*.pyc + +# Binaries +# -------- +*.dll +*.exe + diff --git a/UnitTests/UnitTests.pro b/UnitTests/UnitTests.pro new file mode 100644 index 0000000..ced2d99 --- /dev/null +++ b/UnitTests/UnitTests.pro @@ -0,0 +1,26 @@ +# +# 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. +# + + +QT += testlib +QT -= gui + +CONFIG(release, debug|release): { + DESTDIR="$$PWD/build/release" +} else { + DESTDIR="$$PWD/build/debug" +} + +include('$$PWD/../QuasarAppLib/QuasarLib.pri') +include('$$PWD/../Deploy/Deploy.pri') + +CONFIG += qt console warn_on depend_includepath testcase +CONFIG -= app_bundle + +TEMPLATE = app + +SOURCES += tst_deploytest.cpp diff --git a/UnitTests/tst_deploytest.cpp b/UnitTests/tst_deploytest.cpp new file mode 100644 index 0000000..a78a709 --- /dev/null +++ b/UnitTests/tst_deploytest.cpp @@ -0,0 +1,120 @@ +/* + * 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. + */ + +#include <QtTest> +#include <quasarapp.h> +#include <deployutils.h> +#include <deploy.h> +#include <windependenciesscanner.h> + +#include <QDir> +// add necessary includes here + +class deploytest : public QObject +{ + Q_OBJECT + +public: + deploytest(); + ~deploytest(); + +private slots: + void initTestCase(); + void cleanupTestCase(); + void testDeployUtils(); + void testDeploy(); + void testDeployScaner(); + +}; + +deploytest::deploytest(){} + +deploytest::~deploytest(){} + +void deploytest::initTestCase() { + QDir qt; + qt.mkpath("./test/Qt/5.12/"); + qt.mkpath("./test/extraPath/"); + qt.mkpath("./test/extra/"); + qt.mkpath("./test/warning/"); + + QFile f( "./test/Qt/5.12/generalLib.so"); + if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) { + f.write("lib", 3); + f.close(); + } + + f.setFileName("./test/extraPath/ExtraLib.so"); + if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) { + f.write("lib", 3); + f.close(); + } + + f.setFileName("./test/extra/ExtraLib.so"); + if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) { + f.write("lib", 3); + f.close(); + } + + f.setFileName("./test/warning/WarningLib.so"); + if (f.open(QIODevice::WriteOnly| QIODevice::Truncate)) { + f.write("lib", 3); + f.close(); + } +} + +void deploytest::cleanupTestCase() { + QDir qt("./test"); + qt.removeRecursively(); + +} + +void deploytest::testDeployUtils() { + QString qtDir = "./test/Qt/5.12/"; + QStringList extraPathes = QStringList() << QFileInfo("./test/extraPath/").absoluteFilePath(); + + DeployUtils::qtDir = QFileInfo(qtDir).absoluteFilePath(); + DeployUtils::extraPaths = extraPathes; + + // qt Dir + QVERIFY(DeployUtils::isQtLib("./test/Qt/5.12/myLib.so")); + QVERIFY(!DeployUtils::isQtLib("/myQtDur/Qt/5.11/myLib.so")); + QVERIFY(!DeployUtils::isQtLib("/mQtDur/Qt/5.12/myLib.so")); + QVERIFY(DeployUtils::isQtLib("./test/Qt/5.12/myLib/testlibs/mylib.so")); + + // extra Dir + QVERIFY(!DeployUtils::isExtraLib("./test/Qt/5.12/myLib.so")); + QVERIFY(!DeployUtils::isExtraLib("/myQtDur/Qt/5.11/myLib.so")); + QVERIFY(!DeployUtils::isExtraLib("/mQtDur/Qt/5.12/myLib.so")); + QVERIFY(!DeployUtils::isExtraLib("./test/Qt/5.12/myLib/testlibs/mylib.so")); + + QVERIFY(DeployUtils::isExtraLib("./test/extraPath/Qt/5.12/myLib.so")); + QVERIFY(DeployUtils::isExtraLib("./test/extraPath/Qt/5/myLib.so")); + QVERIFY(DeployUtils::isExtraLib("./test/extraPath/myLib.so")); + QVERIFY(DeployUtils::isExtraLib("./test/extraPath/Qt/5.12/myLib/testlibs/mylib.so")); + + //getLibPriority + + QVERIFY(DeployUtils::getLibPriority("./tst/Qt/5.12/generalLib.so") == 0); + QVERIFY(DeployUtils::getLibPriority("./test/Qt/5.12/generalLib.so") == 3); + QVERIFY(DeployUtils::getLibPriority("./test/extraPath/ExtraLib.so") == 2); + QVERIFY(DeployUtils::getLibPriority("./test/extra/ExtraLib.so") == 1); + + +} + +void deploytest::testDeploy() { + +} + +void deploytest::testDeployScaner() { + +} + +QTEST_APPLESS_MAIN(deploytest) + +#include "tst_deploytest.moc"