blob: 291821bba022ed65bcc52e99f8660bc70c6219b5 [file] [log] [blame]
Colin Cross3f40fa42015-01-30 17:27:36 -08001// 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
15package cc
16
17import (
Tim Kilbourn1a9bf262015-03-18 12:28:32 -070018 "fmt"
19
Colin Cross3f40fa42015-01-30 17:27:36 -080020 "android/soong/common"
21)
22
23type toolchainFactory func(archVariant string, cpuVariant string) toolchain
24
25var toolchainFactories = map[common.HostOrDevice]map[common.ArchType]toolchainFactory{
26 common.Host: make(map[common.ArchType]toolchainFactory),
27 common.Device: make(map[common.ArchType]toolchainFactory),
28}
29
30func registerToolchainFactory(hod common.HostOrDevice, arch common.ArchType,
31 factory toolchainFactory) {
32
33 toolchainFactories[hod][arch] = factory
34}
35
36type toolchain interface {
37 GccRoot() string
38 GccTriple() string
39 Cflags() string
40 Cppflags() string
41 Ldflags() string
42 IncludeFlags() string
Tim Kilbourn1a9bf262015-03-18 12:28:32 -070043 InstructionSetFlags(string) (string, error)
Colin Cross3f40fa42015-01-30 17:27:36 -080044
45 ClangTriple() string
46 ClangCflags() string
47 ClangCppflags() string
48 ClangLdflags() string
49
50 Is64Bit() bool
51}
52
Tim Kilbourn1a9bf262015-03-18 12:28:32 -070053type toolchainBase struct {
54}
55
56func (toolchainBase) InstructionSetFlags(s string) (string, error) {
57 if s != "" {
58 return "", fmt.Errorf("instruction_set: %s is not a supported instruction set", s)
59 }
60 return "", nil
61}
62
Colin Cross3f40fa42015-01-30 17:27:36 -080063type toolchain64Bit struct {
Tim Kilbourn1a9bf262015-03-18 12:28:32 -070064 toolchainBase
Colin Cross3f40fa42015-01-30 17:27:36 -080065}
66
67func (toolchain64Bit) Is64Bit() bool {
68 return true
69}
70
71type toolchain32Bit struct {
Tim Kilbourn1a9bf262015-03-18 12:28:32 -070072 toolchainBase
Colin Cross3f40fa42015-01-30 17:27:36 -080073}
74
75func (toolchain32Bit) Is64Bit() bool {
76 return false
77}