BaseQtVersion: remove qmakeProperty(...) getter

Qt 6 will not use qmake to identify a Qt version, so this can not
be part of the public interface of BaseQtVersion anymore.

Provide getters for the information actually read via qmakeProperty(...).

Use the getters whenever possible.

Change-Id: Iadbee80b75e4f8b06caf90e7ed69fae2029b4dd7
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Tobias Hunger
2019-09-30 14:34:31 +02:00
parent fc2e22dad2
commit b489bfd615
22 changed files with 239 additions and 193 deletions

View File

@@ -212,7 +212,7 @@ bool AndroidBuildApkStep::init()
if (!AbstractProcessStep::init())
return false;
QString command = version->qmakeProperty("QT_HOST_BINS");
QString command = version->hostBinPath().toString();
if (!command.endsWith('/'))
command += '/';
command += "androiddeployqt";

View File

@@ -240,7 +240,7 @@ bool AndroidDeployQtStep::init()
emit addOutput(tr("Cannot find the androiddeploy Json file."), OutputFormat::Stderr);
return false;
}
m_command = FilePath::fromString(version->qmakeProperty("QT_HOST_BINS"));
m_command = version->hostBinPath();
if (m_command.isEmpty()) {
emit addOutput(tr("Cannot find the androiddeployqt tool."), OutputFormat::Stderr);
return false;

View File

@@ -238,9 +238,8 @@ int AndroidManager::minimumSDK(const ProjectExplorer::Kit *kit)
int minSDKVersion = -1;
QtSupport::BaseQtVersion *version = QtSupport::QtKitAspect::qtVersion(kit);
if (version && version->targetDeviceTypes().contains(Constants::ANDROID_DEVICE_TYPE)) {
Utils::FilePath stockManifestFilePath =
Utils::FilePath::fromUserInput(version->qmakeProperty("QT_INSTALL_PREFIX") +
QLatin1String("/src/android/templates/AndroidManifest.xml"));
Utils::FilePath stockManifestFilePath = Utils::FilePath::fromUserInput(
version->prefix().toString() + "/src/android/templates/AndroidManifest.xml");
QDomDocument doc;
if (openXmlFile(doc, stockManifestFilePath)) {
minSDKVersion = parseMinSdk(doc.documentElement());
@@ -276,7 +275,7 @@ QJsonObject AndroidManager::deploymentSettings(const Target *target)
return {};
QJsonObject settings;
settings["_description"] = "This file is generated by QtCreator to be read by androiddeployqt and should not be modified by hand.";
settings["qt"] = qt->qmakeProperty("QT_INSTALL_PREFIX");
settings["qt"] = qt->prefix().toString();
settings["ndk"] = AndroidConfigurations::currentConfig().ndkLocation().toString();
settings["sdk"] = AndroidConfigurations::currentConfig().sdkLocation().toString();
settings["stdcpp-path"] = AndroidConfigurations::currentConfig().toolchainPath().pathAppended("sysroot/usr/lib/").toString();
@@ -728,8 +727,8 @@ bool AndroidManager::updateGradleProperties(ProjectExplorer::Target *target, con
const QString gradlePropertiesPath = packageSourceDir.pathAppended("gradle.properties").toString();
GradleProperties gradleProperties = readGradleProperties(gradlePropertiesPath);
gradleProperties["qt5AndroidDir"] = version->qmakeProperty("QT_INSTALL_PREFIX")
.append(QLatin1String("/src/android/java")).toLocal8Bit();
gradleProperties["qt5AndroidDir"] = (version->prefix().toString() + "/src/android/java")
.toLocal8Bit();
gradleProperties["buildDir"] = ".build";
gradleProperties["androidCompileSdkVersion"] = buildTargetSDK(target).split(QLatin1Char('-')).last().toLocal8Bit();
if (gradleProperties["androidBuildToolsVersion"].isEmpty()) {

View File

@@ -322,21 +322,19 @@ void CreateAndroidManifestWizard::createAndroidTemplateFiles()
if (!version)
return;
if (version->qtVersion() < QtSupport::QtVersionNumber(5, 4, 0)) {
const QString src(version->qmakeProperty("QT_INSTALL_PREFIX")
.append(QLatin1String("/src/android/java/AndroidManifest.xml")));
const QString src = version->prefix().toString() + "/src/android/java/AndroidManifest.xml";
FileUtils::copyRecursively(FilePath::fromString(src),
FilePath::fromString(m_directory + QLatin1String("/AndroidManifest.xml")),
nullptr, [this, &addedFiles](QFileInfo src, QFileInfo dst, QString *){return copy(src, dst, &addedFiles);});
} else {
const QString src(version->qmakeProperty("QT_INSTALL_PREFIX")
.append(QLatin1String("/src/android/templates")));
const QString src = version->prefix().toString() + "/src/android/templates";
FileUtils::copyRecursively(FilePath::fromString(src),
FilePath::fromString(m_directory),
nullptr, [this, &addedFiles](QFileInfo src, QFileInfo dst, QString *){return copy(src, dst, &addedFiles);});
if (m_copyGradle) {
FilePath gradlePath = FilePath::fromString(version->qmakeProperty("QT_INSTALL_PREFIX").append(QLatin1String("/src/3rdparty/gradle")));
FilePath gradlePath = version->prefix().pathAppended("src/3rdparty/gradle");
if (!gradlePath.exists())
gradlePath = AndroidConfigurations::currentConfig().sdkLocation().pathAppended("/tools/templates/gradle/wrapper");
FileUtils::copyRecursively(gradlePath, FilePath::fromString(m_directory),

View File

@@ -292,10 +292,8 @@ const QList<BuildTargetInfo> CMakeBuildConfiguration::appTargets() const
bti.runEnvModifier = [this](Environment &env, bool) {
if (HostOsInfo::isWindowsHost()) {
const Kit *k = target()->kit();
if (const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k)) {
const QString installBinPath = qt->qmakeProperty("QT_INSTALL_BINS");
env.prependOrSetPath(installBinPath);
}
if (const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(k))
env.prependOrSetPath(qt->binPath().toString());
}
};

View File

@@ -1001,7 +1001,7 @@ Tasks CMakeConfigurationKitAspect::validate(const Kit *k) const
Utils::FilePath(), -1, Core::Id(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM));
}
}
if (version && !qtInstallDirs.contains(version->qmakeProperty("QT_INSTALL_PREFIX")) && !isQt4) {
if (version && !qtInstallDirs.contains(version->prefix().toString()) && !isQt4) {
if (version->isValid()) {
result << Task(Task::Warning, tr("CMake configuration has no CMAKE_PREFIX_PATH set "
"that points to the kit Qt version."),

View File

@@ -106,7 +106,7 @@ void GenericBuildConfiguration::addToEnvironment(Utils::Environment &env) const
prependCompilerPathToEnvironment(target()->kit(), env);
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(target()->kit());
if (qt)
env.prependOrSetPath(qt->binPath().toString());
env.prependOrSetPath(qt->hostBinPath().toString());
}
} // namespace Internal

View File

@@ -300,7 +300,7 @@ QStringList PerfDataReader::collectArguments(const QString &executableDirPath,
arguments << QLatin1String("--extra") << QString::fromLatin1("%1%5%2%5%3%5%4")
.arg(QDir::toNativeSeparators(qt->libraryPath().toString()))
.arg(QDir::toNativeSeparators(qt->pluginPath().toString()))
.arg(QDir::toNativeSeparators(qt->binPath().toString()))
.arg(QDir::toNativeSeparators(qt->hostBinPath().toString()))
.arg(QDir::toNativeSeparators(qt->qmlPath().toString()))
.arg(QDir::listSeparator());
}

View File

@@ -186,7 +186,7 @@ bool QbsProjectImporter::matchKit(void *directoryData, const Kit *k) const
if (!bgData->qtBinPath.isEmpty()) {
if (!qtVersion)
return false;
if (bgData->qtBinPath != qtVersion->binPath())
if (bgData->qtBinPath != qtVersion->hostBinPath())
return false;
}
if (bgData->sysroot != SysRootKitAspect::sysRoot(k))

View File

@@ -507,8 +507,8 @@ QString QmakeBuildConfiguration::extractSpecFromArguments(QString *args,
if (parsedSpec.isEmpty())
return {};
FilePath baseMkspecDir = FilePath::fromUserInput(
version->qmakeProperty("QT_HOST_DATA") + QLatin1String("/mkspecs"));
FilePath baseMkspecDir = FilePath::fromUserInput(version->hostDataPath().toString()
+ "/mkspecs");
baseMkspecDir = FilePath::fromString(baseMkspecDir.toFileInfo().canonicalFilePath());
// if the path is relative it can be
@@ -608,7 +608,7 @@ BuildInfo QmakeBuildConfigurationFactory::createBuildInfo(const Kit *k,
QString projectDirectory = projectPath.toFileInfo().absolutePath();
QDir qtSourceDir = QDir(version->sourcePath().toString());
QString relativeProjectPath = qtSourceDir.relativeFilePath(projectDirectory);
QString qtBuildDir = version->qmakeProperty("QT_INSTALL_PREFIX");
QString qtBuildDir = version->prefix().toString();
QString absoluteBuildPath = QDir::cleanPath(qtBuildDir + QLatin1Char('/') + relativeProjectPath);
info.buildDirectory = FilePath::fromString(absoluteBuildPath);
@@ -672,8 +672,8 @@ void QmakeBuildConfiguration::setupBuildEnvironment(Kit *k, Environment &env)
{
prependCompilerPathToEnvironment(k, env);
const BaseQtVersion *qt = QtKitAspect::qtVersion(k);
if (qt && !qt->binPath().isEmpty())
env.prependOrSetPath(qt->binPath().toString());
if (qt && !qt->hostBinPath().isEmpty())
env.prependOrSetPath(qt->hostBinPath().toString());
}
QmakeBuildConfiguration::LastKitState::LastKitState() = default;

View File

@@ -92,7 +92,7 @@ QByteArray PuppetCreator::qtHash() const
{
QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit);
if (currentQtVersion) {
return QCryptographicHash::hash(currentQtVersion->qmakeProperty("QT_INSTALL_DATA").toUtf8(),
return QCryptographicHash::hash(currentQtVersion->dataPath().toString().toUtf8(),
QCryptographicHash::Sha1)
.toBase64(QByteArray::Base64UrlEncoding | QByteArray::OmitTrailingEquals);
}
@@ -104,7 +104,7 @@ QDateTime PuppetCreator::qtLastModified() const
{
QtSupport::BaseQtVersion *currentQtVersion = QtSupport::QtKitAspect::qtVersion(m_kit);
if (currentQtVersion)
return QFileInfo(currentQtVersion->qmakeProperty("QT_INSTALL_LIBS")).lastModified();
return currentQtVersion->libraryPath().toFileInfo().lastModified();
return QDateTime();
}
@@ -422,7 +422,7 @@ QProcessEnvironment PuppetCreator::processEnvironment() const
const QtSupport::BaseQtVersion *qt = QtSupport::QtKitAspect::qtVersion(m_kit);
if (QTC_GUARD(qt)) { // Kits without a Qt version should not have a puppet!
// Update PATH to include QT_HOST_BINS
const Utils::FilePath qtBinPath = qt->binPath();
const Utils::FilePath qtBinPath = qt->hostBinPath();
environment.prependOrSetPath(qtBinPath.toString());
}
environment.set("QML_BAD_GUI_RENDER_LOOP", "true");

View File

@@ -98,7 +98,7 @@ void GenerateResource::generateMenuEntry()
return;
temp.close();
auto rccBinary = QtSupport::QtKitAspect::qtVersion(currentProject->activeTarget()->kit())->binPath();
auto rccBinary = QtSupport::QtKitAspect::qtVersion(currentProject->activeTarget()->kit())->hostBinPath();
#ifdef Q_OS_WIN
rccBinary = rccBinary.pathAppended("rcc.exe");
#else

View File

@@ -76,15 +76,15 @@ static QStringList searchPaths(Kit *kit)
if (!qtVersion)
return {};
const QDir pluginDir(qtVersion->qmakeProperty("QT_INSTALL_PLUGINS"));
const QDir pluginDir(qtVersion->pluginPath().toString());
const QStringList pluginSubDirs = pluginDir.entryList(QDir::Dirs | QDir::NoDotAndDotDot);
QStringList searchPaths;
for (const QString &dir : pluginSubDirs)
searchPaths << qtVersion->qmakeProperty("QT_INSTALL_PLUGINS") + '/' + dir;
searchPaths << qtVersion->pluginPath().toString() + '/' + dir;
searchPaths << qtVersion->qmakeProperty("QT_INSTALL_LIBS");
searchPaths << qtVersion->libraryPath().toString();
searchPaths << qtVersion->qnxTarget().pathAppended(qtVersion->cpuDir() + "/lib").toString();
searchPaths << qtVersion->qnxTarget().pathAppended(qtVersion->cpuDir() + "/usr/lib").toString();

View File

@@ -234,16 +234,16 @@ QList<DeployableFile> QnxDeployQtLibrariesDialog::gatherFiles()
QTC_ASSERT(qtVersion, return result);
if (Utils::HostOsInfo::isWindowsHost()) {
result.append(gatherFiles(qtVersion->qmakeProperty("QT_INSTALL_LIBS"),
QString(), QStringList() << QLatin1String("*.so.?")));
result.append(gatherFiles(qtVersion->qmakeProperty("QT_INSTALL_LIBS")
+ QLatin1String("/fonts")));
result.append(gatherFiles(qtVersion->libraryPath().toString(),
QString(),
QStringList() << QLatin1String("*.so.?")));
result.append(gatherFiles(qtVersion->libraryPath().toString() + QLatin1String("/fonts")));
} else {
result.append(gatherFiles(qtVersion->qmakeProperty("QT_INSTALL_LIBS")));
result.append(gatherFiles(qtVersion->libraryPath().toString()));
}
result.append(gatherFiles(qtVersion->qmakeProperty("QT_INSTALL_PLUGINS")));
result.append(gatherFiles(qtVersion->qmakeProperty("QT_INSTALL_IMPORTS")));
result.append(gatherFiles(qtVersion->pluginPath().toString()));
result.append(gatherFiles(qtVersion->importsPath().toString()));
result.append(gatherFiles(qtVersion->qmlPath().toString()));
return result;

View File

@@ -130,7 +130,7 @@ void QnxQtVersion::addToEnvironment(const ProjectExplorer::Kit *k, Utils::Enviro
updateEnvironment();
env.modify(m_qnxEnv);
env.prependOrSetLibrarySearchPath(qmakeProperty("QT_INSTALL_LIBS", PropertyVariantDev));
env.prependOrSetLibrarySearchPath(libraryPath().toString());
}
Utils::Environment QnxQtVersion::qmakeRunEnvironment() const

View File

@@ -141,9 +141,11 @@ public:
const Environment &env,
QHash<ProKey, ProString> *versionInfo,
QString *error = nullptr);
enum PropertyVariant { PropertyVariantDev, PropertyVariantGet, PropertyVariantSrc };
QString qmakeProperty(const QByteArray &name, PropertyVariant variant = PropertyVariantGet);
static QString qmakeProperty(const QHash<ProKey, ProString> &versionInfo,
const QByteArray &name,
BaseQtVersion::PropertyVariant variant = BaseQtVersion::PropertyVariantGet);
PropertyVariant variant = PropertyVariantGet);
static FilePath mkspecDirectoryFromVersionInfo(const QHash<ProKey,ProString> &versionInfo);
static FilePath mkspecFromVersionInfo(const QHash<ProKey,ProString> &versionInfo);
static FilePath sourcePath(const QHash<ProKey,ProString> &versionInfo);
@@ -158,6 +160,7 @@ public:
bool m_isAutodetected = false;
QString m_type;
bool m_isUpdating = false;
bool m_hasQmlDump = false; // controlled by m_versionInfoUpToDate
bool m_mkspecUpToDate = false;
bool m_mkspecReadUpToDate = false;
@@ -512,41 +515,76 @@ Tasks BaseQtVersion::validateKit(const Kit *k)
return result;
}
FilePath BaseQtVersion::headerPath() const
FilePath BaseQtVersion::prefix() const // QT_INSTALL_PREFIX
{
return FilePath::fromUserInput(qmakeProperty("QT_INSTALL_HEADERS"));
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_PREFIX"));
}
FilePath BaseQtVersion::docsPath() const
FilePath BaseQtVersion::binPath() const // QT_INSTALL_BINS
{
return FilePath::fromUserInput(qmakeProperty("QT_INSTALL_DOCS"));
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_BINS"));
}
FilePath BaseQtVersion::libraryPath() const
FilePath BaseQtVersion::configurationPath() const // QT_INSTALL_CONFIGURATION
{
return FilePath::fromUserInput(qmakeProperty("QT_INSTALL_LIBS"));
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_CONFIGURATION"));
}
FilePath BaseQtVersion::pluginPath() const
FilePath BaseQtVersion::headerPath() const // QT_INSTALL_HEADERS
{
return FilePath::fromUserInput(qmakeProperty("QT_INSTALL_PLUGINS"));
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_HEADERS"));
}
FilePath BaseQtVersion::qmlPath() const
FilePath BaseQtVersion::dataPath() const // QT_INSTALL_DATA
{
return FilePath::fromUserInput(qmakeProperty("QT_INSTALL_QML"));
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_DATA"));
}
FilePath BaseQtVersion::binPath() const
FilePath BaseQtVersion::docsPath() const // QT_INSTALL_DOCS
{
return FilePath::fromUserInput(qmakeProperty("QT_HOST_BINS"));
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_DOCS"));
}
FilePath BaseQtVersion::importsPath() const // QT_INSTALL_IMPORTS
{
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_IMPORTS"));
}
FilePath BaseQtVersion::libraryPath() const // QT_INSTALL_LIBS
{
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_LIBS"));
}
FilePath BaseQtVersion::pluginPath() const // QT_INSTALL_PLUGINS
{
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_PLUGINS"));
}
FilePath BaseQtVersion::qmlPath() const // QT_INSTALL_QML
{
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_QML"));
}
FilePath BaseQtVersion::translationsPath() const // QT_INSTALL_TRANSLATIONS
{
return FilePath::fromUserInput(d->qmakeProperty("QT_INSTALL_TRANSLATIONS"));
}
FilePath BaseQtVersion::hostBinPath() const // QT_HOST_BINS
{
return FilePath::fromUserInput(d->qmakeProperty("QT_HOST_BINS"));
}
FilePath BaseQtVersion::hostDataPath() const // QT_HOST_DATA
{
return FilePath::fromUserInput(d->qmakeProperty("QT_HOST_DATA"));
}
FilePath BaseQtVersion::mkspecsPath() const
{
const FilePath result = FilePath::fromUserInput(qmakeProperty("QT_HOST_DATA"));
const FilePath result = hostDataPath();
if (result.isEmpty())
return FilePath::fromUserInput(qmakeProperty("QMAKE_MKSPECS"));
return FilePath::fromUserInput(d->qmakeProperty(d->m_versionInfo, "QMAKE_MKSPECS"));
return result.pathAppended("mkspecs");
}
@@ -557,8 +595,7 @@ FilePath BaseQtVersion::qmlBinPath() const
FilePath BaseQtVersion::librarySearchPath() const
{
return HostOsInfo::isWindowsHost()
? FilePath::fromUserInput(qmakeProperty("QT_INSTALL_BINS")) : libraryPath();
return HostOsInfo::isWindowsHost() ? binPath() : libraryPath();
}
FilePathList BaseQtVersion::directoriesToIgnoreInProjectTree() const
@@ -567,7 +604,8 @@ FilePathList BaseQtVersion::directoriesToIgnoreInProjectTree() const
const FilePath mkspecPathGet = mkspecsPath();
result.append(mkspecPathGet);
FilePath mkspecPathSrc = FilePath::fromUserInput(qmakeProperty("QT_HOST_DATA", PropertyVariantSrc));
FilePath mkspecPathSrc = FilePath::fromUserInput(
d->qmakeProperty("QT_HOST_DATA", BaseQtVersionPrivate::PropertyVariantSrc));
if (!mkspecPathSrc.isEmpty()) {
mkspecPathSrc = mkspecPathSrc.pathAppended("mkspecs");
if (mkspecPathSrc != mkspecPathGet)
@@ -663,11 +701,8 @@ bool BaseQtVersion::isValid() const
d->updateVersionInfo();
d->updateMkspec();
return !qmakeCommand().isEmpty()
&& d->m_installed
&& !qmakeProperty("QT_HOST_BINS").isNull()
&& !d->m_mkspecFullPath.isEmpty()
&& d->m_qmakeIsExecutable;
return !qmakeCommand().isEmpty() && d->m_installed && !binPath().isEmpty()
&& !d->m_mkspecFullPath.isEmpty() && d->m_qmakeIsExecutable;
}
BaseQtVersion::Predicate BaseQtVersion::isValidPredicate(const BaseQtVersion::Predicate &predicate)
@@ -687,7 +722,7 @@ QString BaseQtVersion::invalidReason() const
return QCoreApplication::translate("QtVersion", "qmake does not exist or is not executable");
if (!d->m_installed)
return QCoreApplication::translate("QtVersion", "Qt version is not properly installed, please run make install");
if (qmakeProperty("QT_HOST_BINS").isNull())
if (binPath().isEmpty())
return QCoreApplication::translate("QtVersion",
"Could not determine the path to the binaries of the Qt installation, maybe the qmake path is wrong?");
if (d->m_mkspecUpToDate && d->m_mkspecFullPath.isEmpty())
@@ -922,7 +957,7 @@ QString BaseQtVersionPrivate::findHostBinary(HostBinaries binary) const
{
QString baseDir;
if (q->qtVersion() < QtVersionNumber(5, 0, 0)) {
baseDir = q->qmakeProperty("QT_HOST_BINS");
baseDir = q->binPath().toString();
} else {
q->ensureMkSpecParsed();
switch (binary) {
@@ -932,7 +967,7 @@ QString BaseQtVersionPrivate::findHostBinary(HostBinaries binary) const
break;
case Uic:
case QScxmlc:
baseDir = q->qmakeProperty("QT_HOST_BINS");
baseDir = q->hostBinPath().toString();
break;
default:
// Can't happen
@@ -1109,8 +1144,7 @@ bool BaseQtVersion::hasMkspec(const QString &spec) const
if (spec.isEmpty())
return true; // default spec of a Qt version
QDir mkspecDir = QDir(QDir::fromNativeSeparators(qmakeProperty("QT_HOST_DATA"))
+ "/mkspecs/");
QDir mkspecDir = QDir(hostDataPath().toString() + "/mkspecs/");
const QString absSpec = mkspecDir.absoluteFilePath(spec);
if (QFileInfo(absSpec).isDir() && QFileInfo(absSpec + "/qmake.conf").isFile())
return true;
@@ -1146,11 +1180,11 @@ QtVersionNumber BaseQtVersion::qtVersion() const
void BaseQtVersionPrivate::updateVersionInfo()
{
if (m_versionInfoUpToDate)
return;
if (!m_qmakeIsExecutable)
if (m_versionInfoUpToDate || !m_qmakeIsExecutable || m_isUpdating)
return;
m_isUpdating = true;
// extract data from qmake executable
m_versionInfo.clear();
m_installed = true;
@@ -1166,9 +1200,8 @@ void BaseQtVersionPrivate::updateVersionInfo()
}
m_qmakeIsExecutable = true;
const QString qtInstallBins = qmakeProperty(m_versionInfo, "QT_INSTALL_BINS");
const QString qtHeaderData = qmakeProperty(m_versionInfo, "QT_INSTALL_HEADERS");
const QString qtInstallBins = q->binPath().toString();
const QString qtHeaderData = q->headerPath().toString();
if (!qtInstallBins.isNull()) {
if (!qtInstallBins.isEmpty()) {
@@ -1179,7 +1212,7 @@ void BaseQtVersionPrivate::updateVersionInfo()
}
// Now check for a qt that is configured with a prefix but not installed
QString installDir = qmakeProperty(m_versionInfo, "QT_HOST_BINS");
QString installDir = q->hostBinPath().toString();
if (!installDir.isNull()) {
if (!QFileInfo::exists(installDir))
m_installed = false;
@@ -1192,23 +1225,24 @@ void BaseQtVersionPrivate::updateVersionInfo()
m_installed = false;
}
}
const QString qtInstallDocs = qmakeProperty(m_versionInfo, "QT_INSTALL_DOCS");
const QString qtInstallDocs = q->docsPath().toString();
if (!qtInstallDocs.isNull()) {
if (QFileInfo::exists(qtInstallDocs))
m_hasDocumentation = true;
}
const QString qtInstallExamples = qmakeProperty(m_versionInfo, "QT_INSTALL_EXAMPLES");
const QString qtInstallExamples = q->examplesPath().toString();
if (!qtInstallExamples.isNull()) {
if (QFileInfo::exists(qtInstallExamples))
m_hasExamples = true;
}
const QString qtInstallDemos = qmakeProperty(m_versionInfo, "QT_INSTALL_DEMOS");
const QString qtInstallDemos = q->demosPath().toString();
if (!qtInstallDemos.isNull()) {
if (QFileInfo::exists(qtInstallDemos))
m_hasDemos = true;
}
m_qtVersionString = qmakeProperty(m_versionInfo, "QT_VERSION");
m_qtVersionString = qmakeProperty("QT_VERSION");
m_isUpdating = false;
m_versionInfoUpToDate = true;
}
@@ -1218,23 +1252,22 @@ QHash<ProKey,ProString> BaseQtVersionPrivate::versionInfo()
return m_versionInfo;
}
QString BaseQtVersionPrivate::qmakeProperty(const QHash<ProKey,ProString> &versionInfo, const QByteArray &name,
BaseQtVersion::PropertyVariant variant)
QString BaseQtVersionPrivate::qmakeProperty(const QHash<ProKey, ProString> &versionInfo,
const QByteArray &name,
PropertyVariant variant)
{
QString val = versionInfo.value(ProKey(QString::fromLatin1(
name + (variant == BaseQtVersion::PropertyVariantDev ? "/dev" :
variant == BaseQtVersion::PropertyVariantGet ? "/get" : "/src")))).toQString();
QString val = versionInfo
.value(ProKey(QString::fromLatin1(
name
+ (variant == PropertyVariantDev
? "/dev"
: variant == PropertyVariantGet ? "/get" : "/src"))))
.toQString();
if (!val.isNull())
return val;
return versionInfo.value(ProKey(name)).toQString();
}
QString BaseQtVersion::qmakeProperty(const QByteArray &name, PropertyVariant variant) const
{
d->updateVersionInfo();
return d->qmakeProperty(d->m_versionInfo, name, variant);
}
void BaseQtVersion::applyProperties(QMakeGlobals *qmakeGlobals) const
{
qmakeGlobals->setProperties(d->versionInfo());
@@ -1254,13 +1287,13 @@ bool BaseQtVersion::hasDemos() const
FilePath BaseQtVersion::demosPath() const
{
return FilePath::fromString(QFileInfo(qmakeProperty("QT_INSTALL_DEMOS")).canonicalFilePath());
return FilePath::fromString(QFileInfo(d->qmakeProperty("QT_INSTALL_DEMOS")).canonicalFilePath());
}
FilePath BaseQtVersion::frameworkPath() const
{
if (HostOsInfo::isMacHost())
return FilePath::fromString(qmakeProperty("QT_INSTALL_LIBS"));
return libraryPath();
return {};
}
@@ -1270,9 +1303,10 @@ bool BaseQtVersion::hasExamples() const
return d->m_hasExamples;
}
FilePath BaseQtVersion::examplesPath() const
FilePath BaseQtVersion::examplesPath() const // QT_INSTALL_EXAMPLES
{
return FilePath::fromString(QFileInfo(qmakeProperty("QT_INSTALL_EXAMPLES")).canonicalFilePath());
return FilePath::fromString(
QFileInfo(d->qmakeProperty("QT_INSTALL_EXAMPLES")).canonicalFilePath());
}
QStringList BaseQtVersion::qtSoPaths() const
@@ -1286,7 +1320,7 @@ QStringList BaseQtVersion::qtSoPaths() const
QSet<QString> paths;
for (uint i = 0; i < sizeof qMakeVariables / sizeof qMakeVariables[0]; ++i) {
QString path = qmakeProperty(qMakeVariables[i]);
QString path = d->qmakeProperty(qMakeVariables[i]);
if (path.isNull())
continue;
QDirIterator it(path, QStringList("*.so"), QDir::Files, QDirIterator::Subdirectories);
@@ -1328,8 +1362,7 @@ BaseQtVersion::createMacroExpander(const std::function<const BaseQtVersion *()>
std::unique_ptr<MacroExpander> expander(new MacroExpander);
expander->setDisplayName(QtKitAspect::tr("Qt version"));
expander->registerVariable(
"Qt:Version",
expander->registerVariable("Qt:Version",
QtKitAspect::tr("The version string of the current Qt version."),
versionProperty([](const BaseQtVersion *version) {
return version->qtVersionString();
@@ -1349,95 +1382,93 @@ BaseQtVersion::createMacroExpander(const std::function<const BaseQtVersion *()>
return QDir::toNativeSeparators(version->mkspec());
}));
expander->registerVariable(
"Qt:QT_INSTALL_PREFIX",
QtKitAspect::tr("The installation prefix of the current Qt version."),
expander->registerVariable("Qt:QT_INSTALL_PREFIX",
QtKitAspect::tr(
"The installation prefix of the current Qt version."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_PREFIX");
return version->prefix().toString();
}));
expander->registerVariable(
"Qt:QT_INSTALL_DATA",
QtKitAspect::tr("The installation location of the current Qt version's data."),
expander->registerVariable("Qt:QT_INSTALL_DATA",
QtKitAspect::tr(
"The installation location of the current Qt version's data."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_DATA");
return version->dataPath().toString();
}));
expander->registerVariable(
"Qt:QT_INSTALL_HEADERS",
QtKitAspect::tr("The installation location of the current Qt version's header files."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_HEADERS");
}));
versionProperty(
[](const BaseQtVersion *version) { return version->headerPath().toString(); }));
expander->registerVariable(
"Qt:QT_INSTALL_LIBS",
QtKitAspect::tr("The installation location of the current Qt version's library files."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_LIBS");
}));
versionProperty(
[](const BaseQtVersion *version) { return version->libraryPath().toString(); }));
expander->registerVariable(
"Qt:QT_INSTALL_DOCS",
QtKitAspect::tr("The installation location of the current Qt version's documentation files."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_DOCS");
}));
QtKitAspect::tr(
"The installation location of the current Qt version's documentation files."),
versionProperty(
[](const BaseQtVersion *version) { return version->docsPath().toString(); }));
expander->registerVariable(
"Qt:QT_INSTALL_BINS",
QtKitAspect::tr("The installation location of the current Qt version's executable files."),
versionProperty([](const BaseQtVersion *version) { return version->binPath().toString(); }));
expander
->registerVariable("Qt:QT_INSTALL_PLUGINS",
QtKitAspect::tr(
"The installation location of the current Qt version's plugins."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_BINS");
return version->pluginPath().toString();
}));
expander->registerVariable(
"Qt:QT_INSTALL_PLUGINS",
QtKitAspect::tr("The installation location of the current Qt version's plugins."),
expander
->registerVariable("Qt:QT_INSTALL_QML",
QtKitAspect::tr(
"The installation location of the current Qt version's QML files."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_PLUGINS");
return version->qmlPath().toString();
}));
expander->registerVariable(
"Qt:QT_INSTALL_QML",
QtKitAspect::tr("The installation location of the current Qt version's QML files."),
expander
->registerVariable("Qt:QT_INSTALL_IMPORTS",
QtKitAspect::tr(
"The installation location of the current Qt version's imports."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_QML");
}));
expander->registerVariable(
"Qt:QT_INSTALL_IMPORTS",
QtKitAspect::tr("The installation location of the current Qt version's imports."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_IMPORTS");
return version->importsPath().toString();
}));
expander->registerVariable(
"Qt:QT_INSTALL_TRANSLATIONS",
QtKitAspect::tr("The installation location of the current Qt version's translation files."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_TRANSLATIONS");
}));
versionProperty(
[](const BaseQtVersion *version) { return version->translationsPath().toString(); }));
expander->registerVariable(
"Qt:QT_INSTALL_CONFIGURATION",
QtKitAspect::tr("The installation location of the current Qt version's translation files."),
versionProperty(
[](const BaseQtVersion *version) { return version->configurationPath().toString(); }));
expander
->registerVariable("Qt:QT_INSTALL_EXAMPLES",
QtKitAspect::tr(
"The installation location of the current Qt version's examples."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_CONFIGURATION");
return version->examplesPath().toString();
}));
expander->registerVariable(
"Qt:QT_INSTALL_EXAMPLES",
QtKitAspect::tr("The installation location of the current Qt version's examples."),
expander->registerVariable("Qt:QT_INSTALL_DEMOS",
QtKitAspect::tr(
"The installation location of the current Qt version's demos."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_EXAMPLES");
}));
expander->registerVariable(
"Qt:QT_INSTALL_DEMOS",
QtKitAspect::tr("The installation location of the current Qt version's demos."),
versionProperty([](const BaseQtVersion *version) {
return version->d->qmakeProperty(version->d->m_versionInfo, "QT_INSTALL_DEMOS");
return version->demosPath().toString();
}));
expander->registerVariable(
@@ -1553,7 +1584,7 @@ QSet<Id> BaseQtVersion::features() const
void BaseQtVersion::addToEnvironment(const Kit *k, Environment &env) const
{
Q_UNUSED(k)
env.set("QTDIR", QDir::toNativeSeparators(qmakeProperty("QT_HOST_DATA")));
env.set("QTDIR", hostDataPath().toUserOutput());
}
// Some Qt versions may require environment settings for qmake to work
@@ -1585,7 +1616,7 @@ bool BaseQtVersion::needsQmlDump() const
QString BaseQtVersion::qmlDumpTool(bool debugVersion) const
{
const QString qtInstallBins = qmakeProperty("QT_INSTALL_BINS");
const QString qtInstallBins = binPath().toString();
return QmlDumpTool::toolForQtPaths(qtInstallBins, debugVersion);
}
@@ -1701,9 +1732,16 @@ bool BaseQtVersionPrivate::queryQMakeVariables(const FilePath &binary, const Env
return true;
}
QString BaseQtVersionPrivate::qmakeProperty(const QByteArray &name,
BaseQtVersionPrivate::PropertyVariant variant)
{
updateVersionInfo();
return qmakeProperty(m_versionInfo, name, variant);
}
FilePath BaseQtVersionPrivate::mkspecDirectoryFromVersionInfo(const QHash<ProKey, ProString> &versionInfo)
{
QString dataDir = qmakeProperty(versionInfo, "QT_HOST_DATA", BaseQtVersion::PropertyVariantSrc);
QString dataDir = qmakeProperty(versionInfo, "QT_HOST_DATA", PropertyVariantSrc);
if (dataDir.isEmpty())
return FilePath();
return FilePath::fromUserInput(dataDir + "/mkspecs");
@@ -1916,10 +1954,10 @@ bool BaseQtVersion::isQtQuickCompilerSupported(QString *reason) const
FilePathList BaseQtVersionPrivate::qtCorePaths()
{
updateVersionInfo();
const QString &versionString = m_qtVersionString;
const QString versionString = m_qtVersionString;
const QString &installLibsDir = qmakeProperty(m_versionInfo, "QT_INSTALL_LIBS");
const QString &installBinDir = qmakeProperty(m_versionInfo, "QT_INSTALL_BINS");
const QString installLibsDir = q->libraryPath().toString();
const QString installBinDir = q->binPath().toString();
const QDir::Filters filters = QDir::Files | QDir::Dirs | QDir::NoDotAndDotDot;

View File

@@ -119,9 +119,6 @@ public:
ProjectExplorer::Abis qtAbis() const;
virtual ProjectExplorer::Abis detectQtAbis() const;
enum PropertyVariant { PropertyVariantDev, PropertyVariantGet, PropertyVariantSrc };
QString qmakeProperty(const QByteArray &name,
PropertyVariant variant = PropertyVariantGet) const;
void applyProperties(QMakeGlobals *qmakeGlobals) const;
virtual void addToEnvironment(const ProjectExplorer::Kit *k, Utils::Environment &env) const;
virtual Utils::Environment qmakeRunEnvironment() const;
@@ -197,15 +194,25 @@ public:
virtual ProjectExplorer::Tasks validateKit(const ProjectExplorer::Kit *k);
Utils::FilePath headerPath() const;
Utils::FilePath prefix() const;
Utils::FilePath binPath() const;
Utils::FilePath configurationPath() const;
Utils::FilePath dataPath() const;
Utils::FilePath demosPath() const;
Utils::FilePath docsPath() const;
Utils::FilePath examplesPath() const;
Utils::FilePath frameworkPath() const;
Utils::FilePath headerPath() const;
Utils::FilePath importsPath() const;
Utils::FilePath libraryPath() const;
Utils::FilePath pluginPath() const;
Utils::FilePath qmlPath() const;
Utils::FilePath binPath() const;
Utils::FilePath translationsPath() const;
Utils::FilePath hostBinPath() const;
Utils::FilePath hostDataPath() const;
Utils::FilePath mkspecsPath() const;
Utils::FilePath qmlBinPath() const;
Utils::FilePath librarySearchPath() const;
@@ -231,7 +238,6 @@ public:
QSet<Core::Id> features() const;
protected:
BaseQtVersion();
BaseQtVersion(const BaseQtVersion &other) = delete;

View File

@@ -58,7 +58,7 @@ static inline QStringList validPrebuiltFilenames(bool debugBuild)
QString QmlDumpTool::toolForVersion(const BaseQtVersion *version, bool debugDump)
{
if (version) {
const QString qtInstallBins = version->qmakeProperty("QT_INSTALL_BINS");
const QString qtInstallBins = version->binPath().toString();
return toolForQtPaths(qtInstallBins, debugDump);
}

View File

@@ -104,30 +104,36 @@ bool QtSupportPlugin::initialize(const QStringList &arguments, QString *errorMes
return true;
}
static QString qmakeProperty(const char *propertyName)
static BaseQtVersion *qtVersion()
{
ProjectExplorer::Project *project = ProjectExplorer::ProjectTree::currentProject();
if (!project || !project->activeTarget())
return QString();
return nullptr;
const BaseQtVersion *qtVersion = QtKitAspect::qtVersion(project->activeTarget()->kit());
if (!qtVersion)
return QString();
return qtVersion->qmakeProperty(propertyName);
return QtKitAspect::qtVersion(project->activeTarget()->kit());
}
void QtSupportPlugin::extensionsInitialized()
{
Utils::MacroExpander *expander = Utils::globalMacroExpander();
expander->registerVariable(kHostBins,
expander->registerVariable(
kHostBins,
tr("Full path to the host bin directory of the current project's Qt version."),
[]() { return qmakeProperty("QT_HOST_BINS"); });
[]() {
BaseQtVersion *qt = qtVersion();
return qt ? qt->hostBinPath().toUserOutput() : QString();
});
expander->registerVariable(kInstallBins,
expander->registerVariable(
kInstallBins,
tr("Full path to the target bin directory of the current project's Qt version.<br>"
"You probably want %1 instead.").arg(QString::fromLatin1(kHostBins)),
[]() { return qmakeProperty("QT_INSTALL_BINS"); });
"You probably want %1 instead.")
.arg(QString::fromLatin1(kInstallBins)),
[]() {
BaseQtVersion *qt = qtVersion();
return qt ? qt->binPath().toUserOutput() : QString();
});
}
} // Internal

View File

@@ -225,7 +225,7 @@ QString WinRtDeviceFactory::findRunnerFilePath() const
BaseQtVersion *qt = nullptr;
for (BaseQtVersion *v : winrtVersions) {
if (!qt || qt->qtVersion() < v->qtVersion()) {
QFileInfo fi(v->binPath().toString() + winRtRunnerExe);
QFileInfo fi(v->hostBinPath().toString() + winRtRunnerExe);
if (fi.isFile() && fi.isExecutable()) {
qt = v;
filePath = fi.absoluteFilePath();

View File

@@ -91,7 +91,8 @@ bool WinRtPackageDeploymentStep::init()
if (!qt)
return false;
const QString windeployqtPath = FileUtils::resolvePath(qt->binPath().toString(), "windeployqt.exe");
const QString windeployqtPath = FileUtils::resolvePath(qt->hostBinPath().toString(),
"windeployqt.exe");
CommandLine windeployqt{windeployqtPath};
windeployqt.addArg(QDir::toNativeSeparators(m_targetFilePath));
@@ -104,8 +105,8 @@ bool WinRtPackageDeploymentStep::init()
ProcessParameters *params = processParameters();
if (!QFile::exists(windeployqtPath)) {
raiseError(tr("Cannot find windeployqt.exe in \"%1\".").arg(
QDir::toNativeSeparators(qt->binPath().toString())));
raiseError(tr("Cannot find windeployqt.exe in \"%1\".")
.arg(QDir::toNativeSeparators(qt->hostBinPath().toString())));
return false;
}
params->setCommandLine(windeployqt);

View File

@@ -62,10 +62,10 @@ WinRtRunnerHelper::WinRtRunnerHelper(ProjectExplorer::RunWorker *runWorker, QStr
return;
}
m_runnerFilePath = qt->binPath().toString() + QStringLiteral("/winrtrunner.exe");
m_runnerFilePath = qt->hostBinPath().toString() + QStringLiteral("/winrtrunner.exe");
if (!QFile::exists(m_runnerFilePath)) {
*errorMessage = tr("Cannot find winrtrunner.exe in \"%1\".").arg(
QDir::toNativeSeparators(qt->binPath().toString()));
QDir::toNativeSeparators(qt->hostBinPath().toString()));
return;
}