AutoTools: Prefer build step ids for setting up the build configuration

Essentially a proof-of-concept that knowing the actual classes is
not needed.

Change-Id: I82b1664c93a25e418860bda77f66ec77144cf658
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
hjk
2019-06-26 12:48:53 +02:00
parent 7ebfa87dc2
commit 5d6c84777a
6 changed files with 30 additions and 38 deletions

View File

@@ -43,15 +43,12 @@ using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
const char AUTOGEN_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.AutogenStep.AdditionalArguments";
const char AUTOGEN_STEP_ID[] = "AutotoolsProjectManager.AutogenStep";
// AutogenStepFactory // AutogenStepFactory
AutogenStepFactory::AutogenStepFactory() AutogenStepFactory::AutogenStepFactory()
{ {
registerStep<AutogenStep>(AUTOGEN_STEP_ID); registerStep<AutogenStep>(Constants::AUTOGEN_STEP_ID);
setDisplayName(AutogenStep::tr("Autogen", "Display name for AutotoolsProjectManager::AutogenStep id.")); setDisplayName(AutogenStep::tr("Autogen", "Display name for AutotoolsProjectManager::AutogenStep id."));
setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
@@ -60,12 +57,13 @@ AutogenStepFactory::AutogenStepFactory()
// AutogenStep // AutogenStep
AutogenStep::AutogenStep(BuildStepList *bsl) : AbstractProcessStep(bsl, AUTOGEN_STEP_ID) AutogenStep::AutogenStep(BuildStepList *bsl) : AbstractProcessStep(bsl, Constants::AUTOGEN_STEP_ID)
{ {
setDefaultDisplayName(tr("Autogen")); setDefaultDisplayName(tr("Autogen"));
m_additionalArgumentsAspect = addAspect<BaseStringAspect>(); m_additionalArgumentsAspect = addAspect<BaseStringAspect>();
m_additionalArgumentsAspect->setSettingsKey(AUTOGEN_ADDITIONAL_ARGUMENTS_KEY); m_additionalArgumentsAspect->setSettingsKey(
"AutotoolsProjectManager.AutogenStep.AdditionalArguments");
m_additionalArgumentsAspect->setLabelText(tr("Arguments:")); m_additionalArgumentsAspect->setLabelText(tr("Arguments:"));
m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs"); m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.AutogenStepArgs");

View File

@@ -40,14 +40,11 @@ using namespace AutotoolsProjectManager;
using namespace AutotoolsProjectManager::Internal; using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
const char AUTORECONF_STEP_ID[] = "AutotoolsProjectManager.AutoreconfStep";
// AutoreconfStepFactory class // AutoreconfStepFactory class
AutoreconfStepFactory::AutoreconfStepFactory() AutoreconfStepFactory::AutoreconfStepFactory()
{ {
registerStep<AutoreconfStep>(AUTORECONF_STEP_ID); registerStep<AutoreconfStep>(Constants::AUTORECONF_STEP_ID);
setDisplayName(AutoreconfStep::tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id.")); setDisplayName(AutoreconfStep::tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id."));
setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
@@ -56,7 +53,8 @@ AutoreconfStepFactory::AutoreconfStepFactory()
// AutoreconfStep class // AutoreconfStep class
AutoreconfStep::AutoreconfStep(BuildStepList *bsl) : AbstractProcessStep(bsl, AUTORECONF_STEP_ID) AutoreconfStep::AutoreconfStep(BuildStepList *bsl)
: AbstractProcessStep(bsl, Constants::AUTORECONF_STEP_ID)
{ {
setDefaultDisplayName(tr("Autoreconf")); setDefaultDisplayName(tr("Autoreconf"));

View File

@@ -26,12 +26,9 @@
****************************************************************************/ ****************************************************************************/
#include "autotoolsbuildconfiguration.h" #include "autotoolsbuildconfiguration.h"
#include "makestep.h"
#include "autotoolsproject.h" #include "autotoolsproject.h"
#include "autotoolsprojectconstants.h" #include "autotoolsprojectconstants.h"
#include "autogenstep.h"
#include "autoreconfstep.h"
#include "configurestep.h"
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
#include <projectexplorer/buildinfo.h> #include <projectexplorer/buildinfo.h>
@@ -72,26 +69,20 @@ void AutotoolsBuildConfiguration::initialize(const BuildInfo &info)
// ### Build Steps Build ### // ### Build Steps Build ###
// autogen.sh or autoreconf // autogen.sh or autoreconf
QFile autogenFile(target()->project()->projectDirectory().toString() + "/autogen.sh"); QFile autogenFile(target()->project()->projectDirectory().toString() + "/autogen.sh");
if (autogenFile.exists()) { if (autogenFile.exists())
auto autogenStep = new AutogenStep(buildSteps); buildSteps->appendStep(Constants::AUTOGEN_STEP_ID);
buildSteps->appendStep(autogenStep); else
} else { buildSteps->appendStep(Constants::AUTORECONF_STEP_ID);
auto autoreconfStep = new AutoreconfStep(buildSteps);
buildSteps->appendStep(autoreconfStep);
}
// ./configure. // ./configure.
auto configureStep = new ConfigureStep(buildSteps); buildSteps->appendStep(Constants::CONFIGURE_STEP_ID);
buildSteps->appendStep(configureStep);
// make // make
auto makeStep = new MakeStep(buildSteps); buildSteps->appendStep(Constants::MAKE_STEP_ID);
buildSteps->appendStep(makeStep);
// ### Build Steps Clean ### // ### Build Steps Clean ###
BuildStepList *cleanSteps = stepList(BUILDSTEPS_CLEAN); BuildStepList *cleanSteps = stepList(BUILDSTEPS_CLEAN);
auto cleanMakeStep = new MakeStep(cleanSteps); cleanSteps->appendStep(Constants::MAKE_STEP_ID);
cleanSteps->appendStep(cleanMakeStep);
} }

View File

@@ -32,9 +32,17 @@ namespace AutotoolsProjectManager {
* Collects project constants, that are shared between several classes. * Collects project constants, that are shared between several classes.
*/ */
namespace Constants { namespace Constants {
const char MAKEFILE_MIMETYPE[] = "text/x-makefile";
const char MAKEFILE_MIMETYPE[] = "text/x-makefile";
// Steps
const char AUTOGEN_STEP_ID[] = "AutotoolsProjectManager.AutogenStep";
const char AUTORECONF_STEP_ID[] = "AutotoolsProjectManager.AutoreconfStep";
const char CONFIGURE_STEP_ID[] = "AutotoolsProjectManager.ConfigureStep";
const char MAKE_STEP_ID[] = "AutotoolsProjectManager.MakeStep";
//Project //Project
const char AUTOTOOLS_PROJECT_ID[] = "AutotoolsProjectManager.AutotoolsProject"; const char AUTOTOOLS_PROJECT_ID[] = "AutotoolsProjectManager.AutotoolsProject";
} // namespace Constants } // namespace Constants
} // namespace AutotoolsProjectManager } // namespace AutotoolsProjectManager

View File

@@ -49,9 +49,6 @@ using namespace AutotoolsProjectManager::Internal;
using namespace ProjectExplorer; using namespace ProjectExplorer;
using namespace Utils; using namespace Utils;
const char CONFIGURE_ADDITIONAL_ARGUMENTS_KEY[] = "AutotoolsProjectManager.ConfigureStep.AdditionalArguments";
const char CONFIGURE_STEP_ID[] = "AutotoolsProjectManager.ConfigureStep";
///////////////////// /////////////////////
// Helper Function // Helper Function
///////////////////// /////////////////////
@@ -71,7 +68,7 @@ static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) {
ConfigureStepFactory::ConfigureStepFactory() ConfigureStepFactory::ConfigureStepFactory()
{ {
registerStep<ConfigureStep>(CONFIGURE_STEP_ID); registerStep<ConfigureStep>(Constants::CONFIGURE_STEP_ID);
setDisplayName(ConfigureStep::tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id.")); setDisplayName(ConfigureStep::tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id."));
setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID);
setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD);
@@ -80,13 +77,15 @@ ConfigureStepFactory::ConfigureStepFactory()
// ConfigureStep // ConfigureStep
ConfigureStep::ConfigureStep(BuildStepList *bsl) : AbstractProcessStep(bsl, CONFIGURE_STEP_ID) ConfigureStep::ConfigureStep(BuildStepList *bsl)
: AbstractProcessStep(bsl, Constants::CONFIGURE_STEP_ID)
{ {
setDefaultDisplayName(tr("Configure")); setDefaultDisplayName(tr("Configure"));
m_additionalArgumentsAspect = addAspect<BaseStringAspect>(); m_additionalArgumentsAspect = addAspect<BaseStringAspect>();
m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay); m_additionalArgumentsAspect->setDisplayStyle(BaseStringAspect::LineEditDisplay);
m_additionalArgumentsAspect->setSettingsKey(CONFIGURE_ADDITIONAL_ARGUMENTS_KEY); m_additionalArgumentsAspect->setSettingsKey(
"AutotoolsProjectManager.ConfigureStep.AdditionalArguments");
m_additionalArgumentsAspect->setLabelText(tr("Arguments:")); m_additionalArgumentsAspect->setLabelText(tr("Arguments:"));
m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.ConfigureArgs"); m_additionalArgumentsAspect->setHistoryCompleter("AutotoolsPM.History.ConfigureArgs");

View File

@@ -37,8 +37,6 @@ using namespace AutotoolsProjectManager;
using namespace AutotoolsProjectManager::Internal; using namespace AutotoolsProjectManager::Internal;
using namespace AutotoolsProjectManager::Constants; using namespace AutotoolsProjectManager::Constants;
const char MAKE_STEP_ID[] = "AutotoolsProjectManager.MakeStep";
// MakeStepFactory // MakeStepFactory
MakeStepFactory::MakeStepFactory() MakeStepFactory::MakeStepFactory()