| # 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/components.gni") |
| import("//build/rust/rustc_binary.gni") |
| import("//build/rust/rustc_library.gni") |
| import("//build/rust/rustc_test.gni") |
| import("//build/rust/rustc_wasm_library.gni") |
| |
| import("//src/diagnostics/wasm/wasm_bindings.gni") |
| |
| group("wasm") { |
| deps = [ ":lib($unknown_wasm32_toolchain)" ] |
| } |
| |
| group("tests") { |
| testonly = true |
| deps = [ |
| # Disabled due to lack of support in Clang and Rust toolchain; |
| # see https://fxbug.dev/325488864. |
| # ":wasm", |
| |
| ":wasm-triage-unittests", |
| ] |
| } |
| |
| # We need to specify configs |
| config("env") { |
| rustenv = [ |
| "CARGO_PKG_NAME=triage_lib", |
| "CARGO_PKG_VERSION=0.1", |
| "CARGO_MANIFEST_DIR=/", |
| ] |
| } |
| |
| lib_deps = [ |
| "//src/diagnostics/lib/triage", |
| "//third_party/rust_crates:anyhow", |
| "//third_party/rust_crates:num-traits", |
| "//third_party/rust_crates:serde_json5", |
| ] |
| |
| if (current_toolchain == unknown_wasm32_toolchain) { |
| rustc_wasm_library("lib") { |
| name = "triage_lib" |
| edition = "2021" |
| |
| configs += [ ":env" ] |
| |
| # Add thinlto config if lto variants are not used. |
| if (!is_lto_variant) { |
| # Allow cross-crate optimization since netstack3 is split between multiple |
| # crates. |
| configs += [ "//build/config/lto:thinlto" ] |
| } |
| |
| deps = lib_deps + [ "//third_party/rust_crates:wasm-bindgen" ] |
| |
| sources = [ |
| "src/lib.rs", |
| "src/shim.rs", |
| ] |
| } |
| } |
| |
| wasm_bindings("lib_wasm") { |
| target = ":lib" |
| target_output_name = "triage_lib" |
| } |
| |
| rustc_test("triage_lib_tests") { |
| edition = "2021" |
| deps = lib_deps + [ |
| "//src/lib/fuchsia", |
| "//third_party/rust_crates:pretty_assertions", |
| ] |
| |
| sources = [ |
| "src/lib.rs", |
| "src/shim.rs", |
| ] |
| } |
| |
| fuchsia_unittest_package("wasm-triage-unittests") { |
| deps = [ ":triage_lib_tests" ] |
| } |