forked from qt-creator/qt-creator
Qnx: Improve reading installed configuration for remote build devices
Simplify the code in the process. In fact, looks like this was not doing much except setting the name and version number, which are not even really needed for building. Change-Id: Iafa65f0e2a0708888d1fc4ca19c932560ee4af68 Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -27,13 +27,11 @@
|
|||||||
#include <debugger/debuggeritemmanager.h>
|
#include <debugger/debuggeritemmanager.h>
|
||||||
#include <debugger/debuggerkitinformation.h>
|
#include <debugger/debuggerkitinformation.h>
|
||||||
|
|
||||||
#include <coreplugin/icore.h>
|
|
||||||
#include <utils/algorithm.h>
|
#include <utils/algorithm.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
#include <QDomDocument>
|
||||||
#include <QMessageBox>
|
#include <QMessageBox>
|
||||||
#include <QFileInfo>
|
|
||||||
|
|
||||||
using namespace ProjectExplorer;
|
using namespace ProjectExplorer;
|
||||||
using namespace QtSupport;
|
using namespace QtSupport;
|
||||||
@@ -194,7 +192,7 @@ FilePath QnxConfiguration::sdpPath() const
|
|||||||
|
|
||||||
QnxQtVersion *QnxConfiguration::qnxQtVersion(const Target &target) const
|
QnxQtVersion *QnxConfiguration::qnxQtVersion(const Target &target) const
|
||||||
{
|
{
|
||||||
const QtVersions versions = QtVersionManager::instance()->versions(
|
const QtVersions versions = QtVersionManager::versions(
|
||||||
Utils::equal(&QtVersion::type, QString::fromLatin1(Constants::QNX_QNX_QT)));
|
Utils::equal(&QtVersion::type, QString::fromLatin1(Constants::QNX_QNX_QT)));
|
||||||
for (QtVersion *version : versions) {
|
for (QtVersion *version : versions) {
|
||||||
auto qnxQt = dynamic_cast<QnxQtVersion *>(version);
|
auto qnxQt = dynamic_cast<QnxQtVersion *>(version);
|
||||||
@@ -336,19 +334,43 @@ void QnxConfiguration::setVersion(const QnxVersionNumber &version)
|
|||||||
|
|
||||||
void QnxConfiguration::readInformation()
|
void QnxConfiguration::readInformation()
|
||||||
{
|
{
|
||||||
const QString qConfigPath = m_qnxConfiguration.pathAppended("qconfig").toString();
|
const FilePath configPath = m_qnxConfiguration / "qconfig";
|
||||||
const QList <ConfigInstallInformation> installInfoList = QnxUtils::installedConfigs(qConfigPath);
|
if (!configPath.isDir())
|
||||||
if (installInfoList.isEmpty())
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
for (const ConfigInstallInformation &info : installInfoList) {
|
configPath.iterateDirectory([this, configPath](const FilePath &sdpFile) {
|
||||||
if (m_qnxHost == FilePath::fromString(info.host).canonicalPath()
|
QFile xmlFile(sdpFile.toFSPathString());
|
||||||
&& m_qnxTarget == FilePath::fromString(info.target).canonicalPath()) {
|
if (!xmlFile.open(QIODevice::ReadOnly))
|
||||||
m_configName = info.name;
|
return IterationPolicy::Continue;
|
||||||
setVersion(QnxVersionNumber(info.version));
|
|
||||||
break;
|
QDomDocument doc;
|
||||||
}
|
if (!doc.setContent(&xmlFile)) // Skip error message
|
||||||
}
|
return IterationPolicy::Continue;
|
||||||
|
|
||||||
|
QDomElement docElt = doc.documentElement();
|
||||||
|
if (docElt.tagName() != QLatin1String("qnxSystemDefinition"))
|
||||||
|
return IterationPolicy::Continue;
|
||||||
|
|
||||||
|
QDomElement childElt = docElt.firstChildElement(QLatin1String("installation"));
|
||||||
|
// The file contains only one installation node
|
||||||
|
if (childElt.isNull()) // The file contains only one base node
|
||||||
|
return IterationPolicy::Continue;
|
||||||
|
|
||||||
|
FilePath host = configPath.withNewPath(
|
||||||
|
childElt.firstChildElement(QLatin1String("host")).text()).canonicalPath();
|
||||||
|
if (m_qnxHost != host)
|
||||||
|
return IterationPolicy::Continue;
|
||||||
|
|
||||||
|
FilePath target = configPath.withNewPath(
|
||||||
|
childElt.firstChildElement(QLatin1String("target")).text()).canonicalPath();
|
||||||
|
if (m_qnxTarget != target)
|
||||||
|
return IterationPolicy::Continue;
|
||||||
|
|
||||||
|
m_configName = childElt.firstChildElement(QLatin1String("name")).text();
|
||||||
|
QString version = childElt.firstChildElement(QLatin1String("version")).text();
|
||||||
|
setVersion(QnxVersionNumber(version));
|
||||||
|
return IterationPolicy::Stop;
|
||||||
|
}, {{"*.xml"}, QDir::Files});
|
||||||
}
|
}
|
||||||
|
|
||||||
void QnxConfiguration::setDefaultConfiguration(const FilePath &envScript)
|
void QnxConfiguration::setDefaultConfiguration(const FilePath &envScript)
|
||||||
|
|||||||
@@ -99,7 +99,6 @@ void QnxConfigurationManager::saveConfigs()
|
|||||||
++count;
|
++count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
data.insert(QLatin1String(QNXConfigCountKey), count);
|
data.insert(QLatin1String(QNXConfigCountKey), count);
|
||||||
m_writer->save(data, Core::ICore::dialogParent());
|
m_writer->save(data, Core::ICore::dialogParent());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -130,8 +130,7 @@ void QnxSettingsWidget::addConfiguration()
|
|||||||
return;
|
return;
|
||||||
|
|
||||||
QnxConfiguration *config = new QnxConfiguration(envFile);
|
QnxConfiguration *config = new QnxConfiguration(envFile);
|
||||||
if (m_qnxConfigManager->configurations().contains(config)
|
if (m_qnxConfigManager->configurations().contains(config) || !config->isValid()) {
|
||||||
|| !config->isValid()) {
|
|
||||||
QMessageBox::warning(Core::ICore::dialogParent(),
|
QMessageBox::warning(Core::ICore::dialogParent(),
|
||||||
Tr::tr("Warning"),
|
Tr::tr("Warning"),
|
||||||
Tr::tr("Configuration already exists or is invalid."));
|
Tr::tr("Configuration already exists or is invalid."));
|
||||||
|
|||||||
@@ -10,9 +10,6 @@
|
|||||||
#include <utils/temporaryfile.h>
|
#include <utils/temporaryfile.h>
|
||||||
|
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QDir>
|
|
||||||
#include <QDirIterator>
|
|
||||||
#include <QDomDocument>
|
|
||||||
#include <QStandardPaths>
|
#include <QStandardPaths>
|
||||||
#include <QApplication>
|
#include <QApplication>
|
||||||
|
|
||||||
@@ -139,59 +136,6 @@ FilePath QnxUtils::envFilePath(const FilePath &sdpPath)
|
|||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
|
|
||||||
QString QnxUtils::defaultTargetVersion(const QString &sdpPath)
|
|
||||||
{
|
|
||||||
const QList<ConfigInstallInformation> configs = installedConfigs();
|
|
||||||
for (const ConfigInstallInformation &sdpInfo : configs) {
|
|
||||||
if (!sdpInfo.path.compare(sdpPath, HostOsInfo::fileNameCaseSensitivity()))
|
|
||||||
return sdpInfo.version;
|
|
||||||
}
|
|
||||||
|
|
||||||
return QString();
|
|
||||||
}
|
|
||||||
|
|
||||||
QList<ConfigInstallInformation> QnxUtils::installedConfigs(const QString &configPath)
|
|
||||||
{
|
|
||||||
QList<ConfigInstallInformation> sdpList;
|
|
||||||
QString sdpConfigPath = configPath;
|
|
||||||
|
|
||||||
if (!QDir(sdpConfigPath).exists())
|
|
||||||
return sdpList;
|
|
||||||
|
|
||||||
const QFileInfoList sdpfileList
|
|
||||||
= QDir(sdpConfigPath).entryInfoList(QStringList{"*.xml"}, QDir::Files, QDir::Time);
|
|
||||||
for (const QFileInfo &sdpFile : sdpfileList) {
|
|
||||||
QFile xmlFile(sdpFile.absoluteFilePath());
|
|
||||||
if (!xmlFile.open(QIODevice::ReadOnly))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QDomDocument doc;
|
|
||||||
if (!doc.setContent(&xmlFile)) // Skip error message
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QDomElement docElt = doc.documentElement();
|
|
||||||
if (docElt.tagName() != QLatin1String("qnxSystemDefinition"))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
QDomElement childElt = docElt.firstChildElement(QLatin1String("installation"));
|
|
||||||
// The file contains only one installation node
|
|
||||||
if (!childElt.isNull()) {
|
|
||||||
// The file contains only one base node
|
|
||||||
ConfigInstallInformation sdpInfo;
|
|
||||||
sdpInfo.path = childElt.firstChildElement(QLatin1String("base")).text();
|
|
||||||
sdpInfo.name = childElt.firstChildElement(QLatin1String("name")).text();
|
|
||||||
sdpInfo.host = childElt.firstChildElement(QLatin1String("host")).text();
|
|
||||||
sdpInfo.target = childElt.firstChildElement(QLatin1String("target")).text();
|
|
||||||
sdpInfo.version = childElt.firstChildElement(QLatin1String("version")).text();
|
|
||||||
sdpInfo.installationXmlFilePath = sdpFile.absoluteFilePath();
|
|
||||||
|
|
||||||
sdpList.append(sdpInfo);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return sdpList;
|
|
||||||
}
|
|
||||||
|
|
||||||
EnvironmentItems QnxUtils::qnxEnvironment(const FilePath &sdpPath)
|
EnvironmentItems QnxUtils::qnxEnvironment(const FilePath &sdpPath)
|
||||||
{
|
{
|
||||||
return qnxEnvironmentFromEnvFile(envFilePath(sdpPath));
|
return qnxEnvironmentFromEnvFile(envFilePath(sdpPath));
|
||||||
|
|||||||
@@ -3,30 +3,14 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include "qnxconstants.h"
|
|
||||||
|
|
||||||
#include <projectexplorer/abi.h>
|
#include <projectexplorer/abi.h>
|
||||||
|
|
||||||
#include <utils/environment.h>
|
#include <utils/environment.h>
|
||||||
#include <utils/qtcassert.h>
|
#include <utils/qtcassert.h>
|
||||||
#include <utils/fileutils.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
namespace Qnx::Internal {
|
namespace Qnx::Internal {
|
||||||
|
|
||||||
class ConfigInstallInformation
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
QString path;
|
|
||||||
QString name;
|
|
||||||
QString host;
|
|
||||||
QString target;
|
|
||||||
QString version;
|
|
||||||
QString installationXmlFilePath;
|
|
||||||
|
|
||||||
bool isValid() { return !path.isEmpty() && !name.isEmpty() && !host.isEmpty()
|
|
||||||
&& !target.isEmpty() && !version.isEmpty() && !installationXmlFilePath.isEmpty(); }
|
|
||||||
};
|
|
||||||
|
|
||||||
class QnxTarget
|
class QnxTarget
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@@ -45,8 +29,6 @@ public:
|
|||||||
static QString cpuDirShortDescription(const QString &cpuDir);
|
static QString cpuDirShortDescription(const QString &cpuDir);
|
||||||
static Utils::EnvironmentItems qnxEnvironmentFromEnvFile(const Utils::FilePath &filePath);
|
static Utils::EnvironmentItems qnxEnvironmentFromEnvFile(const Utils::FilePath &filePath);
|
||||||
static Utils::FilePath envFilePath(const Utils::FilePath &sdpPath);
|
static Utils::FilePath envFilePath(const Utils::FilePath &sdpPath);
|
||||||
static QString defaultTargetVersion(const QString &sdpPath);
|
|
||||||
static QList<ConfigInstallInformation> installedConfigs(const QString &configPath = QString());
|
|
||||||
static Utils::EnvironmentItems qnxEnvironment(const Utils::FilePath &sdpPath);
|
static Utils::EnvironmentItems qnxEnvironment(const Utils::FilePath &sdpPath);
|
||||||
static QList<QnxTarget> findTargets(const Utils::FilePath &basePath);
|
static QList<QnxTarget> findTargets(const Utils::FilePath &basePath);
|
||||||
static ProjectExplorer::Abi convertAbi(const ProjectExplorer::Abi &abi);
|
static ProjectExplorer::Abi convertAbi(const ProjectExplorer::Abi &abi);
|
||||||
|
|||||||
Reference in New Issue
Block a user