| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 1 | // 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 |  | 
 | 15 | package config | 
 | 16 |  | 
 | 17 | import ( | 
 | 18 | 	"strings" | 
 | 19 |  | 
 | 20 | 	"android/soong/android" | 
 | 21 | ) | 
 | 22 |  | 
 | 23 | var ( | 
 | 24 | 	ArmRustFlags            = []string{} | 
 | 25 | 	ArmArchFeatureRustFlags = map[string][]string{} | 
| Ivan Lozano | 6d45a98 | 2020-09-09 09:08:44 -0400 | [diff] [blame] | 26 | 	ArmLinkFlags            = []string{} | 
| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 27 |  | 
 | 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 |  | 
 | 36 | func 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 |  | 
| Cole Faust | 8982b1c | 2024-04-08 16:54:45 -0700 | [diff] [blame] | 47 | 	pctx.StaticVariable("DEVICE_ARM_RUSTC_FLAGS", strings.Join(ArmRustFlags, " ")) | 
| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 48 | } | 
 | 49 |  | 
 | 50 | type toolchainArm struct { | 
| Ivan Lozano | 9d1df10 | 2020-04-28 10:10:23 -0400 | [diff] [blame] | 51 | 	toolchain32Bit | 
| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 52 | 	toolchainRustFlags string | 
 | 53 | } | 
 | 54 |  | 
 | 55 | func (t *toolchainArm) RustTriple() string { | 
| Matthew Maurer | ad64c39 | 2020-09-24 14:19:27 -0700 | [diff] [blame] | 56 | 	return "armv7-linux-androideabi" | 
| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 57 | } | 
 | 58 |  | 
 | 59 | func (t *toolchainArm) ToolchainLinkFlags() string { | 
| Ivan Lozano | 6d45a98 | 2020-09-09 09:08:44 -0400 | [diff] [blame] | 60 | 	// Prepend the lld flags from cc_config so we stay in sync with cc | 
 | 61 | 	return "${config.DeviceGlobalLinkFlags} ${cc_config.ArmLldflags} ${config.ArmToolchainLinkFlags}" | 
| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 62 | } | 
 | 63 |  | 
 | 64 | func (t *toolchainArm) ToolchainRustFlags() string { | 
 | 65 | 	return t.toolchainRustFlags | 
 | 66 | } | 
 | 67 |  | 
 | 68 | func (t *toolchainArm) RustFlags() string { | 
 | 69 | 	return "${config.ArmToolchainRustFlags}" | 
 | 70 | } | 
 | 71 |  | 
 | 72 | func (t *toolchainArm) Supported() bool { | 
 | 73 | 	return true | 
 | 74 | } | 
 | 75 |  | 
| Ivan Lozano | 6cd99e6 | 2020-02-11 08:24:25 -0500 | [diff] [blame] | 76 | func (toolchainArm) LibclangRuntimeLibraryArch() string { | 
 | 77 | 	return "arm" | 
 | 78 | } | 
 | 79 |  | 
| Ivan Lozano | e91823e | 2019-09-20 13:45:59 -0700 | [diff] [blame] | 80 | func ArmToolchainFactory(arch android.Arch) Toolchain { | 
 | 81 | 	toolchainRustFlags := []string{ | 
 | 82 | 		"${config.ArmToolchainRustFlags}", | 
 | 83 | 		"${config.Arm" + arch.ArchVariant + "VariantRustFlags}", | 
 | 84 | 	} | 
 | 85 |  | 
 | 86 | 	toolchainRustFlags = append(toolchainRustFlags, deviceGlobalRustFlags...) | 
 | 87 |  | 
 | 88 | 	for _, feature := range arch.ArchFeatures { | 
 | 89 | 		toolchainRustFlags = append(toolchainRustFlags, ArmArchFeatureRustFlags[feature]...) | 
 | 90 | 	} | 
 | 91 |  | 
 | 92 | 	return &toolchainArm{ | 
 | 93 | 		toolchainRustFlags: strings.Join(toolchainRustFlags, " "), | 
 | 94 | 	} | 
 | 95 | } |