1 /*
2  * Copyright (C) 2014 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include "Abi.h"
18 
19 using namespace android;
20 
21 namespace split {
22 namespace abi {
23 
buildVariants(Variant v1,Variant v2)24 static Vector<Variant> buildVariants(Variant v1, Variant v2) {
25     Vector<Variant> v;
26     v.add(v1);
27     v.add(v2);
28     return v;
29 }
30 
buildVariants(Variant v1,Variant v2,Variant v3)31 static Vector<Variant> buildVariants(Variant v1, Variant v2, Variant v3) {
32     Vector<Variant> v;
33     v.add(v1);
34     v.add(v2);
35     v.add(v3);
36     return v;
37 }
38 
39 static const Vector<Variant> sNoneVariants;
40 static const Vector<Variant> sArmVariants = buildVariants(Variant_armeabi, Variant_armeabi_v7a, Variant_arm64_v8a);
41 static const Vector<Variant> sIntelVariants = buildVariants(Variant_x86, Variant_x86_64);
42 static const Vector<Variant> sMipsVariants = buildVariants(Variant_mips, Variant_mips64);
43 
getFamily(Variant variant)44 Family getFamily(Variant variant) {
45     switch (variant) {
46         case Variant_none:
47             return Family_none;
48         case Variant_armeabi:
49         case Variant_armeabi_v7a:
50         case Variant_arm64_v8a:
51             return Family_arm;
52         case Variant_x86:
53         case Variant_x86_64:
54             return Family_intel;
55         case Variant_mips:
56         case Variant_mips64:
57             return Family_mips;
58     }
59     return Family_none;
60 }
61 
getVariants(Family family)62 const Vector<Variant>& getVariants(Family family) {
63     switch (family) {
64         case Family_none:
65             return sNoneVariants;
66         case Family_arm:
67             return sArmVariants;
68         case Family_intel:
69             return sIntelVariants;
70         case Family_mips:
71             return sMipsVariants;
72     }
73     return sNoneVariants;
74 }
75 
toString(Variant variant)76 const char* toString(Variant variant) {
77     switch (variant) {
78         case Variant_none:
79             return "";
80         case Variant_armeabi:
81             return "armeabi";
82         case Variant_armeabi_v7a:
83             return "armeabi-v7a";
84         case Variant_arm64_v8a:
85             return "arm64-v8a";
86         case Variant_x86:
87             return "x86";
88         case Variant_x86_64:
89             return "x86_64";
90         case Variant_mips:
91             return "mips";
92         case Variant_mips64:
93             return "mips64";
94     }
95     return "";
96 }
97 
98 } // namespace abi
99 } // namespace split
100