diff --git a/Deploy/deploy.cpp b/Deploy/deploy.cpp index f4370f5..bb0f51b 100644 --- a/Deploy/deploy.cpp +++ b/Deploy/deploy.cpp @@ -315,6 +315,10 @@ void Deploy::setExtraPlugins(const QStringList &value) { void Deploy::setDepchLimit(int value) { depchLimit = value; } +void Deploy::setIgnoreEnvList(const QStringList &value) { + ignoreEnvList = value; +} + bool Deploy::fileActionPrivate(const QString &file, const QString &target, QStringList *masks, bool isMove) { @@ -685,6 +689,12 @@ void Deploy::addEnv(const QString &dir) { auto path = QFileInfo(dir).absoluteFilePath(); + for (QString & i :ignoreEnvList) { + if (path.contains(i)) { + return; + } + } + if (path.contains(appDir)) { QuasarAppUtils::Params::verboseLog("is cqtdeployer dir!: " + path + " app dir : " + appDir); return; diff --git a/Deploy/deploy.h b/Deploy/deploy.h index 0c46a19..dd63535 100644 --- a/Deploy/deploy.h +++ b/Deploy/deploy.h @@ -41,6 +41,7 @@ class DEPLOYSHARED_EXPORT Deploy { QStringList systemLibs; QStringList neededPlugins; QStringList ignoreList; + QStringList ignoreEnvList; QStringList extraPlugins; QString appDir; @@ -127,6 +128,7 @@ public: void setDepchLimit(int value); friend class deploytest; + void setIgnoreEnvList(const QStringList &value); }; #endif // DEPLOY_H diff --git a/Deploy/deployutils.cpp b/Deploy/deployutils.cpp index eb7c8b4..d4c391c 100644 --- a/Deploy/deployutils.cpp +++ b/Deploy/deployutils.cpp @@ -100,34 +100,35 @@ void DeployUtils::help() { qInfo() << "Usage: cqtdeployer <-bin [params]> [options]"; qInfo() << ""; qInfo() << "Options:"; - qInfo() << " help / h : show help."; - qInfo() << " always-overwrite : Copy files even if the target file exists."; - qInfo() << " -bin [list, params] : deployment binry or directory."; - qInfo() << " | example -bin ~/my/project/bin/,~/my/project/bin.exe"; - qInfo() << " -binDir [params] : folder with deployment binaries with recursive search"; - qInfo() << " | WARNING this flag support only 'so', 'dll' and 'exe' files"; - qInfo() << " | if you want deploy linux binary then use '-bin' flag"; - qInfo() << " -qmlDir [params] : qml datadir of project. for example -qmlDir ~/my/project/qml"; - qInfo() << " deploySystem : deploy all libs"; - qInfo() << " -qmake [params] : qmake path. for example"; - qInfo() << " | -qmake ~/Qt/5.11.1/gcc_64/bin/qmake"; - qInfo() << " -ignore [list,params] : ignore filter for libs"; - qInfo() << " | for example -ignore libicudata.so.56,libicudata2.so.56"; - qInfo() << " clear : delete all old deploy data"; - qInfo() << " | for example -runScript myApp.sh"; - qInfo() << " allQmlDependes : This flag will force to extract all qml libraries."; - qInfo() << " | (not recommended, as it takes up a lot of memory)"; - qInfo() << " -libDir [list,params] : set additional path for extralib of app."; - qInfo() << " | for example -libDir ~/myLib,~/newLibs "; - qInfo() << " -extraPlugin[list,params]: set additional path for extraPlugin of app"; - qInfo() << " -recursiveDepth [params] : set Depth for recursive search of libs (default 0)"; - qInfo() << " -targetDir [params] : set target Dir for binaryes (default is path of first target)"; - qInfo() << " noStrip : skip strip step"; - qInfo() << " noTranslations : skip translations files"; - qInfo() << " qmlExtern : use qml external scanner (qmlimportscaner)"; - qInfo() << " | not work without qmake and in snap package"; + qInfo() << " help / h : Shows help."; + qInfo() << " always-overwrite : Copies files and replaces the existing ones."; + qInfo() << " -bin [list, params] : Deployable file or folder."; + qInfo() << " | For example -bin /my/project/bin/,/my/project/bin.exe"; + qInfo() << " -binDir [params] : A folder which includes deployable files (recursive search)."; + qInfo() << " | WARNING: this flag supports 'so', 'dll' and 'exe' files only."; + qInfo() << " | Use '-bin' flag if you want to deploy linux binary files"; + qInfo() << " -qmlDir [params] : Qml data dir. For example -qmlDir ~/my/project/qml"; + qInfo() << " deploy-not-qt : Deploys all the libs"; + qInfo() << " -qmake [params] : Qmake path."; + qInfo() << " | For example -qmake ~/Qt/5.11.1/gcc_64/bin/qmake"; + qInfo() << " -ignore [list,params] : The list of the libs to ignore."; + qInfo() << " | For example -ignore libicudata.so.56,libicudata2.so.56"; + qInfo() << " -ignoreEnv [list,params] : The list of the environment to ignore"; + qInfo() << " | for example -ignoreEnv /bad/dir,/my/bad/Dir"; + qInfo() << " clear : Deletes deployable files of the previous session."; + qInfo() << " allQmlDependes : Extracts all the qml libraries."; + qInfo() << " | (not recommended, as it takes great amount of computer memory)"; + qInfo() << " -libDir [list,params] : Sets additional paths for extra libs of an app."; + qInfo() << " | For example -libDir /myLib,/newLibs "; + qInfo() << " -extraPlugin[list,params]: Sets an additional path to extraPlugin of an app"; + qInfo() << " -recursiveDepth [params] : Sets the Depth of recursive search of the libs (default 0)"; + qInfo() << " -targetDir [params] : Sets target directory(by default it is the path to the first deployable file)"; + qInfo() << " noStrip : Skips strip step"; + qInfo() << " noTranslations : Skips the translations files."; + qInfo() << " qmlExtern : Use the qml external scanner (qmlimportscaner)"; + qInfo() << " | It doesn't work without qmake and inside a snap package"; - qInfo() << " verbose : show debug log"; + qInfo() << " verbose [1,2,3] : show debug log"; qInfo() << ""; qInfo() << "Example: cqtdeployer -bin myApp -qmlDir ~/Qt/5.11.1/gcc_64/qml -qmake ~/Qt/5.11.1/gcc_64/bin/qmake clear"; @@ -160,6 +161,11 @@ bool DeployUtils::parseQt(Deploy *deploy) { deploy->clear(); } + if (QuasarAppUtils::Params::isEndable("ignoreEnv")) { + auto ignoreList = QuasarAppUtils::Params::getStrArg("ignoreEnv").split(','); + deploy->setIgnoreEnvList(ignoreList); + } + int limit = 0; if (QuasarAppUtils::Params::isEndable("recursiveDepth")) { diff --git a/README.md b/README.md index a27aadd..71568d7 100644 --- a/README.md +++ b/README.md @@ -19,29 +19,31 @@ Key differences of this program: | Option | Descriptiion | |-----------------------------|-----------------------------------------------------------------| | help / h | Shows help. | -| always-overwrite | Copies files and replaces the existing ones. | +| always-overwrite | Copies files and replaces the existing ones. | | -bin [list, params] | Deployable file or folder. For example -bin ~/my/project/bin/,~/my/project/bin.exe| | -binDir [params] | A folder which includes deployable files (recursive search). WARNING: this flag supports 'so', 'dll' and 'exe' files only. Use '-bin' flag if you want to deploy linux binary files | -| -qmlDir [params] | Qml data dir. For example -qmlDir ~/my/project/qml | -| deploySystem | Deploys all the libs | +| -qmlDir [params] | Qml data dir. For example -qmlDir ~/my/project/qml | +| deploySystem | Deploys all the libs | | -qmake [params] | Qmake path. For example | | | -qmake ~/Qt/5.11.1/gcc_64/bin/qmake | -| -ignore [list,params] | The list of the libs to ignore. | +| -ignore [list,params] | The list of the libs to ignore. | | | For example -ignore libicudata.so.56,libicudata2.so.56 | -| clear | Deletes deployable files of the previous session. | +| -ignoreEnv [list,params] | The list of the environment to ignore. | +| | For example -ignoreEnv /bad/dir,/my/bad/Dir | +| clear | Deletes deployable files of the previous session. | | | For example -runScript myApp.sh | -| allQmlDependes | Extracts all the qml libraries. | -| | (not recommended, as it takes great amount of computer memory) | -| -libDir [list,params] | Sets additional paths for extra libs of an app. | +| allQmlDependes | Extracts all the qml libraries. | +| | (not recommended, as it takes great amount of computer memory) | +| -libDir [list,params] | Sets additional paths for extra libs of an app. | | | For example -libDir ~/myLib,~/newLibs | -| -extraPlugin [list,params] | Sets an additional path to extraPlugin of an app | -| -recursiveDepth [params] | Sets the Depth of recursive search of the libs (default 0) | -| -targetDir [params] | Sets target directory(by default it is the path to the first deployable file) | -| noStrip | Skips strip step | -| noTranslations | Skips the translations files. | +| -extraPlugin [list,params] | Sets an additional path to extraPlugin of an app | +| -recursiveDepth [params] | Sets the Depth of recursive search of the libs (default 0) | +| -targetDir [params] | Sets target directory(by default it is the path to the first deployable file)| +| noStrip | Skips strip step | +| noTranslations | Skips the translations files. | | qmlExtern | Use qml external scanner (qmlimportscaner) | -| | It doesn't work without qmake and inside a snap package | -| -verbose [0-3] | Shows debug log | +| | It doesn't work without qmake and inside a snap package | +| -verbose [0-3] | Shows debug log | @@ -94,6 +96,8 @@ Console QtDeployer является консольной реализацией | | -qmake ~/Qt/5.11.1/gcc_64/bin/qmake | | -ignore [list,params] | Список библиотек для игнорирования | | | Пример -ignore libicudata.so.56,libicudata2.so.56 | +| -ignoreEnv [list,params] | Список путей для игнорирования. | +| | Пример -ignoreEnv /bad/dir,/my/bad/Dir | | clear | Удаляет все старые файлы (с прошлого запуска) | | | пример -runScript myApp.sh | | allQmlDependes | Извлекает все библиотеки qml. | diff --git a/UnitTests/tst_deploytest.cpp b/UnitTests/tst_deploytest.cpp index eb27d49..16537f0 100644 --- a/UnitTests/tst_deploytest.cpp +++ b/UnitTests/tst_deploytest.cpp @@ -29,6 +29,8 @@ private: const QString& filename, const QString &qt = ""); QStringList getFilesFromDir(const QString& dir); + + public: deploytest(); /** @@ -42,6 +44,8 @@ public: bool mainTestOnlyC(); bool mainTestQMake(); bool mainTestQML(); + bool testEnvIgnore(); + ~deploytest(); @@ -132,6 +136,75 @@ QStringList deploytest::getFilesFromDir(const QString &path) { return res; } +bool deploytest::testEnvIgnore() +{ +#ifdef WITH_ALL_TESTS + + QFileInfo QtDir = QFileInfo(QT_BASE_DIR); + + if (!QtDir.isDir()) { + return false; + } + + int argc = 9; + std::string qmakePath = (QtDir.absoluteFilePath() + "bin/qmake.exe").toStdString(); + std::string qtPath = (QtDir.absoluteFilePath()).toStdString(); + + const char *qmake = qmakePath.c_str(); + const char *qt = qtPath.c_str(); +#ifdef Q_OS_WIN + + const char * argv[] = {"./", + "-bin", "./../../../tests/build/QtWidgetsProject.exe", + "-qmake", qmake, + "-ignoreEnv", qt, + "-targetDir", "./Distro"}; +#else + const char * argv[] = {"./", + "-bin", "./../../../tests/build/QtWidgetsProject", + "-qmake", qmake, + "-ignoreEnv", qt, + + "-targetDir", "./Distro"}; +#endif + if (!QuasarAppUtils::Params::parseParams(argc, argv)) { + return false; + } + + Deploy deploy; + + if (!DeployUtils::parseQt(&deploy)) { + return false; + } + + deploy.deploy(); + + if (!QFileInfo("./Distro").isDir()) { + return false; + } +#ifdef Q_OS_WIN + QDir info("./Distro"); + +#else + QDir info("./Distro/lib"); +#endif + + for (auto &i :info.entryInfoList()) { + if (i.fileName().contains("Qt")) { + return false; + } + + } + if (!info.removeRecursively()) { + return false; + } + + return true; +#else + return false; +#endif +} + deploytest::deploytest(){} int deploytest::generateLib(const QString &paath) @@ -453,6 +526,8 @@ void deploytest::mainTests() { QVERIFY(mainTestOnlyC()); QVERIFY(mainTestQMake()); QVERIFY(mainTestQML()); + QVERIFY(testEnvIgnore()); + #endif } @@ -564,6 +639,9 @@ bool deploytest::mainTestQMake() { #else return false; #endif + + + } bool deploytest::mainTestQML() {