buildconfiguration.h 5.38 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3 4
** Copyright (C) 2016 The Qt Company Ltd.
** Contact: https://www.qt.io/licensing/
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8 9 10 11
** 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
12 13 14
** 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.
15
**
16 17 18 19 20 21 22
** 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.
con's avatar
con committed
23
**
hjk's avatar
hjk committed
24
****************************************************************************/
hjk's avatar
hjk committed
25

Tobias Hunger's avatar
Tobias Hunger committed
26
#pragma once
con's avatar
con committed
27

con's avatar
con committed
28
#include "projectexplorer_export.h"
29
#include "projectconfiguration.h"
30 31

#include <utils/environment.h>
32
#include <utils/fileutils.h>
con's avatar
con committed
33

con's avatar
con committed
34
namespace ProjectExplorer {
35

36
class BuildConfiguration;
37
class BuildInfo;
38
class NamedWidget;
Tobias Hunger's avatar
Tobias Hunger committed
39
class BuildStepList;
Tobias Hunger's avatar
Tobias Hunger committed
40
class Kit;
Tobias Hunger's avatar
Tobias Hunger committed
41
class Target;
42
class IOutputParser;
con's avatar
con committed
43

44
class PROJECTEXPLORER_EXPORT BuildConfiguration : public ProjectConfiguration
con's avatar
con committed
45
{
con's avatar
con committed
46 47
    Q_OBJECT

con's avatar
con committed
48
public:
dt's avatar
dt committed
49 50
    // ctors are protected

51 52
    Utils::FileName buildDirectory() const;
    Utils::FileName rawBuildDirectory() const;
53
    void setBuildDirectory(const Utils::FileName &dir);
54

55
    virtual NamedWidget *createConfigWidget() = 0;
56
    virtual QList<NamedWidget *> createSubConfigWidgets();
Tobias Hunger's avatar
Tobias Hunger committed
57

Daniel Teske's avatar
Daniel Teske committed
58
    // Maybe the BuildConfiguration is not the best place for the environment
59
    Utils::Environment baseEnvironment() const;
60
    QString baseEnvironmentText() const;
61 62 63
    Utils::Environment environment() const;
    void setUserEnvironmentChanges(const QList<Utils::EnvironmentItem> &diff);
    QList<Utils::EnvironmentItem> userEnvironmentChanges() const;
64 65 66
    bool useSystemEnvironment() const;
    void setUseSystemEnvironment(bool b);

67 68
    virtual void addToEnvironment(Utils::Environment &env) const;

69 70
    QList<Core::Id> knownStepLists() const;
    BuildStepList *stepList(Core::Id id) const;
Tobias Hunger's avatar
Tobias Hunger committed
71

72 73
    bool fromMap(const QVariantMap &map) override;
    QVariantMap toMap() const override;
74

Tobias Hunger's avatar
Tobias Hunger committed
75
    Target *target() const;
76
    Project *project() const override;
Tobias Hunger's avatar
Tobias Hunger committed
77

78
    virtual bool isEnabled() const;
dt_'s avatar
dt_ committed
79
    virtual QString disabledReason() const;
80

81 82 83
    enum BuildType {
        Unknown,
        Debug,
Ulf Hermann's avatar
Ulf Hermann committed
84
        Profile,
85 86 87 88
        Release
    };
    virtual BuildType buildType() const = 0;

89 90
    static QString buildTypeName(BuildType type);

91 92 93
signals:
    void environmentChanged();
    void buildDirectoryChanged();
94
    void enabledChanged();
95
    void buildTypeChanged();
96

dt's avatar
dt committed
97
protected:
98
    BuildConfiguration(Target *target, Core::Id id);
Tobias Hunger's avatar
Tobias Hunger committed
99
    BuildConfiguration(Target *target, BuildConfiguration *source);
Tobias Hunger's avatar
Tobias Hunger committed
100

Tobias Hunger's avatar
Tobias Hunger committed
101
    void cloneSteps(BuildConfiguration *source);
102
    void emitEnvironmentChanged();
103

104
private:
105
    void handleKitUpdate();
106
    void emitBuildDirectoryChanged();
107

108
    void ctor();
109

110
    bool m_clearSystemEnvironment;
111
    QList<Utils::EnvironmentItem> m_userEnvironmentChanges;
Tobias Hunger's avatar
Tobias Hunger committed
112
    QList<BuildStepList *> m_stepLists;
113 114
    Utils::FileName m_buildDirectory;
    Utils::FileName m_lastEmmitedBuildDirectory;
115
    mutable Utils::Environment m_cachedEnvironment;
con's avatar
con committed
116
};
117

118
class PROJECTEXPLORER_EXPORT IBuildConfigurationFactory : public QObject
119 120 121 122
{
    Q_OBJECT

public:
123
    explicit IBuildConfigurationFactory(QObject *parent = nullptr);
124
    ~IBuildConfigurationFactory() override;
125

126 127 128 129
    // The priority is negative if this factory can not create anything for the target.
    // It is 0 for the "default" factory that wants to handle the target.
    // Add 100 for each specialization.
    virtual int priority(const Target *parent) const = 0;
130 131 132
    // List of build information that can be used to create a new build configuration via
    // "Add Build Configuration" button.
    virtual QList<BuildInfo *> availableBuilds(const Target *parent) const = 0;
133

134
    virtual int priority(const Kit *k, const QString &projectPath) const = 0;
135 136 137
    // List of build information that can be used to initially set up a new build configuration.
    virtual QList<BuildInfo *> availableSetups(const Kit *k, const QString &projectPath) const = 0;

138
    virtual BuildConfiguration *create(Target *parent, const BuildInfo *info) const = 0;
139

140
    // used to recreate the runConfigurations when restoring settings
Tobias Hunger's avatar
Tobias Hunger committed
141
    virtual bool canRestore(const Target *parent, const QVariantMap &map) const = 0;
Tobias Hunger's avatar
Tobias Hunger committed
142
    virtual BuildConfiguration *restore(Target *parent, const QVariantMap &map) = 0;
Tobias Hunger's avatar
Tobias Hunger committed
143
    virtual bool canClone(const Target *parent, BuildConfiguration *product) const = 0;
Tobias Hunger's avatar
Tobias Hunger committed
144
    virtual BuildConfiguration *clone(Target *parent, BuildConfiguration *product) = 0;
con's avatar
con committed
145

Tobias Hunger's avatar
Tobias Hunger committed
146
    static IBuildConfigurationFactory *find(Target *parent, const QVariantMap &map);
147
    static IBuildConfigurationFactory *find(const Kit *k, const QString &projectPath);
Tobias Hunger's avatar
Tobias Hunger committed
148
    static IBuildConfigurationFactory *find(Target *parent);
149
    static IBuildConfigurationFactory *find(Target *parent, BuildConfiguration *bc);
Tobias Hunger's avatar
Tobias Hunger committed
150

con's avatar
con committed
151
signals:
152
    void availableCreationIdsChanged();
153 154
};

hjk's avatar
hjk committed
155
} // namespace ProjectExplorer