From 9686e91bd549f5d071e32ce387b69fdd3ad60171 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 9 Jan 2020 14:00:22 +0100 Subject: [PATCH] Autotools: De-Q_OBJECT-ify build related classes Only used for translations, and that can be achieved much cheaper without the extra translation units created by moc. This reduces the size of the autotoolsprojectmanagers/.obj build dir from 23220 kB to 17696 kB for my debug buld. Take the opportunity to sprinkle in a few 'final'. Change-Id: I85b36c6b8ca58469d0906f1105b2b1587b7c7e6c Reviewed-by: Eike Ziller --- .../autotoolsprojectmanager/autogenstep.cpp | 61 ++++++++++++---- .../autotoolsprojectmanager/autogenstep.h | 40 +---------- .../autoreconfstep.cpp | 59 +++++++++++---- .../autotoolsprojectmanager/autoreconfstep.h | 40 +---------- .../autotoolsbuildconfiguration.cpp | 44 ++++++------ .../autotoolsbuildconfiguration.h | 8 --- .../autotoolsbuildsystem.h | 6 +- .../autotoolsprojectplugin.cpp | 1 + .../autotoolsprojectmanager/configurestep.cpp | 72 ++++++++++++++----- .../autotoolsprojectmanager/configurestep.h | 43 +---------- .../autotoolsprojectmanager/makestep.cpp | 30 +++++--- .../autotoolsprojectmanager/makestep.h | 16 +---- 12 files changed, 204 insertions(+), 216 deletions(-) diff --git a/src/plugins/autotoolsprojectmanager/autogenstep.cpp b/src/plugins/autotoolsprojectmanager/autogenstep.cpp index 0d3ef11ff70..07bc98024ed 100644 --- a/src/plugins/autotoolsprojectmanager/autogenstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autogenstep.cpp @@ -29,31 +29,47 @@ #include "autotoolsprojectconstants.h" +#include #include #include +#include #include #include #include -using namespace AutotoolsProjectManager; -using namespace AutotoolsProjectManager::Internal; using namespace ProjectExplorer; using namespace Utils; -// AutogenStepFactory - -AutogenStepFactory::AutogenStepFactory() -{ - registerStep(Constants::AUTOGEN_STEP_ID); - setDisplayName(AutogenStep::tr("Autogen", "Display name for AutotoolsProjectManager::AutogenStep id.")); - setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); - setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); -} - +namespace AutotoolsProjectManager { +namespace Internal { // 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. + */ + +class AutogenStep : public AbstractProcessStep +{ + Q_DECLARE_TR_FUNCTIONS(AutotoolsProjectManager::Internal::AutogenStep) + +public: + AutogenStep(BuildStepList *bsl, Core::Id id); + +private: + bool init() override; + void doRun() override; + + BaseStringAspect *m_additionalArgumentsAspect = nullptr; + bool m_runAutogen = false; +}; + AutogenStep::AutogenStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id) { setDefaultDisplayName(tr("Autogen")); @@ -104,7 +120,7 @@ void AutogenStep::doRun() BuildConfiguration *bc = buildConfiguration(); // Check whether we need to run autogen.sh - const QString projectDir(bc->target()->project()->projectDirectory().toString()); + const QString projectDir = bc->target()->project()->projectDirectory().toString(); const QFileInfo configureInfo(projectDir + "/configure"); const QFileInfo configureAcInfo(projectDir + "/configure.ac"); const QFileInfo makefileAmInfo(projectDir + "/Makefile.am"); @@ -124,3 +140,22 @@ void AutogenStep::doRun() m_runAutogen = false; AbstractProcessStep::doRun(); } + +// AutogenStepFactory + +/** + * @brief Implementation of the ProjectExplorer::BuildStepFactory interface. + * + * This factory is used to create instances of AutogenStep. + */ + +AutogenStepFactory::AutogenStepFactory() +{ + registerStep(Constants::AUTOGEN_STEP_ID); + setDisplayName(AutogenStep::tr("Autogen", "Display name for AutotoolsProjectManager::AutogenStep id.")); + setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); +} + +} // Internal +} // AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autogenstep.h b/src/plugins/autotoolsprojectmanager/autogenstep.h index b0e2c6c553a..0d2c7eaa9a6 100644 --- a/src/plugins/autotoolsprojectmanager/autogenstep.h +++ b/src/plugins/autotoolsprojectmanager/autogenstep.h @@ -27,52 +27,16 @@ #pragma once -#include -#include +#include namespace AutotoolsProjectManager { namespace Internal { -///////////////////////////// -// AutogenStepFactory class -///////////////////////////// -/** - * @brief Implementation of the ProjectExplorer::IBuildStepFactory interface. - * - * This factory is used to create instances of AutogenStep. - */ -class AutogenStepFactory : public ProjectExplorer::BuildStepFactory +class AutogenStepFactory final : public ProjectExplorer::BuildStepFactory { public: AutogenStepFactory(); }; -/////////////////////// -// AutogenStep class -/////////////////////// -/** - * @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. - */ - -class AutogenStep : public ProjectExplorer::AbstractProcessStep -{ - Q_OBJECT - -public: - AutogenStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); - -private: - bool init() override; - void doRun() override; - - ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; - bool m_runAutogen = false; -}; - } // namespace Internal } // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp index 40f43f2596d..d3651e6f3b7 100644 --- a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp @@ -29,28 +29,44 @@ #include "autotoolsprojectconstants.h" +#include #include #include #include +#include #include -using namespace AutotoolsProjectManager; -using namespace AutotoolsProjectManager::Internal; using namespace ProjectExplorer; -// AutoreconfStepFactory class - -AutoreconfStepFactory::AutoreconfStepFactory() -{ - registerStep(Constants::AUTORECONF_STEP_ID); - setDisplayName(AutoreconfStep::tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id.")); - setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); - setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); -} - +namespace AutotoolsProjectManager { +namespace Internal { // AutoreconfStep class +/** + * @brief Implementation of the ProjectExplorer::AbstractProcessStep interface. + * + * A autoreconf 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. + */ + +class AutoreconfStep : public AbstractProcessStep +{ + Q_DECLARE_TR_FUNCTIONS(AutotoolsProjectManager::Internal::AutoreconfStep) + +public: + AutoreconfStep(BuildStepList *bsl, Core::Id id); + + bool init() override; + void doRun() override; + +private: + BaseStringAspect *m_additionalArgumentsAspect = nullptr; + bool m_runAutoreconf = false; +}; + AutoreconfStep::AutoreconfStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id) { @@ -115,3 +131,22 @@ void AutoreconfStep::doRun() m_runAutoreconf = false; AbstractProcessStep::doRun(); } + +// AutoreconfStepFactory class + +/** + * @brief Implementation of the ProjectExplorer::IBuildStepFactory interface. + * + * The factory is used to create instances of AutoreconfStep. + */ + +AutoreconfStepFactory::AutoreconfStepFactory() +{ + registerStep(Constants::AUTORECONF_STEP_ID); + setDisplayName(AutoreconfStep::tr("Autoreconf", "Display name for AutotoolsProjectManager::AutoreconfStep id.")); + setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); +} + +} // Internal +} // AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autoreconfstep.h b/src/plugins/autotoolsprojectmanager/autoreconfstep.h index 35ff0e6859d..338fed5e865 100644 --- a/src/plugins/autotoolsprojectmanager/autoreconfstep.h +++ b/src/plugins/autotoolsprojectmanager/autoreconfstep.h @@ -27,52 +27,16 @@ #pragma once -#include -#include +#include namespace AutotoolsProjectManager { namespace Internal { -//////////////////////////////// -// AutoreconfStepFactory class -//////////////////////////////// -/** - * @brief Implementation of the ProjectExplorer::IBuildStepFactory interface. - * - * The factory is used to create instances of AutoreconfStep. - */ -class AutoreconfStepFactory : public ProjectExplorer::BuildStepFactory +class AutoreconfStepFactory final : public ProjectExplorer::BuildStepFactory { public: AutoreconfStepFactory(); }; -///////////////////////// -// AutoreconfStep class -///////////////////////// -/** - * @brief Implementation of the ProjectExplorer::AbstractProcessStep interface. - * - * A autoreconf 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. - */ - -class AutoreconfStep : public ProjectExplorer::AbstractProcessStep -{ - Q_OBJECT - -public: - AutoreconfStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); - - bool init() override; - void doRun() override; - -private: - ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; - bool m_runAutoreconf = false; -}; - } // namespace Internal } // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp index 257d547f36f..f2b069d6d1a 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp @@ -35,9 +35,7 @@ #include #include -using namespace AutotoolsProjectManager::Constants; using namespace ProjectExplorer; -using namespace ProjectExplorer::Constants; using namespace Utils; namespace AutotoolsProjectManager { @@ -45,28 +43,34 @@ namespace Internal { // AutotoolsBuildConfiguration -AutotoolsBuildConfiguration::AutotoolsBuildConfiguration(Target *target, Core::Id id) - : BuildConfiguration(target, id) +class AutotoolsBuildConfiguration : public BuildConfiguration { - // / is used so the un-changed check in setBuildDirectory() works correctly. - // The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory. - setBuildDirectory(Utils::FilePath::fromString("/")); - setBuildDirectoryHistoryCompleter("AutoTools.BuildDir.History"); - setConfigWidgetDisplayName(tr("Autotools Manager")); + Q_DECLARE_TR_FUNCTIONS(AutotoolsProjectManager::Internal::AutotoolsBuildConfiguration) - // ### Build Steps Build ### - QFile autogenFile(target->project()->projectDirectory().toString() + "/autogen.sh"); - if (autogenFile.exists()) - appendInitialBuildStep(Constants::AUTOGEN_STEP_ID); // autogen.sh - else - appendInitialBuildStep(Constants::AUTORECONF_STEP_ID); // autoreconf +public: + AutotoolsBuildConfiguration(Target *target, Core::Id id) + : BuildConfiguration(target, id) + { + // / is used so the un-changed check in setBuildDirectory() works correctly. + // The leading / is to avoid the relative the path expansion in BuildConfiguration::buildDirectory. + setBuildDirectory(Utils::FilePath::fromString("/")); + setBuildDirectoryHistoryCompleter("AutoTools.BuildDir.History"); + setConfigWidgetDisplayName(tr("Autotools Manager")); - appendInitialBuildStep(Constants::CONFIGURE_STEP_ID); // ./configure. - appendInitialBuildStep(Constants::MAKE_STEP_ID); // make + // ### Build Steps Build ### + QFile autogenFile(target->project()->projectDirectory().toString() + "/autogen.sh"); + if (autogenFile.exists()) + appendInitialBuildStep(Constants::AUTOGEN_STEP_ID); // autogen.sh + else + appendInitialBuildStep(Constants::AUTORECONF_STEP_ID); // autoreconf - // ### Build Steps Clean ### - appendInitialBuildStep(Constants::MAKE_STEP_ID); -} + appendInitialBuildStep(Constants::CONFIGURE_STEP_ID); // ./configure. + appendInitialBuildStep(Constants::MAKE_STEP_ID); // make + + // ### Build Steps Clean ### + appendInitialBuildStep(Constants::MAKE_STEP_ID); + } +}; AutotoolsBuildConfigurationFactory::AutotoolsBuildConfigurationFactory() { diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h index 1e6fa46fbae..031849e4d47 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.h @@ -32,14 +32,6 @@ namespace AutotoolsProjectManager { namespace Internal { -class AutotoolsBuildConfiguration : public ProjectExplorer::BuildConfiguration -{ - Q_OBJECT - - friend class ProjectExplorer::BuildConfigurationFactory; - AutotoolsBuildConfiguration(ProjectExplorer::Target *target, Core::Id id); -}; - class AutotoolsBuildConfigurationFactory final : public ProjectExplorer::BuildConfigurationFactory { public: diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h b/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h index 3af006b0948..d4f1e0f80a8 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h @@ -36,13 +36,11 @@ namespace Internal { class MakefileParserThread; -class AutotoolsBuildSystem : public ProjectExplorer::BuildSystem +class AutotoolsBuildSystem final : public ProjectExplorer::BuildSystem { - Q_OBJECT - public: explicit AutotoolsBuildSystem(ProjectExplorer::Target *target); - ~AutotoolsBuildSystem() override; + ~AutotoolsBuildSystem() final; private: void triggerParsing() final; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp b/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp index 6aaf8f64a23..3851fefc2f7 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp @@ -37,6 +37,7 @@ #include +#include #include #include diff --git a/src/plugins/autotoolsprojectmanager/configurestep.cpp b/src/plugins/autotoolsprojectmanager/configurestep.cpp index 35d00a17cc2..044e8fd4c76 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.cpp +++ b/src/plugins/autotoolsprojectmanager/configurestep.cpp @@ -30,22 +30,25 @@ #include "autotoolsbuildconfiguration.h" #include "autotoolsprojectconstants.h" +#include #include +#include #include #include #include #include -using namespace AutotoolsProjectManager; -using namespace AutotoolsProjectManager::Internal; using namespace ProjectExplorer; using namespace Utils; -///////////////////// +namespace AutotoolsProjectManager { +namespace Internal { + // Helper Function -///////////////////// -static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) { + +static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) +{ const QDir buildDir(bc->buildDirectory().toString()); QString projDirToBuildDir = buildDir.relativeFilePath( bc->project()->projectDirectory().toString()); @@ -56,20 +59,36 @@ static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) { return projDirToBuildDir; } - -// ConfigureStepFactory - -ConfigureStepFactory::ConfigureStepFactory() -{ - registerStep(Constants::CONFIGURE_STEP_ID); - setDisplayName(ConfigureStep::tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id.")); - setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); - setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); -} - - // ConfigureStep +///** +// * @brief Implementation of the ProjectExplorer::AbstractProcessStep interface. +// * +// * A configure 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. The corresponding +// * configuration widget is created by MakeStep::createConfigWidget and is +// * represented by an instance of the class MakeStepConfigWidget. +// */ + +class ConfigureStep : public ProjectExplorer::AbstractProcessStep +{ + Q_DECLARE_TR_FUNCTIONS(AutotoolsProjectManager::Internal::ConfigureStep) + +public: + ConfigureStep(BuildStepList *bsl, Core::Id id); + + void setAdditionalArguments(const QString &list); + +private: + bool init() override; + void doRun() override; + + ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; + bool m_runConfigure = false; +}; + ConfigureStep::ConfigureStep(BuildStepList *bsl, Core::Id id) : AbstractProcessStep(bsl, id) { @@ -139,3 +158,22 @@ void ConfigureStep::doRun() m_runConfigure = false; AbstractProcessStep::doRun(); } + +// ConfigureStepFactory + +/** + * @brief Implementation of the ProjectExplorer::IBuildStepFactory interface. + * + * The factory is used to create instances of ConfigureStep. + */ + +ConfigureStepFactory::ConfigureStepFactory() +{ + registerStep(Constants::CONFIGURE_STEP_ID); + setDisplayName(ConfigureStep::tr("Configure", "Display name for AutotoolsProjectManager::ConfigureStep id.")); + setSupportedProjectType(Constants::AUTOTOOLS_PROJECT_ID); + setSupportedStepList(ProjectExplorer::Constants::BUILDSTEPS_BUILD); +} + +} // namespace Internal +} // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/configurestep.h b/src/plugins/autotoolsprojectmanager/configurestep.h index b2e15de1d6f..8ec1239f8c0 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.h +++ b/src/plugins/autotoolsprojectmanager/configurestep.h @@ -27,55 +27,16 @@ #pragma once -#include -#include +#include namespace AutotoolsProjectManager { namespace Internal { -////////////////////////////////// -// ConfigureStepFactory Class -////////////////////////////////// -/** - * @brief Implementation of the ProjectExplorer::IBuildStepFactory interface. - * - * The factory is used to create instances of ConfigureStep. - */ -class ConfigureStepFactory : public ProjectExplorer::BuildStepFactory +class ConfigureStepFactory final : public ProjectExplorer::BuildStepFactory { public: ConfigureStepFactory(); }; -////////////////////////// -//// ConfigureStep class -////////////////////////// -///** -// * @brief Implementation of the ProjectExplorer::AbstractProcessStep interface. -// * -// * A configure 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. The corresponding -// * configuration widget is created by MakeStep::createConfigWidget and is -// * represented by an instance of the class MakeStepConfigWidget. -// */ -class ConfigureStep : public ProjectExplorer::AbstractProcessStep -{ - Q_OBJECT - -public: - ConfigureStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); - - void setAdditionalArguments(const QString &list); - -private: - bool init() override; - void doRun() override; - - ProjectExplorer::BaseStringAspect *m_additionalArgumentsAspect = nullptr; - bool m_runConfigure = false; -}; - } // namespace Internal } // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/makestep.cpp b/src/plugins/autotoolsprojectmanager/makestep.cpp index 2905ca9597b..2ab3d684b49 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.cpp +++ b/src/plugins/autotoolsprojectmanager/makestep.cpp @@ -31,21 +31,19 @@ #include #include -using namespace AutotoolsProjectManager; -using namespace AutotoolsProjectManager::Internal; using namespace AutotoolsProjectManager::Constants; -// MakeStepFactory - -MakeStepFactory::MakeStepFactory() -{ - registerStep(MAKE_STEP_ID); - setDisplayName(ProjectExplorer::MakeStep::defaultDisplayName()); - setSupportedProjectType(AUTOTOOLS_PROJECT_ID); -} +namespace AutotoolsProjectManager { +namespace Internal { // MakeStep +class MakeStep : public ProjectExplorer::MakeStep +{ +public: + MakeStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); +}; + MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl, Core::Id id) : ProjectExplorer::MakeStep(bsl, id) { @@ -57,3 +55,15 @@ MakeStep::MakeStep(ProjectExplorer::BuildStepList *bsl, Core::Id id) setBuildTarget("all", true); } } + +// MakeStepFactory + +MakeStepFactory::MakeStepFactory() +{ + registerStep(MAKE_STEP_ID); + setDisplayName(ProjectExplorer::MakeStep::defaultDisplayName()); + setSupportedProjectType(AUTOTOOLS_PROJECT_ID); +} + +} // Internal +} // AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/makestep.h b/src/plugins/autotoolsprojectmanager/makestep.h index 211913bb3f6..389eac723d4 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.h +++ b/src/plugins/autotoolsprojectmanager/makestep.h @@ -32,25 +32,11 @@ namespace AutotoolsProjectManager { namespace Internal { -/////////////////////////// -// MakeStepFactory class -/////////////////////////// -class MakeStepFactory : public ProjectExplorer::BuildStepFactory +class MakeStepFactory final : public ProjectExplorer::BuildStepFactory { public: MakeStepFactory(); }; -///////////////////// -// MakeStep class -///////////////////// -class MakeStep : public ProjectExplorer::MakeStep -{ - Q_OBJECT - -public: - MakeStep(ProjectExplorer::BuildStepList *bsl, Core::Id id); -}; - } // namespace Internal } // namespace AutotoolsProjectManager