From 957b91e5559f50c09c0c4dc4f45da8941a7de662 Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Tue, 26 Aug 2014 16:57:44 +0200 Subject: [PATCH] windeployqt: Fix -webkit2 / -no-webkit2 command line options. Introduce convenience function for exclusive options. Task-number: QTBUG-40663 Change-Id: I03dd88f5bcec55f0190501c1faae0ec66d607016 Reviewed-by: Andrew Knight --- src/windeployqt/main.cpp | 64 +++++++++++++++++++++++++++++++++++------------- 1 file changed, 47 insertions(+), 17 deletions(-) diff --git a/src/windeployqt/main.cpp b/src/windeployqt/main.cpp index 73cae15..8b16863 100644 --- a/src/windeployqt/main.cpp +++ b/src/windeployqt/main.cpp @@ -187,8 +187,32 @@ static Platform platformFromMkSpec(const QString &xSpec) return UnknownPlatform; } +// Helpers for exclusive options, "-foo", "--no-foo" +enum ExlusiveOptionValue { + OptionAuto, + OptionEnabled, + OptionDisabled +}; + +static ExlusiveOptionValue parseExclusiveOptions(const QCommandLineParser *parser, + const QCommandLineOption &enableOption, + const QCommandLineOption &disableOption) +{ + const bool enabled = parser->isSet(enableOption); + const bool disabled = parser->isSet(disableOption); + if (enabled) { + if (disabled) { + std::wcerr << "Warning: both -" << enableOption.names().first() + << " and -" << disableOption.names().first() << " were specified, defaulting to -" + << enableOption.names().first() << ".\n"; + } + return OptionEnabled; + } + return disabled ? OptionDisabled : OptionAuto; +} + bool optHelp = false; -int optWebKit2 = 0; +ExlusiveOptionValue optWebKit2 = OptionAuto; struct Options { enum DebugDetection { @@ -404,23 +428,29 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse return CommandLineParseError; } - const bool forceDebug = parser->isSet(debugOption); - const bool forceRelease = parser->isSet(releaseOption); - if (forceDebug && forceRelease) - std::wcerr << "Warning: both -debug and -release were specified, defaulting to debug.\n"; - if (forceDebug) + switch (parseExclusiveOptions(parser, debugOption, releaseOption)) { + case OptionAuto: + break; + case OptionEnabled: options->debugDetection = Options::DebugDetectionForceDebug; - else if (forceRelease) - options->debugDetection = Options::DebugDetectionForceRelease; - - const bool forceAngle = parser->isSet(angleOption); - const bool disableAngle = parser->isSet(noAngleOption); - if (forceAngle && disableAngle) - std::wcerr << "Warning: both -angle and -no-angle specified, defaulting to on.\n"; - if (forceAngle) + break; + case OptionDisabled: + options->debugDetection = Options::DebugDetectionForceRelease; + break; + } + + switch (parseExclusiveOptions(parser, angleOption, noAngleOption)) { + case OptionAuto: + break; + case OptionEnabled: options->angleDetection = Options::AngleDetectionForceOn; - else if (disableAngle) + break; + case OptionDisabled: options->angleDetection = Options::AngleDetectionForceOff; + break; + } + + optWebKit2 = parseExclusiveOptions(parser, webKitOption, noWebKitOption); if (parser->isSet(forceOption)) options->updateFileFlags |= ForceUpdateFile; @@ -1241,8 +1271,8 @@ int main(int argc, char **argv) return 1; } - if ((optWebKit2 != -1) - && (optWebKit2 == 1 + if ((optWebKit2 != OptionDisabled) + && (optWebKit2 == OptionEnabled || ((result.deployedQtLibraries & QtWebKitModule) && (result.directlyUsedQtLibraries & QtQuickModule)))) { if (optVerboseLevel) -- 2.7.4