toolchain.h 5.32 KB
Newer Older
1 2 3 4 5 6
/**************************************************************************
**
** This file is part of Qt Creator
**
** Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies).
**
7
** Contact: Nokia Corporation (qt-info@nokia.com)
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
**
** Commercial Usage
**
** Licensees holding valid Qt Commercial licenses may use this file in
** accordance with the Qt Commercial License Agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Nokia.
**
** GNU Lesser General Public License Usage
**
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** If you are unsure which license is appropriate for your use, please
hjk's avatar
hjk committed
26
** contact the sales department at http://qt.nokia.com/contact.
27 28 29
**
**************************************************************************/

dt's avatar
dt committed
30 31 32 33
#ifndef TOOLCHAIN_H
#define TOOLCHAIN_H

#include "environment.h"
34
#include "project.h"
dt's avatar
dt committed
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
#include <QtCore/QString>
#include <QtCore/QPair>

namespace ProjectExplorer {

class PROJECTEXPLORER_EXPORT HeaderPath
{
public:
    enum Kind {
        GlobalHeaderPath,
        UserHeaderPath,
        FrameworkHeaderPath
    };

    HeaderPath()
        : _kind(GlobalHeaderPath)
    { }

    HeaderPath(const QString &path, Kind kind)
        : _path(path), _kind(kind)
    { }

    QString path() const { return _path; }
    Kind    kind() const { return _kind; }

private:
    QString _path;
    Kind _kind;
};



class PROJECTEXPLORER_EXPORT ToolChain
{
public:
    enum ToolChainType
    {
con's avatar
con committed
72 73 74 75 76
        GCC = 0,
        LinuxICC = 1,
        MinGW = 2,
        MSVC = 3,
        WINCE = 4,
77
#ifdef QTCREATOR_WITH_S60
con's avatar
con committed
78 79
        WINSCW = 5,
        GCCE = 6,
con's avatar
con committed
80 81
        RVCT_ARMV5 = 7,
        RVCT_ARMV6 = 8,
82 83 84
        LAST_VALID = 9,
#else
        LAST_VALID = 5,
85
#endif
con's avatar
con committed
86 87 88
        OTHER = 200,
        UNKNOWN = 201,
        INVALID = 202
dt's avatar
dt committed
89 90 91 92 93 94
    };

    virtual QByteArray predefinedMacros() = 0;
    virtual QList<HeaderPath> systemHeaderPaths() = 0;
    virtual void addToEnvironment(ProjectExplorer::Environment &env) = 0;
    virtual ToolChainType type() const = 0;
95
    virtual QString makeCommand() const = 0;
dt's avatar
dt committed
96 97 98 99 100

    ToolChain();
    virtual ~ToolChain();
    
    static bool equals(ToolChain *, ToolChain *);
101
    // Factory methods
dt's avatar
dt committed
102 103
    static ToolChain *createGccToolChain(const QString &gcc);
    static ToolChain *createMinGWToolChain(const QString &gcc, const QString &mingwPath);
104
    static ToolChain *createMSVCToolChain(const QString &name, bool amd64);
dt's avatar
dt committed
105 106
    static ToolChain *createWinCEToolChain(const QString &name, const QString &platform);
    static QStringList availableMSVCVersions();
107
    static QList<ToolChain::ToolChainType> supportedToolChains();
dt's avatar
dt committed
108

109 110
    static QString toolChainName(ToolChainType tc);

dt's avatar
dt committed
111 112 113 114
protected:
    virtual bool equals(ToolChain *other) const = 0;
};

115
class PROJECTEXPLORER_EXPORT GccToolChain : public ToolChain
dt's avatar
dt committed
116 117 118 119 120 121 122
{
public:
    GccToolChain(const QString &gcc);
    virtual QByteArray predefinedMacros();
    virtual QList<HeaderPath> systemHeaderPaths();
    virtual void addToEnvironment(ProjectExplorer::Environment &env);
    virtual ToolChainType type() const;
123
    virtual QString makeCommand() const;
dt's avatar
dt committed
124 125 126 127 128

protected:
    virtual bool equals(ToolChain *other) const;
    QByteArray m_predefinedMacros;
    QList<HeaderPath> m_systemHeaderPaths;
129 130
private:
    QString m_gcc;
dt's avatar
dt committed
131 132 133
};

// TODO this class needs to fleshed out more
134
class PROJECTEXPLORER_EXPORT MinGWToolChain : public GccToolChain
dt's avatar
dt committed
135 136 137 138 139
{
public:
    MinGWToolChain(const QString &gcc, const QString &mingwPath);
    virtual void addToEnvironment(ProjectExplorer::Environment &env);
    virtual ToolChainType type() const;
140
    virtual QString makeCommand() const;
dt's avatar
dt committed
141 142 143 144 145 146 147
protected:
    virtual bool equals(ToolChain *other) const;
private:
    QString m_mingwPath;
};

// TODO some stuff needs to be moved into this
148
class PROJECTEXPLORER_EXPORT MSVCToolChain : public ToolChain
dt's avatar
dt committed
149 150
{
public:
151
    MSVCToolChain(const QString &name, bool amd64 = false);
dt's avatar
dt committed
152 153 154 155
    virtual QByteArray predefinedMacros();
    virtual QList<HeaderPath> systemHeaderPaths();
    virtual void addToEnvironment(ProjectExplorer::Environment &env);
    virtual ToolChainType type() const;
156
    virtual QString makeCommand() const;
dt's avatar
dt committed
157 158
protected:
    virtual bool equals(ToolChain *other) const;
159
    QByteArray m_predefinedMacros;
dt's avatar
dt committed
160 161 162 163
    QString m_name;
private:
    mutable QList<QPair<QString, QString> > m_values;
    mutable bool m_valuesSet;
164
    mutable ProjectExplorer::Environment m_lastEnvironment;
165
    bool m_amd64;
dt's avatar
dt committed
166 167 168
};

// TODO some stuff needs to be moved into here
169
class PROJECTEXPLORER_EXPORT WinCEToolChain : public MSVCToolChain
dt's avatar
dt committed
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184
{
public:
    WinCEToolChain(const QString &name, const QString &platform);
    virtual QByteArray predefinedMacros();
    virtual QList<HeaderPath> systemHeaderPaths();
    virtual void addToEnvironment(ProjectExplorer::Environment &env);
    virtual ToolChainType type() const;
protected:
    virtual bool equals(ToolChain *other) const;
private:
    QString m_platform;
};

}

185 186
Q_DECLARE_METATYPE(ProjectExplorer::ToolChain::ToolChainType);

dt's avatar
dt committed
187
#endif // TOOLCHAIN_H