diff options
author | Jake Petroules <jake.petroules@petroules.com> | 2014-07-16 11:33:49 -0400 |
---|---|---|
committer | Jake Petroules <jake.petroules@petroules.com> | 2015-02-12 02:22:42 +0000 |
commit | 5447c56a01ac944900026e4634ef1c6e285eda00 (patch) | |
tree | 8bc2c2f96a760468f37d71fb737ac07f119c3fbd /src | |
parent | 2e9bb43b47f27641f3ad166665aec5a5e00a8c77 (diff) |
Add an API to support build system generators.
More generally, a plugin-based API to support performing arbitrary
operations producing some output given a resolved qbs project.
Task-number: QBS-658
Change-Id: I5c0c3652520ec17e751ad9980bc186dde58e48d1
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'src')
22 files changed, 559 insertions, 2 deletions
diff --git a/src/app/qbs/commandlinefrontend.cpp b/src/app/qbs/commandlinefrontend.cpp index e40dbb566..50332a700 100644 --- a/src/app/qbs/commandlinefrontend.cpp +++ b/src/app/qbs/commandlinefrontend.cpp @@ -342,6 +342,10 @@ void CommandLineFrontend::handleProjectsResolved() if (m_cancelStatus != CancelStatusNone) throw ErrorInfo(Tr::tr("Execution canceled.")); switch (m_parser.command()) { + case GenerateCommandType: + generate(); + qApp->quit(); + break; case ResolveCommandType: qApp->quit(); break; @@ -463,6 +467,28 @@ void CommandLineFrontend::build() m_currentBuildEffort = 0; } +void CommandLineFrontend::generate() +{ + const QString generatorName = m_parser.generateOptions().generatorName(); + QSharedPointer<ProjectGenerator> generator(ProjectGeneratorManager::findGenerator(generatorName)); + if (!generator) { + const QString generatorNames = ProjectGeneratorManager::loadedGeneratorNames() + .join(QLatin1String("\n\t")); + if (generatorName.isEmpty()) { + throw ErrorInfo(Tr::tr("No generator specified. Available generators:\n\t%1") + .arg(generatorNames)); + } + + throw ErrorInfo(Tr::tr("No generator named '%1'. Available generators:\n\t%2") + .arg(generatorName) + .arg(generatorNames)); + } + + generator->clearProjects(); + generator->addProjects(m_projects); + generator->generate(m_parser.installOptions()); +} + int CommandLineFrontend::runTarget() { try { diff --git a/src/app/qbs/commandlinefrontend.h b/src/app/qbs/commandlinefrontend.h index ee315499b..df5c3f2aa 100644 --- a/src/app/qbs/commandlinefrontend.h +++ b/src/app/qbs/commandlinefrontend.h @@ -80,6 +80,7 @@ private: void makeClean(); int runShell(); void build(); + void generate(); int runTarget(); void updateTimestamps(); void dumpNodesTree(); diff --git a/src/app/qbs/parser/command.cpp b/src/app/qbs/parser/command.cpp index bfe58cfed..2426d2076 100644 --- a/src/app/qbs/parser/command.cpp +++ b/src/app/qbs/parser/command.cpp @@ -188,6 +188,36 @@ QList<CommandLineOption::Type> ResolveCommand::supportedOptions() const return resolveOptions(); } +QString GenerateCommand::shortDescription() const +{ + return Tr::tr("Generate files for another build tool."); +} + +QString GenerateCommand::longDescription() const +{ + QString description = Tr::tr("qbs %1 [options] [[variant] [property:value] ...] ...\n") + .arg(representation()); + description += Tr::tr("Generates project files to build the project using another build tool."); + return description += supportedOptionsDescription(); +} + +QString GenerateCommand::representation() const +{ + return QLatin1String("generate"); +} + +QList<CommandLineOption::Type> GenerateCommand::supportedOptions() const +{ + return QList<CommandLineOption::Type>() + << CommandLineOption::FileOptionType + << CommandLineOption::LogLevelOptionType + << CommandLineOption::VerboseOptionType + << CommandLineOption::QuietOptionType + << CommandLineOption::ShowProgressOptionType + << CommandLineOption::LogTimeOptionType + << CommandLineOption::GeneratorOptionType; +} + QString BuildCommand::shortDescription() const { return Tr::tr("Build (parts of) a project. This is the default command."); diff --git a/src/app/qbs/parser/command.h b/src/app/qbs/parser/command.h index 51f07b7fe..cf6510a87 100644 --- a/src/app/qbs/parser/command.h +++ b/src/app/qbs/parser/command.h @@ -81,6 +81,19 @@ private: QList<CommandLineOption::Type> supportedOptions() const; }; +class GenerateCommand : public Command +{ +public: + GenerateCommand(CommandLineOptionPool &optionPool) : Command(optionPool) {} + +private: + CommandType type() const { return GenerateCommandType; } + QString shortDescription() const; + QString longDescription() const; + QString representation() const; + QList<CommandLineOption::Type> supportedOptions() const; +}; + class BuildCommand : public Command { public: diff --git a/src/app/qbs/parser/commandlineoption.cpp b/src/app/qbs/parser/commandlineoption.cpp index a6b791c27..5d3c661b6 100644 --- a/src/app/qbs/parser/commandlineoption.cpp +++ b/src/app/qbs/parser/commandlineoption.cpp @@ -115,6 +115,33 @@ void BuildDirectoryOption::doParse(const QString &representation, QStringList &i m_projectBuildDirectory = getArgument(representation, input); } +QString GeneratorOption::description(CommandType command) const +{ + Q_UNUSED(command); + return Tr::tr("%1|%2 <generator>\n" + "\tUse the given build system generator.\n") + .arg(longRepresentation(), shortRepresentation()); +} + +QString GeneratorOption::shortRepresentation() const +{ + return QLatin1String("-g"); +} + +QString GeneratorOption::longRepresentation() const +{ + return QLatin1String("--generator"); +} + +void GeneratorOption::doParse(const QString &representation, QStringList &input) +{ + m_generatorName = getArgument(representation, input); + if (m_generatorName.isEmpty()) { + throw ErrorInfo(Tr::tr("Invalid use of option '%1': No generator given.\nUsage: %2") + .arg(representation, description(command()))); + } +} + static QString loglevelLongRepresentation() { return QLatin1String("--log-level"); } QString VerboseOption::description(CommandType command) const diff --git a/src/app/qbs/parser/commandlineoption.h b/src/app/qbs/parser/commandlineoption.h index a319365d7..7ffa18074 100644 --- a/src/app/qbs/parser/commandlineoption.h +++ b/src/app/qbs/parser/commandlineoption.h @@ -57,7 +57,8 @@ public: BuildNonDefaultOptionType, LogTimeOptionType, ShowCommandLinesOptionType, - SettingsDirOptionType + SettingsDirOptionType, + GeneratorOptionType }; virtual ~CommandLineOption(); @@ -109,6 +110,21 @@ private: QString m_projectBuildDirectory; }; +class GeneratorOption : public CommandLineOption +{ +public: + QString generatorName() const { return m_generatorName; } + +private: + QString description(CommandType command) const; + QString shortRepresentation() const; + QString longRepresentation() const; + void doParse(const QString &representation, QStringList &input); + +private: + QString m_generatorName; +}; + class CountingOption : public CommandLineOption { public: diff --git a/src/app/qbs/parser/commandlineoptionpool.cpp b/src/app/qbs/parser/commandlineoptionpool.cpp index b5298dab5..dcd734002 100644 --- a/src/app/qbs/parser/commandlineoptionpool.cpp +++ b/src/app/qbs/parser/commandlineoptionpool.cpp @@ -107,6 +107,9 @@ CommandLineOption *CommandLineOptionPool::getOption(CommandLineOption::Type type case CommandLineOption::SettingsDirOptionType: option = new SettingsDirOption; break; + case CommandLineOption::GeneratorOptionType: + option = new GeneratorOption; + break; default: qFatal("Unknown option type %d", type); } @@ -227,4 +230,9 @@ SettingsDirOption *CommandLineOptionPool::settingsDirOption() const return static_cast<SettingsDirOption *>(getOption(CommandLineOption::SettingsDirOptionType)); } +GeneratorOption *CommandLineOptionPool::generatorOption() const +{ + return static_cast<GeneratorOption *>(getOption(CommandLineOption::GeneratorOptionType)); +} + } // namespace qbs diff --git a/src/app/qbs/parser/commandlineoptionpool.h b/src/app/qbs/parser/commandlineoptionpool.h index e3eafaadc..76c89bb38 100644 --- a/src/app/qbs/parser/commandlineoptionpool.h +++ b/src/app/qbs/parser/commandlineoptionpool.h @@ -64,6 +64,7 @@ public: LogTimeOption *logTimeOption() const; ShowCommandLinesOption *showCommandLinesOption() const; SettingsDirOption *settingsDirOption() const; + GeneratorOption *generatorOption() const; private: mutable QHash<CommandLineOption::Type, CommandLineOption *> m_options; diff --git a/src/app/qbs/parser/commandlineparser.cpp b/src/app/qbs/parser/commandlineparser.cpp index 675285c1c..5cf445b05 100644 --- a/src/app/qbs/parser/commandlineparser.cpp +++ b/src/app/qbs/parser/commandlineparser.cpp @@ -41,6 +41,7 @@ #include <tools/buildoptions.h> #include <tools/cleanoptions.h> #include <tools/error.h> +#include <tools/generateoptions.h> #include <tools/hostosinfo.h> #include <tools/installoptions.h> #include <tools/preferences.h> @@ -157,6 +158,14 @@ CleanOptions CommandLineParser::cleanOptions() const return options; } +GenerateOptions CommandLineParser::generateOptions() const +{ + Q_ASSERT(command() == GenerateCommandType); + GenerateOptions options; + options.setGeneratorName(d->optionPool.generatorOption()->generatorName()); + return options; +} + InstallOptions CommandLineParser::installOptions() const { Q_ASSERT(command() == InstallCommandType || command() == RunCommandType); @@ -365,6 +374,7 @@ Command *CommandLineParser::CommandLineParserPrivate::commandFromString(const QS QList<Command *> CommandLineParser::CommandLineParserPrivate::allCommands() const { return QList<Command *>() + << commandPool.getCommand(GenerateCommandType) << commandPool.getCommand(ResolveCommandType) << commandPool.getCommand(BuildCommandType) << commandPool.getCommand(CleanCommandType) diff --git a/src/app/qbs/parser/commandlineparser.h b/src/app/qbs/parser/commandlineparser.h index ae5744377..d6880be05 100644 --- a/src/app/qbs/parser/commandlineparser.h +++ b/src/app/qbs/parser/commandlineparser.h @@ -38,6 +38,7 @@ namespace qbs { class BuildOptions; class CleanOptions; +class GenerateOptions; class InstallOptions; class Settings; @@ -58,6 +59,7 @@ public: QString projectBuildDirectory() const; BuildOptions buildOptions() const; CleanOptions cleanOptions() const; + GenerateOptions generateOptions() const; InstallOptions installOptions() const; bool force() const; bool forceTimestampCheck() const; diff --git a/src/app/qbs/parser/commandpool.cpp b/src/app/qbs/parser/commandpool.cpp index e34b8f467..81463e5c1 100644 --- a/src/app/qbs/parser/commandpool.cpp +++ b/src/app/qbs/parser/commandpool.cpp @@ -50,6 +50,9 @@ qbs::Command *CommandPool::getCommand(CommandType type) const case ResolveCommandType: command = new ResolveCommand(m_optionPool); break; + case GenerateCommandType: + command = new GenerateCommand(m_optionPool); + break; case BuildCommandType: command = new BuildCommand(m_optionPool); break; diff --git a/src/app/qbs/parser/commandtype.h b/src/app/qbs/parser/commandtype.h index b8e166035..861c522cd 100644 --- a/src/app/qbs/parser/commandtype.h +++ b/src/app/qbs/parser/commandtype.h @@ -35,7 +35,7 @@ namespace qbs { enum CommandType { ResolveCommandType, BuildCommandType, CleanCommandType, RunCommandType, ShellCommandType, StatusCommandType, UpdateTimestampsCommandType, DumpNodesTreeCommandType, - InstallCommandType, HelpCommandType + InstallCommandType, HelpCommandType, GenerateCommandType }; } // namespace qbs diff --git a/src/lib/corelib/corelib.pro b/src/lib/corelib/corelib.pro index 9580973c5..cf70291c1 100644 --- a/src/lib/corelib/corelib.pro +++ b/src/lib/corelib/corelib.pro @@ -14,6 +14,7 @@ DEFINES += SRCDIR=\\\"$$PWD\\\" include(api/api.pri) include(buildgraph/buildgraph.pri) +include(generators/generators.pri) include(jsextensions/jsextensions.pri) include(language/language.pri) include(logging/logging.pri) diff --git a/src/lib/corelib/corelib.qbs b/src/lib/corelib/corelib.qbs index ed7b48f88..d30f59887 100644 --- a/src/lib/corelib/corelib.qbs +++ b/src/lib/corelib/corelib.qbs @@ -307,6 +307,7 @@ QbsLibrary { "fileinfo.cpp", "fileinfo.h", "filetime.h", + "generateoptions.cpp", "hostosinfo.h", "id.cpp", "id.h", @@ -320,6 +321,7 @@ QbsLibrary { "profile.cpp", "progressobserver.cpp", "progressobserver.h", + "projectgeneratormanager.cpp", "propertyfinder.cpp", "propertyfinder.h", "qbsassert.cpp", @@ -349,10 +351,12 @@ QbsLibrary { "cleanoptions.h", "codelocation.h", "error.h", + "generateoptions.h", "installoptions.h", "preferences.h", "processresult.h", "profile.h", + "projectgeneratormanager.h", "qbs_export.h", "settings.h", "settingsmodel.h", diff --git a/src/lib/corelib/generators/generator.h b/src/lib/corelib/generators/generator.h new file mode 100644 index 000000000..0c2ffada6 --- /dev/null +++ b/src/lib/corelib/generators/generator.h @@ -0,0 +1,106 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef GENERATORPLUGIN_H +#define GENERATORPLUGIN_H + +#include <api/project.h> +#include <QList> +#include <QString> + +namespace qbs { + +/*! + * \class ProjectGenerator + * \brief The \c ProjectGenerator class is an abstract base class for generators which generate + * arbitrary output given a resolved Qbs project. + */ + +class ProjectGenerator +{ +public: + virtual ~ProjectGenerator() + { + } + + /*! + * Returns the name of the generator used to create the external build system files. + */ + virtual QString generatorName() const = 0; + + virtual void generate(const InstallOptions &installOptions) = 0; + + QList<Project> projects() const + { + return m_projects; + } + + void addProject(const Project &project) + { + m_projects << project; + } + + void addProjects(const QList<Project> &projects) + { + m_projects << projects; + } + + void removeProject(const Project &project) + { + m_projects.removeOne(project); + } + + void clearProjects() + { + m_projects.clear(); + } + +protected: + ProjectGenerator() + { + } + +private: + QList<Project> m_projects; +}; + +} // namespace qbs + +#ifdef __cplusplus +extern "C" { +#endif + +typedef qbs::ProjectGenerator **(*getGenerators_f)(); + +#ifdef __cplusplus +} +#endif + +#endif // GENERATORPLUGIN_H diff --git a/src/lib/corelib/generators/generators.pri b/src/lib/corelib/generators/generators.pri new file mode 100644 index 000000000..6372e8197 --- /dev/null +++ b/src/lib/corelib/generators/generators.pri @@ -0,0 +1,2 @@ +HEADERS += \ + $$PWD/generator.h diff --git a/src/lib/corelib/qbs.h b/src/lib/corelib/qbs.h index ca07e66a6..f045f926f 100644 --- a/src/lib/corelib/qbs.h +++ b/src/lib/corelib/qbs.h @@ -40,6 +40,8 @@ #include "tools/buildoptions.h" #include "tools/cleanoptions.h" #include "tools/error.h" +#include "tools/generateoptions.h" +#include "tools/projectgeneratormanager.h" #include "tools/installoptions.h" #include "tools/preferences.h" #include "tools/profile.h" diff --git a/src/lib/corelib/tools/generateoptions.cpp b/src/lib/corelib/tools/generateoptions.cpp new file mode 100644 index 000000000..e12c58eb3 --- /dev/null +++ b/src/lib/corelib/tools/generateoptions.cpp @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#include "generateoptions.h" + +#include <QSharedData> +#include <QString> + +namespace qbs { +namespace Internal { + +class GenerateOptionsPrivate : public QSharedData +{ +public: + GenerateOptionsPrivate() + : generatorName() + {} + + QString generatorName; +}; + +} // namespace Internal + +/*! + * \class GenerateOptions + * \brief The \c GenerateOptions class comprises parameters that influence the behavior of + * generate operations. + */ + +GenerateOptions::GenerateOptions() : d(new Internal::GenerateOptionsPrivate) +{ +} + +GenerateOptions::GenerateOptions(const GenerateOptions &other) : d(other.d) +{ +} + +GenerateOptions &GenerateOptions::operator=(const GenerateOptions &other) +{ + d = other.d; + return *this; +} + +GenerateOptions::~GenerateOptions() +{ +} + +/*! + * Returns the name of the generator used to create the external build system files. + * The default is empty. + */ +QString GenerateOptions::generatorName() const +{ + return d->generatorName; +} + +/*! + * \brief Sets the name of the generator used to create the external build system files. + */ +void GenerateOptions::setGeneratorName(const QString &generatorName) +{ + d->generatorName = generatorName; +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/generateoptions.h b/src/lib/corelib/tools/generateoptions.h new file mode 100644 index 000000000..edb736c06 --- /dev/null +++ b/src/lib/corelib/tools/generateoptions.h @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ +#ifndef QBS_GENERATEOPTIONS_H +#define QBS_GENERATEOPTIONS_H + +#include "qbs_export.h" + +#include <QSharedDataPointer> + +QT_BEGIN_NAMESPACE +class QString; +QT_END_NAMESPACE + +namespace qbs { +namespace Internal { class GenerateOptionsPrivate; } + +class QBS_EXPORT GenerateOptions +{ +public: + GenerateOptions(); + GenerateOptions(const GenerateOptions &other); + GenerateOptions &operator=(const GenerateOptions &other); + ~GenerateOptions(); + + QString generatorName() const; + void setGeneratorName(const QString &generatorName); + +private: + QSharedDataPointer<Internal::GenerateOptionsPrivate> d; +}; + +} // namespace qbs + +#endif // QBS_GENERATEOPTIONS_H diff --git a/src/lib/corelib/tools/projectgeneratormanager.cpp b/src/lib/corelib/tools/projectgeneratormanager.cpp new file mode 100644 index 000000000..cd45f4682 --- /dev/null +++ b/src/lib/corelib/tools/projectgeneratormanager.cpp @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#include "projectgeneratormanager.h" + +#include <logging/logger.h> +#include <logging/translator.h> +#include <tools/hostosinfo.h> + +#include <QCoreApplication> +#include <QDirIterator> +#include <QLibrary> + +namespace qbs { + +using namespace Internal; + +ProjectGeneratorManager::~ProjectGeneratorManager() +{ + foreach (QLibrary * const lib, m_libs) { + lib->unload(); + delete lib; + } +} + +ProjectGeneratorManager *ProjectGeneratorManager::instance() +{ + static ProjectGeneratorManager generatorPlugin; + return &generatorPlugin; +} + +ProjectGeneratorManager::ProjectGeneratorManager() +{ + QList<QSharedPointer<ProjectGenerator> > generators; + foreach (QSharedPointer<ProjectGenerator> generator, generators) { + m_generators[generator->generatorName()] = generator; + } +} + +QStringList ProjectGeneratorManager::loadedGeneratorNames() +{ + return instance()->m_generators.keys(); +} + +QSharedPointer<ProjectGenerator> ProjectGeneratorManager::findGenerator(const QString &generatorName) +{ + return instance()->m_generators.value(generatorName); +} + +} // namespace qbs diff --git a/src/lib/corelib/tools/projectgeneratormanager.h b/src/lib/corelib/tools/projectgeneratormanager.h new file mode 100644 index 000000000..8a79e5afc --- /dev/null +++ b/src/lib/corelib/tools/projectgeneratormanager.h @@ -0,0 +1,70 @@ +/**************************************************************************** +** +** Copyright (C) 2015 The Qt Company Ltd. +** Copyright (C) 2015 Jake Petroules. +** Contact: http://www.qt-project.org/legal +** +** This file is part of the Qt Build Suite. +** +** 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 Digia. For licensing terms and +** conditions see http://qt.digia.com/licensing. For further information +** use the contact form at http://qt.digia.com/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Digia gives you certain additional +** rights. These rights are described in the Digia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +****************************************************************************/ + +#ifndef QBS_PROJECTGENERATORMANAGER_H +#define QBS_PROJECTGENERATORMANAGER_H + +#include <language/filetags.h> +#include <generators/generator.h> + +#include <QMap> +#include <QSharedPointer> +#include <QString> +#include <QStringList> + +QT_BEGIN_NAMESPACE +class QLibrary; +QT_END_NAMESPACE + +namespace qbs { +class ProjectGenerator; +namespace Internal { +class Logger; +} + +class QBS_EXPORT ProjectGeneratorManager +{ +public: + ~ProjectGeneratorManager(); + static ProjectGeneratorManager *instance(); + static QStringList loadedGeneratorNames(); + static QSharedPointer<ProjectGenerator> findGenerator(const QString &generatorName); + +private: + ProjectGeneratorManager(); + +private: + QList<QLibrary *> m_libs; + QMap<QString, QSharedPointer<ProjectGenerator> > m_generators; +}; + +} // namespace qbs + +#endif diff --git a/src/lib/corelib/tools/tools.pri b/src/lib/corelib/tools/tools.pri index 14433de2b..c6e508aa3 100644 --- a/src/lib/corelib/tools/tools.pri +++ b/src/lib/corelib/tools/tools.pri @@ -8,6 +8,7 @@ HEADERS += \ $$PWD/executablefinder.h \ $$PWD/fileinfo.h \ $$PWD/filetime.h \ + $$PWD/generateoptions.h \ $$PWD/id.h \ $$PWD/persistence.h \ $$PWD/scannerpluginmanager.h \ @@ -19,6 +20,7 @@ HEADERS += \ $$PWD/processresult.h \ $$PWD/processresult_p.h \ $$PWD/progressobserver.h \ + $$PWD/projectgeneratormanager.h \ $$PWD/propertyfinder.h \ $$PWD/shellutils.h \ $$PWD/hostosinfo.h \ @@ -40,6 +42,7 @@ SOURCES += \ $$PWD/error.cpp \ $$PWD/executablefinder.cpp \ $$PWD/fileinfo.cpp \ + $$PWD/generateoptions.cpp \ $$PWD/id.cpp \ $$PWD/persistence.cpp \ $$PWD/scannerpluginmanager.cpp \ @@ -50,6 +53,7 @@ SOURCES += \ $$PWD/processresult.cpp \ $$PWD/profile.cpp \ $$PWD/progressobserver.cpp \ + $$PWD/projectgeneratormanager.cpp \ $$PWD/propertyfinder.cpp \ $$PWD/shellutils.cpp \ $$PWD/buildoptions.cpp \ @@ -86,6 +90,8 @@ qbs_enable_unit_tests { $$PWD/processresult.h \ $$PWD/qbs_export.h \ $$PWD/buildoptions.h \ + $$PWD/generateoptions.h \ + $$PWD/generatorpluginmanager.h \ $$PWD/installoptions.h \ $$PWD/setupprojectparameters.h tools_headers.path = $${QBS_INSTALL_PREFIX}/include/qbs/tools |