aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/projectexplorer/toolchainmanager.h
blob: 563539847d98ff38ef1b5288a65de9d7e2b3ca32 (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
// Copyright (C) 2016 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0

#pragma once

#include "projectexplorer_export.h"

#include "toolchain.h"

#include <QList>
#include <QObject>
#include <QSet>
#include <QString>

#include <functional>

namespace Utils { class FilePath; }

namespace ProjectExplorer {

class ProjectExplorerPlugin;
class Abi;

class ToolchainDetectionSettings
{
public:
    bool detectX64AsX32 = false;
};

// --------------------------------------------------------------------------
// ToolchainManager
// --------------------------------------------------------------------------

class PROJECTEXPLORER_EXPORT ToolchainManager : public QObject
{
    Q_OBJECT

public:
    static ToolchainManager *instance();
    ~ToolchainManager() override;

    static const Toolchains &toolchains();
    static Toolchains toolchains(const Toolchain::Predicate &predicate);

    static Toolchain *toolchain(const Toolchain::Predicate &predicate);
    static QList<Toolchain *> findToolchains(const Abi &abi);
    static Toolchain *findToolchain(const QByteArray &id);

    static bool isLoaded();

    static bool registerToolchain(Toolchain *tc);
    static void deregisterToolchain(Toolchain *tc);

    static QList<Utils::Id> allLanguages();
    static bool registerLanguage(const Utils::Id &language, const QString &displayName);
    static QString displayNameOfLanguageId(const Utils::Id &id);
    static bool isLanguageSupported(const Utils::Id &id);

    static void aboutToShutdown();

    static ToolchainDetectionSettings detectionSettings();
    static void setDetectionSettings(const ToolchainDetectionSettings &settings);

    static void resetBadToolchains();
    static bool isBadToolchain(const Utils::FilePath &toolchain);
    static void addBadToolchain(const Utils::FilePath &toolchain);

    void saveToolchains();

signals:
    void toolhainAdded(ProjectExplorer::Toolchain *);
    // Toolchain is still valid when this call happens!
    void toolchainRemoved(ProjectExplorer::Toolchain *);
    // Toolchain was updated.
    void toolchainUpdated(ProjectExplorer::Toolchain *);
    // Something changed.
    void toolchainsChanged();
    //
    void toolchainsLoaded();

private:
    explicit ToolchainManager(QObject *parent = nullptr);

    // Make sure the this is only called after all toolchain factories are registered!
    static void restoreToolchains();

    static void notifyAboutUpdate(Toolchain *);

    friend class ProjectExplorerPlugin; // for constructor
    friend class Toolchain;
};

} // namespace ProjectExplorer