forked from qt-creator/qt-creator
Add option to place shadow build directory parallel to source tree.
This option requires that the projects directory setting is enabled. For example with the following settings: Projects directory: $HOME/depot Build directory: $HOME/build This will by default place the default shadow build directory in the $HOME/build tree instead of adjacent to the source in $HOME/depot. Change-Id: I74bfc00883d0479d5965350c760d14ef7602cc34 Reviewed-by: Daniel Teske <daniel.teske@digia.com>
This commit is contained in:
@@ -97,6 +97,8 @@ static const char editorsKeyC[] = "EditorIds";
|
|||||||
static const char directoryGroupC[] = "Directories";
|
static const char directoryGroupC[] = "Directories";
|
||||||
static const char projectDirectoryKeyC[] = "Projects";
|
static const char projectDirectoryKeyC[] = "Projects";
|
||||||
static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory";
|
static const char useProjectDirectoryKeyC[] = "UseProjectsDirectory";
|
||||||
|
static const char buildDirectoryKeyC[] = "BuildDirectory";
|
||||||
|
static const char useBuildDirectoryKeyC[] = "UseBuildDirectory";
|
||||||
|
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
@@ -156,6 +158,8 @@ struct DocumentManagerPrivate
|
|||||||
QString m_lastVisitedDirectory;
|
QString m_lastVisitedDirectory;
|
||||||
QString m_projectsDirectory;
|
QString m_projectsDirectory;
|
||||||
bool m_useProjectsDirectory;
|
bool m_useProjectsDirectory;
|
||||||
|
QString m_buildDirectory;
|
||||||
|
bool m_useBuildDirectory;
|
||||||
// When we are callling into a IDocument
|
// When we are callling into a IDocument
|
||||||
// we don't want to receive a changed()
|
// we don't want to receive a changed()
|
||||||
// signal
|
// signal
|
||||||
@@ -198,6 +202,7 @@ DocumentManagerPrivate::DocumentManagerPrivate(QMainWindow *mw) :
|
|||||||
m_blockActivated(false),
|
m_blockActivated(false),
|
||||||
m_lastVisitedDirectory(QDir::currentPath()),
|
m_lastVisitedDirectory(QDir::currentPath()),
|
||||||
m_useProjectsDirectory(Utils::HostOsInfo::isMacHost()), // Creator is in bizarre places when launched via finder.
|
m_useProjectsDirectory(Utils::HostOsInfo::isMacHost()), // Creator is in bizarre places when launched via finder.
|
||||||
|
m_useBuildDirectory(false),
|
||||||
m_blockedIDocument(0)
|
m_blockedIDocument(0)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -1165,6 +1170,8 @@ void DocumentManager::saveSettings()
|
|||||||
s->beginGroup(QLatin1String(directoryGroupC));
|
s->beginGroup(QLatin1String(directoryGroupC));
|
||||||
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory);
|
s->setValue(QLatin1String(projectDirectoryKeyC), d->m_projectsDirectory);
|
||||||
s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory);
|
s->setValue(QLatin1String(useProjectDirectoryKeyC), d->m_useProjectsDirectory);
|
||||||
|
s->setValue(QLatin1String(buildDirectoryKeyC), d->m_buildDirectory);
|
||||||
|
s->setValue(QLatin1String(useBuildDirectoryKeyC), d->m_useBuildDirectory);
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1197,6 +1204,16 @@ void readSettings()
|
|||||||
}
|
}
|
||||||
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
|
d->m_useProjectsDirectory = s->value(QLatin1String(useProjectDirectoryKeyC),
|
||||||
d->m_useProjectsDirectory).toBool();
|
d->m_useProjectsDirectory).toBool();
|
||||||
|
|
||||||
|
const QString settingsShadowDir = s->value(QLatin1String(buildDirectoryKeyC),
|
||||||
|
QString()).toString();
|
||||||
|
if (!settingsShadowDir.isEmpty() && QFileInfo(settingsShadowDir).isDir())
|
||||||
|
d->m_buildDirectory = settingsShadowDir;
|
||||||
|
else
|
||||||
|
d->m_buildDirectory = Utils::PathChooser::homePath();
|
||||||
|
|
||||||
|
d->m_useBuildDirectory = s->value(QLatin1String(useBuildDirectoryKeyC),
|
||||||
|
d->m_useBuildDirectory).toBool();
|
||||||
s->endGroup();
|
s->endGroup();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1267,6 +1284,47 @@ void DocumentManager::setProjectsDirectory(const QString &dir)
|
|||||||
d->m_projectsDirectory = dir;
|
d->m_projectsDirectory = dir;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns whether the default shadow build directory is placed adjacent to the source in the
|
||||||
|
projects directory or in a separate build tree.
|
||||||
|
|
||||||
|
\sa setUseBuildDirectory, setBuildDirectory
|
||||||
|
*/
|
||||||
|
bool DocumentManager::useBuildDirectory()
|
||||||
|
{
|
||||||
|
return d->m_useBuildDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets whether a separate build directory is to the used when shadow building.
|
||||||
|
|
||||||
|
\sa buildDirectory, usebuildDirectory
|
||||||
|
*/
|
||||||
|
void DocumentManager::setUseBuildDirectory(bool use)
|
||||||
|
{
|
||||||
|
d->m_useBuildDirectory = use;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Returns the shadow build directory.
|
||||||
|
|
||||||
|
\sa setBuildDirectory, useBuildDirectory
|
||||||
|
*/
|
||||||
|
QString DocumentManager::buildDirectory()
|
||||||
|
{
|
||||||
|
return d->m_buildDirectory;
|
||||||
|
}
|
||||||
|
|
||||||
|
/*!
|
||||||
|
Sets the shadow build directory to \a directory.
|
||||||
|
|
||||||
|
\sa buildDirectory, useBuildDirectory
|
||||||
|
*/
|
||||||
|
void DocumentManager::setBuildDirectory(const QString &directory)
|
||||||
|
{
|
||||||
|
d->m_buildDirectory = directory;
|
||||||
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
||||||
Returns whether the directory for projects is to be
|
Returns whether the directory for projects is to be
|
||||||
|
|||||||
@@ -129,6 +129,12 @@ public:
|
|||||||
static QString projectsDirectory();
|
static QString projectsDirectory();
|
||||||
static void setProjectsDirectory(const QString &);
|
static void setProjectsDirectory(const QString &);
|
||||||
|
|
||||||
|
static bool useBuildDirectory();
|
||||||
|
static void setUseBuildDirectory(bool use);
|
||||||
|
|
||||||
|
static QString buildDirectory();
|
||||||
|
static void setBuildDirectory(const QString &directory);
|
||||||
|
|
||||||
static void populateOpenWithMenu(QMenu *menu, const QString &fileName);
|
static void populateOpenWithMenu(QMenu *menu, const QString &fileName);
|
||||||
|
|
||||||
/* Used to notify e.g. the code model to update the given files. Does *not*
|
/* Used to notify e.g. the code model to update the given files. Does *not*
|
||||||
|
|||||||
@@ -53,6 +53,8 @@ ProjectExplorerSettingsWidget::ProjectExplorerSettingsWidget(QWidget *parent) :
|
|||||||
m_ui.directoryButtonGroup->setId(m_ui.directoryRadioButton, UseProjectDirectory);
|
m_ui.directoryButtonGroup->setId(m_ui.directoryRadioButton, UseProjectDirectory);
|
||||||
connect(m_ui.directoryButtonGroup, SIGNAL(buttonClicked(int)),
|
connect(m_ui.directoryButtonGroup, SIGNAL(buttonClicked(int)),
|
||||||
this, SLOT(slotDirectoryButtonGroupChanged()));
|
this, SLOT(slotDirectoryButtonGroupChanged()));
|
||||||
|
connect(m_ui.buildDirectoryCheckBox, SIGNAL(toggled(bool)),
|
||||||
|
this, SLOT(slotBuildDirectoryCheckBoxChanged(bool)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void ProjectExplorerSettingsWidget::setJomVisible(bool v)
|
void ProjectExplorerSettingsWidget::setJomVisible(bool v)
|
||||||
@@ -118,9 +120,40 @@ void ProjectExplorerSettingsWidget::setUseProjectsDirectory(bool b)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ProjectExplorerSettingsWidget::useBuildDirectory() const
|
||||||
|
{
|
||||||
|
return m_ui.buildDirectoryCheckBox->isChecked();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectExplorerSettingsWidget::setUseBuildDirectory(bool v)
|
||||||
|
{
|
||||||
|
if (useBuildDirectory() != v) {
|
||||||
|
m_ui.buildDirectoryCheckBox->setChecked(v);
|
||||||
|
slotBuildDirectoryCheckBoxChanged(v);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QString ProjectExplorerSettingsWidget::buildDirectory() const
|
||||||
|
{
|
||||||
|
return m_ui.buildDirectoryPathChooser->path();
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectExplorerSettingsWidget::setBuildDirectory(const QString &bd)
|
||||||
|
{
|
||||||
|
m_ui.buildDirectoryPathChooser->setPath(bd);
|
||||||
|
}
|
||||||
|
|
||||||
void ProjectExplorerSettingsWidget::slotDirectoryButtonGroupChanged()
|
void ProjectExplorerSettingsWidget::slotDirectoryButtonGroupChanged()
|
||||||
{
|
{
|
||||||
m_ui.projectsDirectoryPathChooser->setEnabled(useProjectsDirectory());
|
bool enable = useProjectsDirectory();
|
||||||
|
m_ui.projectsDirectoryPathChooser->setEnabled(enable);
|
||||||
|
m_ui.buildDirectoryCheckBox->setEnabled(enable);
|
||||||
|
m_ui.buildDirectoryPathChooser->setEnabled(enable && useBuildDirectory());
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectExplorerSettingsWidget::slotBuildDirectoryCheckBoxChanged(bool checked)
|
||||||
|
{
|
||||||
|
m_ui.buildDirectoryPathChooser->setEnabled(useProjectsDirectory() && checked);
|
||||||
}
|
}
|
||||||
|
|
||||||
QString ProjectExplorerSettingsWidget::searchKeywords() const
|
QString ProjectExplorerSettingsWidget::searchKeywords() const
|
||||||
@@ -167,6 +200,8 @@ QWidget *ProjectExplorerSettingsPage::createPage(QWidget *parent)
|
|||||||
m_widget->setSettings(ProjectExplorerPlugin::instance()->projectExplorerSettings());
|
m_widget->setSettings(ProjectExplorerPlugin::instance()->projectExplorerSettings());
|
||||||
m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory());
|
m_widget->setProjectsDirectory(Core::DocumentManager::projectsDirectory());
|
||||||
m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory());
|
m_widget->setUseProjectsDirectory(Core::DocumentManager::useProjectsDirectory());
|
||||||
|
m_widget->setUseBuildDirectory(Core::DocumentManager::useBuildDirectory());
|
||||||
|
m_widget->setBuildDirectory(Core::DocumentManager::buildDirectory());
|
||||||
if (m_searchKeywords.isEmpty())
|
if (m_searchKeywords.isEmpty())
|
||||||
m_searchKeywords = m_widget->searchKeywords();
|
m_searchKeywords = m_widget->searchKeywords();
|
||||||
return m_widget;
|
return m_widget;
|
||||||
@@ -178,6 +213,8 @@ void ProjectExplorerSettingsPage::apply()
|
|||||||
ProjectExplorerPlugin::instance()->setProjectExplorerSettings(m_widget->settings());
|
ProjectExplorerPlugin::instance()->setProjectExplorerSettings(m_widget->settings());
|
||||||
Core::DocumentManager::setProjectsDirectory(m_widget->projectsDirectory());
|
Core::DocumentManager::setProjectsDirectory(m_widget->projectsDirectory());
|
||||||
Core::DocumentManager::setUseProjectsDirectory(m_widget->useProjectsDirectory());
|
Core::DocumentManager::setUseProjectsDirectory(m_widget->useProjectsDirectory());
|
||||||
|
Core::DocumentManager::setUseBuildDirectory(m_widget->useBuildDirectory());
|
||||||
|
Core::DocumentManager::setBuildDirectory(m_widget->buildDirectory());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -55,10 +55,17 @@ public:
|
|||||||
bool useProjectsDirectory();
|
bool useProjectsDirectory();
|
||||||
void setUseProjectsDirectory(bool v);
|
void setUseProjectsDirectory(bool v);
|
||||||
|
|
||||||
|
bool useBuildDirectory() const;
|
||||||
|
void setUseBuildDirectory(bool v);
|
||||||
|
|
||||||
|
QString buildDirectory() const;
|
||||||
|
void setBuildDirectory(const QString &bd);
|
||||||
|
|
||||||
QString searchKeywords() const;
|
QString searchKeywords() const;
|
||||||
|
|
||||||
private slots:
|
private slots:
|
||||||
void slotDirectoryButtonGroupChanged();
|
void slotDirectoryButtonGroupChanged();
|
||||||
|
void slotBuildDirectoryCheckBoxChanged(bool checked);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
void setJomVisible(bool);
|
void setJomVisible(bool);
|
||||||
|
|||||||
@@ -20,6 +20,9 @@
|
|||||||
<property name="fieldGrowthPolicy">
|
<property name="fieldGrowthPolicy">
|
||||||
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
<enum>QFormLayout::ExpandingFieldsGrow</enum>
|
||||||
</property>
|
</property>
|
||||||
|
<property name="labelAlignment">
|
||||||
|
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
|
||||||
|
</property>
|
||||||
<item row="0" column="0" colspan="2">
|
<item row="0" column="0" colspan="2">
|
||||||
<widget class="QRadioButton" name="currentDirectoryRadioButton">
|
<widget class="QRadioButton" name="currentDirectoryRadioButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -30,6 +33,23 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
|
<item row="1" column="1">
|
||||||
|
<widget class="Utils::PathChooser" name="projectsDirectoryPathChooser" native="true"/>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="0">
|
||||||
|
<widget class="QCheckBox" name="buildDirectoryCheckBox">
|
||||||
|
<property name="text">
|
||||||
|
<string>Build directory</string>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
|
<item row="2" column="1">
|
||||||
|
<widget class="Utils::PathChooser" name="buildDirectoryPathChooser" native="true">
|
||||||
|
<property name="enabled">
|
||||||
|
<bool>false</bool>
|
||||||
|
</property>
|
||||||
|
</widget>
|
||||||
|
</item>
|
||||||
<item row="1" column="0">
|
<item row="1" column="0">
|
||||||
<widget class="QRadioButton" name="directoryRadioButton">
|
<widget class="QRadioButton" name="directoryRadioButton">
|
||||||
<property name="text">
|
<property name="text">
|
||||||
@@ -43,9 +63,6 @@
|
|||||||
</attribute>
|
</attribute>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
<item row="1" column="1">
|
|
||||||
<widget class="Utils::PathChooser" name="projectsDirectoryPathChooser" native="true"/>
|
|
||||||
</item>
|
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
</item>
|
</item>
|
||||||
@@ -237,6 +254,7 @@
|
|||||||
<class>Utils::PathChooser</class>
|
<class>Utils::PathChooser</class>
|
||||||
<extends>QWidget</extends>
|
<extends>QWidget</extends>
|
||||||
<header location="global">utils/pathchooser.h</header>
|
<header location="global">utils/pathchooser.h</header>
|
||||||
|
<container>1</container>
|
||||||
</customwidget>
|
</customwidget>
|
||||||
</customwidgets>
|
</customwidgets>
|
||||||
<resources/>
|
<resources/>
|
||||||
|
|||||||
@@ -46,6 +46,7 @@
|
|||||||
#include <coreplugin/messagemanager.h>
|
#include <coreplugin/messagemanager.h>
|
||||||
#include <coreplugin/coreconstants.h>
|
#include <coreplugin/coreconstants.h>
|
||||||
#include <coreplugin/progressmanager/progressmanager.h>
|
#include <coreplugin/progressmanager/progressmanager.h>
|
||||||
|
#include <coreplugin/documentmanager.h>
|
||||||
#include <extensionsystem/pluginmanager.h>
|
#include <extensionsystem/pluginmanager.h>
|
||||||
#include <cpptools/ModelManagerInterface.h>
|
#include <cpptools/ModelManagerInterface.h>
|
||||||
#include <qmljs/qmljsmodelmanagerinterface.h>
|
#include <qmljs/qmljsmodelmanagerinterface.h>
|
||||||
@@ -1426,9 +1427,25 @@ QString Qt4Project::shadowBuildDirectory(const QString &profilePath, const Kit *
|
|||||||
if (version && !version->supportsShadowBuilds())
|
if (version && !version->supportsShadowBuilds())
|
||||||
return info.absolutePath();
|
return info.absolutePath();
|
||||||
|
|
||||||
QString base = QDir::cleanPath(projectDirectory(profilePath) + QLatin1String("/../")
|
Utils::FileName buildDirBase = Utils::FileName::fromString(projectDirectory(profilePath));
|
||||||
+ info.baseName() + QLatin1String("-build-"));
|
if (Core::DocumentManager::useProjectsDirectory() &&
|
||||||
return base + buildNameFor(k) + QLatin1String("-") + sanitize(suffix);
|
Core::DocumentManager::useBuildDirectory()) {
|
||||||
|
const Utils::FileName projectsDirectory =
|
||||||
|
Utils::FileName::fromString(Core::DocumentManager::projectsDirectory());
|
||||||
|
|
||||||
|
if (buildDirBase.isChildOf(projectsDirectory)) {
|
||||||
|
Utils::FileName buildDirectory =
|
||||||
|
Utils::FileName::fromString(Core::DocumentManager::buildDirectory());
|
||||||
|
|
||||||
|
buildDirectory.appendPath(buildDirBase.relativeChildPath(projectsDirectory).toString());
|
||||||
|
buildDirBase = buildDirectory;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
buildDirBase.append(QLatin1String("-build-") + buildNameFor(k) +
|
||||||
|
QLatin1Char('-') + sanitize(suffix));
|
||||||
|
|
||||||
|
return QDir::cleanPath(buildDirBase.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
QString Qt4Project::buildNameFor(const Kit *k)
|
QString Qt4Project::buildNameFor(const Kit *k)
|
||||||
|
|||||||
Reference in New Issue
Block a user