diff --git a/Deploy/deployutils.cpp b/Deploy/deployutils.cpp index 01732b8..f40534a 100644 --- a/Deploy/deployutils.cpp +++ b/Deploy/deployutils.cpp @@ -235,6 +235,68 @@ QStringList DeployUtils::extractTranslation(const QStringList &libs) { return res.toList(); } +MSVCVersion DeployUtils::getMSVC(const QString &_qmake) { + QFileInfo qmake(_qmake); + + int res = MSVCVersion::MSVC_Unknown; + + if (!qmake.isFile()) { + QuasarAppUtils::Params::verboseLog("qmake is wrong!"); + return static_cast(res); + } + + QDir dir = qmake.absoluteDir(); + + if (!dir.cdUp()) { + QuasarAppUtils::Params::verboseLog("is not standart qt repo"); + return static_cast(res); + } + + auto msvcPath = dir.absolutePath(); + + if (!(dir.cdUp() && dir.cdUp())) { + QuasarAppUtils::Params::verboseLog("is not standart qt repo"); + return static_cast(res); + } + + if (!msvcPath.contains("msvc")) { + QuasarAppUtils::Params::verboseLog("vcredis not defined"); + return static_cast(res); + } + + auto base = msvcPath.mid(msvcPath.indexOf("msvc"), 11); + auto version = base.mid(4 , 4); + auto type = base.right(2); + + if (version == "2013") { + res |= MSVC_13; + } + else if (version == "2015") { + res |= MSVC_15; + } + else if (version == "2017") { + res |= MSVC_17; + } + else if (version == "2019") { + res |= MSVC_19; + } + + if (type == "32") { + res |= MSVC_x32; + } + else if (type == "64") { + res |= MSVC_x64; + } + + return static_cast(res); +} + +QString DeployUtils::getVCredist(const QString &_qmake) { + auto msvc = getMSVC(_qmake); + + return ""; +} + bool DeployUtils::isQtLib(const QString &lib) { QFileInfo info(lib); return !qtDir.isEmpty() && info.absoluteFilePath().contains(qtDir); diff --git a/Deploy/deployutils.h b/Deploy/deployutils.h index 92d1fad..bfd67f4 100644 --- a/Deploy/deployutils.h +++ b/Deploy/deployutils.h @@ -12,6 +12,16 @@ #include #include "deploy_global.h" +enum MSVCVersion: int { + MSVC_Unknown = 0x0, + MSVC_x64 = 0x01, + MSVC_x32 = 0x02, + MSVC_13 = 0x10, + MSVC_15 = 0x20, + MSVC_17 = 0x40, + MSVC_19 = 0x80, +}; + struct DEPLOYSHARED_EXPORT QtModuleEntry { quint64 module; const char *option; @@ -87,6 +97,9 @@ public: static QStringList extraPaths; static QtModuleEntry qtModuleEntries[]; + static MSVCVersion getMSVC(const QString & _qmake); + static QString getVCredist(const QString & _qmake); + static bool isQtLib(const QString &lib); static bool isExtraLib(const QString &lib); static int getLibPriority(const QString &lib); diff --git a/UnitTests/tst_deploytest.cpp b/UnitTests/tst_deploytest.cpp index 39a5508..b6b9304 100644 --- a/UnitTests/tst_deploytest.cpp +++ b/UnitTests/tst_deploytest.cpp @@ -40,7 +40,7 @@ private slots: void testTranslations(); void testStrip(); void testDeploy(); - + void testMSVC(); }; deploytest::deploytest(){} @@ -274,8 +274,7 @@ void deploytest::testStrip() { #endif } -void deploytest::testDeploy() -{ +void deploytest::testDeploy() { QuasarAppUtils::Params::parseParams(0, nullptr); Deploy *deploy = new Deploy(); @@ -283,6 +282,33 @@ void deploytest::testDeploy() delete deploy; } +void deploytest::testMSVC() { + QString testPath = "./Qt/5.11.2/msvc2017_64/bin/"; + QString testqmakepath = testPath +"qmake"; + + QDir d; + QDir oldDir("./Qt"); + oldDir.removeRecursively(); + QVERIFY(d.mkpath(testPath)); + + QFile file(testqmakepath); + + QVERIFY(file.open(QIODevice::ReadWrite | QIODevice::Truncate)); + + QVERIFY(file.write("test")); + + file.close(); + + + auto msvc = DeployUtils::getMSVC(testqmakepath); + + QVERIFY(msvc & MSVCVersion::MSVC_17); + QVERIFY(msvc & MSVCVersion::MSVC_x64); + + QVERIFY(file.remove()); + +} + void deploytest::testTranslations() { QStringList trList = { ("./test/QtDir/translations/qtbase_ru.qm"),