| # Copyright 2017 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. |
| |
| # Generates metadata about a crate. |
| # |
| # Only for use with third-party crates. |
| # |
| # Parameters |
| # |
| # name |
| # Name of the crate as defined in its manifest file. |
| # |
| # deps (optional) |
| # List of labels for Rust artifacts this library depends on. |
| # |
| # non_rust_deps (optional) |
| # List of labels this target depends on that are not Rust artifacts. |
| # |
| # native_lib (optional) |
| # Name of the native library this crate links against. |
| template("rust_info") { |
| if (!defined(invoker.name)) { |
| assert(false, "Must specify a crate name") |
| } |
| |
| target_label = get_label_info(":$target_name", "label_no_toolchain") |
| base_gen_dir = "$target_gen_dir/$target_name.rust" |
| output_file = "$base_gen_dir/$target_name.info.toml" |
| |
| action(target_name) { |
| script = "//build/rust/build_info.py" |
| |
| outputs = [ |
| output_file, |
| ] |
| |
| rust_deps = [] |
| if (defined(invoker.deps)) { |
| foreach(dep, invoker.deps) { |
| rust_deps += [ get_label_info(dep, "label_no_toolchain") ] |
| } |
| } |
| |
| deps = rust_deps |
| if (defined(invoker.non_rust_deps)) { |
| deps += invoker.non_rust_deps |
| } |
| |
| args = [ |
| "--name", |
| invoker.name, |
| "--label", |
| target_label, |
| "--gen-dir", |
| rebase_path(base_gen_dir), |
| "--root-gen-dir", |
| rebase_path(root_gen_dir), |
| "--deps", |
| ] + rust_deps |
| |
| if (defined(invoker.native_lib)) { |
| args += [ |
| "--native-lib", |
| invoker.native_lib, |
| ] |
| } |
| } |
| } |