Add Rust darwin host support.
Support for building Rust modules on darwin hosts.
Bug: 140640858
Test: m libremain works on darwin
Change-Id: Ieb1ff9167de34cffbebebab31fa48da07081c8a6
diff --git a/Android.bp b/Android.bp
index b15a875b..817710e 100644
--- a/Android.bp
+++ b/Android.bp
@@ -340,6 +340,7 @@
"rust/config/global.go",
"rust/config/toolchain.go",
"rust/config/whitelist.go",
+ "rust/config/x86_darwin_host.go",
"rust/config/x86_linux_host.go",
"rust/config/x86_64_device.go",
],
diff --git a/rust/config/x86_darwin_host.go b/rust/config/x86_darwin_host.go
new file mode 100644
index 0000000..7cfc59c
--- /dev/null
+++ b/rust/config/x86_darwin_host.go
@@ -0,0 +1,81 @@
+// Copyright 2019 The Android Open Source Project
+//
+// Licensed under the Apache License, Version 2.0 (the "License");
+// you may not use this file except in compliance with the License.
+// You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing, software
+// distributed under the License is distributed on an "AS IS" BASIS,
+// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+// See the License for the specific language governing permissions and
+// limitations under the License.
+
+package config
+
+import (
+ "strings"
+
+ "android/soong/android"
+)
+
+var (
+ DarwinRustFlags = []string{}
+ DarwinRustLinkFlags = []string{}
+ darwinX8664Rustflags = []string{}
+ darwinX8664Linkflags = []string{}
+)
+
+func init() {
+ registerToolchainFactory(android.Darwin, android.X86_64, darwinX8664ToolchainFactory)
+ pctx.StaticVariable("DarwinToolchainRustFlags", strings.Join(DarwinRustFlags, " "))
+ pctx.StaticVariable("DarwinToolchainLinkFlags", strings.Join(DarwinRustLinkFlags, " "))
+ pctx.StaticVariable("DarwinToolchainX8664RustFlags", strings.Join(darwinX8664Rustflags, " "))
+ pctx.StaticVariable("DarwinToolchainX8664LinkFlags", strings.Join(darwinX8664Linkflags, " "))
+
+}
+
+type toolchainDarwin struct {
+ toolchainRustFlags string
+ toolchainLinkFlags string
+}
+
+type toolchainDarwinX8664 struct {
+ toolchain64Bit
+ toolchainDarwin
+}
+
+func (toolchainDarwinX8664) Supported() bool {
+ return true
+}
+
+func (toolchainDarwinX8664) Bionic() bool {
+ return false
+}
+
+func (t *toolchainDarwinX8664) Name() string {
+ return "x86_64"
+}
+
+func (t *toolchainDarwinX8664) RustTriple() string {
+ return "x86_64-apple-darwin"
+}
+
+func (t *toolchainDarwin) ShlibSuffix() string {
+ return ".dylib"
+}
+
+func (t *toolchainDarwinX8664) ToolchainLinkFlags() string {
+ return "${config.DarwinToolchainLinkFlags} ${config.DarwinToolchainX8664LinkFlags}"
+}
+
+func (t *toolchainDarwinX8664) ToolchainRustFlags() string {
+ return "${config.DarwinToolchainRustFlags} ${config.DarwinToolchainX8664RustFlags}"
+}
+
+func darwinX8664ToolchainFactory(arch android.Arch) Toolchain {
+ return toolchainDarwinX8664Singleton
+}
+
+var toolchainDarwinX8664Singleton Toolchain = &toolchainDarwinX8664{}
diff --git a/rust/rust.go b/rust/rust.go
index 4f5e7fb..707de4b 100644
--- a/rust/rust.go
+++ b/rust/rust.go
@@ -164,15 +164,11 @@
android.AddLoadHook(mod, func(ctx android.LoadHookContext) {
disableTargets := struct {
Target struct {
- Darwin struct {
- Enabled *bool
- }
Linux_bionic struct {
Enabled *bool
}
}
}{}
- disableTargets.Target.Darwin.Enabled = proptools.BoolPtr(false)
disableTargets.Target.Linux_bionic.Enabled = proptools.BoolPtr(false)
ctx.AppendProperties(&disableTargets)