Skip to content

Commit 595224f

Browse files
committed
fuzz: Check in generated Rust source
The file itself is shorter than the code to generate it, and easier to understand.
1 parent c905978 commit 595224f

4 files changed

Lines changed: 162 additions & 238 deletions

File tree

fuzz/build.rs

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
11
use std::env;
2-
use std::fs;
32
use std::io;
43
use std::path::PathBuf;
5-
use std::process::{Command, ExitCode};
6-
7-
mod ops;
4+
use std::process::Command;
85

96
// NB: Any new symbols exported from the C++ source file need to be listed here,
107
// everything else will get pruned.
@@ -20,7 +17,7 @@ const CXX_EXPORTED_SYMBOLS: &[&str] = &[
2017
"cxx_apf_eval_op_x87_f80",
2118
];
2219

23-
fn main() -> io::Result<ExitCode> {
20+
fn main() -> io::Result<()> {
2421
// Only rerun if sources run by the fuzzer change
2522
println!("cargo::rerun-if-changed=build.rs");
2623
println!("cargo::rerun-if-changed=cxx");
@@ -30,16 +27,14 @@ fn main() -> io::Result<ExitCode> {
3027
let (_, llvm_commit_hash) = env!("CARGO_PKG_VERSION").split_once("+llvm-").unwrap();
3128
assert_eq!(llvm_commit_hash.len(), 12);
3229

33-
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
34-
fs::write(out_dir.join("generated_fuzz_ops.rs"), ops::generate_rust())?;
35-
3630
// FIXME(eddyb) add a way to disable the C++ build below, or automatically
3731
// disable it if on an unsupported target (e.g. Windows).
3832
let cxx = true;
3933
if !cxx {
40-
return Ok(ExitCode::SUCCESS);
34+
return Ok(());
4135
}
4236

37+
let out_dir = PathBuf::from(env::var_os("OUT_DIR").unwrap());
4338
let manifest_dir =
4439
PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR unset"));
4540
let target_dir = env::var_os("CARGO_TARGET_DIR")
@@ -156,5 +151,5 @@ fn main() -> io::Result<ExitCode> {
156151
println!("cargo:rustc-link-lib=cxx_apf_fuzz");
157152
println!("cargo:rustc-link-lib=stdc++");
158153

159-
Ok(ExitCode::SUCCESS)
154+
Ok(())
160155
}

fuzz/ops.rs

Lines changed: 0 additions & 225 deletions
This file was deleted.

0 commit comments

Comments
 (0)