2022-08-19 15:59:36 +02:00
|
|
|
// Copyright (C) 2016 Openismus GmbH.
|
2022-12-21 10:12:09 +01:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
#include "autogenstep.h"
|
2019-08-13 12:47:11 +02:00
|
|
|
|
2011-11-29 14:19:28 +01:00
|
|
|
#include "autotoolsprojectconstants.h"
|
2022-09-29 17:11:01 +02:00
|
|
|
#include "autotoolsprojectmanagertr.h"
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2020-01-09 14:00:22 +01:00
|
|
|
#include <projectexplorer/abstractprocessstep.h>
|
2018-10-17 13:01:19 +02:00
|
|
|
#include <projectexplorer/buildconfiguration.h>
|
2018-11-17 21:19:04 +02:00
|
|
|
#include <projectexplorer/processparameters.h>
|
2019-08-13 12:47:11 +02:00
|
|
|
#include <projectexplorer/project.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <projectexplorer/projectexplorerconstants.h>
|
2018-10-17 13:01:19 +02:00
|
|
|
#include <projectexplorer/target.h>
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2020-09-18 12:11:40 +02:00
|
|
|
#include <utils/aspects.h>
|
2023-07-12 14:20:01 +02:00
|
|
|
#include <utils/process.h>
|
2020-09-18 12:11:40 +02:00
|
|
|
|
2012-02-15 10:42:41 +01:00
|
|
|
#include <QDateTime>
|
2011-11-29 14:19:28 +01:00
|
|
|
|
|
|
|
|
using namespace ProjectExplorer;
|
2019-06-21 08:31:37 +02:00
|
|
|
using namespace Utils;
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2022-09-29 17:11:01 +02:00
|
|
|
namespace AutotoolsProjectManager::Internal {
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2020-01-09 14:00:22 +01:00
|
|
|
// AutogenStep
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Implementation of the ProjectExplorer::AbstractProcessStep interface.
|
|
|
|
|
*
|
|
|
|
|
* A autogen step can be configured by selecting the "Projects" button of Qt Creator
|
|
|
|
|
* (in the left hand side menu) and under "Build Settings".
|
|
|
|
|
*
|
|
|
|
|
* It is possible for the user to specify custom arguments.
|
|
|
|
|
*/
|
|
|
|
|
|
2020-10-05 12:42:37 +02:00
|
|
|
class AutogenStep final : public AbstractProcessStep
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2020-01-09 14:00:22 +01:00
|
|
|
public:
|
2020-10-05 12:42:37 +02:00
|
|
|
AutogenStep(BuildStepList *bsl, Id id);
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2020-01-09 14:00:22 +01:00
|
|
|
private:
|
2023-07-12 16:30:33 +02:00
|
|
|
Tasking::GroupItem runRecipe() final;
|
2020-01-09 14:00:22 +01:00
|
|
|
|
|
|
|
|
bool m_runAutogen = false;
|
2023-06-01 16:36:33 +02:00
|
|
|
StringAspect m_arguments{this};
|
2020-01-09 14:00:22 +01:00
|
|
|
};
|
2011-11-29 14:19:28 +01:00
|
|
|
|
2020-10-05 12:42:37 +02:00
|
|
|
AutogenStep::AutogenStep(BuildStepList *bsl, Id id) : AbstractProcessStep(bsl, id)
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2023-06-01 16:36:33 +02:00
|
|
|
m_arguments.setSettingsKey("AutotoolsProjectManager.AutogenStep.AdditionalArguments");
|
|
|
|
|
m_arguments.setLabelText(Tr::tr("Arguments:"));
|
|
|
|
|
m_arguments.setDisplayStyle(StringAspect::LineEditDisplay);
|
|
|
|
|
m_arguments.setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs");
|
2020-10-05 12:42:37 +02:00
|
|
|
|
2023-06-01 16:36:33 +02:00
|
|
|
connect(&m_arguments, &BaseAspect::changed, this, [this] { m_runAutogen = true; });
|
2023-01-17 15:51:29 +01:00
|
|
|
|
|
|
|
|
setWorkingDirectoryProvider([this] { return project()->projectDirectory(); });
|
2019-06-25 10:41:32 +02:00
|
|
|
|
2023-06-01 16:36:33 +02:00
|
|
|
setCommandLineProvider([this] {
|
2023-01-17 15:51:29 +01:00
|
|
|
return CommandLine(project()->projectDirectory() / "autogen.sh",
|
2023-06-01 16:36:33 +02:00
|
|
|
m_arguments(),
|
2020-08-13 16:48:25 +02:00
|
|
|
CommandLine::Raw);
|
|
|
|
|
});
|
|
|
|
|
|
2019-06-25 10:41:32 +02:00
|
|
|
setSummaryUpdater([this] {
|
|
|
|
|
ProcessParameters param;
|
2020-08-13 16:48:25 +02:00
|
|
|
setupProcessParameters(¶m);
|
2019-06-25 10:41:32 +02:00
|
|
|
return param.summary(displayName());
|
|
|
|
|
});
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
|
|
|
|
|
2023-07-12 16:30:33 +02:00
|
|
|
Tasking::GroupItem AutogenStep::runRecipe()
|
2011-11-29 14:19:28 +01:00
|
|
|
{
|
2023-07-12 14:20:01 +02:00
|
|
|
using namespace Tasking;
|
|
|
|
|
|
|
|
|
|
const auto onSetup = [this] {
|
|
|
|
|
// Check whether we need to run autogen.sh
|
|
|
|
|
const FilePath projectDir = project()->projectDirectory();
|
|
|
|
|
const FilePath configure = projectDir / "configure";
|
|
|
|
|
const FilePath configureAc = projectDir / "configure.ac";
|
|
|
|
|
const FilePath makefileAm = projectDir / "Makefile.am";
|
|
|
|
|
|
|
|
|
|
if (!configure.exists()
|
|
|
|
|
|| configure.lastModified() < configureAc.lastModified()
|
|
|
|
|
|| configure.lastModified() < makefileAm.lastModified()) {
|
|
|
|
|
m_runAutogen = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!m_runAutogen) {
|
|
|
|
|
emit addOutput(Tr::tr("Configuration unchanged, skipping autogen step."),
|
|
|
|
|
OutputFormat::NormalMessage);
|
2023-11-04 12:57:23 +01:00
|
|
|
return SetupResult::StopWithSuccess;
|
2023-07-12 14:20:01 +02:00
|
|
|
}
|
|
|
|
|
return SetupResult::Continue;
|
|
|
|
|
};
|
|
|
|
|
|
2023-11-03 18:50:32 +01:00
|
|
|
return Group {
|
|
|
|
|
onGroupSetup(onSetup),
|
|
|
|
|
onGroupDone([this] { m_runAutogen = false; }, CallDoneIf::Success),
|
|
|
|
|
defaultProcessTask()
|
|
|
|
|
};
|
2011-11-29 14:19:28 +01:00
|
|
|
}
|
2020-01-09 14:00:22 +01:00
|
|
|
|
|
|
|
|
// AutogenStepFactory
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @brief Implementation of the ProjectExplorer::BuildStepFactory interface.
|
|
|
|
|
*
|
|
|
|
|
* This factory is used to create instances of AutogenStep.
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
AutogenStepFactory::AutogenStepFactory()
|
|
|
|
|
{
|
|
|
|
|
registerStep<AutogenStep>(Constants::AUTOGEN_STEP_ID);
|
2022-09-29 17:11:01 +02:00
|
|
|
setDisplayName(Tr::tr("Autogen", "Display name for AutotoolsProjectManager::AutogenStep id."));
|
2020-01-09 14:00:22 +01:00
|
|
|
setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID);
|
|
|
|
|
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
|
|
|
|
|
}
|
|
|
|
|
|
2022-09-29 17:11:01 +02:00
|
|
|
} // AutotoolsProjectManager::Internal
|