diff options
author | Tobias Hunger <tobias.hunger@digia.com> | 2013-08-16 17:45:16 +0200 |
---|---|---|
committer | Tobias Hunger <tobias.hunger@digia.com> | 2013-08-28 11:41:38 +0200 |
commit | a7bb77288d28160daabbc00179e77736886ce8d2 (patch) | |
tree | 04dcfc73f09e702e0597f9b1c8ff05313dc50f5c /src/plugins/autotoolsprojectmanager | |
parent | 52a41ecb0c455b9979b2a55cc5f96b078b696996 (diff) | |
download | qt-creator-a7bb77288d28160daabbc00179e77736886ce8d2.tar.gz |
BC: Move builddirectory handling into BC itself
Use setBuildDirectory() in the different BuildConfigurations instead
of reimplementing that over and over again.
Change-Id: Ic355fdb4624c71667ce470b3e2865c9a8722ef09
Reviewed-by: Daniel Teske <daniel.teske@digia.com>
Reviewed-by: Tobias Hunger <tobias.hunger@digia.com>
Diffstat (limited to 'src/plugins/autotoolsprojectmanager')
9 files changed, 34 insertions, 62 deletions
diff --git a/src/plugins/autotoolsprojectmanager/autogenstep.cpp b/src/plugins/autotoolsprojectmanager/autogenstep.cpp index f8afd63a02..06071a228e 100644 --- a/src/plugins/autotoolsprojectmanager/autogenstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autogenstep.cpp @@ -158,7 +158,7 @@ bool AutogenStep::init() ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setEnvironment(bc->environment()); - pp->setWorkingDirectory(bc->buildDirectory()); + pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(QLatin1String("autogen.sh")); pp->setArguments(additionalArguments()); pp->resolveAll(); @@ -171,9 +171,10 @@ void AutogenStep::run(QFutureInterface<bool> &interface) BuildConfiguration *bc = buildConfiguration(); // Check whether we need to run autogen.sh - const QFileInfo configureInfo(bc->buildDirectory() + QLatin1String("/configure")); - const QFileInfo configureAcInfo(bc->buildDirectory() + QLatin1String("/configure.ac")); - const QFileInfo makefileAmInfo(bc->buildDirectory() + QLatin1String("/Makefile.am")); + const QString buildDir = bc->buildDirectory().toString(); + const QFileInfo configureInfo(buildDir + QLatin1String("/configure")); + const QFileInfo configureAcInfo(buildDir + QLatin1String("/configure.ac")); + const QFileInfo makefileAmInfo(buildDir + QLatin1String("/Makefile.am")); if (!configureInfo.exists() || configureInfo.lastModified() < configureAcInfo.lastModified() @@ -275,7 +276,7 @@ void AutogenStepConfigWidget::updateDetails() ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); - param.setWorkingDirectory(bc->buildDirectory()); + param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(QLatin1String("autogen.sh")); param.setArguments(m_autogenStep->additionalArguments()); m_summaryText = param.summary(displayName()); diff --git a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp index adcb7b0096..1b8d7b8990 100644 --- a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp @@ -157,7 +157,7 @@ bool AutoreconfStep::init() ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setEnvironment(bc->environment()); - pp->setWorkingDirectory(bc->buildDirectory()); + pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(QLatin1String("autoreconf")); pp->setArguments(additionalArguments()); pp->resolveAll(); @@ -170,7 +170,8 @@ void AutoreconfStep::run(QFutureInterface<bool> &interface) BuildConfiguration *bc = buildConfiguration(); // Check whether we need to run autoreconf - const QFileInfo configureInfo(bc->buildDirectory() + QLatin1String("/configure")); + const QString buildDir = bc->buildDirectory().toString(); + const QFileInfo configureInfo(buildDir + QLatin1String("/configure")); if (!configureInfo.exists()) m_runAutoreconf = true; @@ -269,7 +270,7 @@ void AutoreconfStepConfigWidget::updateDetails() ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); - param.setWorkingDirectory(bc->buildDirectory()); + param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(QLatin1String("autoreconf")); param.setArguments(m_autoreconfStep->additionalArguments()); m_summaryText = param.summary(displayName()); diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp index bf07d5c593..26bdc479b6 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp @@ -59,11 +59,7 @@ using namespace ProjectExplorer::Constants; ////////////////////////////////////// AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent) : BuildConfiguration(parent, Core::Id(AUTOTOOLS_BC_ID)) -{ - AutotoolsProject *project = qobject_cast<AutotoolsProject *>(parent->project()); - if (project) - m_buildDirectory = project->defaultBuildDirectory(); -} +{ } NamedWidget *AutotoolsBuildConfiguration::createConfigWidget() { @@ -72,46 +68,15 @@ NamedWidget *AutotoolsBuildConfiguration::createConfigWidget() AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, const Core::Id id) : BuildConfiguration(parent, id) -{ -} +{ } AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, AutotoolsBuildConfiguration *source) - : BuildConfiguration(parent, source), - m_buildDirectory(source->m_buildDirectory) + : BuildConfiguration(parent, source) { cloneSteps(source); } -QVariantMap AutotoolsBuildConfiguration::toMap() const -{ - QVariantMap map = BuildConfiguration::toMap(); - map.insert(QLatin1String(BUILD_DIRECTORY_KEY), m_buildDirectory); - return map; -} - -bool AutotoolsBuildConfiguration::fromMap(const QVariantMap &map) -{ - if (!BuildConfiguration::fromMap(map)) - return false; - - m_buildDirectory = map.value(QLatin1String(BUILD_DIRECTORY_KEY)).toString(); - return true; -} - -QString AutotoolsBuildConfiguration::buildDirectory() const -{ - return m_buildDirectory; -} - -void AutotoolsBuildConfiguration::setBuildDirectory(const QString &buildDirectory) -{ - if (m_buildDirectory == buildDirectory) - return; - m_buildDirectory = buildDirectory; - emit buildDirectoryChanged(); -} - ////////////////////////////////////// // AutotoolsBuildConfiguration class ////////////////////////////////////// diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h index 639efc305d..7fb3a04792 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h @@ -39,6 +39,7 @@ namespace Internal { class AutotoolsTarget; class AutotoolsBuildConfigurationFactory; +class AutotoolsBuildSettingsWidget; class AutotoolsBuildConfiguration : public ProjectExplorer::BuildConfiguration { @@ -50,19 +51,13 @@ public: ProjectExplorer::NamedWidget *createConfigWidget(); - QString buildDirectory() const; - void setBuildDirectory(const QString &buildDirectory); - QVariantMap toMap() const; BuildType buildType() const; protected: AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, const Core::Id id); AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, AutotoolsBuildConfiguration *source); - bool fromMap(const QVariantMap &map); - -private: - QString m_buildDirectory; + friend class AutotoolsBuildSettingsWidget; }; class AutotoolsBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp index e55079283b..627510bb46 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.cpp @@ -59,15 +59,24 @@ AutotoolsBuildSettingsWidget::AutotoolsBuildSettingsWidget(AutotoolsBuildConfigu m_pathChooser = new Utils::PathChooser(this); m_pathChooser->setEnabled(true); m_pathChooser->setExpectedKind(Utils::PathChooser::Directory); + m_pathChooser->setBaseDirectory(bc->target()->project()->projectDirectory()); + m_pathChooser->setEnvironment(bc->environment()); fl->addRow(tr("Build directory:"), m_pathChooser); connect(m_pathChooser, SIGNAL(changed(QString)), this, SLOT(buildDirectoryChanged())); m_pathChooser->setBaseDirectory(bc->target()->project()->projectDirectory()); - m_pathChooser->setPath(m_buildConfiguration->buildDirectory()); + m_pathChooser->setPath(m_buildConfiguration->rawBuildDirectory().toString()); setDisplayName(tr("Autotools Manager")); + + connect(bc, SIGNAL(environmentChanged()), this, SLOT(environmentHasChanged())); } void AutotoolsBuildSettingsWidget::buildDirectoryChanged() { - m_buildConfiguration->setBuildDirectory(m_pathChooser->rawPath()); + m_buildConfiguration->setBuildDirectory(Utils::FileName::fromString(m_pathChooser->rawPath())); +} + +void AutotoolsBuildSettingsWidget::environmentHasChanged() +{ + m_pathChooser->setEnvironment(m_buildConfiguration->environment()); } diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.h b/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.h index 459fb2e234..183c2e4300 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildsettingswidget.h @@ -61,6 +61,7 @@ public: private slots: void buildDirectoryChanged(); + void environmentHasChanged(); private: Utils::PathChooser *m_pathChooser; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectconstants.h b/src/plugins/autotoolsprojectmanager/autotoolsprojectconstants.h index 382737e709..44a0c21f6d 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectconstants.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectconstants.h @@ -41,7 +41,6 @@ namespace Constants { //BuildConfiguration const char AUTOTOOLS_BC_ID[] = "AutotoolsProjectManager.AutotoolsBuildConfiguration"; - const char BUILD_DIRECTORY_KEY[] = "AutotoolsProjectManager.AutotoolsBuildConfiguration.BuildDirectory"; //Project const char AUTOTOOLS_PROJECT_ID[] = "AutotoolsProjectManager.AutotoolsProject"; diff --git a/src/plugins/autotoolsprojectmanager/configurestep.cpp b/src/plugins/autotoolsprojectmanager/configurestep.cpp index 687fcc924e..8f0b13d818 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.cpp +++ b/src/plugins/autotoolsprojectmanager/configurestep.cpp @@ -158,7 +158,7 @@ bool ConfigureStep::init() ProcessParameters *pp = processParameters(); pp->setMacroExpander(bc->macroExpander()); pp->setEnvironment(bc->environment()); - pp->setWorkingDirectory(bc->buildDirectory()); + pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(QLatin1String("configure")); pp->setArguments(additionalArguments()); pp->resolveAll(); @@ -171,8 +171,9 @@ void ConfigureStep::run(QFutureInterface<bool>& interface) BuildConfiguration *bc = buildConfiguration(); //Check whether we need to run configure - const QFileInfo configureInfo(bc->buildDirectory() + QLatin1String("/configure")); - const QFileInfo configStatusInfo(bc->buildDirectory() + QLatin1String("/config.status")); + QString buildDir = bc->buildDirectory().toString(); + const QFileInfo configureInfo(buildDir +QLatin1String("/configure")); + const QFileInfo configStatusInfo(buildDir + QLatin1String("/config.status")); if (!configStatusInfo.exists() || configStatusInfo.lastModified() < configureInfo.lastModified()) { @@ -273,7 +274,7 @@ void ConfigureStepConfigWidget::updateDetails() ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); - param.setWorkingDirectory(bc->buildDirectory()); + param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(QLatin1String("configure")); param.setArguments(m_configureStep->additionalArguments()); m_summaryText = param.summary(displayName()); diff --git a/src/plugins/autotoolsprojectmanager/makestep.cpp b/src/plugins/autotoolsprojectmanager/makestep.cpp index 2485779999..51206624c4 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.cpp +++ b/src/plugins/autotoolsprojectmanager/makestep.cpp @@ -186,7 +186,7 @@ bool MakeStep::init() // addToEnvironment() to not screw up the users run environment. env.set(QLatin1String("LC_ALL"), QLatin1String("C")); pp->setEnvironment(env); - pp->setWorkingDirectory(bc->buildDirectory()); + pp->setWorkingDirectory(bc->buildDirectory().toString()); pp->setCommand(tc ? tc->makeCommand(bc->environment()) : QLatin1String("make")); pp->setArguments(arguments); pp->resolveAll(); @@ -321,7 +321,7 @@ void MakeStepConfigWidget::updateDetails() ProcessParameters param; param.setMacroExpander(bc->macroExpander()); param.setEnvironment(bc->environment()); - param.setWorkingDirectory(bc->buildDirectory()); + param.setWorkingDirectory(bc->buildDirectory().toString()); param.setCommand(tc->makeCommand(bc->environment())); param.setArguments(arguments); m_summaryText = param.summary(displayName()); |