blob: 274accf34e5e747b4efe1d4410013e3ba2c29dc8 [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/package.gni")
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" ]
}
package("toy-example") {
deps = [ ":toy_example_bin" ]
meta = [
{
path = "meta/toy_example.cmx"
dest = "toy_example.cmx"
},
]
binaries = [
{
name = "toy_example"
},
]
}