Windeployqt: add custom qml output directory command line option

Added the qml-deploy-dir option, which deploys imported qml files to
the directory passed as an argument. If no option is given, a "qml"
directory is created, and files are deployed there.

[ChangeLog][QtTools][Windeployqt] Windeployqt's default behavior is
now to deploy qml imports to a "qml" directory inside the deploy
directory, rather than directly to the deploy directory.

Task-number: QTBUG-99516
Pick-to: 6.5
Change-Id: I49262a38c4a42ef20b05b603f5eb5393fe9cc218
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
This commit is contained in:
Timothée Keller 2022-12-22 19:02:40 +01:00
parent a2dab1bda9
commit 0b4286ff28

View File

@ -181,6 +181,7 @@ struct Options {
QStringList languages;
QString libraryDirectory;
QString pluginDirectory;
QString qmlDirectory;
QStringList binaries;
JsonOutput *json = nullptr;
ListOption list = ListNone;
@ -336,6 +337,11 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse
QStringLiteral("path"));
parser->addOption(pluginDirOption);
QCommandLineOption qmlDeployDirOption(QStringLiteral("qml-deploy-dir"),
QStringLiteral("Copy qml files to path."),
QStringLiteral("path"));
parser->addOption(qmlDeployDirOption);
QCommandLineOption debugOption(QStringLiteral("debug"),
QStringLiteral("Assume debug binaries."));
parser->addOption(debugOption);
@ -472,6 +478,7 @@ static inline int parseArguments(const QStringList &arguments, QCommandLineParse
options->libraryDirectory = parser->value(libDirOption);
options->pluginDirectory = parser->value(pluginDirOption);
options->qmlDirectory = parser->value(qmlDeployDirOption);
options->plugins = !parser->isSet(noPluginsOption);
options->libraries = !parser->isSet(noLibraryOption);
options->translations = !parser->isSet(noTranslationOption);
@ -1476,13 +1483,18 @@ static DeployResult deploy(const Options &options, const QMap<QString, QString>
// Do not be fooled by QtWebKit.dll depending on Quick into always installing Quick imports
// for WebKit1-applications. Check direct dependency only.
if (options.quickImports && usesQml2) {
const QString targetPath = options.qmlDirectory.isEmpty()
? options.directory + QStringLiteral("/qml")
: options.qmlDirectory;
if (!createDirectory(targetPath, errorMessage))
return result;
for (const QmlImportScanResult::Module &module : std::as_const(qmlScanResult.modules)) {
const QString installPath = module.installPath(options.directory);
const QString installPath = module.installPath(targetPath);
if (optVerboseLevel > 1)
std::wcout << "Installing: '" << module.name
<< "' from " << module.sourcePath << " to "
<< QDir::toNativeSeparators(installPath) << '\n';
if (installPath != options.directory && !createDirectory(installPath, errorMessage))
if (installPath != targetPath && !createDirectory(installPath, errorMessage))
return result;
unsigned updateFileFlags = options.updateFileFlags
| SkipQmlDesignerSpecificsDirectories;