Skip to content

Commit 22469d6

Browse files
committed
Move argument parser to previous location
1 parent 9f73828 commit 22469d6

File tree

1 file changed

+76
-76
lines changed

1 file changed

+76
-76
lines changed

tools/linuxdeployqt/main.cpp

Lines changed: 76 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -213,82 +213,6 @@ int main(int argc, char **argv)
213213
extern QStringList excludeLibs;
214214
extern bool copyCopyrightFiles;
215215

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-
292216
/* FHS-like mode is for an application that has been installed to a $PREFIX which is otherwise empty, e.g., /path/to/usr.
293217
* In this case, we want to construct an AppDir in /path/to. */
294218
if (QDir().exists((QDir::cleanPath(appBinaryPath + "/../../bin"))) == true) {
@@ -440,6 +364,82 @@ int main(int argc, char **argv)
440364
}
441365
}
442366

367+
// Check arguments
368+
for (int i = 1; i < argc; ++i) {
369+
QByteArray argument = QByteArray(argv[i]);
370+
371+
if (!argument.startsWith("-")) {
372+
continue;
373+
} else if (argument == QByteArray("-no-plugins")) {
374+
LogDebug() << "Argument found:" << argument;
375+
plugins = false;
376+
} else if (argument == QByteArray("-appimage")) {
377+
LogDebug() << "Argument found:" << argument;
378+
appimage = true;
379+
bundleAllButCoreLibs = true;
380+
} else if (argument == QByteArray("-no-strip")) {
381+
LogDebug() << "Argument found:" << argument;
382+
runStripEnabled = false;
383+
} else if (argument == QByteArray("-bundle-non-qt-libs")) {
384+
LogDebug() << "Argument found:" << argument;
385+
bundleAllButCoreLibs = true;
386+
} else if (argument.startsWith(QByteArray("-verbose"))) {
387+
LogDebug() << "Argument found:" << argument;
388+
int index = argument.indexOf("=");
389+
bool ok = false;
390+
int number = argument.mid(index+1).toInt(&ok);
391+
if (!ok)
392+
LogError() << "Could not parse verbose level";
393+
else
394+
logLevel = number;
395+
} else if (argument.startsWith(QByteArray("-executable"))) {
396+
LogDebug() << "Argument found:" << argument;
397+
int index = argument.indexOf('=');
398+
if (index == -1)
399+
LogError() << "Missing executable path";
400+
else
401+
additionalExecutables << argument.mid(index+1);
402+
} else if (argument.startsWith(QByteArray("-qmldir"))) {
403+
LogDebug() << "Argument found:" << argument;
404+
qmldirArgumentUsed = true;
405+
int index = argument.indexOf('=');
406+
if (index == -1)
407+
LogError() << "Missing qml directory path";
408+
else
409+
qmlDirs << argument.mid(index+1);
410+
} else if (argument.startsWith("-no-copy-copyright-files")) {
411+
LogDebug() << "Argument found:" << argument;
412+
copyCopyrightFiles = false;
413+
} else if (argument == QByteArray("-always-overwrite")) {
414+
LogDebug() << "Argument found:" << argument;
415+
alwaysOwerwriteEnabled = true;
416+
} else if (argument.startsWith("-qmake=")) {
417+
LogDebug() << "Argument found:" << argument;
418+
int index = argument.indexOf("=");
419+
qmakeExecutable = argument.mid(index+1);
420+
} else if (argument == QByteArray("-no-translations")) {
421+
LogDebug() << "Argument found:" << argument;
422+
skipTranslations = true;
423+
} else if (argument.startsWith("-extra-plugins=")) {
424+
LogDebug() << "Argument found:" << argument;
425+
int index = argument.indexOf("=");
426+
extraQtPlugins = QString(argument.mid(index + 1)).split(",");
427+
} else if (argument.startsWith("-exclude-libs=")) {
428+
LogDebug() << "Argument found:" << argument;
429+
int index = argument.indexOf("=");
430+
excludeLibs = QString(argument.mid(index + 1)).split(",");
431+
} else if (argument == QByteArray("-show-exclude-libs")) {
432+
qInfo() << EXCLUDELIST;
433+
return 0;
434+
} else if (argument.startsWith("--")) {
435+
LogError() << "Error: arguments must not start with --, only -:" << argument << "\n";
436+
return 1;
437+
} else {
438+
LogError() << "Unknown argument:" << argument << "\n";
439+
return 1;
440+
}
441+
}
442+
443443
if (appimage) {
444444
if(checkAppImagePrerequisites(appDirPath) == false){
445445
LogError() << "checkAppImagePrerequisites failed\n";

0 commit comments

Comments
 (0)