blob: fab75e237f6a2d238317d1cfa661a48e08e0b14d [file] [log] [blame]
# 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") {
edition = "2021"
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") {
edition = "2021"
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") {
edition = "2021"
source_root = "src/main.rs"
deps = [ ":helper" ]
sources = [ "src/main.rs" ]
}
# TODO
rustc_library("helper") {
edition = "2021"
source_root = "helper/lib.rs"
deps = [ "//src/lib/fuzzing/rust:fuzz" ]
sources = [ "helper/lib.rs" ]
}
rustc_fuzzer("toy_example_same_name") {
edition = "2021"
deps = [ ":helper" ]
sources = [ "src/lib.rs" ]
}
# Fake tool to demostrate that fuzzers can exist alongside Rust binaries.
rustc_binary("toy_example_bin") {
edition = "2021"
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" ]
}