Skip to content

Commit

Permalink
fixed up formatting of new code
Browse files Browse the repository at this point in the history
  • Loading branch information
cwshugg committed Oct 15, 2024
1 parent 30bac16 commit 2e88c5f
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/project.rs
Original file line number Diff line number Diff line change
Expand Up @@ -342,17 +342,18 @@ impl FuzzProject {
Ok(None)
}
}

// Helper function for `exec_build()` used to expose cargo-fuzz information
// via environment variables. Such environment variables can be used by fuzz
// target dependencies' build scripts to detect whether or not cargo-fuzz is
// responsible for the build.
//
// This is called directly before the `cargo build ...` command is executed.
fn build_env_expose(&self,
_mode: options::BuildMode,
_build: &options::BuildOptions,
_fuzz_target: Option<&str>
fn build_env_expose(
&self,
_mode: options::BuildMode,
_build: &options::BuildOptions,
_fuzz_target: Option<&str>,
) -> Result<()> {
// expose a flag environment variable to allow the detection of cargo-fuzz
env::set_var(BUILD_ENV_FLAG, "1");
Expand All @@ -363,7 +364,7 @@ impl FuzzProject {

Ok(())
}

// Helper function for `exec_build()` used to un-expose cargo-fuzz
// information that was previously exposed in environment variables during
// `build_env_expose()`.
Expand Down Expand Up @@ -396,24 +397,22 @@ impl FuzzProject {
if let Some(target_dir) = self.target_dir(&build)? {
cmd.arg("--target-dir").arg(target_dir);
}

// expose build information via environment variables, before executing
// the build command
self.build_env_expose(mode, build, fuzz_target).expect(
"Failed to set cargo-fuzz build environment variables."
);
self.build_env_expose(mode, build, fuzz_target)
.expect("Failed to set cargo-fuzz build environment variables.");

let status = cmd
.status()
.with_context(|| format!("failed to execute: {:?}", cmd))?;
if !status.success() {
bail!("failed to build fuzz script: {:?}", cmd);
}

// un-expose build information, after the command has finished
self.build_env_unexpose().expect(
"Failed to un-set cargo-fuzz build environment variables."
);
self.build_env_unexpose()
.expect("Failed to un-set cargo-fuzz build environment variables.");

Ok(())
}
Expand Down

0 comments on commit 2e88c5f

Please sign in to comment.