| # Copyright 2020 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/rust/rustc_macro.gni") |
| import("//build/tools/json_merge/json_merge.gni") |
| |
| if (is_host) { |
| json_merge("config.json") { |
| sources = [ |
| rebase_path("//src/developer/ffx/daemon/data/config.json"), |
| get_label_info("//src/developer/ffx:config.json", "target_out_dir") + |
| "/config.json", |
| ] |
| deps = [ "//src/developer/ffx:config.json" ] |
| } |
| |
| config_path = "$target_out_dir/config.json" |
| |
| # Rust looks for files included with `include_str` relative to the |
| # callsite. Rebase the config path relative to the files in src/. |
| rebased_config_path = rebase_path(config_path, "src") |
| |
| config("env") { |
| rustenv = [ "FFX_DEFAULT_CONFIG_JSON=$rebased_config_path" ] |
| } |
| |
| rustc_macro("config-proc-macros") { |
| name = "config_proc_macros" |
| version = "0.1.0" |
| edition = "2018" |
| |
| configs += [ ":env" ] |
| |
| deps = [ |
| ":config.json", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:proc-macro-hack", |
| "//third_party/rust_crates:proc-macro2", |
| "//third_party/rust_crates:quote", |
| "//third_party/rust_crates:serde", |
| "//third_party/rust_crates:serde_json", |
| "//third_party/rust_crates:syn", |
| ] |
| |
| sources = [ "src/lib.rs" ] |
| inputs = [ config_path ] |
| } |
| } |