From fb21b78444fa2ff18fecaf45db36bd72b3dfe734 Mon Sep 17 00:00:00 2001 From: Tobias Hunger Date: Tue, 13 Aug 2019 12:47:11 +0200 Subject: Autotools: Introduce AutotoolsBuildSystem Introduce AutotoolsBuildSystem and slim down AutotoolsProject. Change-Id: I68296152f9ecd5d14198c8d0b36a06c2d1b162ec Reviewed-by: Christian Kandeler --- src/plugins/autotoolsprojectmanager/CMakeLists.txt | 2 +- .../autotoolsprojectmanager/autogenstep.cpp | 7 +- .../autotoolsprojectmanager/autoreconfstep.cpp | 6 +- .../autotoolsbuildconfiguration.cpp | 7 +- .../autotoolsbuildsystem.cpp | 209 +++++++++++++++++ .../autotoolsprojectmanager/autotoolsbuildsystem.h | 77 ++++++ .../autotoolsopenprojectwizard.cpp | 3 +- .../autotoolsprojectmanager/autotoolsproject.cpp | 257 --------------------- .../autotoolsprojectmanager/autotoolsproject.h | 97 -------- .../autotoolsprojectmanager.pro | 8 +- .../autotoolsprojectmanager.qbs | 4 +- .../autotoolsprojectplugin.cpp | 24 +- .../autotoolsprojectplugin.h | 16 ++ .../autotoolsprojectmanager/configurestep.cpp | 18 +- .../autotoolsprojectmanager/makefileparser.cpp | 7 +- src/plugins/autotoolsprojectmanager/makestep.cpp | 2 - src/plugins/projectexplorer/project.h | 2 +- 17 files changed, 343 insertions(+), 403 deletions(-) create mode 100644 src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.cpp create mode 100644 src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h delete mode 100644 src/plugins/autotoolsprojectmanager/autotoolsproject.cpp delete mode 100644 src/plugins/autotoolsprojectmanager/autotoolsproject.h diff --git a/src/plugins/autotoolsprojectmanager/CMakeLists.txt b/src/plugins/autotoolsprojectmanager/CMakeLists.txt index ca8765cba9..ac341c3eaf 100644 --- a/src/plugins/autotoolsprojectmanager/CMakeLists.txt +++ b/src/plugins/autotoolsprojectmanager/CMakeLists.txt @@ -4,8 +4,8 @@ add_qtc_plugin(AutotoolsProjectManager autogenstep.cpp autogenstep.h autoreconfstep.cpp autoreconfstep.h autotoolsbuildconfiguration.cpp autotoolsbuildconfiguration.h + autotoolsbuildsystem.cpp autotoolsbuildsystem.h autotoolsopenprojectwizard.cpp autotoolsopenprojectwizard.h - autotoolsproject.cpp autotoolsproject.h autotoolsprojectconstants.h autotoolsprojectplugin.cpp autotoolsprojectplugin.h configurestep.cpp configurestep.h diff --git a/src/plugins/autotoolsprojectmanager/autogenstep.cpp b/src/plugins/autotoolsprojectmanager/autogenstep.cpp index 1fe6520c3b..2541c1169c 100644 --- a/src/plugins/autotoolsprojectmanager/autogenstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autogenstep.cpp @@ -26,14 +26,12 @@ ****************************************************************************/ #include "autogenstep.h" + #include "autotoolsprojectconstants.h" #include -#include -#include #include -#include -#include +#include #include #include @@ -43,7 +41,6 @@ using namespace AutotoolsProjectManager::Internal; using namespace ProjectExplorer; using namespace Utils; - // AutogenStepFactory AutogenStepFactory::AutogenStepFactory() diff --git a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp index fa15515078..eeb3da1118 100644 --- a/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp +++ b/src/plugins/autotoolsprojectmanager/autoreconfstep.cpp @@ -26,14 +26,12 @@ ****************************************************************************/ #include "autoreconfstep.h" + #include "autotoolsprojectconstants.h" #include -#include -#include #include -#include -#include +#include #include using namespace AutotoolsProjectManager; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp index 64f31d6642..42f665b0e6 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildconfiguration.cpp @@ -27,18 +27,13 @@ #include "autotoolsbuildconfiguration.h" -#include "autotoolsproject.h" #include "autotoolsprojectconstants.h" -#include #include #include -#include +#include #include #include -#include -#include -#include using namespace AutotoolsProjectManager::Constants; using namespace ProjectExplorer; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.cpp b/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.cpp new file mode 100644 index 0000000000..1adf9e003d --- /dev/null +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.cpp @@ -0,0 +1,209 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Openismus GmbH. +** Author: Peter Penz (ppenz@openismus.com) +** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#include "autotoolsbuildsystem.h" + +#include "makefileparserthread.h" +#include "makestep.h" + +#include +#include +#include +#include + +#include + +using namespace ProjectExplorer; + +namespace AutotoolsProjectManager { +namespace Internal { + +AutotoolsBuildSystem::AutotoolsBuildSystem(Project *project) + : BuildSystem(project) + , m_cppCodeModelUpdater(new CppTools::CppProjectUpdater) +{ + connect(project, &Project::activeBuildConfigurationChanged, this, [this]() { requestParse(); }); + + connect(project, &Project::projectFileIsDirty, this, [this]() { requestParse(); }); +} + +AutotoolsBuildSystem::~AutotoolsBuildSystem() +{ + delete m_cppCodeModelUpdater; + + if (m_makefileParserThread) { + m_makefileParserThread->wait(); + delete m_makefileParserThread; + m_makefileParserThread = nullptr; + } +} + +void AutotoolsBuildSystem::parseProject(BuildSystem::ParsingContext &&ctx) +{ + if (m_makefileParserThread) { + // The thread is still busy parsing a previous configuration. + // Wait until the thread has been finished and delete it. + // TODO: Discuss whether blocking is acceptable. + disconnect(m_makefileParserThread, + &QThread::finished, + this, + &AutotoolsBuildSystem::makefileParsingFinished); + m_makefileParserThread->wait(); + delete m_makefileParserThread; + m_makefileParserThread = nullptr; + } + + // Parse the makefile asynchronously in a thread + m_makefileParserThread = new MakefileParserThread(project()->projectFilePath().toString(), + std::move(ctx.guard)); + + connect(m_makefileParserThread, + &MakefileParserThread::finished, + this, + &AutotoolsBuildSystem::makefileParsingFinished); + m_makefileParserThread->start(); +} + +void AutotoolsBuildSystem::makefileParsingFinished() +{ + // The finished() signal is from a previous makefile-parser-thread + // and can be skipped. This can happen, if the thread has emitted the + // finished() signal during the execution of AutotoolsBuildSystem::loadProjectTree(). + // In this case the signal is in the message queue already and deleting + // the thread of course does not remove the signal again. + if (sender() != m_makefileParserThread) + return; + + if (m_makefileParserThread->isCanceled()) { + // The parsing has been cancelled by the user. Don't show any + // project data at all. + m_makefileParserThread->deleteLater(); + m_makefileParserThread = nullptr; + return; + } + + if (m_makefileParserThread->hasError()) + qWarning("Parsing of makefile contained errors."); + + m_files.clear(); + + QVector filesToWatch; + + // Apply sources to m_files, which are returned at AutotoolsBuildSystem::files() + const QFileInfo fileInfo = project()->projectFilePath().toFileInfo(); + const QDir dir = fileInfo.absoluteDir(); + const QStringList files = m_makefileParserThread->sources(); + foreach (const QString& file, files) + m_files.append(dir.absoluteFilePath(file)); + + // Watch for changes of Makefile.am files. If a Makefile.am file + // has been changed, the project tree must be reparsed. + const QStringList makefiles = m_makefileParserThread->makefiles(); + foreach (const QString &makefile, makefiles) { + const QString absMakefile = dir.absoluteFilePath(makefile); + + m_files.append(absMakefile); + + filesToWatch.append(Utils::FilePath::fromString(absMakefile)); + } + + // Add configure.ac file to project and watch for changes. + const QLatin1String configureAc(QLatin1String("configure.ac")); + const QFile configureAcFile(fileInfo.absolutePath() + QLatin1Char('/') + configureAc); + if (configureAcFile.exists()) { + const QString absConfigureAc = dir.absoluteFilePath(configureAc); + m_files.append(absConfigureAc); + + filesToWatch.append(Utils::FilePath::fromString(absConfigureAc)); + } + + auto newRoot = std::make_unique(project()->projectDirectory()); + for (const QString &f : m_files) { + const Utils::FilePath path = Utils::FilePath::fromString(f); + newRoot->addNestedNode(std::make_unique(path, + FileNode::fileTypeForFileName(path))); + } + project()->setRootProjectNode(std::move(newRoot)); + project()->setExtraProjectFiles(filesToWatch); + + updateCppCodeModel(); + + m_makefileParserThread->deleteLater(); + m_makefileParserThread = nullptr; +} + +static QStringList filterIncludes(const QString &absSrc, const QString &absBuild, + const QStringList &in) +{ + QStringList result; + foreach (const QString i, in) { + QString out = i; + out.replace(QLatin1String("$(top_srcdir)"), absSrc); + out.replace(QLatin1String("$(abs_top_srcdir)"), absSrc); + + out.replace(QLatin1String("$(top_builddir)"), absBuild); + out.replace(QLatin1String("$(abs_top_builddir)"), absBuild); + + result << out; + } + + return result; +} + +void AutotoolsBuildSystem::updateCppCodeModel() +{ + QtSupport::CppKitInfo kitInfo(project()); + QTC_ASSERT(kitInfo.isValid(), return ); + + const Utils::FilePath projectFilePath = project()->projectFilePath(); + + CppTools::RawProjectPart rpp; + rpp.setDisplayName(project()->displayName()); + rpp.setProjectFileLocation(projectFilePath.toString()); + rpp.setQtVersion(kitInfo.projectPartQtVersion); + const QStringList cflags = m_makefileParserThread->cflags(); + QStringList cxxflags = m_makefileParserThread->cxxflags(); + if (cxxflags.isEmpty()) + cxxflags = cflags; + rpp.setFlagsForC({kitInfo.cToolChain, cflags}); + rpp.setFlagsForCxx({kitInfo.cxxToolChain, cxxflags}); + + const QString absSrc = project()->projectDirectory().toString(); + const Target *target = project()->activeTarget(); + BuildConfiguration *bc = target ? target->activeBuildConfiguration() : nullptr; + + const QString absBuild = bc ? bc->buildDirectory().toString() : QString(); + + rpp.setIncludePaths(filterIncludes(absSrc, absBuild, m_makefileParserThread->includePaths())); + rpp.setMacros(m_makefileParserThread->macros()); + rpp.setFiles(m_files); + + m_cppCodeModelUpdater->update({project(), kitInfo, project()->activeParseEnvironment(), {rpp}}); +} + +} // namespace Internal +} // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h b/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h new file mode 100644 index 0000000000..8bbad6a580 --- /dev/null +++ b/src/plugins/autotoolsprojectmanager/autotoolsbuildsystem.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2016 Openismus GmbH. +** Author: Peter Penz (ppenz@openismus.com) +** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com) +** Contact: https://www.qt.io/licensing/ +** +** This file is part of Qt Creator. +** +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3 as published by the Free Software +** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-3.0.html. +** +****************************************************************************/ + +#pragma once + +#include + +namespace Utils { class FileSystemWatcher; } + +namespace CppTools { class CppProjectUpdater; } + +namespace AutotoolsProjectManager { + +namespace Internal { + +class MakefileParserThread; + +class AutotoolsBuildSystem : public ProjectExplorer::BuildSystem +{ + Q_OBJECT + +public: + explicit AutotoolsBuildSystem(ProjectExplorer::Project *project); + ~AutotoolsBuildSystem() override; + +protected: + void parseProject(ParsingContext &&ctx) final; + +private: + /** + * 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(); + + /** + * This function is in charge of the code completion. + */ + void updateCppCodeModel(); + + /// Return value for AutotoolsProject::files() + QStringList m_files; + + /// Responsible for parsing the makefiles asynchronously in a thread + MakefileParserThread *m_makefileParserThread = nullptr; + + CppTools::CppProjectUpdater *m_cppCodeModelUpdater = nullptr; +}; + +} // namespace Internal +} // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp b/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp index cbfbe47173..ef57ca24ea 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsopenprojectwizard.cpp @@ -29,10 +29,9 @@ #include -#include +#include #include #include -#include using namespace AutotoolsProjectManager; using namespace AutotoolsProjectManager::Internal; diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp b/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp deleted file mode 100644 index 6487d424da..0000000000 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.cpp +++ /dev/null @@ -1,257 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Openismus GmbH. -** Author: Peter Penz (ppenz@openismus.com) -** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com) -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#include "autotoolsproject.h" -#include "autotoolsbuildconfiguration.h" -#include "autotoolsprojectconstants.h" -#include "autotoolsopenprojectwizard.h" -#include "makestep.h" -#include "makefileparserthread.h" - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -using namespace AutotoolsProjectManager; -using namespace AutotoolsProjectManager::Internal; -using namespace ProjectExplorer; - -AutotoolsProject::AutotoolsProject(const Utils::FilePath &fileName) - : Project(Constants::MAKEFILE_MIMETYPE, fileName) - , m_cppCodeModelUpdater(new CppTools::CppProjectUpdater) -{ - setId(Constants::AUTOTOOLS_PROJECT_ID); - setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); - setDisplayName(projectDirectory().fileName()); - - setHasMakeInstallEquivalent(true); - - connect(this, &AutotoolsProject::projectFileIsDirty, this, &AutotoolsProject::loadProjectTree); -} - -AutotoolsProject::~AutotoolsProject() -{ - delete m_cppCodeModelUpdater; - - setRootProjectNode(nullptr); - - if (m_makefileParserThread) { - m_makefileParserThread->wait(); - delete m_makefileParserThread; - m_makefileParserThread = nullptr; - } -} - -// This function, is called at the very beginning, to -// restore the settings if there are some stored. -Project::RestoreResult AutotoolsProject::fromMap(const QVariantMap &map, QString *errorMessage) -{ - RestoreResult result = Project::fromMap(map, errorMessage); - if (result != RestoreResult::Ok) - return result; - - // Load the project tree structure. - loadProjectTree(); - - if (!activeTarget()) - addTargetForDefaultKit(); - - return RestoreResult::Ok; -} - -void AutotoolsProject::loadProjectTree() -{ - if (m_makefileParserThread) { - // The thread is still busy parsing a previus configuration. - // Wait until the thread has been finished and delete it. - // TODO: Discuss whether blocking is acceptable. - disconnect(m_makefileParserThread, &QThread::finished, - this, &AutotoolsProject::makefileParsingFinished); - m_makefileParserThread->wait(); - delete m_makefileParserThread; - m_makefileParserThread = nullptr; - } - - // Parse the makefile asynchronously in a thread - m_makefileParserThread = new MakefileParserThread(projectFilePath().toString(), - guardParsingRun()); - - connect(m_makefileParserThread, &MakefileParserThread::started, - this, &AutotoolsProject::makefileParsingStarted); - - connect(m_makefileParserThread, &MakefileParserThread::finished, - this, &AutotoolsProject::makefileParsingFinished); - m_makefileParserThread->start(); -} - -void AutotoolsProject::makefileParsingStarted() -{ - QApplication::setOverrideCursor(QCursor(Qt::WaitCursor)); -} - -void AutotoolsProject::makefileParsingFinished() -{ - // The finished() signal is from a previous makefile-parser-thread - // and can be skipped. This can happen, if the thread has emitted the - // finished() signal during the execution of AutotoolsProject::loadProjectTree(). - // In this case the signal is in the message queue already and deleting - // the thread of course does not remove the signal again. - if (sender() != m_makefileParserThread) - return; - - QApplication::restoreOverrideCursor(); - - if (m_makefileParserThread->isCanceled()) { - // The parsing has been cancelled by the user. Don't show any - // project data at all. - m_makefileParserThread->deleteLater(); - m_makefileParserThread = nullptr; - return; - } - - if (m_makefileParserThread->hasError()) - qWarning("Parsing of makefile contained errors."); - - m_files.clear(); - - QVector filesToWatch; - - // Apply sources to m_files, which are returned at AutotoolsProject::files() - const QFileInfo fileInfo = projectFilePath().toFileInfo(); - const QDir dir = fileInfo.absoluteDir(); - const QStringList files = m_makefileParserThread->sources(); - foreach (const QString& file, files) - m_files.append(dir.absoluteFilePath(file)); - - // Watch for changes of Makefile.am files. If a Makefile.am file - // has been changed, the project tree must be reparsed. - const QStringList makefiles = m_makefileParserThread->makefiles(); - foreach (const QString &makefile, makefiles) { - const QString absMakefile = dir.absoluteFilePath(makefile); - - m_files.append(absMakefile); - - filesToWatch.append(Utils::FilePath::fromString(absMakefile)); - } - - // Add configure.ac file to project and watch for changes. - const QLatin1String configureAc(QLatin1String("configure.ac")); - const QFile configureAcFile(fileInfo.absolutePath() + QLatin1Char('/') + configureAc); - if (configureAcFile.exists()) { - const QString absConfigureAc = dir.absoluteFilePath(configureAc); - m_files.append(absConfigureAc); - - filesToWatch.append(Utils::FilePath::fromString(absConfigureAc)); - } - - auto newRoot = std::make_unique(projectDirectory()); - for (const QString &f : m_files) { - const Utils::FilePath path = Utils::FilePath::fromString(f); - newRoot->addNestedNode(std::make_unique(path, - FileNode::fileTypeForFileName(path))); - } - setRootProjectNode(std::move(newRoot)); - setExtraProjectFiles(filesToWatch); - - updateCppCodeModel(); - - m_makefileParserThread->deleteLater(); - m_makefileParserThread = nullptr; -} - -static QStringList filterIncludes(const QString &absSrc, const QString &absBuild, - const QStringList &in) -{ - QStringList result; - foreach (const QString i, in) { - QString out = i; - out.replace(QLatin1String("$(top_srcdir)"), absSrc); - out.replace(QLatin1String("$(abs_top_srcdir)"), absSrc); - - out.replace(QLatin1String("$(top_builddir)"), absBuild); - out.replace(QLatin1String("$(abs_top_builddir)"), absBuild); - - result << out; - } - - return result; -} - -void AutotoolsProject::updateCppCodeModel() -{ - QtSupport::CppKitInfo kitInfo(this); - QTC_ASSERT(kitInfo.isValid(), return); - - CppTools::RawProjectPart rpp; - rpp.setDisplayName(displayName()); - rpp.setProjectFileLocation(projectFilePath().toString()); - rpp.setQtVersion(kitInfo.projectPartQtVersion); - const QStringList cflags = m_makefileParserThread->cflags(); - QStringList cxxflags = m_makefileParserThread->cxxflags(); - if (cxxflags.isEmpty()) - cxxflags = cflags; - rpp.setFlagsForC({kitInfo.cToolChain, cflags}); - rpp.setFlagsForCxx({kitInfo.cxxToolChain, cxxflags}); - - const QString absSrc = projectDirectory().toString(); - const Target *target = activeTarget(); - const QString absBuild = (target && target->activeBuildConfiguration()) - ? target->activeBuildConfiguration()->buildDirectory().toString() : QString(); - - rpp.setIncludePaths(filterIncludes(absSrc, absBuild, m_makefileParserThread->includePaths())); - rpp.setMacros(m_makefileParserThread->macros()); - rpp.setFiles(m_files); - - m_cppCodeModelUpdater->update({this, kitInfo, activeParseEnvironment(), {rpp}}); -} diff --git a/src/plugins/autotoolsprojectmanager/autotoolsproject.h b/src/plugins/autotoolsprojectmanager/autotoolsproject.h deleted file mode 100644 index 44e5d81657..0000000000 --- a/src/plugins/autotoolsprojectmanager/autotoolsproject.h +++ /dev/null @@ -1,97 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2016 Openismus GmbH. -** Author: Peter Penz (ppenz@openismus.com) -** Author: Patricia Santana Cruz (patriciasantanacruz@gmail.com) -** Contact: https://www.qt.io/licensing/ -** -** This file is part of Qt Creator. -** -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 3 as published by the Free Software -** Foundation with exceptions as appearing in the file LICENSE.GPL3-EXCEPT -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-3.0.html. -** -****************************************************************************/ - -#pragma once - -#include - -#include - -namespace Utils { class FileSystemWatcher; } - -namespace CppTools { class CppProjectUpdater; } - -namespace AutotoolsProjectManager { -namespace Internal { - -class MakefileParserThread; - -/** - * @brief Implementation of the ProjectExplorer::Project interface. - * - * Loads the autotools project and embeds it into the QtCreator project tree. - * The class AutotoolsProject is the core of the autotools project plugin. - * It is responsible to parse the Makefile.am files and do trigger project - * updates if a Makefile.am file or a configure.ac file has been changed. - */ -class AutotoolsProject : public ProjectExplorer::Project -{ - Q_OBJECT - -public: - explicit AutotoolsProject(const Utils::FilePath &fileName); - ~AutotoolsProject() override; - -protected: - RestoreResult fromMap(const QVariantMap &map, QString *errorMessage) override; - -private: - /** - * Loads the project tree by parsing the makefiles. - */ - void loadProjectTree(); - - /** - * Is invoked when the makefile parsing by m_makefileParserThread has - * been started. Turns the mouse cursor into a busy cursor. - */ - void makefileParsingStarted(); - - /** - * 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(); - - /** - * This function is in charge of the code completion. - */ - void updateCppCodeModel(); - - /// Return value for AutotoolsProject::files() - QStringList m_files; - - /// Responsible for parsing the makefiles asynchronously in a thread - MakefileParserThread *m_makefileParserThread = nullptr; - - CppTools::CppProjectUpdater *m_cppCodeModelUpdater = nullptr; -}; - -} // namespace Internal -} // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro index 92b6dd8e7d..37dce96bbb 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.pro @@ -1,8 +1,8 @@ include(../../qtcreatorplugin.pri) -HEADERS = autotoolsprojectplugin.h\ +HEADERS = autotoolsbuildsystem.h \ + autotoolsprojectplugin.h\ autotoolsopenprojectwizard.h\ - autotoolsproject.h\ autotoolsbuildconfiguration.h\ autotoolsprojectconstants.h\ makestep.h\ @@ -12,9 +12,9 @@ HEADERS = autotoolsprojectplugin.h\ makefileparserthread.h\ makefileparser.h -SOURCES = autotoolsprojectplugin.cpp\ +SOURCES = autotoolsbuildsystem.cpp \ + autotoolsprojectplugin.cpp\ autotoolsopenprojectwizard.cpp\ - autotoolsproject.cpp\ autotoolsbuildconfiguration.cpp\ makestep.cpp\ autogenstep.cpp\ diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs index a6e4a2721b..75f81d09b7 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectmanager.qbs @@ -18,10 +18,10 @@ QtcPlugin { "autoreconfstep.h", "autotoolsbuildconfiguration.cpp", "autotoolsbuildconfiguration.h", + "autotoolsbuildsystem.cpp", + "autotoolsbuildsystem.h", "autotoolsopenprojectwizard.cpp", "autotoolsopenprojectwizard.h", - "autotoolsproject.cpp", - "autotoolsproject.h", "autotoolsprojectconstants.h", "autotoolsprojectplugin.cpp", "autotoolsprojectplugin.h", diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp b/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp index 5b3643dcd3..e3cd87f0ce 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.cpp @@ -26,19 +26,33 @@ ****************************************************************************/ #include "autotoolsprojectplugin.h" -#include "autotoolsproject.h" -#include "autotoolsprojectconstants.h" -#include "autotoolsbuildconfiguration.h" -#include "makestep.h" + #include "autogenstep.h" #include "autoreconfstep.h" +#include "autotoolsbuildconfiguration.h" +#include "autotoolsbuildsystem.h" +#include "autotoolsprojectconstants.h" #include "configurestep.h" +#include "makestep.h" +#include #include namespace AutotoolsProjectManager { namespace Internal { +AutotoolsProject::AutotoolsProject(const Utils::FilePath &fileName) + : Project(Constants::MAKEFILE_MIMETYPE, fileName) +{ + setId(Constants::AUTOTOOLS_PROJECT_ID); + setProjectLanguages(Core::Context(ProjectExplorer::Constants::CXX_LANGUAGE_ID)); + setDisplayName(projectDirectory().fileName()); + + setHasMakeInstallEquivalent(true); + + setBuildSystem(std::make_unique(this)); +} + class AutotoolsProjectPluginPrivate { public: @@ -69,5 +83,5 @@ bool AutotoolsProjectPlugin::initialize(const QStringList &arguments, return true; } -} // Internal +} // namespace Internal } // AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.h b/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.h index dd08cbd1c8..bdf319150f 100644 --- a/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.h +++ b/src/plugins/autotoolsprojectmanager/autotoolsprojectplugin.h @@ -27,6 +27,8 @@ #pragma once +#include + #include namespace AutotoolsProjectManager { @@ -73,5 +75,19 @@ class AutotoolsProjectPlugin : public ExtensionSystem::IPlugin class AutotoolsProjectPluginPrivate *d; }; +/** + * @brief Implementation of the ProjectExplorer::Project interface. + * + * Loads the autotools project and embeds it into the QtCreator project tree. + * The class AutotoolsProject is the core of the autotools project plugin. + * It is responsible to parse the Makefile.am files and do trigger project + * updates if a Makefile.am file or a configure.ac file has been changed. + */ +class AutotoolsProject : public ProjectExplorer::Project +{ +public: + explicit AutotoolsProject(const Utils::FilePath &fileName); +}; + } // namespace Internal } // namespace AutotoolsProjectManager diff --git a/src/plugins/autotoolsprojectmanager/configurestep.cpp b/src/plugins/autotoolsprojectmanager/configurestep.cpp index 53f4c71a3e..c722aa3a9f 100644 --- a/src/plugins/autotoolsprojectmanager/configurestep.cpp +++ b/src/plugins/autotoolsprojectmanager/configurestep.cpp @@ -26,23 +26,16 @@ ****************************************************************************/ #include "configurestep.h" -#include "autotoolsproject.h" + #include "autotoolsbuildconfiguration.h" #include "autotoolsprojectconstants.h" -#include -#include -#include -#include #include -#include -#include -#include +#include +#include -#include #include -#include -#include +#include using namespace AutotoolsProjectManager; using namespace AutotoolsProjectManager::Internal; @@ -55,7 +48,7 @@ using namespace Utils; static QString projectDirRelativeToBuildDir(BuildConfiguration *bc) { const QDir buildDir(bc->buildDirectory().toString()); QString projDirToBuildDir = buildDir.relativeFilePath( - bc->target()->project()->projectDirectory().toString()); + bc->project()->projectDirectory().toString()); if (projDirToBuildDir.isEmpty()) return QString("./"); if (!projDirToBuildDir.endsWith('/')) @@ -106,7 +99,6 @@ ConfigureStep::ConfigureStep(BuildStepList *bsl) return param.summaryInWorkdir(displayName()); }); - } bool ConfigureStep::init() diff --git a/src/plugins/autotoolsprojectmanager/makefileparser.cpp b/src/plugins/autotoolsprojectmanager/makefileparser.cpp index 39596a724e..8c379ee823 100644 --- a/src/plugins/autotoolsprojectmanager/makefileparser.cpp +++ b/src/plugins/autotoolsprojectmanager/makefileparser.cpp @@ -30,10 +30,9 @@ #include #include -#include #include -#include -#include +#include +#include using namespace AutotoolsProjectManager::Internal; @@ -49,7 +48,7 @@ bool MakefileParser::parse() { m_mutex.lock(); m_cancel = false; - m_mutex.unlock(), + m_mutex.unlock(); m_success = true; m_executable.clear(); diff --git a/src/plugins/autotoolsprojectmanager/makestep.cpp b/src/plugins/autotoolsprojectmanager/makestep.cpp index 14b58c8368..7a7fbbddb3 100644 --- a/src/plugins/autotoolsprojectmanager/makestep.cpp +++ b/src/plugins/autotoolsprojectmanager/makestep.cpp @@ -26,9 +26,7 @@ ****************************************************************************/ #include "makestep.h" -#include "autotoolsproject.h" #include "autotoolsprojectconstants.h" -#include "autotoolsbuildconfiguration.h" #include #include diff --git a/src/plugins/projectexplorer/project.h b/src/plugins/projectexplorer/project.h index c4f29f0d1a..9c4f38fecb 100644 --- a/src/plugins/projectexplorer/project.h +++ b/src/plugins/projectexplorer/project.h @@ -232,6 +232,7 @@ public: // FIXME: Make this private and the BuildSystem a friend ParseGuard guardParsingRun() { return ParseGuard(this); } + void setRootProjectNode(std::unique_ptr &&root); // Set project files that will be watched and trigger the same callback // as the main project file. @@ -285,7 +286,6 @@ protected: void setCanBuildProducts(); void setId(Core::Id id); - void setRootProjectNode(std::unique_ptr &&root); // takes ownership! void setProjectLanguages(Core::Context language); void addProjectLanguage(Core::Id id); void removeProjectLanguage(Core::Id id); -- cgit v1.2.1