3333#include < stdlib.h>
3434#include < QSettings>
3535#include < QDirIterator>
36+ #include < sstream>
3637
3738int main (int argc, char **argv)
3839{
@@ -43,41 +44,61 @@ int main(int argc, char **argv)
4344
4445 QString firstArgument = QString::fromLocal8Bit (argv[1 ]);
4546
46- if (argc < 2 || firstArgument.startsWith (" -" )) {
47- qDebug () << " Usage: linuxdeployqt <app-binary|desktop file> [options]" ;
48- qDebug () << " " ;
49- qDebug () << " Options:" ;
50- qDebug () << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default)," ;
51- qDebug () << " 2 = normal, 3 = debug" ;
52- qDebug () << " -no-plugins : Skip plugin deployment" ;
53- qDebug () << " -appimage : Create an AppImage (implies -bundle-non-qt-libs)" ;
54- qDebug () << " -no-strip : Don't run 'strip' on the binaries" ;
55- qDebug () << " -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries" ;
56- qDebug () << " -executable=<path> : Let the given executable use the deployed libraries" ;
57- qDebug () << " too" ;
58- qDebug () << " -qmldir=<path> : Scan for QML imports in the given path" ;
59- qDebug () << " -always-overwrite : Copy files even if the target file exists" ;
60- qDebug () << " -qmake=<path> : The qmake executable to use" ;
61- qDebug () << " -no-translations : Skip deployment of translations." ;
62- qDebug () << " -extra-plugins=<list> : List of extra plugins which should be deployed," ;
63- qDebug () << " separated by comma." ;
64- qDebug () << " " ;
65- qDebug () << " linuxdeployqt takes an application as input and makes it" ;
66- qDebug () << " self-contained by copying in the Qt libraries and plugins that" ;
67- qDebug () << " the application uses." ;
68- qDebug () << " " ;
69- qDebug () << " By default it deploys the Qt instance that qmake on the $PATH points to." ;
70- qDebug () << " The '-qmake' option can be used to point to the qmake executable" ;
71- qDebug () << " to be used instead." ;
72- qDebug () << " " ;
73- qDebug () << " Plugins related to a Qt library are copied in with the library." ;
47+ // print version statement
48+ std::stringstream version;
49+ version << " linuxdeployqt " << LINUXDEPLOYQT_VERSION
50+ << " (commit " << LINUXDEPLOYQT_GIT_COMMIT << " ), "
51+ << " build " << BUILD_NUMBER << " built on " << BUILD_DATE;
52+ qInfo ().noquote () << QString::fromStdString (version.str ());
53+
54+ // due to the structure of the argument parser, we have to check all arguments at first to check whether the user
55+ // wants to get the version only
56+ // TODO: replace argument parser with position independent, less error prone version
57+ for (int i = 0 ; i < argc; i++ ) {
58+ QString argument = argv[i];
59+ if (argument == " -version" || argument == " -V" || argument == " --version" ) {
60+ // can just exit normally, version has been printed above
61+ return 0 ;
62+ }
63+ }
64+
65+ if (argc < 2 || (firstArgument.startsWith (" -" ))) {
66+ qInfo () << " " ;
67+ qInfo () << " Usage: linuxdeployqt <app-binary|desktop file> [options]" ;
68+ qInfo () << " " ;
69+ qInfo () << " Options:" ;
70+ qInfo () << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default)," ;
71+ qInfo () << " 2 = normal, 3 = debug" ;
72+ qInfo () << " -no-plugins : Skip plugin deployment" ;
73+ qInfo () << " -appimage : Create an AppImage (implies -bundle-non-qt-libs)" ;
74+ qInfo () << " -no-strip : Don't run 'strip' on the binaries" ;
75+ qInfo () << " -bundle-non-qt-libs : Also bundle non-core, non-Qt libraries" ;
76+ qInfo () << " -executable=<path> : Let the given executable use the deployed libraries" ;
77+ qInfo () << " too" ;
78+ qInfo () << " -qmldir=<path> : Scan for QML imports in the given path" ;
79+ qInfo () << " -always-overwrite : Copy files even if the target file exists" ;
80+ qInfo () << " -qmake=<path> : The qmake executable to use" ;
81+ qInfo () << " -no-translations : Skip deployment of translations." ;
82+ qInfo () << " -extra-plugins=<list> : List of extra plugins which should be deployed," ;
83+ qInfo () << " separated by comma." ;
84+ qInfo () << " -version : Print version statement and exit." ;
85+ qInfo () << " " ;
86+ qInfo () << " linuxdeployqt takes an application as input and makes it" ;
87+ qInfo () << " self-contained by copying in the Qt libraries and plugins that" ;
88+ qInfo () << " the application uses." ;
89+ qInfo () << " " ;
90+ qInfo () << " By default it deploys the Qt instance that qmake on the $PATH points to." ;
91+ qInfo () << " The '-qmake' option can be used to point to the qmake executable" ;
92+ qInfo () << " to be used instead." ;
93+ qInfo () << " " ;
94+ qInfo () << " Plugins related to a Qt library are copied in with the library." ;
7495 /* TODO: To be implemented
7596 qDebug() << "The accessibility, image formats, and text codec";
7697 qDebug() << "plugins are always copied, unless \"-no-plugins\" is specified.";
7798 */
78- qDebug () << " " ;
79- qDebug () << " See the \" Deploying Applications on Linux\" topic in the" ;
80- qDebug () << " documentation for more information about deployment on Linux." ;
99+ qInfo () << " " ;
100+ qInfo () << " See the \" Deploying Applications on Linux\" topic in the" ;
101+ qInfo () << " documentation for more information about deployment on Linux." ;
81102
82103 return 1 ;
83104 }
@@ -389,8 +410,11 @@ int main(int argc, char **argv)
389410 } else if (argument.startsWith (" -extra-plugins=" )) {
390411 LogDebug () << " Argument found:" << argument;
391412 int index = argument.indexOf (" =" );
392- extraQtPlugins = QString (argument.mid (index+ 1 )).split (" ," );
413+ extraQtPlugins = QString (argument.mid (index + 1 )).split (" ," );
393414 } else if (argument.startsWith (" -" )) {
415+ LogError () << " Error: arguments must not start with --, only -" << " \n " ;
416+ return 1 ;
417+ } else {
394418 LogError () << " Unknown argument" << argument << " \n " ;
395419 return 1 ;
396420 }
0 commit comments