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

View File

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

View File

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

View File

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