From 1364db690afe19ce9730ffca580393932c677d11 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 21 Jun 2024 11:49:41 +0200 Subject: [PATCH] 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 (cherry picked from commit 58615c066707d0c3592e79b5a03f1330e28c64b5) Reviewed-by: Qt Cherry-pick Bot --- src/tools/macdeployqt/macdeployqt/main.cpp | 38 +++++++++++++++------- 1 file changed, 26 insertions(+), 12 deletions(-) diff --git a/src/tools/macdeployqt/macdeployqt/main.cpp b/src/tools/macdeployqt/macdeployqt/main.cpp index 8b6c476fa53..28b8004dd4c 100644 --- a/src/tools/macdeployqt/macdeployqt/main.cpp +++ b/src/tools/macdeployqt/macdeployqt/main.cpp @@ -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;