summaryrefslogtreecommitdiff
path: root/src/plugins/boostbuildprojectmanager/b2buildconfiguration.h
blob: b2914111ec849fc1861e14c21ccceab9c040a82b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
//
// Copyright (C) 2013 Mateusz Łoskot <mateusz@loskot.net>
//
// This file is part of Qt Creator Boost.Build plugin project.
//
// This is free software; you can redistribute and/or modify it under
// the terms of the GNU Lesser General Public License, Version 2.1
// as published by the Free Software Foundation.
// See accompanying file LICENSE.txt or copy at
// http://www.gnu.org/licenses/lgpl-2.1-standalone.html.
//
#ifndef BBBUILDCONFIGURATION_HPP
#define BBBUILDCONFIGURATION_HPP

#include <projectexplorer/buildconfiguration.h>
#include <projectexplorer/namedwidget.h>
#include <utils/fileutils.h>

#include <QList>
#include <QString>
#include <QVariantMap>

namespace Utils {
class FileName;
class PathChooser;
}

namespace BoostBuildProjectManager {
namespace Internal {

class BuildInfo;
class BuildSettingsWidget;

class BuildConfiguration : public ProjectExplorer::BuildConfiguration
{
    Q_OBJECT

    friend class BuildConfigurationFactory;

public:
    explicit BuildConfiguration(ProjectExplorer::Target* parent);

    QVariantMap toMap() const;

    ProjectExplorer::NamedWidget* createConfigWidget();

    BuildType buildType() const;

    Utils::FileName workingDirectory() const;
    void setWorkingDirectory(Utils::FileName const& dir);

signals:
    void workingDirectoryChanged();

protected:
    BuildConfiguration(ProjectExplorer::Target* parent, BuildConfiguration* source);
    BuildConfiguration(ProjectExplorer::Target* parent, Core::Id const id);

    bool fromMap(QVariantMap const& map);

    friend class BuildSettingsWidget;

private slots:
    void emitWorkingDirectoryChanged();

private:
    Utils::FileName m_workingDirectory;
    Utils::FileName m_lastEmmitedWorkingDirectory;
};

class BuildConfigurationFactory : public ProjectExplorer::IBuildConfigurationFactory
{
    Q_OBJECT

public:
    explicit BuildConfigurationFactory(QObject* parent = 0);

    int priority(ProjectExplorer::Target const* parent) const;
    int priority(ProjectExplorer::Kit const* k, QString const& projectPath) const;

    QList<ProjectExplorer::BuildInfo*>
    availableBuilds(ProjectExplorer::Target const* parent) const;

    QList<ProjectExplorer::BuildInfo*>
    availableSetups(ProjectExplorer::Kit const* k, QString const& projectPath) const;

    ProjectExplorer::BuildConfiguration*
    create(ProjectExplorer::Target* parent
         , ProjectExplorer::BuildInfo const* info) const;

    bool
    canClone(ProjectExplorer::Target const* parent
           , ProjectExplorer::BuildConfiguration* source) const;

    BuildConfiguration*
    clone(ProjectExplorer::Target* parent, ProjectExplorer::BuildConfiguration* source);

    bool
    canRestore(ProjectExplorer::Target const* parent, QVariantMap const& map) const;

    BuildConfiguration*
    restore(ProjectExplorer::Target *parent, QVariantMap const& map);

    static Utils::FileName defaultBuildDirectory(QString const& top);
    static Utils::FileName defaultWorkingDirectory(QString const& top);

private:
    bool canHandle(ProjectExplorer::Target const* target) const;

    BuildInfo*
    createBuildInfo(ProjectExplorer::Kit const* k
                  , QString const& projectPath
                  , BuildConfiguration::BuildType type) const;
};

class BuildSettingsWidget : public ProjectExplorer::NamedWidget
{
    Q_OBJECT

public:
    BuildSettingsWidget(BuildConfiguration* bc);

private slots:
    void environmentHasChanged();
    void buildDirectoryChanged();
    void workingDirectoryChanged();

private:
    BuildConfiguration *m_bc;
    Utils::PathChooser *m_workPathChooser;
    Utils::PathChooser *m_buildPathChooser;
};

} // namespace Internal
} // namespace BoostBuildProjectManager

#endif // BBBUILDCONFIGURATION_HPP