macdeployqt: Treat argument parsing errors as fatal

Passing options such as `-codesign` or `-fs` without an additional
argument would just print an error, but proceed with deployment,
giving the user an app bundle that didn't reflect the intent of
passing the command line options.

We now treat such errors as fatal.

Change-Id: Iff1b3fac3eb8defadea0425dc13996ed80fe3840
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
(cherry picked from commit 58615c066707d0c3592e79b5a03f1330e28c64b5)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
Tor Arne Vestbø 2024-06-21 11:49:41 +02:00 committed by Qt Cherry-pick Bot
parent 67b3c40ae2
commit 1364db690a

View File

@ -100,39 +100,49 @@ int main(int argc, char **argv)
int index = argument.indexOf("=");
bool ok = false;
int number = argument.mid(index+1).toInt(&ok);
if (!ok)
if (!ok) {
LogError() << "Could not parse verbose level";
else
return 1;
} else {
logLevel = number;
}
} else if (argument.startsWith(QByteArray("-executable"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
if (index == -1) {
LogError() << "Missing executable path";
else
return 1;
} else {
additionalExecutables << argument.mid(index+1);
}
} else if (argument.startsWith(QByteArray("-qmldir"))) {
LogDebug() << "Argument found:" << argument;
qmldirArgumentUsed = true;
int index = argument.indexOf('=');
if (index == -1)
if (index == -1) {
LogError() << "Missing qml directory path";
else
return 1;
} else {
qmlDirs << argument.mid(index+1);
}
} else if (argument.startsWith(QByteArray("-qmlimport"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
if (index == -1) {
LogError() << "Missing qml import path";
else
return 1;
} else {
qmlImportPaths << argument.mid(index+1);
}
} else if (argument.startsWith(QByteArray("-libpath"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
if (index == -1) {
LogError() << "Missing library search path";
else
return 1;
} else {
librarySearchPath << argument.mid(index+1);
}
} else if (argument == QByteArray("-always-overwrite")) {
LogDebug() << "Argument found:" << argument;
alwaysOwerwriteEnabled = true;
@ -141,6 +151,7 @@ int main(int argc, char **argv)
int index = argument.indexOf("=");
if (index < 0 || index >= argument.size()) {
LogError() << "Missing code signing identity";
return 1;
} else {
runCodesign = true;
codesignIdentiy = argument.mid(index+1);
@ -150,6 +161,7 @@ int main(int argc, char **argv)
int index = argument.indexOf("=");
if (index < 0 || index >= argument.size()) {
LogError() << "Missing code signing identity";
return 1;
} else {
runCodesign = true;
hardenedRuntime = true;
@ -174,10 +186,12 @@ int main(int argc, char **argv)
} else if (argument.startsWith(QByteArray("-fs"))) {
LogDebug() << "Argument found:" << argument;
int index = argument.indexOf('=');
if (index == -1)
if (index == -1) {
LogError() << "Missing filesystem type";
else
return 1;
} else {
filesystem = argument.mid(index+1);
}
} else if (argument.startsWith("-")) {
LogError() << "Unknown argument" << argument << "\n";
return 1;