aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/extracompiler.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@theqtcompany.com>2016-01-15 16:12:54 +0100
committerUlf Hermann <ulf.hermann@theqtcompany.com>2016-02-16 12:53:05 +0000
commit2e3e06052065c97fa4a2ddd2b1418bb3447387d4 (patch)
tree0628f8d1a68a3f16b66e3d61c6a26a7bb34ed21c /src/plugins/projectexplorer/extracompiler.h
parent13e0abf526e87179fc6b50e967902189fc42b832 (diff)
Generalize support for extra compilers
Allow for different extra compilers which may get called to generate additional code for the code model. The build system is expected to know what files are generated from which source file and the extra compilers know how to generate the content of those files, without touching the build directory. the uic adapter is refactored to be the first such extra compiler. The extra compiler is run when an editor for its source document loses focus, or after a timeout of 1s when the source document has been changed. Change-Id: I13c110c61120c812f02639a3684144daf8979b37 Reviewed-by: Tobias Hunger <tobias.hunger@theqtcompany.com>
Diffstat (limited to 'src/plugins/projectexplorer/extracompiler.h')
-rw-r--r--src/plugins/projectexplorer/extracompiler.h94
1 files changed, 94 insertions, 0 deletions
diff --git a/src/plugins/projectexplorer/extracompiler.h b/src/plugins/projectexplorer/extracompiler.h
new file mode 100644
index 0000000000..94c313e225
--- /dev/null
+++ b/src/plugins/projectexplorer/extracompiler.h
@@ -0,0 +1,94 @@
+/****************************************************************************
+**
+** Copyright (C) 2016 The Qt Company Ltd.
+** 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 "projectnodes.h"
+#include "project.h"
+
+#include <coreplugin/editormanager/ieditor.h>
+#include <utils/fileutils.h>
+#include <utils/environment.h>
+
+namespace ProjectExplorer {
+
+class ExtraCompilerPrivate;
+class PROJECTEXPLORER_EXPORT ExtraCompiler : public QObject
+{
+ Q_OBJECT
+public:
+
+ ExtraCompiler(const Project *project, const Utils::FileName &source,
+ const Utils::FileNameList &targets, QObject *parent = 0);
+ virtual ~ExtraCompiler() override;
+
+ const Project *project() const;
+ Utils::FileName source() const;
+
+ // You can set the contents from the outside. This is done if the file has been (re)created by
+ // the regular build process.
+ void setContent(const Utils::FileName &file, const QString &content);
+ QString content(const Utils::FileName &file) const;
+
+ Utils::FileNameList targets() const;
+
+ void setCompileTime(const QDateTime &time);
+ QDateTime compileTime() const;
+
+signals:
+ void contentsChanged(const Utils::FileName &file);
+
+protected:
+ Utils::Environment buildEnvironment() const;
+
+private:
+ void onTargetsBuilt(Project *project);
+ void onEditorChanged(Core::IEditor *editor);
+ void onEditorAboutToClose(Core::IEditor *editor);
+ void onActiveTargetChanged();
+ void onActiveBuildConfigurationChanged();
+ void setDirty();
+ virtual void run(const QByteArray &sourceContent) = 0;
+
+ ExtraCompilerPrivate *const d;
+};
+
+class PROJECTEXPLORER_EXPORT ExtraCompilerFactory : public QObject
+{
+ Q_OBJECT
+public:
+ explicit ExtraCompilerFactory(QObject *parent = 0);
+
+ virtual FileType sourceType() const = 0;
+ virtual QString sourceTag() const = 0;
+
+ virtual ExtraCompiler *create(const Project *project, const Utils::FileName &source,
+ const Utils::FileNameList &targets) = 0;
+
+ static void registerExtraCompilerFactory(ExtraCompilerFactory *factory);
+ static QList<ExtraCompilerFactory *> extraCompilerFactories();
+};
+
+} // namespace ProjectExplorer