blob: c6b9258beada6a559a59b9551d600c72442521ef [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/config.gni") # for rust_build_{args,deps,inputs}
third_party_lock = "//third_party/rust-crates/rustc_deps/Cargo.lock"
third_party_toml = "//third_party/rust-crates/rustc_deps/Cargo.toml"
fuchsia_zircon_dir = "//garnet/public/rust/crates/fuchsia-zircon"
fuchsia_zircon_sys_dir = "${fuchsia_zircon_dir}/fuchsia-zircon-sys"
fuchsia_zircon_src = exec_script(
"//build/rust/list_files_in_dir.py",
["--dir", rebase_path("${fuchsia_zircon_dir}/src")],
"list lines",
# lib.rs will contain `mod` statements for all top-level files
[rebase_path("${fuchsia_zircon_dir}/src/lib.rs")]
)
fuchsia_zircon_sys_src = exec_script(
"//build/rust/list_files_in_dir.py",
["--dir", rebase_path("${fuchsia_zircon_sys_dir}/src")],
"list lines",
# lib.rs will contain `mod` statements for all top-level files
[rebase_path("${fuchsia_zircon_sys_dir}/src/lib.rs")]
)
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 ]
inputs += fuchsia_zircon_src
inputs += fuchsia_zircon_sys_src
out_dir = "${root_out_dir}/rust_third_party"
out_deps_data = "${out_dir}/deps_data.json"
args = [
"--cargo", rebase_path("${rustc_prefix}/cargo"),
"--crate-root", rebase_path("//third_party/rust-crates/rustc_deps"),
"--out-dir", rebase_path(out_dir),
"--out-deps-data", rebase_path(out_deps_data),
]
args += rust_build_args
deps = rust_build_deps
inputs += rust_build_inputs
outputs = [ out_deps_data ]
}