Colin Cross | 3f40fa4 | 2015-01-30 17:27:36 -0800 | [diff] [blame^] | 1 | // Copyright 2015 Google Inc. All rights reserved. |
| 2 | // |
| 3 | // Licensed under the Apache License, Version 2.0 (the "License"); |
| 4 | // you may not use this file except in compliance with the License. |
| 5 | // You may obtain a copy of the License at |
| 6 | // |
| 7 | // http://www.apache.org/licenses/LICENSE-2.0 |
| 8 | // |
| 9 | // Unless required by applicable law or agreed to in writing, software |
| 10 | // distributed under the License is distributed on an "AS IS" BASIS, |
| 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 12 | // See the License for the specific language governing permissions and |
| 13 | // limitations under the License. |
| 14 | |
| 15 | package cc |
| 16 | |
| 17 | import ( |
| 18 | "android/soong/common" |
| 19 | ) |
| 20 | |
| 21 | type toolchainFactory func(archVariant string, cpuVariant string) toolchain |
| 22 | |
| 23 | var toolchainFactories = map[common.HostOrDevice]map[common.ArchType]toolchainFactory{ |
| 24 | common.Host: make(map[common.ArchType]toolchainFactory), |
| 25 | common.Device: make(map[common.ArchType]toolchainFactory), |
| 26 | } |
| 27 | |
| 28 | func registerToolchainFactory(hod common.HostOrDevice, arch common.ArchType, |
| 29 | factory toolchainFactory) { |
| 30 | |
| 31 | toolchainFactories[hod][arch] = factory |
| 32 | } |
| 33 | |
| 34 | type toolchain interface { |
| 35 | GccRoot() string |
| 36 | GccTriple() string |
| 37 | Cflags() string |
| 38 | Cppflags() string |
| 39 | Ldflags() string |
| 40 | IncludeFlags() string |
| 41 | |
| 42 | ClangTriple() string |
| 43 | ClangCflags() string |
| 44 | ClangCppflags() string |
| 45 | ClangLdflags() string |
| 46 | |
| 47 | Is64Bit() bool |
| 48 | } |
| 49 | |
| 50 | type toolchain64Bit struct { |
| 51 | } |
| 52 | |
| 53 | func (toolchain64Bit) Is64Bit() bool { |
| 54 | return true |
| 55 | } |
| 56 | |
| 57 | type toolchain32Bit struct { |
| 58 | } |
| 59 | |
| 60 | func (toolchain32Bit) Is64Bit() bool { |
| 61 | return false |
| 62 | } |