blob: 42c1c02564d328b4fc4775ee26a9ed54473e1d7d [file] [log] [blame]
Ivan Lozanoe91823e2019-09-20 13:45:59 -07001// Copyright 2019 The Android Open Source Project
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 config
16
17import (
18 "strings"
19
20 "android/soong/android"
21)
22
23var (
24 ArmRustFlags = []string{}
25 ArmArchFeatureRustFlags = map[string][]string{}
Ivan Lozano6d45a982020-09-09 09:08:44 -040026 ArmLinkFlags = []string{}
Ivan Lozanoe91823e2019-09-20 13:45:59 -070027
28 ArmArchVariantRustFlags = map[string][]string{
29 "armv7-a": []string{},
30 "armv7-a-neon": []string{},
31 "armv8-a": []string{},
32 "armv8-2a": []string{},
33 }
34)
35
36func init() {
37 registerToolchainFactory(android.Android, android.Arm, ArmToolchainFactory)
38
39 pctx.StaticVariable("ArmToolchainRustFlags", strings.Join(ArmRustFlags, " "))
40 pctx.StaticVariable("ArmToolchainLinkFlags", strings.Join(ArmLinkFlags, " "))
41
42 for variant, rustFlags := range ArmArchVariantRustFlags {
43 pctx.StaticVariable("Arm"+variant+"VariantRustFlags",
44 strings.Join(rustFlags, " "))
45 }
46
47}
48
49type toolchainArm struct {
Ivan Lozano9d1df102020-04-28 10:10:23 -040050 toolchain32Bit
Ivan Lozanoe91823e2019-09-20 13:45:59 -070051 toolchainRustFlags string
52}
53
54func (t *toolchainArm) RustTriple() string {
Matthew Maurerad64c392020-09-24 14:19:27 -070055 return "armv7-linux-androideabi"
Ivan Lozanoe91823e2019-09-20 13:45:59 -070056}
57
58func (t *toolchainArm) ToolchainLinkFlags() string {
Ivan Lozano6d45a982020-09-09 09:08:44 -040059 // Prepend the lld flags from cc_config so we stay in sync with cc
60 return "${config.DeviceGlobalLinkFlags} ${cc_config.ArmLldflags} ${config.ArmToolchainLinkFlags}"
Ivan Lozanoe91823e2019-09-20 13:45:59 -070061}
62
63func (t *toolchainArm) ToolchainRustFlags() string {
64 return t.toolchainRustFlags
65}
66
67func (t *toolchainArm) RustFlags() string {
68 return "${config.ArmToolchainRustFlags}"
69}
70
71func (t *toolchainArm) Supported() bool {
72 return true
73}
74
Ivan Lozano6cd99e62020-02-11 08:24:25 -050075func (toolchainArm) LibclangRuntimeLibraryArch() string {
76 return "arm"
77}
78
Ivan Lozanoe91823e2019-09-20 13:45:59 -070079func ArmToolchainFactory(arch android.Arch) Toolchain {
80 toolchainRustFlags := []string{
81 "${config.ArmToolchainRustFlags}",
82 "${config.Arm" + arch.ArchVariant + "VariantRustFlags}",
83 }
84
85 toolchainRustFlags = append(toolchainRustFlags, deviceGlobalRustFlags...)
86
87 for _, feature := range arch.ArchFeatures {
88 toolchainRustFlags = append(toolchainRustFlags, ArmArchFeatureRustFlags[feature]...)
89 }
90
91 return &toolchainArm{
92 toolchainRustFlags: strings.Join(toolchainRustFlags, " "),
93 }
94}