forked from qt-creator/qt-creator
Unify the common part for extracting the Qt project target info.
This code was (more or less) duplicated in 4 places.
This commit is contained in:
@@ -565,65 +565,25 @@ void MaemoRunConfiguration::updateTarget()
|
||||
m_executable = QString::null;
|
||||
m_cachedTargetInformationValid = true;
|
||||
|
||||
if (Qt4Project *qt4Project = project()) {
|
||||
Qt4BuildConfiguration *qt4bc = qt4Project->activeQt4BuildConfiguration();
|
||||
Qt4ProFileNode *proFileNode = qt4Project->rootProjectNode()->findProFileFor(m_proFilePath);
|
||||
if (!proFileNode) {
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
ProFileReader *reader = qt4Project->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
QStringList addedUserConfigArguments;
|
||||
QStringList removedUserConfigArguments;
|
||||
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
qt4Project->destroyProFileReader(reader);
|
||||
Qt4TargetInformation info = project()->targetInformation(project()->activeQt4BuildConfiguration(),
|
||||
m_proFilePath);
|
||||
if (info.error != Qt4TargetInformation::NoError) {
|
||||
if (info.error == Qt4TargetInformation::ProParserError) {
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr(
|
||||
"Could not parse %1. The Maemo run configuration %2 "
|
||||
"can not be started.").arg(m_proFilePath).arg(name()));
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract data
|
||||
QDir baseProjectDirectory =
|
||||
QFileInfo(project()->file()->fileName()).absoluteDir();
|
||||
QString relSubDir =
|
||||
baseProjectDirectory.relativeFilePath(QFileInfo(m_proFilePath).path());
|
||||
QDir baseBuildDirectory = qt4bc->buildDirectory();
|
||||
QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir);
|
||||
|
||||
if (!reader->contains("DESTDIR")) {
|
||||
#if 0 // TODO: fix this, seems to be wrong on windows
|
||||
if (reader->values("CONFIG").contains("debug_and_release_target")) {
|
||||
QString qmakeBuildConfig = "release";
|
||||
if (projectBuildConfiguration & QtVersion::DebugBuild)
|
||||
qmakeBuildConfig = "debug";
|
||||
baseDir += QLatin1Char('/') + qmakeBuildConfig;
|
||||
}
|
||||
#endif
|
||||
} else {
|
||||
const QString &destDir = reader->value("DESTDIR");
|
||||
if (QDir::isRelativePath(destDir))
|
||||
baseDir += QLatin1Char('/') + destDir;
|
||||
else
|
||||
baseDir = destDir;
|
||||
}
|
||||
|
||||
QString target = reader->value("TARGET");
|
||||
if (target.isEmpty())
|
||||
target = QFileInfo(m_proFilePath).baseName();
|
||||
|
||||
m_executable = QDir::cleanPath(baseDir + QLatin1Char('/') + target);
|
||||
qt4Project->destroyProFileReader(reader);
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
|
||||
QString baseDir;
|
||||
if (info.hasCustomDestDir)
|
||||
baseDir = info.workingDir;
|
||||
else
|
||||
baseDir = info.baseDestDir;
|
||||
m_executable = QDir::cleanPath(baseDir + QLatin1Char('/') + info.target);
|
||||
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
|
||||
@@ -280,54 +280,33 @@ void S60DeviceRunConfiguration::updateTarget()
|
||||
{
|
||||
if (m_cachedTargetInformationValid)
|
||||
return;
|
||||
Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration();
|
||||
Qt4ProFileNode *proFileNode = qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath);
|
||||
if (!proFileNode) {
|
||||
Qt4TargetInformation info = qt4Project()->targetInformation(qt4Project()->activeQt4BuildConfiguration(),
|
||||
m_proFilePath);
|
||||
if (info.error != Qt4TargetInformation::NoError) {
|
||||
if (info.error == Qt4TargetInformation::ProParserError) {
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(
|
||||
tr("Could not parse %1. The QtS60 Device run configuration %2 can not be started.")
|
||||
.arg(m_proFilePath).arg(name()));
|
||||
}
|
||||
m_targetName = QString::null;
|
||||
m_baseFileName = QString::null;
|
||||
m_packageTemplateFileName = QString::null;
|
||||
m_platform = QString::null;
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
QString workingDir;
|
||||
if (info.hasCustomDestDir)
|
||||
workingDir = info.workingDir;
|
||||
else
|
||||
workingDir = info.baseDestDir;
|
||||
m_targetName = info.target;
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
QStringList addedUserConfigArguments;
|
||||
QStringList removedUserConfigArguments;
|
||||
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The QtS60 Device run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract data
|
||||
const QDir baseProjectDirectory = QFileInfo(project()->file()->fileName()).absoluteDir();
|
||||
const QString relSubDir = baseProjectDirectory.relativeFilePath(QFileInfo(m_proFilePath).path());
|
||||
const QDir baseBuildDirectory = qt4bc->buildDirectory();
|
||||
const QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir);
|
||||
|
||||
// Directory
|
||||
QString m_workingDir;
|
||||
if (reader->contains("DESTDIR")) {
|
||||
m_workingDir = reader->value("DESTDIR");
|
||||
if (QDir::isRelativePath(m_workingDir)) {
|
||||
m_workingDir = baseDir + QLatin1Char('/') + m_workingDir;
|
||||
}
|
||||
} else {
|
||||
m_workingDir = baseDir;
|
||||
}
|
||||
|
||||
m_targetName = reader->value("TARGET");
|
||||
if (m_targetName.isEmpty())
|
||||
m_targetName = QFileInfo(m_proFilePath).baseName();
|
||||
|
||||
m_baseFileName = QDir::cleanPath(m_workingDir + QLatin1Char('/') + m_targetName);
|
||||
m_packageTemplateFileName = QDir::cleanPath(
|
||||
m_workingDir + QLatin1Char('/') + m_targetName + QLatin1String("_template.pkg"));
|
||||
m_baseFileName = workingDir + QLatin1Char('/') + m_targetName;
|
||||
m_packageTemplateFileName = m_baseFileName + QLatin1String("_template.pkg");
|
||||
|
||||
Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration();
|
||||
switch (qt4bc->toolChainType()) {
|
||||
case ToolChain::GCCE:
|
||||
case ToolChain::GCCE_GNUPOC:
|
||||
@@ -345,7 +324,7 @@ void S60DeviceRunConfiguration::updateTarget()
|
||||
else
|
||||
m_target = QLatin1String("urel");
|
||||
m_baseFileName += QLatin1Char('_') + m_platform + QLatin1Char('_') + m_target;
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
@@ -127,29 +127,21 @@ void S60EmulatorRunConfiguration::updateTarget()
|
||||
{
|
||||
if (m_cachedTargetInformationValid)
|
||||
return;
|
||||
Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration();
|
||||
Qt4ProFileNode *proFileNode = qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath);
|
||||
if (!proFileNode) {
|
||||
Qt4TargetInformation info = qt4Project()->targetInformation(qt4Project()->activeQt4BuildConfiguration(),
|
||||
m_proFilePath);
|
||||
if (info.error != Qt4TargetInformation::NoError) {
|
||||
if (info.error == Qt4TargetInformation::ProParserError) {
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(
|
||||
tr("Could not parse %1. The Qt for Symbian emulator run configuration %2 can not be started.")
|
||||
.arg(m_proFilePath).arg(name()));
|
||||
}
|
||||
m_executable = QString::null;
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit targetInformationChanged();
|
||||
return;
|
||||
}
|
||||
ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
QStringList addedUserConfigArguments;
|
||||
QStringList removedUserConfigArguments;
|
||||
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt for Symbian emulator run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
|
||||
return;
|
||||
}
|
||||
|
||||
Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration();
|
||||
QtVersion *qtVersion = qt4bc->qtVersion();
|
||||
QString baseDir = S60Manager::instance()->deviceForQtVersion(qtVersion).epocRoot;
|
||||
QString qmakeBuildConfig = "urel";
|
||||
@@ -157,15 +149,10 @@ void S60EmulatorRunConfiguration::updateTarget()
|
||||
qmakeBuildConfig = "udeb";
|
||||
baseDir += "/epoc32/release/winscw/" + qmakeBuildConfig;
|
||||
|
||||
QString target = reader->value("TARGET");
|
||||
if (target.isEmpty())
|
||||
target = QFileInfo(m_proFilePath).baseName();
|
||||
|
||||
m_executable = QDir::toNativeSeparators(
|
||||
QDir::cleanPath(baseDir + QLatin1Char('/') + target));
|
||||
QDir::cleanPath(baseDir + QLatin1Char('/') + info.target));
|
||||
m_executable += QLatin1String(".exe");
|
||||
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit targetInformationChanged();
|
||||
}
|
||||
|
||||
@@ -896,6 +896,85 @@ void Qt4Project::destroyProFileReader(ProFileReader *reader)
|
||||
}
|
||||
}
|
||||
|
||||
Qt4TargetInformation Qt4Project::targetInformation(Qt4BuildConfiguration *buildConfiguration,
|
||||
const QString &proFilePath)
|
||||
{
|
||||
Qt4TargetInformation info;
|
||||
Qt4ProFileNode *proFileNode = rootProjectNode()->findProFileFor(proFilePath);
|
||||
if (!proFileNode) {
|
||||
info.error = Qt4TargetInformation::InvalidProjectError;
|
||||
return info;
|
||||
}
|
||||
ProFileReader *reader = createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
QStringList addedUserConfigArguments;
|
||||
QStringList removedUserConfigArguments;
|
||||
buildConfiguration->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(proFilePath)) {
|
||||
destroyProFileReader(reader);
|
||||
info.error = Qt4TargetInformation::ProParserError;
|
||||
return info;
|
||||
}
|
||||
|
||||
// Extract data
|
||||
const QDir baseProjectDirectory = QFileInfo(file()->fileName()).absoluteDir();
|
||||
const QString relSubDir = baseProjectDirectory.relativeFilePath(QFileInfo(proFilePath).path());
|
||||
const QDir baseBuildDirectory = buildConfiguration->buildDirectory();
|
||||
const QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir);
|
||||
info.baseDestDir = QDir::cleanPath(baseDir);
|
||||
//qDebug()<<relSubDir<<baseDir;
|
||||
|
||||
// Working Directory
|
||||
if (reader->contains("DESTDIR")) {
|
||||
info.hasCustomDestDir = true;
|
||||
//qDebug() << "reader contains destdir:" << reader->value("DESTDIR");
|
||||
info.workingDir = reader->value("DESTDIR");
|
||||
if (QDir::isRelativePath(info.workingDir)) {
|
||||
info.workingDir = baseDir + QLatin1Char('/') + info.workingDir;
|
||||
//qDebug() << "was relative and expanded to" << info.workingDir;
|
||||
}
|
||||
} else {
|
||||
info.hasCustomDestDir = false;
|
||||
//qDebug() << "reader didn't contain DESTDIR, setting to " << baseDir;
|
||||
info.workingDir = baseDir;
|
||||
if (reader->values("CONFIG").contains("debug_and_release_target")) {
|
||||
//qDebug() << "reader has debug_and_release_target";
|
||||
QString qmakeBuildConfig = "release";
|
||||
if (buildConfiguration->qmakeBuildConfiguration() & QtVersion::DebugBuild)
|
||||
qmakeBuildConfig = "debug";
|
||||
info.workingDir += QLatin1Char('/') + qmakeBuildConfig;
|
||||
}
|
||||
}
|
||||
|
||||
info.target = reader->value("TARGET");
|
||||
if (info.target.isEmpty())
|
||||
info.target = QFileInfo(proFilePath).baseName();
|
||||
|
||||
#if defined (Q_OS_MAC)
|
||||
if (reader->values("CONFIG").contains("app_bundle")) {
|
||||
info.workingDir += QLatin1Char('/')
|
||||
+ info.target
|
||||
+ QLatin1String(".app/Contents/MacOS");
|
||||
}
|
||||
#endif
|
||||
|
||||
info.workingDir = QDir::cleanPath(info.workingDir);
|
||||
info.executable = QDir::cleanPath(info.workingDir + QLatin1Char('/') + info.target);
|
||||
//qDebug() << "##### updateTarget sets:" << info.workingDir << info.executable;
|
||||
|
||||
#if defined (Q_OS_WIN)
|
||||
info.executable += QLatin1String(".exe");
|
||||
#endif
|
||||
|
||||
destroyProFileReader(reader);
|
||||
info.error = Qt4TargetInformation::NoError;
|
||||
return info;
|
||||
}
|
||||
|
||||
Qt4ProFileNode *Qt4Project::rootProjectNode() const
|
||||
{
|
||||
return m_rootProjectNode;
|
||||
|
||||
@@ -148,6 +148,22 @@ private:
|
||||
QMap<QString, VersionInfo> m_versions;
|
||||
};
|
||||
|
||||
struct Qt4TargetInformation
|
||||
{
|
||||
enum ErrorCode {
|
||||
NoError,
|
||||
InvalidProjectError,
|
||||
ProParserError
|
||||
};
|
||||
|
||||
ErrorCode error;
|
||||
bool hasCustomDestDir;
|
||||
QString baseDestDir;
|
||||
QString workingDir;
|
||||
QString target;
|
||||
QString executable;
|
||||
};
|
||||
|
||||
class Qt4Project : public ProjectExplorer::Project
|
||||
{
|
||||
Q_OBJECT
|
||||
@@ -196,6 +212,9 @@ public:
|
||||
Internal::ProFileReader *createProFileReader(Internal::Qt4ProFileNode *qt4ProFileNode);
|
||||
void destroyProFileReader(Internal::ProFileReader *reader);
|
||||
|
||||
Qt4TargetInformation targetInformation(Internal::Qt4BuildConfiguration *buildConfiguration,
|
||||
const QString &proFilePath);
|
||||
|
||||
signals:
|
||||
/// convenience signal, emitted if either the active buildconfiguration emits
|
||||
/// targetInformationChanged() or if the active build configuration changes
|
||||
|
||||
@@ -570,81 +570,22 @@ void Qt4RunConfiguration::updateTarget()
|
||||
{
|
||||
if (m_cachedTargetInformationValid)
|
||||
return;
|
||||
//qDebug()<<"updateTarget";
|
||||
Qt4BuildConfiguration *qt4bc = qt4Project()->activeQt4BuildConfiguration();
|
||||
Qt4ProFileNode *proFileNode = qt4Project()->rootProjectNode()->findProFileFor(m_proFilePath);
|
||||
if (!proFileNode) {
|
||||
Qt4TargetInformation info = qt4Project()->targetInformation(qt4Project()->activeQt4BuildConfiguration(),
|
||||
m_proFilePath);
|
||||
if (info.error != Qt4TargetInformation::NoError) {
|
||||
if (info.error == Qt4TargetInformation::ProParserError) {
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(
|
||||
tr("Could not parse %1. The Qt4 run configuration %2 can not be started.")
|
||||
.arg(m_proFilePath).arg(name()));
|
||||
}
|
||||
m_workingDir = QString::null;
|
||||
m_executable = QString::null;
|
||||
m_cachedTargetInformationValid = true;
|
||||
emit effectiveTargetInformationChanged();
|
||||
return;
|
||||
}
|
||||
ProFileReader *reader = qt4Project()->createProFileReader(proFileNode);
|
||||
reader->setCumulative(false);
|
||||
|
||||
// Find out what flags we pass on to qmake
|
||||
QStringList addedUserConfigArguments;
|
||||
QStringList removedUserConfigArguments;
|
||||
qt4bc->getConfigCommandLineArguments(&addedUserConfigArguments, &removedUserConfigArguments);
|
||||
reader->setConfigCommandLineArguments(addedUserConfigArguments, removedUserConfigArguments);
|
||||
|
||||
if (!reader->readProFile(m_proFilePath)) {
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
Core::ICore::instance()->messageManager()->printToOutputPane(tr("Could not parse %1. The Qt4 run configuration %2 can not be started.").arg(m_proFilePath).arg(name()));
|
||||
return;
|
||||
}
|
||||
|
||||
// Extract data
|
||||
QDir baseProjectDirectory = QFileInfo(project()->file()->fileName()).absoluteDir();
|
||||
QString relSubDir = baseProjectDirectory.relativeFilePath(QFileInfo(m_proFilePath).path());
|
||||
QDir baseBuildDirectory = project()->activeBuildConfiguration()->buildDirectory();
|
||||
QString baseDir = baseBuildDirectory.absoluteFilePath(relSubDir);
|
||||
|
||||
//qDebug()<<relSubDir<<baseDir;
|
||||
|
||||
// Working Directory
|
||||
if (reader->contains("DESTDIR")) {
|
||||
//qDebug()<<"reader contains destdir:"<<reader->value("DESTDIR");
|
||||
m_workingDir = reader->value("DESTDIR");
|
||||
if (QDir::isRelativePath(m_workingDir)) {
|
||||
m_workingDir = baseDir + QLatin1Char('/') + m_workingDir;
|
||||
//qDebug()<<"was relative and expanded to"<<m_workingDir;
|
||||
}
|
||||
} else {
|
||||
//qDebug()<<"reader didn't contain DESTDIR, setting to "<<baseDir;
|
||||
m_workingDir = baseDir;
|
||||
if (reader->values("CONFIG").contains("debug_and_release_target")) {
|
||||
//qDebug()<<"reader has debug_and_release_target";
|
||||
QString qmakeBuildConfig = "release";
|
||||
if (qt4bc->qmakeBuildConfiguration() & QtVersion::DebugBuild)
|
||||
qmakeBuildConfig = "debug";
|
||||
if (!reader->contains("DESTDIR"))
|
||||
m_workingDir += QLatin1Char('/') + qmakeBuildConfig;
|
||||
}
|
||||
}
|
||||
|
||||
QString target = reader->value("TARGET");
|
||||
if (target.isEmpty())
|
||||
target = QFileInfo(m_proFilePath).baseName();
|
||||
|
||||
#if defined (Q_OS_MAC)
|
||||
if (reader->values("CONFIG").contains("app_bundle")) {
|
||||
m_workingDir += QLatin1Char('/')
|
||||
+ target
|
||||
+ QLatin1String(".app/Contents/MacOS");
|
||||
}
|
||||
#endif
|
||||
|
||||
m_workingDir = QDir::cleanPath(m_workingDir);
|
||||
m_executable = QDir::cleanPath(m_workingDir + QLatin1Char('/') + target);
|
||||
//qDebug()<<"##### updateTarget sets:"<<m_workingDir<<m_executable;
|
||||
|
||||
#if defined (Q_OS_WIN)
|
||||
m_executable += QLatin1String(".exe");
|
||||
#endif
|
||||
|
||||
qt4Project()->destroyProFileReader(reader);
|
||||
m_workingDir = info.workingDir;
|
||||
m_executable = info.executable;
|
||||
|
||||
m_cachedTargetInformationValid = true;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user