forked from qt-creator/qt-creator
Report project issues in the Project Mode window
* Add test for build- and sourcedirectories being at different levels Reviewed-by: dt
This commit is contained in:
@@ -179,7 +179,7 @@ bool QMakeStep::init()
|
|||||||
|
|
||||||
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project();
|
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project();
|
||||||
QString proFile = pro->file()->fileName();
|
QString proFile = pro->file()->fileName();
|
||||||
m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile);
|
m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile, workingDirectory);
|
||||||
m_scriptTemplate = pro->rootProjectNode()->projectType() == ScriptTemplate;
|
m_scriptTemplate = pro->rootProjectNode()->projectType() == ScriptTemplate;
|
||||||
|
|
||||||
return AbstractProcessStep::init();
|
return AbstractProcessStep::init();
|
||||||
|
@@ -341,18 +341,32 @@ void Qt4ProjectConfigWidget::updateImportLabel()
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
QString sourceDirectory =
|
QString buildDirectory = m_buildConfiguration->target()->project()->projectDirectory();;
|
||||||
m_buildConfiguration->target()->project()->projectDirectory();
|
if (m_buildConfiguration->shadowBuild())
|
||||||
if (!sourceDirectory.endsWith('/'))
|
buildDirectory = m_buildConfiguration->buildDirectory();
|
||||||
sourceDirectory.append('/');
|
QList<ProjectExplorer::Task> issues = m_buildConfiguration->qtVersion()->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(),
|
||||||
bool invalidBuildDirectory = m_buildConfiguration->shadowBuild()
|
buildDirectory);
|
||||||
&& m_buildConfiguration->buildDirectory().startsWith(sourceDirectory);
|
|
||||||
|
|
||||||
if (invalidBuildDirectory) {
|
if (!issues.isEmpty()) {
|
||||||
m_ui->problemLabel->setVisible(true);
|
m_ui->problemLabel->setVisible(true);
|
||||||
m_ui->warningLabel->setVisible(true);
|
m_ui->warningLabel->setVisible(true);
|
||||||
m_ui->importLabel->setVisible(visible);
|
m_ui->importLabel->setVisible(visible);
|
||||||
m_ui->problemLabel->setText(tr("Building in subdirectories of the source directory is not supported by qmake."));
|
QString text = "<nobr>";
|
||||||
|
foreach (const ProjectExplorer::Task &task, issues) {
|
||||||
|
QString type;
|
||||||
|
switch (task.type) {
|
||||||
|
case ProjectExplorer::Task::Error:
|
||||||
|
type = tr("Error: ");
|
||||||
|
break;
|
||||||
|
case ProjectExplorer::Task::Warning:
|
||||||
|
type = tr("Warning: ");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (!text.endsWith(QLatin1String("br>")))
|
||||||
|
text.append(QLatin1String("<br>"));
|
||||||
|
text.append(type + task.description);
|
||||||
|
}
|
||||||
|
m_ui->problemLabel->setText(text);
|
||||||
} else if (targetMatches) {
|
} else if (targetMatches) {
|
||||||
m_ui->problemLabel->setVisible(false);
|
m_ui->problemLabel->setVisible(false);
|
||||||
m_ui->warningLabel->setVisible(false);
|
m_ui->warningLabel->setVisible(false);
|
||||||
|
@@ -638,10 +638,14 @@ bool QtVersion::supportsShadowBuilds() const
|
|||||||
}
|
}
|
||||||
|
|
||||||
QList<ProjectExplorer::Task>
|
QList<ProjectExplorer::Task>
|
||||||
QtVersion::reportIssues(const QString &proFile)
|
QtVersion::reportIssues(const QString &proFile, const QString &buildDir)
|
||||||
{
|
{
|
||||||
QList<ProjectExplorer::Task> results;
|
QList<ProjectExplorer::Task> results;
|
||||||
|
|
||||||
|
QString tmpBuildDir = buildDir;
|
||||||
|
if (!buildDir.endsWith(QChar('/')))
|
||||||
|
tmpBuildDir.append(QChar('/'));
|
||||||
|
|
||||||
if (!isValid()) {
|
if (!isValid()) {
|
||||||
//: %1: Reason for being invalid
|
//: %1: Reason for being invalid
|
||||||
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", "The Qt version is invalid: %1").arg(invalidReason());
|
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion", "The Qt version is invalid: %1").arg(invalidReason());
|
||||||
@@ -659,6 +663,22 @@ QtVersion::reportIssues(const QString &proFile)
|
|||||||
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QString sourcePath = QFileInfo(proFile).absolutePath();
|
||||||
|
if (!sourcePath.endsWith(QChar('/')))
|
||||||
|
sourcePath.append(QChar('/'));
|
||||||
|
|
||||||
|
if ((tmpBuildDir.startsWith(sourcePath)) && (tmpBuildDir != sourcePath)) {
|
||||||
|
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
|
||||||
|
"Qmake does not support build directories below the source directory.");
|
||||||
|
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1,
|
||||||
|
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
||||||
|
} else if (tmpBuildDir.count(QChar('/')) != sourcePath.count(QChar('/'))) {
|
||||||
|
const QString msg = QCoreApplication::translate("Qt4ProjectManager::QtVersion",
|
||||||
|
"The build directory needs to be at the same level as the source directory.");
|
||||||
|
results.append(ProjectExplorer::Task(ProjectExplorer::Task::Warning, msg, QString(), -1,
|
||||||
|
QLatin1String(ProjectExplorer::Constants::TASK_CATEGORY_BUILDSYSTEM)));
|
||||||
|
}
|
||||||
|
|
||||||
QSet<QString> targets = supportedTargetIds();
|
QSet<QString> targets = supportedTargetIds();
|
||||||
if (targets.contains(Constants::S60_DEVICE_TARGET_ID) ||
|
if (targets.contains(Constants::S60_DEVICE_TARGET_ID) ||
|
||||||
targets.contains(Constants::S60_EMULATOR_TARGET_ID))
|
targets.contains(Constants::S60_EMULATOR_TARGET_ID))
|
||||||
|
@@ -147,7 +147,7 @@ public:
|
|||||||
/// its symbian setup.
|
/// its symbian setup.
|
||||||
/// @return a list of tasks, ordered on severity (errors first, then
|
/// @return a list of tasks, ordered on severity (errors first, then
|
||||||
/// warnings and finally info items.
|
/// warnings and finally info items.
|
||||||
QList<ProjectExplorer::Task> reportIssues(const QString &proFile);
|
QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<QSharedPointer<ProjectExplorer::ToolChain> > toolChains() const;
|
QList<QSharedPointer<ProjectExplorer::ToolChain> > toolChains() const;
|
||||||
|
@@ -130,10 +130,20 @@ void TargetSetupPage::setImportInfos(const QList<ImportInfo> &infos)
|
|||||||
foreach (const ImportInfo &i, m_infos) {
|
foreach (const ImportInfo &i, m_infos) {
|
||||||
++pos;
|
++pos;
|
||||||
|
|
||||||
|
QString buildDir;
|
||||||
|
if (i.directory.isEmpty()) {
|
||||||
|
if (i.version->supportsShadowBuilds())
|
||||||
|
buildDir = Qt4Target::defaultShadowBuildDirectory(Qt4Project::defaultTopLevelBuildDirectory(m_proFilePath), t);
|
||||||
|
else
|
||||||
|
buildDir = Qt4Project::projectDirectory(m_proFilePath);
|
||||||
|
} else {
|
||||||
|
buildDir = i.directory;
|
||||||
|
}
|
||||||
|
|
||||||
if (!i.version->supportsTargetId(t))
|
if (!i.version->supportsTargetId(t))
|
||||||
continue;
|
continue;
|
||||||
QTreeWidgetItem *versionItem = new QTreeWidgetItem(targetItem);
|
QTreeWidgetItem *versionItem = new QTreeWidgetItem(targetItem);
|
||||||
QPair<QIcon, QString> issues = reportIssues(i.version);
|
QPair<QIcon, QString> issues = reportIssues(i.version, buildDir);
|
||||||
|
|
||||||
QString toolTip = i.version->displayName();
|
QString toolTip = i.version->displayName();
|
||||||
if (!issues.second.isEmpty())
|
if (!issues.second.isEmpty())
|
||||||
@@ -168,17 +178,9 @@ void TargetSetupPage::setImportInfos(const QList<ImportInfo> &infos)
|
|||||||
versionItem->setToolTip(1, status);
|
versionItem->setToolTip(1, status);
|
||||||
|
|
||||||
// Column 2 (directory):
|
// Column 2 (directory):
|
||||||
QString dir;
|
buildDir = QDir::toNativeSeparators(buildDir);
|
||||||
if (i.directory.isEmpty()) {
|
versionItem->setText(2, buildDir);
|
||||||
if (i.version->supportsShadowBuilds())
|
versionItem->setToolTip(2, buildDir);
|
||||||
dir = QDir::toNativeSeparators(Qt4Target::defaultShadowBuildDirectory(Qt4Project::defaultTopLevelBuildDirectory(m_proFilePath), t));
|
|
||||||
else
|
|
||||||
dir = QDir::toNativeSeparators(Qt4Project::projectDirectory(m_proFilePath));
|
|
||||||
} else {
|
|
||||||
dir = QDir::toNativeSeparators(i.directory);
|
|
||||||
}
|
|
||||||
versionItem->setText(2, dir);
|
|
||||||
versionItem->setToolTip(2, dir);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -441,7 +443,8 @@ void TargetSetupPage::resetInfos()
|
|||||||
m_infos.clear();
|
m_infos.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion *version)
|
QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion *version,
|
||||||
|
const QString &buildDir)
|
||||||
{
|
{
|
||||||
if (m_proFilePath.isEmpty())
|
if (m_proFilePath.isEmpty())
|
||||||
return qMakePair(QIcon(), QString());
|
return qMakePair(QIcon(), QString());
|
||||||
@@ -450,7 +453,7 @@ QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion
|
|||||||
->getObject<ProjectExplorer::TaskWindow>();
|
->getObject<ProjectExplorer::TaskWindow>();
|
||||||
QTC_ASSERT(taskWindow, return qMakePair(QIcon(), QString()));
|
QTC_ASSERT(taskWindow, return qMakePair(QIcon(), QString()));
|
||||||
|
|
||||||
QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath);
|
QList<ProjectExplorer::Task> issues = version->reportIssues(m_proFilePath, buildDir);
|
||||||
|
|
||||||
|
|
||||||
QString text;
|
QString text;
|
||||||
|
@@ -121,7 +121,7 @@ private slots:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
void resetInfos();
|
void resetInfos();
|
||||||
QPair<QIcon, QString> reportIssues(QtVersion *version);
|
QPair<QIcon, QString> reportIssues(QtVersion *version, const QString &buildDir);
|
||||||
|
|
||||||
QList<ImportInfo> m_infos;
|
QList<ImportInfo> m_infos;
|
||||||
bool m_preferMobile;
|
bool m_preferMobile;
|
||||||
|
Reference in New Issue
Block a user