Skip to content

Commit

Permalink
Abort build if binary artifact ambiguous
Browse files Browse the repository at this point in the history
proceeding leads to indeterminte result
where trunk picks up an arbitrary binary for the target.
See #475
  • Loading branch information
samoylovfp committed Jan 4, 2023
1 parent 3f2101b commit 44c4305
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Subheadings to categorize changes are `added, changed, deprecated, removed, fixe
### fixed
- Nested WS proxies - if `backend=ws://localhost:8000/ws` is set, queries for `ws://localhost:8080/ws/entityX` will be linked with `ws://localhost:8000/ws/entityX`
- Updated all dependencies in both Trunk and its examples, to fix currently open security advisories for old dependencies.
- Fix indeterminate trunk behaviour when the project defines several binary crates and index.html has no `<link rel="rust" data-bin=...>`

## 0.16.0
### added
Expand Down
11 changes: 11 additions & 0 deletions src/pipelines/rust.rs
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,17 @@ impl RustApp {
_ => None,
})
.collect::<Result<_>>()?;

// If there is already a `link data-trunk rel=rust` in index.html
// then the --bin flag was passed to the cargo command
// and it has built just a single binary
if artifacts.len() > 1 {
bail!(
"found more that one binary crate: {bin_names:?}, \
consider adding `<link data-trunk rel=\"rust\" data-bin={{bin}} />` to the index.html",
bin_names = artifacts.iter().map(|a| &a.target.name).collect::<Vec<_>>()
)
}
let Some(artifact) = artifacts.pop() else {
bail!("cargo artifacts not found for target crate")
};
Expand Down

0 comments on commit 44c4305

Please sign in to comment.