blob: 180dd8fb81b08193c3b93e377cbf4e8c69dfc599 [file] [log] [blame]
Adam Lesinski40e8eef2014-09-16 14:43:29 -07001/*
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
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080019using namespace android;
20
Adam Lesinski40e8eef2014-09-16 14:43:29 -070021namespace split {
22namespace abi {
23
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080024static Vector<Variant> buildVariants(Variant v1, Variant v2) {
25 Vector<Variant> v;
26 v.add(v1);
27 v.add(v2);
28 return v;
29}
30
31static 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
39static const Vector<Variant> sNoneVariants;
40static const Vector<Variant> sArmVariants = buildVariants(Variant_armeabi, Variant_armeabi_v7a, Variant_arm64_v8a);
41static const Vector<Variant> sIntelVariants = buildVariants(Variant_x86, Variant_x86_64);
42static const Vector<Variant> sMipsVariants = buildVariants(Variant_mips, Variant_mips64);
Adam Lesinski40e8eef2014-09-16 14:43:29 -070043
44Family getFamily(Variant variant) {
45 switch (variant) {
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080046 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;
Adam Lesinski40e8eef2014-09-16 14:43:29 -070058 }
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080059 return Family_none;
Adam Lesinski40e8eef2014-09-16 14:43:29 -070060}
61
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080062const Vector<Variant>& getVariants(Family family) {
Adam Lesinski40e8eef2014-09-16 14:43:29 -070063 switch (family) {
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080064 case Family_none:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070065 return sNoneVariants;
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080066 case Family_arm:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070067 return sArmVariants;
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080068 case Family_intel:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070069 return sIntelVariants;
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080070 case Family_mips:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070071 return sMipsVariants;
72 }
73 return sNoneVariants;
74}
75
76const char* toString(Variant variant) {
77 switch (variant) {
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080078 case Variant_none:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070079 return "";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080080 case Variant_armeabi:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070081 return "armeabi";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080082 case Variant_armeabi_v7a:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070083 return "armeabi-v7a";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080084 case Variant_arm64_v8a:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070085 return "arm64-v8a";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080086 case Variant_x86:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070087 return "x86";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080088 case Variant_x86_64:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070089 return "x86_64";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080090 case Variant_mips:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070091 return "mips";
Adam Lesinskic3dc0b52014-11-03 12:05:15 -080092 case Variant_mips64:
Adam Lesinski40e8eef2014-09-16 14:43:29 -070093 return "mips64";
94 }
95 return "";
96}
97
98} // namespace abi
99} // namespace split