From 4f8474e5326ebb9d23d85141e416e82eb04cb160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kai=20K=C3=B6hne?= Date: Tue, 9 Mar 2021 13:16:04 +0100 Subject: [PATCH] Simplify handling of qmlplugindump Much of it isn't needed anymore: - we do not build a debug version of qmlplugindump anymore since Qt 5.0 - on mac, qmlplugindump is not an app bundle since Qt 5.1 - since commit 6871f31b4ec6, the env parameter was just passed through So if we take out this and all the infrastructure around it, qmlplugindump is just a tool that we can handle like all the other tools. Change-Id: Ifa583ce7052a9030858312ab7c2e20f7ebce4051 Reviewed-by: Thomas Hartmann Reviewed-by: Ulf Hermann Reviewed-by: Fawzi Mohamed --- src/plugins/qmljstools/qmljsmodelmanager.cpp | 22 +--- src/plugins/qtsupport/CMakeLists.txt | 1 - src/plugins/qtsupport/baseqtversion.cpp | 49 ++++---- src/plugins/qtsupport/baseqtversion.h | 5 +- src/plugins/qtsupport/qmldumptool.cpp | 116 ------------------- src/plugins/qtsupport/qmldumptool.h | 54 --------- src/plugins/qtsupport/qtsupport.pro | 2 - src/plugins/qtsupport/qtsupport.qbs | 2 - 8 files changed, 27 insertions(+), 224 deletions(-) delete mode 100644 src/plugins/qtsupport/qmldumptool.cpp delete mode 100644 src/plugins/qtsupport/qmldumptool.h diff --git a/src/plugins/qmljstools/qmljsmodelmanager.cpp b/src/plugins/qmljstools/qmljsmodelmanager.cpp index 56c974c07cc..c41d55b9967 100644 --- a/src/plugins/qmljstools/qmljsmodelmanager.cpp +++ b/src/plugins/qmljstools/qmljsmodelmanager.cpp @@ -49,7 +49,6 @@ #include #include #include -#include #include #include #include @@ -128,14 +127,10 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( Kit *activeKit = activeTarget ? activeTarget->kit() : KitManager::defaultKit(); QtSupport::BaseQtVersion *qtVersion = QtSupport::QtKitAspect::qtVersion(activeKit); - bool preferDebugDump = false; - bool setPreferDump = false; projectInfo.tryQmlDump = false; if (activeTarget) { if (BuildConfiguration *bc = activeTarget->activeBuildConfiguration()) { - preferDebugDump = bc->buildType() == BuildConfiguration::Debug; - setPreferDump = true; // Append QML2_IMPORT_PATH if it is defined in build configuration. // It enables qmlplugindump to correctly dump custom plugins or other dependent // plugins that are not installed in default Qt qml installation directory. @@ -149,8 +144,6 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( projectInfo.applicationDirectories.append(target.targetFilePath.parentDir().toString()); } } - if (!setPreferDump && qtVersion) - preferDebugDump = (qtVersion->defaultBuildConfig() & QtSupport::BaseQtVersion::DebugBuild); if (qtVersion && qtVersion->isValid()) { projectInfo.tryQmlDump = project && qtVersion->type() == QLatin1String(QtSupport::Constants::DESKTOPQT); projectInfo.qtQmlPath = qtVersion->qmlPath().toFileInfo().canonicalFilePath(); @@ -160,16 +153,13 @@ ModelManagerInterface::ProjectInfo ModelManager::defaultProjectInfoForProject( projectInfo.qtVersionString = QLatin1String(qVersion()); } - if (projectInfo.tryQmlDump) { - QtSupport::QmlDumpTool::pathAndEnvironment(activeKit, - preferDebugDump, &projectInfo.qmlDumpPath, - &projectInfo.qmlDumpEnvironment); - projectInfo.qmlDumpHasRelocatableFlag = qtVersion->hasQmlDumpWithRelocatableFlag(); - } else { - projectInfo.qmlDumpPath.clear(); - projectInfo.qmlDumpEnvironment.clear(); - projectInfo.qmlDumpHasRelocatableFlag = true; + projectInfo.qmlDumpPath.clear(); + const QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(activeKit); + if (version && projectInfo.tryQmlDump) { + projectInfo.qmlDumpPath = version->qmlplugindumpCommand(); + projectInfo.qmlDumpHasRelocatableFlag = version->hasQmlDumpWithRelocatableFlag(); } + setupProjectInfoQmlBundles(projectInfo); return projectInfo; } diff --git a/src/plugins/qtsupport/CMakeLists.txt b/src/plugins/qtsupport/CMakeLists.txt index 0f032ac76c6..97b79767536 100644 --- a/src/plugins/qtsupport/CMakeLists.txt +++ b/src/plugins/qtsupport/CMakeLists.txt @@ -11,7 +11,6 @@ add_qtc_plugin(QtSupport exampleslistmodel.cpp exampleslistmodel.h gettingstartedwelcomepage.cpp gettingstartedwelcomepage.h profilereader.cpp profilereader.h - qmldumptool.cpp qmldumptool.h qscxmlcgenerator.cpp qscxmlcgenerator.h qtbuildaspects.cpp qtbuildaspects.h qtconfigwidget.cpp qtconfigwidget.h diff --git a/src/plugins/qtsupport/baseqtversion.cpp b/src/plugins/qtsupport/baseqtversion.cpp index d8002505628..edac4e570d8 100644 --- a/src/plugins/qtsupport/baseqtversion.cpp +++ b/src/plugins/qtsupport/baseqtversion.cpp @@ -25,7 +25,6 @@ #include "baseqtversion.h" #include "qtconfigwidget.h" -#include "qmldumptool.h" #include "qtkitinformation.h" #include "qtversionfactory.h" @@ -48,6 +47,7 @@ #include #include +#include #include #include #include @@ -211,7 +211,6 @@ public: QtVersionData m_data; bool m_isUpdating = false; - bool m_hasQmlDump = false; // controlled by m_versionInfoUpToDate bool m_mkspecUpToDate = false; bool m_mkspecReadUpToDate = false; bool m_defaultConfigIsDebug = true; @@ -238,6 +237,7 @@ public: QString m_linguistCommand; QString m_qscxmlcCommand; QString m_qmlsceneCommand; + QString m_qmlplugindumpCommand; MacroExpanderWrapper m_expander; }; @@ -1010,6 +1010,24 @@ QString BaseQtVersion::qmlsceneCommand() const return d->m_qmlsceneCommand; } +QString BaseQtVersion::qmlplugindumpCommand() const +{ + if (!isValid()) + return QString(); + + if (!d->m_qmlplugindumpCommand.isNull()) + return d->m_qmlplugindumpCommand; + + ensureMkSpecParsed(); + + const QString path + = qmlBinPath().pathAppended(HostOsInfo::withExecutableSuffix("qmlplugindump")).toString(); + + d->m_qmlplugindumpCommand = QFileInfo(path).isFile() ? path : QString(); + + return d->m_qmlplugindumpCommand; +} + QString BaseQtVersionPrivate::findHostBinary(HostBinaries binary) const { QString baseDir; @@ -1261,7 +1279,6 @@ void BaseQtVersionPrivate::updateVersionInfo() m_data.installed = true; m_data.hasExamples = false; m_data.hasDocumentation = false; - m_hasQmlDump = false; if (!queryQMakeVariables(m_qmakeCommand, q->qmakeRunEnvironment(), &m_versionInfo)) { m_qmakeIsExecutable = false; @@ -1292,17 +1309,8 @@ void BaseQtVersionPrivate::updateVersionInfo() m_data.hostDataPath = FilePath::fromUserInput(qmakeProperty("QT_HOST_DATA")); m_data.hostPrefixPath = FilePath::fromUserInput(qmakeProperty("QT_HOST_PREFIX")); - const QString qtInstallBins = q->binPath().toString(); const QString qtHeaderData = q->headerPath().toString(); - if (!qtInstallBins.isNull()) { - if (!qtInstallBins.isEmpty()) { - m_hasQmlDump - = !QmlDumpTool::toolForQtPaths(qtInstallBins, false).isEmpty() - || !QmlDumpTool::toolForQtPaths(qtInstallBins, true).isEmpty(); - } - } - // Now check for a qt that is configured with a prefix but not installed QString installDir = q->hostBinPath().toString(); if (!installDir.isNull()) { @@ -1676,29 +1684,12 @@ Environment BaseQtVersion::qmakeRunEnvironment() const return Environment::systemEnvironment(); } -bool BaseQtVersion::hasQmlDump() const -{ - d->updateVersionInfo(); - return d->m_hasQmlDump; -} - bool BaseQtVersion::hasQmlDumpWithRelocatableFlag() const { return ((qtVersion() > QtVersionNumber(4, 8, 4) && qtVersion() < QtVersionNumber(5, 0, 0)) || qtVersion() >= QtVersionNumber(5, 1, 0)); } -bool BaseQtVersion::needsQmlDump() const -{ - return qtVersion() < QtVersionNumber(4, 8, 0); -} - -QString BaseQtVersion::qmlDumpTool(bool debugVersion) const -{ - const QString qtInstallBins = binPath().toString(); - return QmlDumpTool::toolForQtPaths(qtInstallBins, debugVersion); -} - Tasks BaseQtVersion::reportIssuesImpl(const QString &proFile, const QString &buildDir) const { Q_UNUSED(proFile) diff --git a/src/plugins/qtsupport/baseqtversion.h b/src/plugins/qtsupport/baseqtversion.h index 29cd2064942..bebaf654ac9 100644 --- a/src/plugins/qtsupport/baseqtversion.h +++ b/src/plugins/qtsupport/baseqtversion.h @@ -138,6 +138,7 @@ public: QString linguistCommand() const; QString qscxmlcCommand() const; QString qmlsceneCommand() const; + QString qmlplugindumpCommand() const; QString qtVersionString() const; QtVersionNumber qtVersion() const; @@ -181,11 +182,7 @@ public: static bool isQtQuickCompilerSupported(const ProjectExplorer::Kit *k, QString *reason = nullptr); bool isQtQuickCompilerSupported(QString *reason = nullptr) const; - QString qmlDumpTool(bool debugVersion) const; - - bool hasQmlDump() const; bool hasQmlDumpWithRelocatableFlag() const; - bool needsQmlDump() const; virtual QtConfigWidget *createConfigurationWidget() const; diff --git a/src/plugins/qtsupport/qmldumptool.cpp b/src/plugins/qtsupport/qmldumptool.cpp deleted file mode 100644 index 5cbed627104..00000000000 --- a/src/plugins/qtsupport/qmldumptool.cpp +++ /dev/null @@ -1,116 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "qmldumptool.h" -#include "qtkitinformation.h" -#include "qtsupportconstants.h" -#include "qtversionmanager.h" - -#include -#include - -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -namespace QtSupport { - -static inline QStringList validPrebuiltFilenames(bool debugBuild) -{ - QStringList list = QStringList(QLatin1String("qmlplugindump")); - list.append(QLatin1String("qmlplugindump.app/Contents/MacOS/qmlplugindump")); - if (debugBuild) - list.prepend(QLatin1String("qmlplugindumpd.exe")); - else - list.prepend(QLatin1String("qmlplugindump.exe")); - return list; -} - -QString QmlDumpTool::toolForVersion(const BaseQtVersion *version, bool debugDump) -{ - if (version) { - const QString qtInstallBins = version->binPath().toString(); - return toolForQtPaths(qtInstallBins, debugDump); - } - - return QString(); -} - -QString QmlDumpTool::toolForQtPaths(const QString &qtInstallBins, - bool debugDump) -{ - if (!Core::ICore::instance()) - return QString(); - - // check for prebuilt binary first - QFileInfo fileInfo; - if (getHelperFileInfoFor(validPrebuiltFilenames(debugDump), qtInstallBins + QLatin1Char('/'), &fileInfo)) - return fileInfo.absoluteFilePath(); - - return QString(); -} - -void QmlDumpTool::pathAndEnvironment(const ProjectExplorer::Kit *k, bool preferDebug, - QString *dumperPath, Utils::Environment *env) -{ - if (!k) - return; - - const BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(k); - if (version && !version->hasQmlDump()) - return; - - QString path; - - path = toolForVersion(version, preferDebug); - if (path.isEmpty()) - path = toolForVersion(version, !preferDebug); - - if (!path.isEmpty()) { - QFileInfo qmldumpFileInfo(path); - if (!qmldumpFileInfo.exists()) { - qWarning() << "QmlDumpTool::qmlDumpPath: qmldump executable does not exist at" << path; - path.clear(); - } else if (!qmldumpFileInfo.isFile()) { - qWarning() << "QmlDumpTool::qmlDumpPath: " << path << " is not a file"; - path.clear(); - } - } - - if (!path.isEmpty() && version && dumperPath && env) { - *dumperPath = path; - k->addToEnvironment(*env); - } -} - -} // namespace QtSupport - diff --git a/src/plugins/qtsupport/qmldumptool.h b/src/plugins/qtsupport/qmldumptool.h deleted file mode 100644 index a22c2697763..00000000000 --- a/src/plugins/qtsupport/qmldumptool.h +++ /dev/null @@ -1,54 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include "qtsupport_global.h" - -#include - -namespace ProjectExplorer { class Kit; } -namespace Utils { class Environment; } - -namespace ProjectExplorer { - class Project; - class ToolChain; -} - -namespace QtSupport { -class BaseQtVersion; - -class QTSUPPORT_EXPORT QmlDumpTool : public Utils::BuildableHelperLibrary -{ -public: - static QString toolForVersion(const BaseQtVersion *version, bool debugDump); - static QString toolForQtPaths(const QString &qtInstallBins, - bool debugDump); - - static void pathAndEnvironment(const ProjectExplorer::Kit *k, bool preferDebug, - QString *path, Utils::Environment *env); -}; - -} // namespace diff --git a/src/plugins/qtsupport/qtsupport.pro b/src/plugins/qtsupport/qtsupport.pro index 5cdbac964a9..fce892021d3 100644 --- a/src/plugins/qtsupport/qtsupport.pro +++ b/src/plugins/qtsupport/qtsupport.pro @@ -22,7 +22,6 @@ HEADERS += \ qtversionmanager.h \ qtversionfactory.h \ baseqtversion.h \ - qmldumptool.h \ qtoptionspage.h \ qtsupportconstants.h \ profilereader.h \ @@ -49,7 +48,6 @@ SOURCES += \ qttestparser.cpp \ qtversionmanager.cpp \ baseqtversion.cpp \ - qmldumptool.cpp \ qtoptionspage.cpp \ profilereader.cpp \ qtparser.cpp \ diff --git a/src/plugins/qtsupport/qtsupport.qbs b/src/plugins/qtsupport/qtsupport.qbs index 6be665d4066..4a3e556f075 100644 --- a/src/plugins/qtsupport/qtsupport.qbs +++ b/src/plugins/qtsupport/qtsupport.qbs @@ -78,8 +78,6 @@ Project { "exampleslistmodel.h", "profilereader.cpp", "profilereader.h", - "qmldumptool.cpp", - "qmldumptool.h", "qscxmlcgenerator.cpp", "qscxmlcgenerator.h", "qtkitinformation.cpp",