abi.h 4.07 KB
Newer Older
1 2 3 4
/**************************************************************************
**
** This file is part of Qt Creator
**
hjk's avatar
hjk committed
5
** Copyright (c) 2012 Nokia Corporation and/or its subsidiary(-ies).
6
**
Eike Ziller's avatar
Eike Ziller committed
7
** Contact: http://www.qt-project.org/
8 9 10 11
**
**
** GNU Lesser General Public License Usage
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18 19
**
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
28 29 30 31 32 33 34 35
**
**************************************************************************/

#ifndef PROJECTEXPLORER_ABI_H
#define PROJECTEXPLORER_ABI_H

#include "projectexplorer_export.h"

Tobias Hunger's avatar
Tobias Hunger committed
36 37
#include <utils/fileutils.h>

38
#include <QList>
39 40 41 42

namespace ProjectExplorer {

// --------------------------------------------------------------------------
43
// ABI (documentation inside)
44 45 46 47 48 49
// --------------------------------------------------------------------------

class PROJECTEXPLORER_EXPORT Abi
{
public:
    enum Architecture {
hjk's avatar
hjk committed
50 51 52
        ArmArchitecture,
        X86Architecture,
        ItaniumArchitecture,
Tobias Hunger's avatar
Tobias Hunger committed
53
        MipsArchitecture,
54
        PowerPCArchitecture,
Tobias Hunger's avatar
Tobias Hunger committed
55
        ShArchitecture,
56
        UnknownArchitecture
57 58 59
    };

    enum OS {
60
        BsdOS,
hjk's avatar
hjk committed
61 62 63 64
        LinuxOS,
        MacOS,
        SymbianOS,
        UnixOS,
65 66
        WindowsOS,
        UnknownOS
67 68
    };

hjk's avatar
hjk committed
69
    enum OSFlavor {
70
        // BSDs
71 72 73
        FreeBsdFlavor,
        NetBsdFlavor,
        OpenBsdFlavor,
74

75
        // Linux
hjk's avatar
hjk committed
76
        GenericLinuxFlavor,
BogDan Vatra's avatar
BogDan Vatra committed
77
        AndroidLinuxFlavor,
hjk's avatar
hjk committed
78 79 80
        HarmattanLinuxFlavor,
        MaemoLinuxFlavor,
        MeegoLinuxFlavor,
81 82

        // Mac
hjk's avatar
hjk committed
83
        GenericMacFlavor,
84 85

        // Symbian
hjk's avatar
hjk committed
86 87
        SymbianDeviceFlavor,
        SymbianEmulatorFlavor,
88 89

        // Unix
hjk's avatar
hjk committed
90
        GenericUnixFlavor,
91
        SolarisUnixFlavor,
92 93

        // Windows
94 95 96
        WindowsMsvc2005Flavor,
        WindowsMsvc2008Flavor,
        WindowsMsvc2010Flavor,
Tobias Hunger's avatar
Tobias Hunger committed
97
        WindowsMsvc2012Flavor,
hjk's avatar
hjk committed
98
        WindowsMSysFlavor,
99 100 101
        WindowsCEFlavor,

        UnknownFlavor
102 103 104
    };

    enum BinaryFormat {
hjk's avatar
hjk committed
105 106 107
        ElfFormat,
        MachOFormat,
        PEFormat,
108 109
        RuntimeQmlFormat,
        UnknownFormat
110 111 112
    };

    Abi() :
hjk's avatar
hjk committed
113 114
        m_architecture(UnknownArchitecture), m_os(UnknownOS),
        m_osFlavor(UnknownFlavor), m_binaryFormat(UnknownFormat), m_wordWidth(0)
115 116 117
    { }

    Abi(const Architecture &a, const OS &o,
hjk's avatar
hjk committed
118
        const OSFlavor &so, const BinaryFormat &f, unsigned char w);
119 120
    Abi(const QString &abiString);

Tobias Hunger's avatar
Tobias Hunger committed
121
    bool operator != (const Abi &other) const;
122 123 124 125
    bool operator == (const Abi &other) const;
    bool isCompatibleWith(const Abi &other) const;

    bool isValid() const;
Tobias Hunger's avatar
Tobias Hunger committed
126
    bool isNull() const;
127 128 129

    Architecture architecture() const { return m_architecture; }
    OS os() const { return m_os; }
hjk's avatar
hjk committed
130
    OSFlavor osFlavor() const { return m_osFlavor; }
131 132 133 134 135 136 137
    BinaryFormat binaryFormat() const { return m_binaryFormat; }
    unsigned char wordWidth() const { return m_wordWidth; }

    QString toString() const;

    static QString toString(const Architecture &a);
    static QString toString(const OS &o);
hjk's avatar
hjk committed
138
    static QString toString(const OSFlavor &of);
139 140 141
    static QString toString(const BinaryFormat &bf);
    static QString toString(int w);

142 143
    static QList<OSFlavor> flavorsForOs(const OS &o);

144
    static Abi hostAbi();
Tobias Hunger's avatar
Tobias Hunger committed
145
    static QList<Abi> abisOfBinary(const Utils::FileName &path);
146 147 148 149

private:
    Architecture m_architecture;
    OS m_os;
hjk's avatar
hjk committed
150
    OSFlavor m_osFlavor;
151 152 153 154 155 156 157
    BinaryFormat m_binaryFormat;
    unsigned char m_wordWidth;
};

} // namespace ProjectExplorer

#endif // PROJECTEXPLORER_ABI_H