Autotools: Hide AutotoolsBuildSystem definition in .cpp

Change-Id: I7ef251452c522593da955a64024068682f7fdfb1
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
This commit is contained in:
hjk
2024-07-19 14:35:13 +02:00
parent e7dcbb6b44
commit e9e793fb6a
5 changed files with 42 additions and 41 deletions

View File

@@ -12,6 +12,8 @@
#include <qtsupport/qtcppkitinfo.h>
#include <solutions/tasking/tasktreerunner.h>
#include <utils/async.h>
#include <utils/qtcassert.h>
@@ -21,6 +23,33 @@ using namespace Utils;
namespace AutotoolsProjectManager::Internal {
class AutotoolsBuildSystem final : public BuildSystem
{
public:
explicit AutotoolsBuildSystem(Target *target);
~AutotoolsBuildSystem() final;
private:
void triggerParsing() final;
QString name() const final { return QLatin1String("autotools"); }
/**
* Is invoked when the makefile parsing by m_makefileParserThread has
* been finished. Adds all sources and files into the project tree and
* takes care listen to file changes for Makefile.am and configure.ac
* files.
*/
void makefileParsingFinished(const MakefileParserOutputData &outputData);
/// Return value for AutotoolsProject::files()
QStringList m_files;
/// Responsible for parsing the makefiles asynchronously in a thread
Tasking::TaskTreeRunner m_parserRunner;
std::unique_ptr<ProjectUpdater> m_cppCodeModelUpdater;
};
AutotoolsBuildSystem::AutotoolsBuildSystem(Target *target)
: BuildSystem(target)
, m_cppCodeModelUpdater(ProjectUpdaterFactory::createCppProjectUpdater())
@@ -147,6 +176,12 @@ void AutotoolsBuildSystem::makefileParsingFinished(const MakefileParserOutputDat
m_cppCodeModelUpdater->update({project(), kitInfo, activeParseEnvironment(), {rpp}});
emitBuildSystemUpdated();}
emitBuildSystemUpdated();
}
BuildSystem *createAutotoolsBuildSystem(Target *target)
{
return new AutotoolsBuildSystem(target);
}
} // AutotoolsProjectManager::Internal

View File

@@ -5,39 +5,8 @@
#include <projectexplorer/buildsystem.h>
#include <solutions/tasking/tasktreerunner.h>
namespace ProjectExplorer { class ProjectUpdater; }
namespace AutotoolsProjectManager::Internal {
class MakefileParserOutputData;
class AutotoolsBuildSystem final : public ProjectExplorer::BuildSystem
{
public:
explicit AutotoolsBuildSystem(ProjectExplorer::Target *target);
~AutotoolsBuildSystem() final;
private:
void triggerParsing() final;
QString name() const final { return QLatin1String("autotools"); }
/**
* Is invoked when the makefile parsing by m_makefileParserThread has
* been finished. Adds all sources and files into the project tree and
* takes care listen to file changes for Makefile.am and configure.ac
* files.
*/
void makefileParsingFinished(const MakefileParserOutputData &outputData);
/// Return value for AutotoolsProject::files()
QStringList m_files;
/// Responsible for parsing the makefiles asynchronously in a thread
Tasking::TaskTreeRunner m_parserRunner;
std::unique_ptr<ProjectExplorer::ProjectUpdater> m_cppCodeModelUpdater;
};
ProjectExplorer::BuildSystem *createAutotoolsBuildSystem(ProjectExplorer::Target *target);
} // AutotoolsProjectManager::Internal

View File

@@ -14,7 +14,6 @@
#include <projectexplorer/projectexplorerconstants.h>
#include <projectexplorer/project.h>
#include <projectexplorer/projectmanager.h>
#include <projectexplorer/target.h>
#include <extensionsystem/iplugin.h>
@@ -41,10 +40,8 @@ public:
setId(Constants::AUTOTOOLS_PROJECT_ID);
setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID));
setDisplayName(projectDirectory().fileName());
setHasMakeInstallEquivalent(true);
setBuildSystemCreator<AutotoolsBuildSystem>();
setBuildSystemCreator(&createAutotoolsBuildSystem);
}
};

View File

@@ -1032,7 +1032,7 @@ Task Project::createProjectTask(Task::TaskType type, const QString &description)
return Task(type, description, FilePath(), -1, Id());
}
void Project::setBuildSystemCreatorImpl(const std::function<BuildSystem *(Target *)> &creator)
void Project::setBuildSystemCreator(const std::function<BuildSystem *(Target *)> &creator)
{
d->m_buildSystemCreator = creator;
}

View File

@@ -234,11 +234,11 @@ protected:
const QString &description);
template <typename BuildSystemImpl>
void setBuildSystemCreator() {
setBuildSystemCreatorImpl([](Target *t) { return new BuildSystemImpl(t); });
setBuildSystemCreator([](Target *t) { return new BuildSystemImpl(t); });
}
private:
void setBuildSystemCreatorImpl(const std::function<BuildSystem *(Target *)> &creator);
void setBuildSystemCreator(const std::function<BuildSystem *(Target *)> &creator);
private:
void addTarget(std::unique_ptr<Target> &&target);
void addProjectLanguage(Utils::Id id);