@@ -16,7 +16,7 @@ pub use self::{
1616
1717use anyhow:: { bail, Error , Result } ;
1818use clap:: { Parser , ValueEnum } ;
19- use std:: { fmt as stdfmt, path:: PathBuf , str:: FromStr } ;
19+ use std:: { fmt as stdfmt, ops :: Deref , path:: PathBuf , str:: FromStr } ;
2020
2121#[ derive( Copy , Clone , Debug , Eq , PartialEq , ValueEnum ) ]
2222pub enum Sanitizer {
@@ -51,6 +51,9 @@ pub enum BuildMode {
5151
5252#[ derive( Clone , Debug , Eq , PartialEq , Parser ) ]
5353pub struct BuildOptions {
54+ #[ command( flatten) ]
55+ pub fuzz_dir_wrapper : FuzzDirWrapper ,
56+
5457 /// Build artifacts in development mode, without optimizations
5558 #[ arg( short = 'D' , long, conflicts_with = "release" ) ]
5659 pub dev : bool ,
@@ -209,6 +212,8 @@ pub struct BuildOptions {
209212
210213impl stdfmt:: Display for BuildOptions {
211214 fn fmt ( & self , f : & mut stdfmt:: Formatter ) -> stdfmt:: Result {
215+ self . fuzz_dir_wrapper . fmt ( f) ?;
216+
212217 if self . dev {
213218 write ! ( f, " -D" ) ?;
214219 }
@@ -270,10 +275,36 @@ pub struct FuzzDirWrapper {
270275 pub fuzz_dir : Option < PathBuf > ,
271276}
272277
278+ #[ derive( Debug , Clone ) ]
279+ pub struct ManifestPath ( PathBuf ) ;
280+
281+ impl ManifestPath {
282+ pub fn new ( path_buf : PathBuf ) -> Self {
283+ Self ( path_buf)
284+ }
285+ }
286+
287+ impl Deref for ManifestPath {
288+ type Target = PathBuf ;
289+
290+ fn deref ( & self ) -> & Self :: Target {
291+ & self . 0
292+ }
293+ }
294+
295+ impl FuzzDirWrapper {
296+ pub fn get_manifest_path ( & self ) -> Option < ManifestPath > {
297+ if let Some ( ref fuzz_dir) = self . fuzz_dir {
298+ return Some ( ManifestPath ( fuzz_dir. join ( "Cargo.toml" ) ) ) ;
299+ }
300+ None
301+ }
302+ }
303+
273304impl stdfmt:: Display for FuzzDirWrapper {
274305 fn fmt ( & self , f : & mut stdfmt:: Formatter ) -> stdfmt:: Result {
275306 if let Some ( ref elem) = self . fuzz_dir {
276- write ! ( f, " --fuzz-dir= {}" , elem. display( ) ) ?;
307+ write ! ( f, " --fuzz-dir {}" , elem. display( ) ) ?;
277308 }
278309
279310 Ok ( ( ) )
@@ -305,6 +336,7 @@ mod test {
305336 #[ test]
306337 fn display_build_options ( ) {
307338 let default_opts = BuildOptions {
339+ fuzz_dir_wrapper : FuzzDirWrapper { fuzz_dir : None } ,
308340 dev : false ,
309341 release : false ,
310342 debug_assertions : false ,
0 commit comments