abi.h 4.4 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
7
**
hjk's avatar
hjk committed
8 9 10 11 12 13 14
** 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
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15 16
**
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17 18 19 20 21 22
** 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.
23
**
hjk's avatar
hjk committed
24 25
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
26 27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
29 30 31 32 33 34

#ifndef PROJECTEXPLORER_ABI_H
#define PROJECTEXPLORER_ABI_H

#include "projectexplorer_export.h"

35
#include <QList>
36

37 38
namespace Utils { class FileName; }

39 40 41
namespace ProjectExplorer {

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

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

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

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

73
        // Linux
hjk's avatar
hjk committed
74
        GenericLinuxFlavor,
BogDan Vatra's avatar
BogDan Vatra committed
75
        AndroidLinuxFlavor,
76 77

        // Mac
hjk's avatar
hjk committed
78
        GenericMacFlavor,
79 80

        // Unix
hjk's avatar
hjk committed
81
        GenericUnixFlavor,
82
        SolarisUnixFlavor,
83 84

        // Windows
85 86 87
        WindowsMsvc2005Flavor,
        WindowsMsvc2008Flavor,
        WindowsMsvc2010Flavor,
Tobias Hunger's avatar
Tobias Hunger committed
88
        WindowsMsvc2012Flavor,
Yuchen Deng's avatar
Yuchen Deng committed
89
        WindowsMsvc2013Flavor,
hjk's avatar
hjk committed
90
        WindowsMSysFlavor,
91 92 93
        WindowsCEFlavor,

        UnknownFlavor
94 95 96
    };

    enum BinaryFormat {
hjk's avatar
hjk committed
97 98 99
        ElfFormat,
        MachOFormat,
        PEFormat,
100 101
        RuntimeQmlFormat,
        UnknownFormat
102 103
    };

Tobias Hunger's avatar
Tobias Hunger committed
104 105 106 107 108 109
    enum Endianness {
        LittleEndian,
        BigEndian,
        UnknownEndian
    };

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

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

119 120
    static Abi abiFromTargetTriplet(const QString &machineTriple);

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

    Architecture architecture() const { return m_architecture; }
Tobias Hunger's avatar
Tobias Hunger committed
129
    Endianness endianness() const;
130
    OS os() const { return m_os; }
hjk's avatar
hjk committed
131
    OSFlavor osFlavor() const { return m_osFlavor; }
132 133 134 135 136 137 138
    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
139
    static QString toString(const OSFlavor &of);
140 141 142
    static QString toString(const BinaryFormat &bf);
    static QString toString(int w);

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

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

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

} // namespace ProjectExplorer

#endif // PROJECTEXPLORER_ABI_H