Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 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 | |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 19 | using namespace android; |
| 20 | |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 21 | namespace split { |
| 22 | namespace abi { |
| 23 | |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 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 | |
| 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); |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 43 | |
| 44 | Family getFamily(Variant variant) { |
| 45 | switch (variant) { |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 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; |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 58 | } |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 59 | return Family_none; |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 60 | } |
| 61 | |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 62 | const Vector<Variant>& getVariants(Family family) { |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 63 | switch (family) { |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 64 | case Family_none: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 65 | return sNoneVariants; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 66 | case Family_arm: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 67 | return sArmVariants; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 68 | case Family_intel: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 69 | return sIntelVariants; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 70 | case Family_mips: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 71 | return sMipsVariants; |
| 72 | } |
| 73 | return sNoneVariants; |
| 74 | } |
| 75 | |
| 76 | const char* toString(Variant variant) { |
| 77 | switch (variant) { |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 78 | case Variant_none: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 79 | return ""; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 80 | case Variant_armeabi: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 81 | return "armeabi"; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 82 | case Variant_armeabi_v7a: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 83 | return "armeabi-v7a"; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 84 | case Variant_arm64_v8a: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 85 | return "arm64-v8a"; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 86 | case Variant_x86: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 87 | return "x86"; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 88 | case Variant_x86_64: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 89 | return "x86_64"; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 90 | case Variant_mips: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 91 | return "mips"; |
Adam Lesinski | c3dc0b5 | 2014-11-03 12:05:15 -0800 | [diff] [blame] | 92 | case Variant_mips64: |
Adam Lesinski | 40e8eef | 2014-09-16 14:43:29 -0700 | [diff] [blame] | 93 | return "mips64"; |
| 94 | } |
| 95 | return ""; |
| 96 | } |
| 97 | |
| 98 | } // namespace abi |
| 99 | } // namespace split |