blob: 46007ebb4496c00e01b15fc8c5838c20931566f1 [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/config.gni") # for rust_build_{args,deps,inputs}
import("//build/rust/rustc_artifact.gni") # for rustc_third_party_artifact
third_party_lock = "//third_party/rust_crates/Cargo.lock"
third_party_toml = "//third_party/rust_crates/Cargo.toml"
third_party_map = "//third_party/rust_crates/crate_map.json"
fuchsia_cprng_dir = "//garnet/public/rust/fuchsia-cprng"
fuchsia_cprng_src =
exec_script("//build/rust/list_files_in_dir.py",
[
"--dir",
rebase_path("${fuchsia_cprng_dir}/src"),
],
"list lines",
# lib.rs will contain `mod` statements for all top-level files
[ rebase_path("${fuchsia_cprng_dir}/src/lib.rs") ])
all_third_party_packages = read_file(third_party_map, "json")
if (is_fuchsia) {
third_party_packages = all_third_party_packages.fuchsia_packages
} else {
third_party_packages = all_third_party_packages.host_packages
}
foreach(package, third_party_packages) {
rustc_third_party_artifact(package.package_name) {
package_name = package.package_name
crate_name = package.crate_name
crate_type = package.crate_type
}
}
# 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_cprng_src
out_dir = "${root_out_dir}/rust_third_party_crates"
out_deps_data = "${out_dir}/deps_data.json"
args = [
"--cargo",
rebase_path("${rustc_prefix}/cargo"),
"--crate-root",
rebase_path("//third_party/rust_crates"),
"--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
if (rust_override_opt != "") {
rust_opt_level = rust_override_opt
} else if (is_debug) {
rust_opt_level = "0"
} else {
rust_opt_level = "z"
}
args += [
"--opt-level",
rust_opt_level,
]
outputs = [
out_deps_data,
]
}