| # Copyright 2018 The Fuchsia Authors. All rights reserved. |
| # Use of this source code is governed by a BSD-style license that can be |
| # found in the LICENSE file. |
| |
| import("//build/config/clang/clang.gni") |
| import("//build/config/compiler.gni") |
| import("//build/config/sysroot.gni") |
| import("//build/fidl/toolchain.gni") |
| |
| default_rust_sysroot = |
| rebase_path("//prebuilt/third_party/rust/${host_platform}", root_build_dir) |
| |
| default_rustc_prefix = |
| rebase_path("//prebuilt/third_party/rust/${host_platform}/bin", |
| root_build_dir) |
| |
| declare_args() { |
| # Sets a custom base directory for `rustc` and `cargo`. |
| # This can be used to test custom Rust toolchains. |
| rustc_prefix = default_rustc_prefix |
| |
| # Sets a custom base directory for where rust tooling |
| # looks for the standard library |
| rust_sysroot = default_rust_sysroot |
| |
| # Sets the default LTO type for rustc bulids. |
| rust_lto = "" |
| |
| # DEPRECATED: Sets the panic type for Rust on fuchsia. |
| # Valid values are "unwind" and "abort". |
| # This arg will be removed soon, and we will always use "abort". |
| rust_panic = "abort" |
| |
| # Sets the fuchsia toolchain target triple suffix (after arch) |
| rust_toolchain_triple_suffix = "fuchsia" |
| |
| # Sets the maximum lint level. |
| # "deny" will make all warnings into errors, "warn" preserves them as warnings, and "allow" will |
| # ignore warnings. |
| rust_cap_lints = "deny" |
| |
| # Overrides the optimization level for all Rust builds, regardless of |
| # debug/release flags or the `force_opt` arg to the rustc_ templates. |
| # Valid values are 0-3, o, and z. |
| rust_override_opt = "" |
| |
| # Overrides the LTO setting for all Rust builds, regardless of |
| # debug/release flags or the `with_lto` arg to the rustc_ templates. |
| # Valid values are "none", "thin", and "fat". |
| rust_override_lto = "" |
| } |
| |
| assert(rust_panic == "unwind" || rust_panic == "abort", |
| "rust_panic was neither 'unwind' nor 'panic'") |
| |
| # Always use panic=unwind on host, or proc macros won't work. |
| if (!is_fuchsia) { |
| rust_panic = "unwind" |
| } |
| |
| std_deps = [] |
| if (is_fuchsia) { |
| std_deps += [ |
| # These libraries are required by libstd. |
| "//zircon/public/lib/fdio", |
| ] |
| } |
| |
| assert( |
| current_os == "mac" || current_os == "linux" || current_os == "fuchsia" || |
| (current_os == "unknown" && current_cpu == "wasm32"), |
| "current_os was neither mac, linux, unknown, nor fuchsia") |
| assert( |
| current_cpu == "x64" || current_cpu == "arm64" || current_cpu == "wasm32") |
| if (current_os == "mac") { |
| _suffix = "apple-darwin" |
| } else if (current_os == "linux") { |
| _suffix = "unknown-linux-gnu" |
| } else if (current_os == "fuchsia") { |
| _suffix = rust_toolchain_triple_suffix |
| } |
| if (current_cpu == "x64") { |
| rust_target = "x86_64-${_suffix}" |
| } else if (current_cpu == "arm64") { |
| rust_target = "aarch64-${_suffix}" |
| } else if (current_cpu == "wasm32" && current_os == "unknown") { |
| rust_target = "wasm32-unknown-unknown" |
| } |