AutoTools: Simplify build step implementations

... and make it usable remotely.

Change-Id: Ib19b661ba5cbb7b8a585c0b130dd672605ff0506
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
hjk
2023-01-17 15:51:29 +01:00
parent d995b650ab
commit 77e7f0e314
4 changed files with 23 additions and 50 deletions

View File

@@ -52,12 +52,12 @@ AutogenStep::AutogenStep(BuildStepList *bsl, Id id) : AbstractProcessStep(bsl, i
arguments->setDisplayStyle(StringAspect::LineEditDisplay); arguments->setDisplayStyle(StringAspect::LineEditDisplay);
arguments->setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs"); arguments->setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs");
connect(arguments, &BaseAspect::changed, this, [this] { connect(arguments, &BaseAspect::changed, this, [this] { m_runAutogen = true; });
m_runAutogen = true;
});
setCommandLineProvider([arguments] { setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
return CommandLine(FilePath("./autogen.sh"),
setCommandLineProvider([this, arguments] {
return CommandLine(project()->projectDirectory() / "autogen.sh",
arguments->value(), arguments->value(),
CommandLine::Raw); CommandLine::Raw);
}); });
@@ -72,14 +72,14 @@ AutogenStep::AutogenStep(BuildStepList *bsl, Id id) : AbstractProcessStep(bsl, i
void AutogenStep::doRun() void AutogenStep::doRun()
{ {
// Check whether we need to run autogen.sh // Check whether we need to run autogen.sh
const QString projectDir = project()->projectDirectory().toString(); const FilePath projectDir = project()->projectDirectory();
const QFileInfo configureInfo(projectDir + "/configure"); const FilePath configure = projectDir / "configure";
const QFileInfo configureAcInfo(projectDir + "/configure.ac"); const FilePath configureAc = projectDir / "configure.ac";
const QFileInfo makefileAmInfo(projectDir + "/Makefile.am"); const FilePath makefileAm = projectDir / "Makefile.am";
if (!configureInfo.exists() if (!configure.exists()
|| configureInfo.lastModified() < configureAcInfo.lastModified() || configure.lastModified() < configureAc.lastModified()
|| configureInfo.lastModified() < makefileAmInfo.lastModified()) { || configure.lastModified() < makefileAm.lastModified()) {
m_runAutogen = true; m_runAutogen = true;
} }

View File

@@ -20,7 +20,7 @@ using namespace Utils;
namespace AutotoolsProjectManager::Internal { namespace AutotoolsProjectManager::Internal {
// AutoreconfStep class // AutoreconfStep
/** /**
* @brief Implementation of the ProjectExplorer::AbstractProcessStep interface. * @brief Implementation of the ProjectExplorer::AbstractProcessStep interface.
@@ -72,9 +72,8 @@ AutoreconfStep::AutoreconfStep(BuildStepList *bsl, Id id)
void AutoreconfStep::doRun() void AutoreconfStep::doRun()
{ {
// Check whether we need to run autoreconf // Check whether we need to run autoreconf
const QString projectDir(project()->projectDirectory().toString()); const FilePath configure = project()->projectDirectory() / "configure";
if (!configure.exists())
if (!QFileInfo::exists(projectDir + "/configure"))
m_runAutoreconf = true; m_runAutoreconf = true;
if (!m_runAutoreconf) { if (!m_runAutoreconf) {
@@ -88,7 +87,7 @@ void AutoreconfStep::doRun()
AbstractProcessStep::doRun(); AbstractProcessStep::doRun();
} }
// AutoreconfStepFactory class // AutoreconfStepFactory
/** /**
* @brief Implementation of the ProjectExplorer::IBuildStepFactory interface. * @brief Implementation of the ProjectExplorer::IBuildStepFactory interface.

View File

@@ -15,27 +15,12 @@
#include <utils/aspects.h> #include <utils/aspects.h>
#include <QDateTime> #include <QDateTime>
#include <QDir>
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
namespace AutotoolsProjectManager::Internal { namespace AutotoolsProjectManager::Internal {
// Helper Function
static QString projectDirRelativeToBuildDir(BuildConfiguration *bc)
{
const QDir buildDir(bc->buildDirectory().toString());
QString projDirToBuildDir = buildDir.relativeFilePath(
bc->project()->projectDirectory().toString());
if (projDirToBuildDir.isEmpty())
return QString("./");
if (!projDirToBuildDir.endsWith('/'))
projDirToBuildDir.append('/');
return projDirToBuildDir;
}
// ConfigureStep // ConfigureStep
///** ///**
@@ -77,8 +62,6 @@ ConfigureStep::ConfigureStep(BuildStepList *bsl, Id id)
m_runConfigure = true; m_runConfigure = true;
}); });
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
setCommandLineProvider([this, arguments] { setCommandLineProvider([this, arguments] {
return getCommandLine(arguments->value()); return getCommandLine(arguments->value());
}); });
@@ -93,24 +76,17 @@ ConfigureStep::ConfigureStep(BuildStepList *bsl, Id id)
CommandLine ConfigureStep::getCommandLine(const QString &arguments) CommandLine ConfigureStep::getCommandLine(const QString &arguments)
{ {
BuildConfiguration *bc = buildConfiguration(); return {project()->projectDirectory() / "configure", arguments, CommandLine::Raw};
return CommandLine({FilePath::fromString(projectDirRelativeToBuildDir(bc) + "configure"),
arguments,
CommandLine::Raw});
} }
void ConfigureStep::doRun() void ConfigureStep::doRun()
{ {
//Check whether we need to run configure // Check whether we need to run configure
const QString projectDir(project()->projectDirectory().toString()); const FilePath configure = project()->projectDirectory() / "configure";
const QFileInfo configureInfo(projectDir + "/configure"); const FilePath configStatus = buildDirectory() / "config.status";
const QFileInfo configStatusInfo(buildDirectory().toString() + "/config.status");
if (!configStatusInfo.exists() if (!configStatus.exists() || configStatus.lastModified() < configure.lastModified())
|| configStatusInfo.lastModified() < configureInfo.lastModified()) {
m_runConfigure = true; m_runConfigure = true;
}
if (!m_runConfigure) { if (!m_runConfigure) {
emit addOutput(Tr::tr("Configuration unchanged, skipping configure step."), OutputFormat::NormalMessage); emit addOutput(Tr::tr("Configuration unchanged, skipping configure step."), OutputFormat::NormalMessage);

View File

@@ -7,8 +7,6 @@
#include <projectexplorer/buildsteplist.h> #include <projectexplorer/buildsteplist.h>
#include <projectexplorer/projectexplorerconstants.h> #include <projectexplorer/projectexplorerconstants.h>
using namespace AutotoolsProjectManager::Constants;
namespace AutotoolsProjectManager::Internal { namespace AutotoolsProjectManager::Internal {
// MakeStep // MakeStep
@@ -33,9 +31,9 @@ public:
MakeStepFactory::MakeStepFactory() MakeStepFactory::MakeStepFactory()
{ {
registerStep<MakeStep>(MAKE_STEP_ID); registerStep<MakeStep>(Constants::MAKE_STEP_ID);
setDisplayName(ProjectExplorer::MakeStep::defaultDisplayName()); setDisplayName(ProjectExplorer::MakeStep::defaultDisplayName());
setSupportedProjectType(AUTOTOOLS_PROJECT_ID); setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID);
} }
} // AutotoolsProjectManager::Internal } // AutotoolsProjectManager::Internal