2012-10-02 09:12:39 +02:00
|
|
|
/****************************************************************************
|
2008-12-02 12:01:29 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +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
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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.
|
2008-12-02 14:17:16 +01:00
|
|
|
**
|
2016-01-15 14:57:40 +01:00
|
|
|
** 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"
|
2010-11-01 11:18:27 +01:00
|
|
|
#include "projectconfiguration.h"
|
2019-05-27 16:09:44 +02:00
|
|
|
#include "task.h"
|
2010-09-23 10:35:23 +02:00
|
|
|
|
|
|
|
|
#include <utils/environment.h>
|
2013-08-16 17:45:16 +02:00
|
|
|
#include <utils/fileutils.h>
|
2009-09-21 15:50:27 +02:00
|
|
|
|
2020-02-18 14:44:58 +01: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; }
|
|
|
|
|
|
2019-11-25 17:55:39 +01:00
|
|
|
class BuildDirectoryAspect;
|
2013-07-22 15:53:57 +02:00
|
|
|
class BuildInfo;
|
2019-10-25 09:55:32 +02:00
|
|
|
class BuildSystem;
|
2010-07-16 14:00:41 +02:00
|
|
|
class BuildStepList;
|
2012-09-03 18:31:44 +02:00
|
|
|
class Kit;
|
2019-04-26 14:27:50 +02:00
|
|
|
class NamedWidget;
|
|
|
|
|
class Node;
|
2019-12-04 17:23:02 +01:00
|
|
|
class RunConfiguration;
|
2010-02-08 15:50:06 +01:00
|
|
|
class Target;
|
2009-09-30 18:36:31 +02:00
|
|
|
|
2010-01-18 12:11:04 +01: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
|
|
|
|
|
|
2017-11-29 12:28:40 +01:00
|
|
|
protected:
|
2019-01-29 08:55:52 +01:00
|
|
|
friend class BuildConfigurationFactory;
|
2017-11-29 12:28:40 +01:00
|
|
|
explicit BuildConfiguration(Target *target, Core::Id id);
|
2009-11-23 12:11:48 +01:00
|
|
|
|
2017-11-29 12:28:40 +01:00
|
|
|
public:
|
2019-12-09 12:59:38 +01:00
|
|
|
~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);
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
virtual BuildSystem *buildSystem() const;
|
|
|
|
|
|
2019-04-26 12:16:08 +02:00
|
|
|
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
|
2012-10-17 14:15:21 +02:00
|
|
|
Utils::Environment baseEnvironment() const;
|
2010-03-11 17:47:09 +01:00
|
|
|
QString baseEnvironmentText() const;
|
2010-09-23 10:35:23 +02:00
|
|
|
Utils::Environment environment() const;
|
2019-05-07 16:51:22 +02:00
|
|
|
void setUserEnvironmentChanges(const Utils::EnvironmentItems &diff);
|
|
|
|
|
Utils::EnvironmentItems userEnvironmentChanges() const;
|
2010-03-11 17:47:09 +01:00
|
|
|
bool useSystemEnvironment() const;
|
|
|
|
|
void setUseSystemEnvironment(bool b);
|
|
|
|
|
|
2015-01-27 18:46:40 +01:00
|
|
|
virtual void addToEnvironment(Utils::Environment &env) const;
|
|
|
|
|
|
2019-12-05 16:19:42 +01:00
|
|
|
BuildStepList *buildSteps() const;
|
|
|
|
|
BuildStepList *cleanSteps() const;
|
2010-07-16 14:00:41 +02:00
|
|
|
|
2019-12-06 18:42:11 +01:00
|
|
|
void appendInitialBuildStep(Core::Id id);
|
|
|
|
|
void appendInitialCleanStep(Core::Id id);
|
|
|
|
|
|
2015-11-13 11:06:27 +01:00
|
|
|
bool fromMap(const QVariantMap &map) override;
|
|
|
|
|
QVariantMap toMap() const override;
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2011-01-19 15:46:01 +01:00
|
|
|
virtual bool isEnabled() const;
|
2011-05-26 15:56:36 +02:00
|
|
|
virtual QString disabledReason() const;
|
2011-01-19 15:46:01 +01:00
|
|
|
|
2018-07-03 15:09:51 +02:00
|
|
|
virtual bool regenerateBuildFiles(Node *node);
|
|
|
|
|
|
2019-12-04 17:23:02 +01:00
|
|
|
virtual void restrictNextBuild(const RunConfiguration *rc);
|
|
|
|
|
|
2011-03-03 16:12:00 +01:00
|
|
|
enum BuildType {
|
|
|
|
|
Unknown,
|
|
|
|
|
Debug,
|
2015-02-20 15:10:56 +01:00
|
|
|
Profile,
|
2011-03-03 16:12:00 +01:00
|
|
|
Release
|
|
|
|
|
};
|
2019-10-21 14:47:17 +02:00
|
|
|
virtual BuildType buildType() const;
|
2019-08-02 18:06:29 +02:00
|
|
|
|
2015-10-22 16:45:52 +02:00
|
|
|
static QString buildTypeName(BuildType type);
|
|
|
|
|
|
2020-02-21 15:18:40 +01:00
|
|
|
bool isActive() const;
|
2016-05-02 16:04:45 +02:00
|
|
|
|
2017-11-28 17:18:38 +01:00
|
|
|
static void prependCompilerPathToEnvironment(Kit *k, Utils::Environment &env);
|
2018-07-03 11:22:37 +02:00
|
|
|
void updateCacheAndEmitEnvironmentChanged();
|
2017-10-17 12:27:37 +02:00
|
|
|
|
2019-11-25 17:55:39 +01:00
|
|
|
ProjectExplorer::BuildDirectoryAspect *buildDirectoryAspect() const;
|
2019-04-26 12:16:08 +02:00
|
|
|
void setConfigWidgetDisplayName(const QString &display);
|
2019-04-29 12:43:34 +02:00
|
|
|
void setBuildDirectoryHistoryCompleter(const QString &history);
|
2019-04-26 18:25:28 +02:00
|
|
|
void setConfigWidgetHasFrame(bool configWidgetHasFrame);
|
2019-04-26 19:26:50 +02:00
|
|
|
void setBuildDirectorySettingsKey(const QString &key);
|
2019-04-26 12:16:08 +02:00
|
|
|
|
2019-10-25 09:55:32 +02:00
|
|
|
void addConfigWidgets(const std::function<void (NamedWidget *)> &adder);
|
|
|
|
|
|
2019-12-09 12:59:38 +01:00
|
|
|
void doInitialize(const BuildInfo &info);
|
|
|
|
|
|
2020-02-18 14:44:58 +01:00
|
|
|
Utils::MacroExpander *macroExpander() const;
|
|
|
|
|
|
2020-03-19 16:45:20 +01:00
|
|
|
bool createBuildDirectory();
|
|
|
|
|
|
2009-11-25 18:50:20 +01:00
|
|
|
signals:
|
|
|
|
|
void environmentChanged();
|
|
|
|
|
void buildDirectoryChanged();
|
2011-01-19 15:46:01 +01:00
|
|
|
void enabledChanged();
|
2014-06-19 15:29:11 +02:00
|
|
|
void buildTypeChanged();
|
2009-11-25 18:50:20 +01:00
|
|
|
|
2009-11-23 12:11:48 +01:00
|
|
|
protected:
|
2019-12-06 17:32:07 +01:00
|
|
|
void setInitializer(const std::function<void(const BuildInfo &info)> &initializer);
|
2010-01-18 12:11:04 +01:00
|
|
|
|
2016-01-29 16:38:37 +02:00
|
|
|
private:
|
2013-08-16 17:45:16 +02:00
|
|
|
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
|
|
|
|
2020-01-09 17:32:51 +01:00
|
|
|
class PROJECTEXPLORER_EXPORT BuildConfigurationFactory
|
2009-09-24 16:02:02 +02:00
|
|
|
{
|
2017-11-29 12:28:40 +01:00
|
|
|
protected:
|
2019-01-29 08:55:52 +01:00
|
|
|
BuildConfigurationFactory();
|
2020-01-09 17:32:51 +01:00
|
|
|
BuildConfigurationFactory(const BuildConfigurationFactory &) = delete;
|
|
|
|
|
BuildConfigurationFactory &operator=(const BuildConfigurationFactory &) = delete;
|
|
|
|
|
|
|
|
|
|
virtual ~BuildConfigurationFactory(); // Needed for dynamic_casts in importers.
|
2009-09-24 16:02:02 +02:00
|
|
|
|
2017-11-29 12:28:40 +01:00
|
|
|
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.
|
2019-01-29 16:51:17 +01:00
|
|
|
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
|
|
|
|
2019-01-29 16:51:17 +01:00
|
|
|
BuildConfiguration *create(Target *parent, const BuildInfo &info) const;
|
2009-09-24 16:02:02 +02:00
|
|
|
|
2018-03-12 10:11:10 +01:00
|
|
|
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);
|
2019-01-29 08:55:52 +01:00
|
|
|
static BuildConfigurationFactory *find(Target *parent);
|
2017-11-29 12:28:40 +01:00
|
|
|
|
2019-05-27 16:09:44 +02:00
|
|
|
using IssueReporter = std::function<Tasks(Kit *, const QString &, const QString &)>;
|
2019-01-29 16:51:17 +01:00
|
|
|
void setIssueReporter(const IssueReporter &issueReporter);
|
2019-05-27 16:09:44 +02:00
|
|
|
const Tasks reportIssues(ProjectExplorer::Kit *kit,
|
|
|
|
|
const QString &projectPath, const QString &buildDir) const;
|
2019-01-29 16:51:17 +01:00
|
|
|
|
2017-11-29 12:28:40 +01:00
|
|
|
protected:
|
2020-01-09 15:06:30 +01:00
|
|
|
using BuildGenerator
|
|
|
|
|
= std::function<QList<BuildInfo>(const Kit *, const Utils::FilePath &, bool)>;
|
|
|
|
|
void setBuildGenerator(const BuildGenerator &buildGenerator);
|
2019-01-29 16:51:17 +01:00
|
|
|
|
2018-01-10 15:06:52 +01:00
|
|
|
bool supportsTargetDeviceType(Core::Id id) const;
|
2017-11-29 12:28:40 +01:00
|
|
|
void setSupportedProjectType(Core::Id id);
|
|
|
|
|
void setSupportedProjectMimeTypeName(const QString &mimeTypeName);
|
2019-01-30 18:48:58 +01:00
|
|
|
void addSupportedTargetDeviceType(Core::Id id);
|
2017-11-29 12:28:40 +01:00
|
|
|
void setDefaultDisplayName(const QString &defaultDisplayName);
|
|
|
|
|
|
|
|
|
|
using BuildConfigurationCreator = std::function<BuildConfiguration *(Target *)>;
|
|
|
|
|
|
|
|
|
|
template <class BuildConfig>
|
|
|
|
|
void registerBuildConfiguration(Core::Id buildConfigId)
|
|
|
|
|
{
|
2018-05-04 16:52:21 +02:00
|
|
|
m_creator = [buildConfigId](Target *t) { return new BuildConfig(t, buildConfigId); };
|
2017-11-29 12:28:40 +01:00
|
|
|
m_buildConfigId = buildConfigId;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private:
|
2018-03-12 10:11:10 +01:00
|
|
|
bool canHandle(const ProjectExplorer::Target *t) const;
|
|
|
|
|
|
2017-11-29 12:28:40 +01:00
|
|
|
BuildConfigurationCreator m_creator;
|
|
|
|
|
Core::Id m_buildConfigId;
|
|
|
|
|
Core::Id m_supportedProjectType;
|
|
|
|
|
QList<Core::Id> m_supportedTargetDeviceTypes;
|
|
|
|
|
QString m_supportedProjectMimeTypeName;
|
2019-01-29 16:51:17 +01:00
|
|
|
IssueReporter m_issueReporter;
|
2020-01-09 15:06:30 +01:00
|
|
|
BuildGenerator m_buildGenerator;
|
2009-09-24 16:02:02 +02:00
|
|
|
};
|
|
|
|
|
|
2008-12-02 16:19:05 +01:00
|
|
|
} // namespace ProjectExplorer
|