blob: ddd93e8894d6a6e159a77c8c890ae9da44f4cfd7 [file] [log] [blame]
Ivan Lozano1c2ff862019-10-21 09:57:38 -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 (
Jeff Vander Stoep6e97a7b2020-07-15 21:34:45 +020024 DarwinRustFlags = []string{}
25 DarwinRustLinkFlags = []string{
ThiƩbaud Weksteen682c9d72020-08-31 10:06:16 +020026 "-B${cc_config.MacToolPath}",
Jeff Vander Stoep6e97a7b2020-07-15 21:34:45 +020027 }
Ivan Lozano1c2ff862019-10-21 09:57:38 -070028 darwinX8664Rustflags = []string{}
29 darwinX8664Linkflags = []string{}
30)
31
32func 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
41type toolchainDarwin struct {
42 toolchainRustFlags string
43 toolchainLinkFlags string
44}
45
46type toolchainDarwinX8664 struct {
47 toolchain64Bit
48 toolchainDarwin
49}
50
51func (toolchainDarwinX8664) Supported() bool {
52 return true
53}
54
55func (toolchainDarwinX8664) Bionic() bool {
56 return false
57}
58
59func (t *toolchainDarwinX8664) Name() string {
60 return "x86_64"
61}
62
63func (t *toolchainDarwinX8664) RustTriple() string {
64 return "x86_64-apple-darwin"
65}
66
Ivan Lozanoc0ccb6b2020-05-28 11:31:16 -040067func (t *toolchainDarwin) SharedLibSuffix() string {
68 return ".dylib"
69}
70
Ivan Lozano33c05282020-07-15 11:33:37 -040071func (t *toolchainDarwin) DylibSuffix() string {
72 return ".rustlib.dylib"
73}
74
Ivan Lozanoc0ccb6b2020-05-28 11:31:16 -040075func (t *toolchainDarwin) ProcMacroSuffix() string {
Ivan Lozano1c2ff862019-10-21 09:57:38 -070076 return ".dylib"
77}
78
79func (t *toolchainDarwinX8664) ToolchainLinkFlags() string {
Ivan Lozano6d45a982020-09-09 09:08:44 -040080 // Prepend the lld flags from cc_config so we stay in sync with cc
81 return "${cc_config.DarwinClangLldflags} ${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
Ivan Lozano1c2ff862019-10-21 09:57:38 -070082}
83
84func (t *toolchainDarwinX8664) ToolchainRustFlags() string {
85 return "${config.DarwinToolchainRustFlags} ${config.DarwinToolchainX8664RustFlags}"
86}
87
88func darwinX8664ToolchainFactory(arch android.Arch) Toolchain {
89 return toolchainDarwinX8664Singleton
90}
91
92var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}