Commit 0d8dd285 authored by Ray Donnelly's avatar Ray Donnelly Committed by Tobias Hunger
Browse files

autotools: Allow builds to be done in buildDir



configure is called using a relative path from buildDir
to the project directory and the configure command line
is updated to reflect changes to buildDir.

Change-Id: Ia9e8eef446efd21b6dcedef4668ff03adfd8a20c
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarDaniel Teske <daniel.teske@digia.com>
parent 600514be
......@@ -158,8 +158,9 @@ bool AutogenStep::init()
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
pp->setWorkingDirectory(bc->buildDirectory().toString());
pp->setCommand(QLatin1String("autogen.sh"));
const QString projectDir(bc->target()->project()->projectDirectory().toString());
pp->setWorkingDirectory(projectDir);
pp->setCommand(QLatin1String("./autogen.sh"));
pp->setArguments(additionalArguments());
pp->resolveAll();
......@@ -171,10 +172,10 @@ void AutogenStep::run(QFutureInterface<bool> &interface)
BuildConfiguration *bc = buildConfiguration();
// Check whether we need to run autogen.sh
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"));
const QString projectDir(bc->target()->project()->projectDirectory().toString());
const QFileInfo configureInfo(projectDir + QLatin1String("/configure"));
const QFileInfo configureAcInfo(projectDir + QLatin1String("/configure.ac"));
const QFileInfo makefileAmInfo(projectDir + QLatin1String("/Makefile.am"));
if (!configureInfo.exists()
|| configureInfo.lastModified() < configureAcInfo.lastModified()
......@@ -276,8 +277,9 @@ void AutogenStepConfigWidget::updateDetails()
ProcessParameters param;
param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory().toString());
param.setCommand(QLatin1String("autogen.sh"));
const QString projectDir(bc->target()->project()->projectDirectory().toString());
param.setWorkingDirectory(projectDir);
param.setCommand(QLatin1String("./autogen.sh"));
param.setArguments(m_autogenStep->additionalArguments());
m_summaryText = param.summary(displayName());
emit updateSummary();
......
......@@ -157,7 +157,8 @@ bool AutoreconfStep::init()
ProcessParameters *pp = processParameters();
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
pp->setWorkingDirectory(bc->buildDirectory().toString());
const QString projectDir(bc->target()->project()->projectDirectory().toString());
pp->setWorkingDirectory(projectDir);
pp->setCommand(QLatin1String("autoreconf"));
pp->setArguments(additionalArguments());
pp->resolveAll();
......@@ -170,8 +171,8 @@ void AutoreconfStep::run(QFutureInterface<bool> &interface)
BuildConfiguration *bc = buildConfiguration();
// Check whether we need to run autoreconf
const QString buildDir = bc->buildDirectory().toString();
const QFileInfo configureInfo(buildDir + QLatin1String("/configure"));
const QString projectDir(bc->target()->project()->projectDirectory().toString());
const QFileInfo configureInfo(projectDir + QLatin1String("/configure"));
if (!configureInfo.exists())
m_runAutoreconf = true;
......@@ -270,7 +271,8 @@ void AutoreconfStepConfigWidget::updateDetails()
ProcessParameters param;
param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory().toString());
const QString projectDir(bc->target()->project()->projectDirectory().toString());
param.setWorkingDirectory(projectDir);
param.setCommand(QLatin1String("autoreconf"));
param.setArguments(m_autoreconfStep->additionalArguments());
m_summaryText = param.summary(displayName());
......
......@@ -223,3 +223,17 @@ BuildConfiguration::BuildType AutotoolsBuildConfiguration::buildType() const
// TODO: Should I return something different from Unknown?
return Unknown;
}
void AutotoolsBuildConfiguration::setBuildDirectory(const Utils::FileName &directory)
{
if (directory == buildDirectory())
return;
BuildConfiguration::setBuildDirectory(directory);
ProjectExplorer::BuildStepList *bsl = stepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
foreach (BuildStep *bs, bsl->steps()) {
ConfigureStep *cs = qobject_cast<ConfigureStep *>(bs);
if (cs) {
cs->notifyBuildDirectoryChanged();
}
}
}
......@@ -60,6 +60,9 @@ protected:
AutotoolsBuildConfiguration(ProjectExplorer::Target *parent, AutotoolsBuildConfiguration *source);
friend class AutotoolsBuildSettingsWidget;
private:
void setBuildDirectory(const Utils::FileName &directory);
};
class AutotoolsBuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
......
......@@ -54,6 +54,20 @@ using namespace ProjectExplorer;
const char CONFIGURE_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.ConfigureStep.AdditionalArguments";
const char CONFIGURE_STEP_ID[] = "AutotoolsProjectManager.ConfigureStep";
/////////////////////
// Helper Function
/////////////////////
static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) {
const QDir buildDir(bc->buildDirectory().toString());
QString projDirToBuildDir = buildDir.relativeFilePath(
bc->target()->project()->projectDirectory().toString());
if (projDirToBuildDir.isEmpty())
return QLatin1String("./");
if (!projDirToBuildDir.endsWith(QLatin1Char('/')))
projDirToBuildDir.append(QLatin1Char('/'));
return projDirToBuildDir;
}
////////////////////////////////
// ConfigureStepFactory Class
////////////////////////////////
......@@ -159,7 +173,7 @@ bool ConfigureStep::init()
pp->setMacroExpander(bc->macroExpander());
pp->setEnvironment(bc->environment());
pp->setWorkingDirectory(bc->buildDirectory().toString());
pp->setCommand(QLatin1String("configure"));
pp->setCommand(projectDirRelativeToBuildDir(bc) + QLatin1String("configure"));
pp->setArguments(additionalArguments());
pp->resolveAll();
......@@ -171,9 +185,9 @@ void ConfigureStep::run(QFutureInterface<bool>& interface)
BuildConfiguration *bc = buildConfiguration();
//Check whether we need to run configure
QString buildDir = bc->buildDirectory().toString();
const QFileInfo configureInfo(buildDir +QLatin1String("/configure"));
const QFileInfo configStatusInfo(buildDir + QLatin1String("/config.status"));
const QString projectDir(bc->target()->project()->projectDirectory().toString());
const QFileInfo configureInfo(projectDir + QLatin1String("/configure"));
const QFileInfo configStatusInfo(bc->buildDirectory().toString() + QLatin1String("/config.status"));
if (!configStatusInfo.exists()
|| configStatusInfo.lastModified() < configureInfo.lastModified()) {
......@@ -212,6 +226,11 @@ void ConfigureStep::setAdditionalArguments(const QString &list)
emit additionalArgumentsChanged(list);
}
void ConfigureStep::notifyBuildDirectoryChanged()
{
emit buildDirectoryChanged();
}
QString ConfigureStep::additionalArguments() const
{
return m_additionalArguments;
......@@ -255,6 +274,8 @@ ConfigureStepConfigWidget::ConfigureStepConfigWidget(ConfigureStep *configureSte
configureStep, SLOT(setAdditionalArguments(QString)));
connect(configureStep, SIGNAL(additionalArgumentsChanged(QString)),
this, SLOT(updateDetails()));
connect(configureStep, SIGNAL(buildDirectoryChanged(void)),
this, SLOT(updateDetails()));
}
QString ConfigureStepConfigWidget::displayName() const
......@@ -275,7 +296,7 @@ void ConfigureStepConfigWidget::updateDetails()
param.setMacroExpander(bc->macroExpander());
param.setEnvironment(bc->environment());
param.setWorkingDirectory(bc->buildDirectory().toString());
param.setCommand(QLatin1String("configure"));
param.setCommand(projectDirRelativeToBuildDir(bc) + QLatin1String("configure"));
param.setArguments(m_configureStep->additionalArguments());
m_summaryText = param.summary(displayName());
emit updateSummary();
......
......@@ -103,9 +103,11 @@ public:
public slots:
void setAdditionalArguments(const QString &list);
void notifyBuildDirectoryChanged();
signals:
void additionalArgumentsChanged(const QString &);
void buildDirectoryChanged();
protected:
ConfigureStep(ProjectExplorer::BuildStepList *bsl, ConfigureStep *bs);
......
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