Commit 423686c0 authored by Tobias Hunger's avatar Tobias Hunger
Browse files

Report project issues in the Project Mode window

 * Add test for build- and sourcedirectories being at different levels

Reviewed-by: dt
parent 4bf97f1f
......@@ -179,7 +179,7 @@ bool QMakeStep::init()
Qt4Project *pro = qt4BuildConfiguration()->qt4Target()->qt4Project();
QString proFile = pro->file()->fileName();
m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile);
m_tasks = qt4BuildConfiguration()->qtVersion()->reportIssues(proFile, workingDirectory);
m_scriptTemplate = pro->rootProjectNode()->projectType() == ScriptTemplate;
return AbstractProcessStep::init();
......
......@@ -341,18 +341,32 @@ void Qt4ProjectConfigWidget::updateImportLabel()
}
}
QString sourceDirectory =
m_buildConfiguration->target()->project()->projectDirectory();
if (!sourceDirectory.endsWith('/'))
sourceDirectory.append('/');
bool invalidBuildDirectory = m_buildConfiguration->shadowBuild()
&& m_buildConfiguration->buildDirectory().startsWith(sourceDirectory);
if (invalidBuildDirectory) {
QString buildDirectory = m_buildConfiguration->target()->project()->projectDirectory();;
if (m_buildConfiguration->shadowBuild())
buildDirectory = m_buildConfiguration->buildDirectory();
QList<ProjectExplorer::Task> issues = m_buildConfiguration->qtVersion()->reportIssues(m_buildConfiguration->target()->project()->file()->fileName(),
buildDirectory);
if (!issues.isEmpty()) {
m_ui->problemLabel->setVisible(true);
m_ui->warningLabel->setVisible(true);
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) {
m_ui->problemLabel->setVisible(false);
m_ui->warningLabel->setVisible(false);
......
......@@ -638,10 +638,14 @@ bool QtVersion::supportsShadowBuilds() const
}
QList<ProjectExplorer::Task>
QtVersion::reportIssues(const QString &proFile)
QtVersion::reportIssues(const QString &proFile, const QString &buildDir)
{
QList<ProjectExplorer::Task> results;
QString tmpBuildDir = buildDir;
if (!buildDir.endsWith(QChar('/')))
tmpBuildDir.append(QChar('/'));
if (!isValid()) {
//: %1: Reason for being invalid
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)));
}
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();
if (targets.contains(Constants::S60_DEVICE_TARGET_ID) ||
targets.contains(Constants::S60_EMULATOR_TARGET_ID))
......
......@@ -147,7 +147,7 @@ public:
/// its symbian setup.
/// @return a list of tasks, ordered on severity (errors first, then
/// warnings and finally info items.
QList<ProjectExplorer::Task> reportIssues(const QString &proFile);
QList<ProjectExplorer::Task> reportIssues(const QString &proFile, const QString &buildDir);
private:
QList<QSharedPointer<ProjectExplorer::ToolChain> > toolChains() const;
......
......@@ -130,10 +130,20 @@ void TargetSetupPage::setImportInfos(const QList<ImportInfo> &infos)
foreach (const ImportInfo &i, m_infos) {
++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))
continue;
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();
if (!issues.second.isEmpty())
......@@ -168,17 +178,9 @@ void TargetSetupPage::setImportInfos(const QList<ImportInfo> &infos)
versionItem->setToolTip(1, status);
// Column 2 (directory):
QString dir;
if (i.directory.isEmpty()) {
if (i.version->supportsShadowBuilds())
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);
buildDir = QDir::toNativeSeparators(buildDir);
versionItem->setText(2, buildDir);
versionItem->setToolTip(2, buildDir);
}
}
......@@ -441,7 +443,8 @@ void TargetSetupPage::resetInfos()
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())
return qMakePair(QIcon(), QString());
......@@ -450,7 +453,7 @@ QPair<QIcon, QString> TargetSetupPage::reportIssues(Qt4ProjectManager::QtVersion
->getObject<ProjectExplorer::TaskWindow>();
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;
......
......@@ -121,7 +121,7 @@ private slots:
private:
void resetInfos();
QPair<QIcon, QString> reportIssues(QtVersion *version);
QPair<QIcon, QString> reportIssues(QtVersion *version, const QString &buildDir);
QList<ImportInfo> m_infos;
bool m_preferMobile;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment