From 9d3608bcf14dc6ce3f12cbf88b0c33f6a10d034c Mon Sep 17 00:00:00 2001 From: EndrII Date: Tue, 20 Apr 2021 20:43:22 +0300 Subject: [PATCH] ref #575 "use call for console applications in windows" --- Deploy/libinfo.cpp | 17 +++++++++++++++++ Deploy/libinfo.h | 3 +++ Deploy/metafilemanager.cpp | 16 ++++++++++++---- UnitTests/tst_deploytest.cpp | 19 +++++++++++++++++++ 4 files changed, 51 insertions(+), 4 deletions(-) diff --git a/Deploy/libinfo.cpp b/Deploy/libinfo.cpp index ff16ef9..e749be9 100644 --- a/Deploy/libinfo.cpp +++ b/Deploy/libinfo.cpp @@ -112,6 +112,23 @@ QtMajorVersion LibInfo::isDependetOfQt() const { return QtMajorVersion::NoQt; } +bool LibInfo::isConsole() const { + for (const auto& i : dependncies) { + + QFileInfo info(i); + + QString fileName = info.fileName(); + if (fileName.contains("Qt4Gui", ONLY_WIN_CASE_INSENSIATIVE) || + fileName.contains("Qt5Gui", ONLY_WIN_CASE_INSENSIATIVE) || + fileName.contains("Qt6Gui", ONLY_WIN_CASE_INSENSIATIVE)) { + + return false; + } + } + + return true; +} + QString LibInfo::fullPath() const { return path + "/" + name; } diff --git a/Deploy/libinfo.h b/Deploy/libinfo.h index a270aa9..b5e9630 100644 --- a/Deploy/libinfo.h +++ b/Deploy/libinfo.h @@ -58,6 +58,9 @@ public: WinAPI getWinApi() const; void setWinApi(WinAPI winApi); QtMajorVersion isDependetOfQt() const; + + bool isConsole() const; + }; uint qHash(const LibInfo& info); diff --git a/Deploy/metafilemanager.cpp b/Deploy/metafilemanager.cpp index 7c4f692..a89ba0f 100644 --- a/Deploy/metafilemanager.cpp +++ b/Deploy/metafilemanager.cpp @@ -18,8 +18,8 @@ bool MetaFileManager::createRunScriptWindows(const QString &target) { auto cnf = DeployCore::_config; - - if (!cnf->targets().contains(target)) { + auto targetinfo = cnf->targets().value(target); + if (!targetinfo.isValid()) { return false; } auto distro = cnf->getDistro(target); @@ -37,6 +37,7 @@ bool MetaFileManager::createRunScriptWindows(const QString &target) { script.close(); } else { + auto systemLibsDir = distro.getLibOutDir() + DeployCore::systemLibsFolderName(); content = @@ -46,8 +47,15 @@ bool MetaFileManager::createRunScriptWindows(const QString &target) { "SET CQT_PKG_ROOT=%BASE_DIR%\n" "SET CQT_RUN_FILE=%BASE_DIR%%5\n" - "%3\n" - "start \"%0\" %4 \"%BASE_DIR%" + distro.getBinOutDir() + "%1\" %2 \n"; + "%3\n"; + + // Run application as invoke of the console for consle applications + // And run gui applciation in the detached mode. + if (targetinfo.isConsole()) { + content += "call \"%BASE_DIR%" + distro.getBinOutDir() + "%1\" %2 \n"; + } else { + content += "start \"%0\" %4 \"%BASE_DIR%" + distro.getBinOutDir() + "%1\" %2 \n"; + } content = content.arg(targetInfo.baseName(), targetInfo.fileName(), "%*", generateCustoScriptBlok(true)); // %0 %1 %2 %3 diff --git a/UnitTests/tst_deploytest.cpp b/UnitTests/tst_deploytest.cpp index 6c78547..f152904 100644 --- a/UnitTests/tst_deploytest.cpp +++ b/UnitTests/tst_deploytest.cpp @@ -2937,6 +2937,25 @@ void deploytest::testOutDirs() { QVERIFY(runScript.contains("SET PATH=%BASE_DIR%\\lolLib\\;%PATH%")); QVERIFY(runScript.contains("start \"TestQMLWidgets\" /B \"%BASE_DIR%\\lol\\TestQMLWidgets.exe\" %*")); + runTestParams({"-bin", TestBinDir + "TestOnlyC.exe, "clear" , + "-binOut", "/lol", + "-libOut", "/lolLib", + "-trOut", "/lolTr", + "-pluginOut", "/p", + "-qmlOut", "/q", + "-qmake", qmake + }, nullptr); + + file.setFileName( "./" + DISTRO_DIR + "/TestOnlyC.bat"); + + QVERIFY(file.open(QIODevice::ReadOnly)); + + runScript = file.readAll(); + file.close(); + + qDebug() << "runScript =" << runScript; + + QVERIFY(runScript.contains("call \"%BASE_DIR%\\lol\\TestOnlyC.exe\" %*")); #endif