Skip to content

Commit

Permalink
fix: iter_mut approach broke everything
Browse files Browse the repository at this point in the history
  • Loading branch information
bmoxb committed Jun 12, 2022
1 parent c24a397 commit 6ab31db
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions service/src/loader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -122,27 +122,29 @@ pub fn build_crate(project_path: &Path, buf: Box<dyn std::io::Write>) -> anyhow:

let mut ws = Workspace::new(&manifest_path, &config)?;

// Ensure a 'cdylib' will be built:

let current = ws.current_mut().unwrap();
if let Some(target) = current
.manifest_mut()
.targets_mut()
.iter_mut()
.find(|target| target.is_lib())
if !current
.manifest()
.targets()
.iter()
.any(|target| target.is_lib())
{
if !target.is_cdylib() {
return Err(anyhow!(
"Your Shuttle project must be a library. Please add `[lib]` to your Cargo.toml file."
));
}

// Ensure a 'cdylib' will be built:

for target in current.manifest_mut().targets_mut() {
if target.is_lib() && !target.is_cdylib() {
*target = cargo::core::manifest::Target::lib_target(
target.name(),
vec![cargo::core::compiler::CrateType::Cdylib],
target.src_path().path().unwrap().to_path_buf(),
target.edition(),
);
}
} else {
return Err(anyhow!(
"Your Shuttle project must be a library. Please add `[lib]` to your Cargo.toml file."
));
}

// Ensure `panic = "abort"` is not set:
Expand Down

0 comments on commit 6ab31db

Please sign in to comment.