Ivan Lozano | 1c2ff86 | 2019-10-21 09:57:38 -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 ( |
Jeff Vander Stoep | 6e97a7b | 2020-07-15 21:34:45 +0200 | [diff] [blame] | 24 | DarwinRustFlags = []string{} |
| 25 | DarwinRustLinkFlags = []string{ |
ThiƩbaud Weksteen | 682c9d7 | 2020-08-31 10:06:16 +0200 | [diff] [blame] | 26 | "-B${cc_config.MacToolPath}", |
Jeff Vander Stoep | 6e97a7b | 2020-07-15 21:34:45 +0200 | [diff] [blame] | 27 | } |
Ivan Lozano | 1c2ff86 | 2019-10-21 09:57:38 -0700 | [diff] [blame] | 28 | darwinX8664Rustflags = []string{} |
| 29 | darwinX8664Linkflags = []string{} |
| 30 | ) |
| 31 | |
| 32 | func init() { |
| 33 | registerToolchainFactory(android.Darwin, android.X86_64, darwinX8664ToolchainFactory) |
| 34 | pctx.StaticVariable("DarwinToolchainRustFlags", strings.Join(DarwinRustFlags, " ")) |
| 35 | pctx.StaticVariable("DarwinToolchainLinkFlags", strings.Join(DarwinRustLinkFlags, " ")) |
| 36 | pctx.StaticVariable("DarwinToolchainX8664RustFlags", strings.Join(darwinX8664Rustflags, " ")) |
| 37 | pctx.StaticVariable("DarwinToolchainX8664LinkFlags", strings.Join(darwinX8664Linkflags, " ")) |
| 38 | |
| 39 | } |
| 40 | |
| 41 | type toolchainDarwin struct { |
| 42 | toolchainRustFlags string |
| 43 | toolchainLinkFlags string |
| 44 | } |
| 45 | |
| 46 | type toolchainDarwinX8664 struct { |
| 47 | toolchain64Bit |
| 48 | toolchainDarwin |
| 49 | } |
| 50 | |
| 51 | func (toolchainDarwinX8664) Supported() bool { |
| 52 | return true |
| 53 | } |
| 54 | |
| 55 | func (toolchainDarwinX8664) Bionic() bool { |
| 56 | return false |
| 57 | } |
| 58 | |
| 59 | func (t *toolchainDarwinX8664) Name() string { |
| 60 | return "x86_64" |
| 61 | } |
| 62 | |
| 63 | func (t *toolchainDarwinX8664) RustTriple() string { |
| 64 | return "x86_64-apple-darwin" |
| 65 | } |
| 66 | |
Ivan Lozano | c0ccb6b | 2020-05-28 11:31:16 -0400 | [diff] [blame] | 67 | func (t *toolchainDarwin) SharedLibSuffix() string { |
| 68 | return ".dylib" |
| 69 | } |
| 70 | |
Ivan Lozano | 33c0528 | 2020-07-15 11:33:37 -0400 | [diff] [blame] | 71 | func (t *toolchainDarwin) DylibSuffix() string { |
| 72 | return ".rustlib.dylib" |
| 73 | } |
| 74 | |
Ivan Lozano | c0ccb6b | 2020-05-28 11:31:16 -0400 | [diff] [blame] | 75 | func (t *toolchainDarwin) ProcMacroSuffix() string { |
Ivan Lozano | 1c2ff86 | 2019-10-21 09:57:38 -0700 | [diff] [blame] | 76 | return ".dylib" |
| 77 | } |
| 78 | |
| 79 | func (t *toolchainDarwinX8664) ToolchainLinkFlags() string { |
Ivan Lozano | 6d45a98 | 2020-09-09 09:08:44 -0400 | [diff] [blame] | 80 | // Prepend the lld flags from cc_config so we stay in sync with cc |
| 81 | return "${cc_config.DarwinClangLldflags} ${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}" |
Ivan Lozano | 1c2ff86 | 2019-10-21 09:57:38 -0700 | [diff] [blame] | 82 | } |
| 83 | |
| 84 | func (t *toolchainDarwinX8664) ToolchainRustFlags() string { |
| 85 | return "${config.DarwinToolchainRustFlags} ${config.DarwinToolchainX8664RustFlags}" |
| 86 | } |
| 87 | |
| 88 | func darwinX8664ToolchainFactory(arch android.Arch) Toolchain { |
| 89 | return toolchainDarwinX8664Singleton |
| 90 | } |
| 91 | |
| 92 | var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{} |