| # 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_binary.gni") |
| import("//build/rust/rustc_fuzzer.gni") |
| import("//build/rust/rustc_library.gni") |
| |
| # Defaults should generally work if the fuzz target function name matches the |
| # fuzzer name. |
| rustc_fuzzer("toy_example_arbitrary") { |
| sources = [ "src/lib.rs" ] |
| } |
| |
| # If the fuzz target function name differs from the fuzzer name, provide it via |
| # the `rustfunction` parameter. |
| rustc_fuzzer("toy_example_raw_bytes") { |
| rustfunction = "toy_example_u8" |
| |
| sources = [ "src/lib.rs" ] |
| } |
| |
| # If it is infeasible to refactor a Rust binary into a library, set the |
| # `source_root` explicitly and conditionally exclude symbols like `main` from |
| # compilation using `#[cfg(not(fuzz))]`. |
| rustc_fuzzer("toy_example_with_main") { |
| source_root = "src/main.rs" |
| deps = [ ":helper" ] |
| |
| sources = [ "src/main.rs" ] |
| } |
| |
| # TODO |
| rustc_library("helper") { |
| source_root = "helper/lib.rs" |
| deps = [ "//src/lib/fuzzing/rust:fuzz" ] |
| |
| sources = [ "helper/lib.rs" ] |
| } |
| |
| rustc_fuzzer("toy_example_same_name") { |
| deps = [ ":helper" ] |
| |
| sources = [ "src/lib.rs" ] |
| } |
| |
| # Fake tool to demostrate that fuzzers can exist alongside Rust binaries. |
| rustc_binary("toy_example_bin") { |
| name = "toy_example" |
| deps = [ |
| ":helper", |
| "//src/lib/fuzzing/rust:fuzz", |
| ] |
| |
| sources = [ "src/main.rs" ] |
| } |
| |
| fuchsia_package_with_single_component("toy-example") { |
| manifest = "meta/toy_example.cml" |
| deps = [ ":toy_example_bin" ] |
| } |