blob: 21e277542bea9df6a1c7f388e18f60551dce66f3 [file] [log] [blame]
# 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/rust/rustc_artifact.gni") # for rustc_third_party_artifact
import("//build/rust/rust_artifact.gni") # for rustc_prefix
third_party_lock = "//third_party/rust-crates/rustc_deps/Cargo.lock"
third_party_toml = "//third_party/rust-crates/rustc_deps/Cargo.toml"
third_party_crate_names = exec_script(
"//build/rust/list_3p_crates.py",
["--cargo-toml", rebase_path(third_party_toml)],
"list lines",
[third_party_toml]
)
foreach(crate_name, third_party_crate_names) {
rustc_third_party_artifact(crate_name) {
crate_name = crate_name
}
}
# This target is implicitly depended upon by every
# rustc_artifact (rustc_binary or rustc_library) target
action("build-third-party") {
script = "//build/rust/compile_3p_crates.py"
inputs = [ third_party_lock, third_party_toml ]
deps = [ "//garnet/public/sdk:zircon_sysroot_export" ]
if (is_debug) {
opt_level = "0"
} else {
opt_level = "z"
}
assert(
current_os == "mac" || current_os == "linux" || current_os == "fuchsia",
"current_os was neither mac, linux, nor fuchsia"
)
if (current_os == "mac") {
target_triple = "x86_64-apple-darwin"
assert(current_cpu == "x64")
} else if (current_os == "linux") {
assert(current_cpu == "x64")
target_triple = "x86_64-unknown-linux-gnu"
} else if (current_os == "fuchsia") {
assert(current_cpu == "x64" || current_cpu == "arm64")
if (current_cpu == "x64") {
target_triple = "x86_64-unknown-fuchsia"
} else if (current_cpu == "arm64") {
target_triple = "aarch64-unknown-fuchsia"
}
}
out_dir = "${root_out_dir}/rust_third_party"
out_deps_data = "${out_dir}/deps_data.json"
args = [
"--rustc", rebase_path("${rustc_prefix}/rustc"),
"--cargo", rebase_path("${rustc_prefix}/cargo"),
"--crate-root", rebase_path("//third_party/rust-crates/rustc_deps"),
"--opt-level", opt_level,
"--out-dir", rebase_path(out_dir),
"--out-deps-data", rebase_path(out_deps_data),
"--target", target_triple,
"--cmake-dir", rebase_path("//buildtools/cmake/bin"),
"--shared-libs-root", rebase_path(
get_label_info("//default($shlib_toolchain)", "root_out_dir")),
"--clang_prefix", rebase_path(clang_prefix, "", root_out_dir),
"--sysroot", rebase_path("$root_out_dir/sdks/zircon_sysroot/sysroot"),
]
outputs = [ out_deps_data ]
}