Files
qt-creator/src/plugins/projectexplorer/buildconfiguration.h
T

205 lines
6.9 KiB
C++
Raw Normal View History

2012-10-02 09:12:39 +02:00
/****************************************************************************
2008-12-02 12:01:29 +01:00
**
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
2008-12-02 12:01:29 +01:00
**
2012-10-02 09:12:39 +02:00
** This file is part of Qt Creator.
2008-12-02 12:01:29 +01:00
**
2012-10-02 09:12:39 +02:00
** 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.
2010-12-17 16:01:08 +01:00
**
2012-10-02 09:12:39 +02:00
****************************************************************************/
2008-12-02 16:19:05 +01:00
2016-02-02 18:26:51 +01:00
#pragma once
2008-12-02 12:01:29 +01:00
2009-09-21 15:50:27 +02:00
#include "projectexplorer_export.h"
#include "projectconfiguration.h"
#include "task.h"
#include <utils/environment.h>
#include <utils/fileutils.h>
2009-09-21 15:50:27 +02:00
namespace Utils { class MacroExpander; }
2008-12-02 12:01:29 +01:00
namespace ProjectExplorer {
2009-06-12 13:55:08 +02:00
2019-10-21 14:47:17 +02:00
namespace Internal { class BuildConfigurationPrivate; }
class BuildDirectoryAspect;
2013-07-22 15:53:57 +02:00
class BuildInfo;
class BuildSystem;
2010-07-16 14:00:41 +02:00
class BuildStepList;
2012-09-03 18:31:44 +02:00
class Kit;
class NamedWidget;
class Node;
class RunConfiguration;
2010-02-08 15:50:06 +01:00
class Target;
2009-09-30 18:36:31 +02:00
class PROJECTEXPLORER_EXPORT BuildConfiguration : public ProjectConfiguration
2008-12-02 12:01:29 +01:00
{
2009-09-21 15:50:27 +02:00
Q_OBJECT
protected:
friend class BuildConfigurationFactory;
explicit BuildConfiguration(Target *target, Core::Id id);
2009-11-23 12:11:48 +01:00
public:
~BuildConfiguration() override;
2019-10-21 14:47:17 +02:00
2019-05-28 13:49:26 +02:00
Utils::FilePath buildDirectory() const;
Utils::FilePath rawBuildDirectory() const;
void setBuildDirectory(const Utils::FilePath &dir);
virtual BuildSystem *buildSystem() const;
virtual NamedWidget *createConfigWidget();
2012-11-08 18:02:50 +01:00
virtual QList<NamedWidget *> createSubConfigWidgets();
2012-04-24 15:49:09 +02:00
2012-05-03 16:10:00 +02:00
// Maybe the BuildConfiguration is not the best place for the environment
Utils::Environment baseEnvironment() const;
QString baseEnvironmentText() const;
Utils::Environment environment() const;
2019-05-07 16:51:22 +02:00
void setUserEnvironmentChanges(const Utils::EnvironmentItems &diff);
Utils::EnvironmentItems userEnvironmentChanges() const;
bool useSystemEnvironment() const;
void setUseSystemEnvironment(bool b);
2015-01-27 18:46:40 +01:00
virtual void addToEnvironment(Utils::Environment &env) const;
BuildStepList *buildSteps() const;
BuildStepList *cleanSteps() const;
2010-07-16 14:00:41 +02:00
void appendInitialBuildStep(Core::Id id);
void appendInitialCleanStep(Core::Id id);
bool fromMap(const QVariantMap &map) override;
QVariantMap toMap() const override;
virtual bool isEnabled() const;
2011-05-26 15:56:36 +02:00
virtual QString disabledReason() const;
virtual bool regenerateBuildFiles(Node *node);
virtual void restrictNextBuild(const RunConfiguration *rc);
enum BuildType {
Unknown,
Debug,
2015-02-20 15:10:56 +01:00
Profile,
Release
};
2019-10-21 14:47:17 +02:00
virtual BuildType buildType() const;
static QString buildTypeName(BuildType type);
bool isActive() const;
2016-05-02 16:04:45 +02:00
static void prependCompilerPathToEnvironment(Kit *k, Utils::Environment &env);
void updateCacheAndEmitEnvironmentChanged();
ProjectExplorer::BuildDirectoryAspect *buildDirectoryAspect() const;
void setConfigWidgetDisplayName(const QString &display);
void setBuildDirectoryHistoryCompleter(const QString &history);
void setConfigWidgetHasFrame(bool configWidgetHasFrame);
2019-04-26 19:26:50 +02:00
void setBuildDirectorySettingsKey(const QString &key);
void addConfigWidgets(const std::function<void (NamedWidget *)> &adder);
void doInitialize(const BuildInfo &info);
Utils::MacroExpander *macroExpander() const;
bool createBuildDirectory();
signals:
void environmentChanged();
void buildDirectoryChanged();
void enabledChanged();
void buildTypeChanged();
2009-11-23 12:11:48 +01:00
protected:
void setInitializer(const std::function<void(const BuildInfo &info)> &initializer);
2016-01-29 16:38:37 +02:00
private:
void emitBuildDirectoryChanged();
2019-10-21 14:47:17 +02:00
Internal::BuildConfigurationPrivate *d = nullptr;
2008-12-02 12:01:29 +01:00
};
2009-06-12 13:55:08 +02:00
class PROJECTEXPLORER_EXPORT BuildConfigurationFactory
{
protected:
BuildConfigurationFactory();
BuildConfigurationFactory(const BuildConfigurationFactory &) = delete;
BuildConfigurationFactory &operator=(const BuildConfigurationFactory &) = delete;
virtual ~BuildConfigurationFactory(); // Needed for dynamic_casts in importers.
public:
2013-07-22 15:53:57 +02:00
// List of build information that can be used to create a new build configuration via
// "Add Build Configuration" button.
const QList<BuildInfo> allAvailableBuilds(const Target *parent) const;
2013-08-13 10:52:57 +02:00
// List of build information that can be used to initially set up a new build configuration.
2019-06-26 17:09:35 +02:00
const QList<BuildInfo>
allAvailableSetups(const Kit *k, const Utils::FilePath &projectPath) const;
2013-08-13 10:52:57 +02:00
BuildConfiguration *create(Target *parent, const BuildInfo &info) const;
static BuildConfiguration *restore(Target *parent, const QVariantMap &map);
static BuildConfiguration *clone(Target *parent, const BuildConfiguration *source);
2009-09-30 16:54:33 +02:00
2019-06-26 17:09:35 +02:00
static BuildConfigurationFactory *find(const Kit *k, const Utils::FilePath &projectPath);
static BuildConfigurationFactory *find(Target *parent);
using IssueReporter = std::function<Tasks(Kit *, const QString &, const QString &)>;
void setIssueReporter(const IssueReporter &issueReporter);
const Tasks reportIssues(ProjectExplorer::Kit *kit,
const QString &projectPath, const QString &buildDir) const;
protected:
using BuildGenerator
= std::function<QList<BuildInfo>(const Kit *, const Utils::FilePath &, bool)>;
void setBuildGenerator(const BuildGenerator &buildGenerator);
bool supportsTargetDeviceType(Core::Id id) const;
void setSupportedProjectType(Core::Id id);
void setSupportedProjectMimeTypeName(const QString &mimeTypeName);
void addSupportedTargetDeviceType(Core::Id id);
void setDefaultDisplayName(const QString &defaultDisplayName);
using BuildConfigurationCreator = std::function<BuildConfiguration *(Target *)>;
template <class BuildConfig>
void registerBuildConfiguration(Core::Id buildConfigId)
{
m_creator = [buildConfigId](Target *t) { return new BuildConfig(t, buildConfigId); };
m_buildConfigId = buildConfigId;
}
private:
bool canHandle(const ProjectExplorer::Target *t) const;
BuildConfigurationCreator m_creator;
Core::Id m_buildConfigId;
Core::Id m_supportedProjectType;
QList<Core::Id> m_supportedTargetDeviceTypes;
QString m_supportedProjectMimeTypeName;
IssueReporter m_issueReporter;
BuildGenerator m_buildGenerator;
};
2008-12-02 16:19:05 +01:00
} // namespace ProjectExplorer