@@ -62,7 +62,7 @@ int main(int argc, char **argv)
6262 }
6363 }
6464
65- if (argc < 2 || (firstArgument. startsWith ( " - " )) ) {
65+ if (argc < 2 ) {
6666 qInfo () << " " ;
6767 qInfo () << " Usage: linuxdeployqt <app-binary|desktop file> [options]" ;
6868 qInfo () << " " ;
@@ -82,6 +82,7 @@ int main(int argc, char **argv)
8282 qInfo () << " -no-translations : Skip deployment of translations." ;
8383 qInfo () << " -qmake=<path> : The qmake executable to use." ;
8484 qInfo () << " -qmldir=<path> : Scan for QML imports in the given path." ;
85+ qInfo () << " -show-exclude-libs : Print exclude libraries list." ;
8586 qInfo () << " -verbose=<0-3> : 0 = no output, 1 = error/warning (default)," ;
8687 qInfo () << " 2 = normal, 3 = debug." ;
8788 qInfo () << " -version : Print version statement and exit." ;
@@ -212,6 +213,82 @@ int main(int argc, char **argv)
212213 extern QStringList excludeLibs;
213214 extern bool copyCopyrightFiles;
214215
216+ // Check arguments
217+ for (int i = 1 ; i < argc; ++i) {
218+ QByteArray argument = QByteArray (argv[i]);
219+
220+ if (!argument.startsWith (" -" )) {
221+ continue ;
222+ } else if (argument == QByteArray (" -no-plugins" )) {
223+ LogDebug () << " Argument found:" << argument;
224+ plugins = false ;
225+ } else if (argument == QByteArray (" -appimage" )) {
226+ LogDebug () << " Argument found:" << argument;
227+ appimage = true ;
228+ bundleAllButCoreLibs = true ;
229+ } else if (argument == QByteArray (" -no-strip" )) {
230+ LogDebug () << " Argument found:" << argument;
231+ runStripEnabled = false ;
232+ } else if (argument == QByteArray (" -bundle-non-qt-libs" )) {
233+ LogDebug () << " Argument found:" << argument;
234+ bundleAllButCoreLibs = true ;
235+ } else if (argument.startsWith (QByteArray (" -verbose" ))) {
236+ LogDebug () << " Argument found:" << argument;
237+ int index = argument.indexOf (" =" );
238+ bool ok = false ;
239+ int number = argument.mid (index+1 ).toInt (&ok);
240+ if (!ok)
241+ LogError () << " Could not parse verbose level" ;
242+ else
243+ logLevel = number;
244+ } else if (argument.startsWith (QByteArray (" -executable" ))) {
245+ LogDebug () << " Argument found:" << argument;
246+ int index = argument.indexOf (' =' );
247+ if (index == -1 )
248+ LogError () << " Missing executable path" ;
249+ else
250+ additionalExecutables << argument.mid (index+1 );
251+ } else if (argument.startsWith (QByteArray (" -qmldir" ))) {
252+ LogDebug () << " Argument found:" << argument;
253+ qmldirArgumentUsed = true ;
254+ int index = argument.indexOf (' =' );
255+ if (index == -1 )
256+ LogError () << " Missing qml directory path" ;
257+ else
258+ qmlDirs << argument.mid (index+1 );
259+ } else if (argument.startsWith (" -no-copy-copyright-files" )) {
260+ LogDebug () << " Argument found:" << argument;
261+ copyCopyrightFiles = false ;
262+ } else if (argument == QByteArray (" -always-overwrite" )) {
263+ LogDebug () << " Argument found:" << argument;
264+ alwaysOwerwriteEnabled = true ;
265+ } else if (argument.startsWith (" -qmake=" )) {
266+ LogDebug () << " Argument found:" << argument;
267+ int index = argument.indexOf (" =" );
268+ qmakeExecutable = argument.mid (index+1 );
269+ } else if (argument == QByteArray (" -no-translations" )) {
270+ LogDebug () << " Argument found:" << argument;
271+ skipTranslations = true ;
272+ } else if (argument.startsWith (" -extra-plugins=" )) {
273+ LogDebug () << " Argument found:" << argument;
274+ int index = argument.indexOf (" =" );
275+ extraQtPlugins = QString (argument.mid (index + 1 )).split (" ," );
276+ } else if (argument.startsWith (" -exclude-libs=" )) {
277+ LogDebug () << " Argument found:" << argument;
278+ int index = argument.indexOf (" =" );
279+ excludeLibs = QString (argument.mid (index + 1 )).split (" ," );
280+ } else if (argument == QByteArray (" -show-exclude-libs" )) {
281+ qInfo () << EXCLUDELIST;
282+ return 0 ;
283+ } else if (argument.startsWith (" --" )) {
284+ LogError () << " Error: arguments must not start with --, only -:" << argument << " \n " ;
285+ return 1 ;
286+ } else {
287+ LogError () << " Unknown argument:" << argument << " \n " ;
288+ return 1 ;
289+ }
290+ }
291+
215292 /* FHS-like mode is for an application that has been installed to a $PREFIX which is otherwise empty, e.g., /path/to/usr.
216293 * In this case, we want to construct an AppDir in /path/to. */
217294 if (QDir ().exists ((QDir::cleanPath (appBinaryPath + " /../../bin" ))) == true ) {
@@ -363,75 +440,6 @@ int main(int argc, char **argv)
363440 }
364441 }
365442
366- for (int i = 2 ; i < argc; ++i) {
367- QByteArray argument = QByteArray (argv[i]);
368- if (argument == QByteArray (" -no-plugins" )) {
369- LogDebug () << " Argument found:" << argument;
370- plugins = false ;
371- } else if (argument == QByteArray (" -appimage" )) {
372- LogDebug () << " Argument found:" << argument;
373- appimage = true ;
374- bundleAllButCoreLibs = true ;
375- } else if (argument == QByteArray (" -no-strip" )) {
376- LogDebug () << " Argument found:" << argument;
377- runStripEnabled = false ;
378- } else if (argument == QByteArray (" -bundle-non-qt-libs" )) {
379- LogDebug () << " Argument found:" << argument;
380- bundleAllButCoreLibs = true ;
381- } else if (argument.startsWith (QByteArray (" -verbose" ))) {
382- LogDebug () << " Argument found:" << argument;
383- int index = argument.indexOf (" =" );
384- bool ok = false ;
385- int number = argument.mid (index+1 ).toInt (&ok);
386- if (!ok)
387- LogError () << " Could not parse verbose level" ;
388- else
389- logLevel = number;
390- } else if (argument.startsWith (QByteArray (" -executable" ))) {
391- LogDebug () << " Argument found:" << argument;
392- int index = argument.indexOf (' =' );
393- if (index == -1 )
394- LogError () << " Missing executable path" ;
395- else
396- additionalExecutables << argument.mid (index+1 );
397- } else if (argument.startsWith (QByteArray (" -qmldir" ))) {
398- LogDebug () << " Argument found:" << argument;
399- qmldirArgumentUsed = true ;
400- int index = argument.indexOf (' =' );
401- if (index == -1 )
402- LogError () << " Missing qml directory path" ;
403- else
404- qmlDirs << argument.mid (index+1 );
405- } else if (argument.startsWith (" -no-copy-copyright-files" )) {
406- LogDebug () << " Argument found:" << argument;
407- copyCopyrightFiles = false ;
408- } else if (argument == QByteArray (" -always-overwrite" )) {
409- LogDebug () << " Argument found:" << argument;
410- alwaysOwerwriteEnabled = true ;
411- } else if (argument.startsWith (" -qmake=" )) {
412- LogDebug () << " Argument found:" << argument;
413- int index = argument.indexOf (" =" );
414- qmakeExecutable = argument.mid (index+1 );
415- } else if (argument == QByteArray (" -no-translations" )) {
416- LogDebug () << " Argument found:" << argument;
417- skipTranslations = true ;
418- } else if (argument.startsWith (" -extra-plugins=" )) {
419- LogDebug () << " Argument found:" << argument;
420- int index = argument.indexOf (" =" );
421- extraQtPlugins = QString (argument.mid (index + 1 )).split (" ," );
422- } else if (argument.startsWith (" -exclude-libs=" )) {
423- LogDebug () << " Argument found:" << argument;
424- int index = argument.indexOf (" =" );
425- excludeLibs = QString (argument.mid (index + 1 )).split (" ," );
426- } else if (argument.startsWith (" --" )) {
427- LogError () << " Error: arguments must not start with --, only -:" << argument << " \n " ;
428- return 1 ;
429- } else {
430- LogError () << " Unknown argument:" << argument << " \n " ;
431- return 1 ;
432- }
433- }
434-
435443 if (appimage) {
436444 if (checkAppImagePrerequisites (appDirPath) == false ){
437445 LogError () << " checkAppImagePrerequisites failed\n " ;
0 commit comments