1 | |
2 | |
3 | |
4 | |
5 | |
6 | |
7 | |
8 | |
9 | #ifndef LLVM_CLANG_DRIVER_DISTRO_H |
10 | #define LLVM_CLANG_DRIVER_DISTRO_H |
11 | |
12 | #include "llvm/Support/VirtualFileSystem.h" |
13 | |
14 | namespace clang { |
15 | namespace driver { |
16 | |
17 | |
18 | |
19 | |
20 | |
21 | |
22 | class Distro { |
23 | public: |
24 | enum DistroType { |
25 | |
26 | |
27 | |
28 | AlpineLinux, |
29 | ArchLinux, |
30 | DebianLenny, |
31 | DebianSqueeze, |
32 | DebianWheezy, |
33 | DebianJessie, |
34 | DebianStretch, |
35 | DebianBuster, |
36 | Exherbo, |
37 | RHEL5, |
38 | RHEL6, |
39 | RHEL7, |
40 | Fedora, |
41 | Gentoo, |
42 | OpenSUSE, |
43 | UbuntuHardy, |
44 | UbuntuIntrepid, |
45 | UbuntuJaunty, |
46 | UbuntuKarmic, |
47 | UbuntuLucid, |
48 | UbuntuMaverick, |
49 | UbuntuNatty, |
50 | UbuntuOneiric, |
51 | UbuntuPrecise, |
52 | UbuntuQuantal, |
53 | UbuntuRaring, |
54 | UbuntuSaucy, |
55 | UbuntuTrusty, |
56 | UbuntuUtopic, |
57 | UbuntuVivid, |
58 | UbuntuWily, |
59 | UbuntuXenial, |
60 | UbuntuYakkety, |
61 | UbuntuZesty, |
62 | UbuntuArtful, |
63 | UbuntuBionic, |
64 | UbuntuCosmic, |
65 | UbuntuDisco, |
66 | UnknownDistro |
67 | }; |
68 | |
69 | private: |
70 | |
71 | DistroType DistroVal; |
72 | |
73 | public: |
74 | |
75 | |
76 | |
77 | |
78 | Distro() : DistroVal() {} |
79 | |
80 | |
81 | Distro(DistroType D) : DistroVal(D) {} |
82 | |
83 | |
84 | explicit Distro(llvm::vfs::FileSystem &VFS); |
85 | |
86 | bool operator==(const Distro &Other) const { |
87 | return DistroVal == Other.DistroVal; |
88 | } |
89 | |
90 | bool operator!=(const Distro &Other) const { |
91 | return DistroVal != Other.DistroVal; |
92 | } |
93 | |
94 | bool operator>=(const Distro &Other) const { |
95 | return DistroVal >= Other.DistroVal; |
96 | } |
97 | |
98 | bool operator<=(const Distro &Other) const { |
99 | return DistroVal <= Other.DistroVal; |
100 | } |
101 | |
102 | |
103 | |
104 | |
105 | |
106 | bool IsRedhat() const { |
107 | return DistroVal == Fedora || (DistroVal >= RHEL5 && DistroVal <= RHEL7); |
108 | } |
109 | |
110 | bool IsOpenSUSE() const { |
111 | return DistroVal == OpenSUSE; |
112 | } |
113 | |
114 | bool IsDebian() const { |
115 | return DistroVal >= DebianLenny && DistroVal <= DebianBuster; |
116 | } |
117 | |
118 | bool IsUbuntu() const { |
119 | return DistroVal >= UbuntuHardy && DistroVal <= UbuntuDisco; |
120 | } |
121 | |
122 | bool IsAlpineLinux() const { |
123 | return DistroVal == AlpineLinux; |
124 | } |
125 | |
126 | bool IsGentoo() const { |
127 | return DistroVal == Gentoo; |
128 | } |
129 | |
130 | |
131 | }; |
132 | |
133 | } |
134 | } |
135 | |
136 | #endif |
137 | |