| # 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/assembly/bootfs_files_for_assembly.gni") | |
| import("//build/components.gni") | |
| import("//build/rust/rustc_staticlib.gni") | |
| import("//build/rust/rustc_test.gni") | |
| import("//build/test.gni") | |
| rustc_staticlib("rust-cpp-test-lib") { | |
| name = "rust_cpp_test_lib" | |
| version = "0.1.0" | |
| edition = "2024" | |
| testonly = true | |
| deps = [ | |
| ":trace", | |
| ":trace-observer", | |
| "//src/lib/fuchsia-async", | |
| ] | |
| public = [ "test/lib.h" ] | |
| source_root = "test/lib.rs" | |
| sources = [ "test/lib.rs" ] | |
| } | |
| source_set("cpp-test-runner") { | |
| testonly = true | |
| visibility = [ ":*" ] | |
| sources = [ "test/test_runner.cc" ] | |
| deps = [ | |
| ":rust-cpp-test-lib", | |
| "//sdk/lib/async", | |
| "//sdk/lib/async:async-cpp", | |
| "//sdk/lib/async-default", | |
| "//sdk/lib/async-loop", | |
| "//sdk/lib/async-loop:async-loop-cpp", | |
| "//sdk/lib/async-loop:async-loop-default", | |
| "//sdk/lib/fdio", | |
| "//zircon/system/ulib/fbl", | |
| "//zircon/system/ulib/trace", | |
| "//zircon/system/ulib/trace-engine:trace-engine-headers-for-reader", | |
| "//zircon/system/ulib/trace-reader", | |
| "//zircon/system/ulib/trace-test-utils", | |
| "//zircon/system/ulib/zx", | |
| "//zircon/system/ulib/zxtest", | |
| ] | |
| } | |
| test("rust_cpp_test") { | |
| deps = [ | |
| ":cpp-test-runner", | |
| "//zircon/system/ulib/trace-engine", | |
| ] | |
| } | |
| rustc_test("trace_test") { | |
| name = "fuchsia_trace_lib_test" | |
| edition = "2024" | |
| sources = [ "src/lib.rs" ] | |
| deps = [ | |
| "//sdk/rust/zx", | |
| "//src/lib/fuchsia-rcu:fuchsia-rcu-traits", | |
| "//src/lib/fuchsia-runtime", | |
| "//third_party/rust_crates:libc", | |
| "//third_party/rust_crates:pin-project", | |
| "//third_party/rust_crates:rand", | |
| "//zircon/system/ulib/trace-engine", | |
| ] | |
| } | |
| fuchsia_unittest_component("fuchsia_trace_lib_test_component") { | |
| deps = [ ":trace_test" ] | |
| } | |
| fuchsia_unittest_component("rust_cpp_test_component") { | |
| deps = [ ":rust_cpp_test" ] | |
| } | |
| fuchsia_test_package("rust-trace-test") { | |
| test_components = [ | |
| ":rust_cpp_test_component", | |
| ":fuchsia_trace_lib_test_component", | |
| ] | |
| test_specs = { | |
| environments = [ emu_env ] | |
| } | |
| } | |
| group("tests") { | |
| testonly = true | |
| deps = [ ":rust-trace-test" ] | |
| } | |
| # Defined in BUILD.bazel too, where it is a static library, so Bazel builds can | |
| # link `:trace-provider`. Kept in GN because librust-trace-provider.so is | |
| # included in bootfs and in the packages of Rust components that use | |
| # `:trace-provider`. | |
| shared_library("rust-trace-provider") { | |
| visibility = [ ":*" ] | |
| deps = [ ":rust-trace-provider-cpp" ] | |
| } | |
| bootfs_files_for_assembly("bootfs") { | |
| deps = [ ":rust-trace-provider" ] | |
| } | |
| # librust-trace-provider.so is C++, so every Rust binary that links | |
| # `:trace-provider` also needs the C++ standard library. Bazel's C++ toolchain | |
| # adds it at link time, but GN links Rust binaries with rustc and needs the | |
| # dynamic_cpp_standard_library config on each of them. The generated | |
| # rustc_library() below can only list the shared library as a private dep, which | |
| # would stop configs at `:trace-provider`, so BUILD.bazel maps that dep to this | |
| # group, which forces the config onto all dependents. | |
| group("rust-trace-provider-for-rust") { | |
| visibility = [ ":*" ] | |
| public_deps = [ ":rust-trace-provider" ] | |
| all_dependent_configs = | |
| [ "//build/config/fuchsia:dynamic_cpp_standard_library" ] | |
| } | |
| ## BAZEL2GN SENTINEL - DO NOT EDIT BELOW THIS LINE ## | |
| # | |
| # ________ _________ ________ ________ | |
| # |\ ____\|\___ ___\\ __ \|\ __ \ | |
| # \ \ \___|\|___ \ \_\ \ \|\ \ \ \|\ \ | |
| # \ \_____ \ \ \ \ \ \ \\\ \ \ ____\ | |
| # \|____|\ \ \ \ \ \ \ \\\ \ \ \___| | |
| # ____\_\ \ \ \__\ \ \_______\ \__\ | |
| # |\_________\ \|__| \|_______|\|__| | |
| # \|_________| | |
| # | |
| # | |
| # AUTO-GENERATED - DO NOT EDIT | |
| # | |
| # The targets below are auto-generated based on the targets defined in the | |
| # BUILD.bazel file from the same directory. If you made changes to targets in | |
| # Bazel, instead of editing this file manually, run: | |
| # | |
| # > fx bazel2gn | |
| # | |
| # Please do NOT edit this file directly. Instead, edit the BUILD.bazel file and | |
| # rerun bazel2gn. | |
| import("//build/tools/bazel2gn/bazel_migration.gni") | |
| rustc_library("trace") { | |
| sources = [ "src/lib.rs" ] | |
| crate_name = "fuchsia_trace" | |
| edition = "2024" | |
| link_deps = [ "//zircon/system/ulib/trace-engine" ] | |
| visibility = [ "//*" ] | |
| deps = [ | |
| "//sdk/rust/zx", | |
| "//src/lib/fuchsia-rcu:fuchsia-rcu-traits", | |
| "//src/lib/fuchsia-runtime", | |
| "//third_party/rust_crates:libc", | |
| "//third_party/rust_crates:pin-project", | |
| "//third_party/rust_crates:rand", | |
| ] | |
| } | |
| source_set("rust-trace-provider-cpp") { | |
| sources = [ "trace-provider/trace_provider.cc" ] | |
| deps = [ | |
| "//sdk/lib/async-loop:async-loop-cpp", | |
| "//sdk/lib/async-loop:async-loop-default", | |
| "//zircon/system/ulib/trace-provider", | |
| ] | |
| visibility = [ ":*" ] | |
| } | |
| rustc_library("trace-provider") { | |
| sources = [ "trace-provider/src/lib.rs" ] | |
| crate_name = "fuchsia_trace_provider" | |
| source_root = "trace-provider/src/lib.rs" | |
| edition = "2024" | |
| link_deps = [ | |
| ":rust-trace-provider-for-rust", | |
| "//zircon/system/ulib/trace-provider", | |
| ] | |
| visibility = [ "//*" ] | |
| deps = [ | |
| "//sdk/lib/async/rust", | |
| "//sdk/lib/async/rust/sys", | |
| "//sdk/rust/zx", | |
| ] | |
| } | |
| rustc_library("trace-observer") { | |
| sources = [ "trace-observer/src/lib.rs" ] | |
| crate_name = "fuchsia_trace_observer" | |
| source_root = "trace-observer/src/lib.rs" | |
| edition = "2024" | |
| link_deps = [ "//zircon/system/ulib/trace" ] | |
| visibility = [ | |
| ":*", | |
| "//src/performance/memory/attribution/monitor:*", | |
| "//src/starnix/kernel/core:*", | |
| "//src/starnix/modules/perfetto_consumer:*", | |
| "//vendor/google/*", | |
| ] | |
| deps = [ | |
| ":trace", | |
| "//sdk/rust/zx", | |
| "//src/lib/fuchsia-async", | |
| ] | |
| } |