Skip to content

Commit 8488d86

Browse files
authored
fix bug reading binaries config from Cargo.toml (#377)
1 parent c145e8b commit 8488d86

File tree

2 files changed

+22
-13
lines changed

2 files changed

+22
-13
lines changed
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
"cargo-packager": patch
3+
"@crabnebula/packager": patch
4+
---
5+
6+
Fixed a bug where "binaries" parameter in Cargo.toml would be ignored and all targets would be packaged.

crates/packager/src/cli/config.rs

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -200,19 +200,22 @@ fn load_configs_from_cargo_workspace(cli: &super::Cli) -> Result<Vec<(Option<Pat
200200
.as_ref()
201201
.map(|p| p.as_std_path().to_owned());
202202
}
203-
let targets = package
204-
.targets
205-
.iter()
206-
.filter(|t| t.is_bin())
207-
.collect::<Vec<_>>();
208-
for target in &targets {
209-
config.binaries.push(Binary {
210-
path: target.name.clone().into(),
211-
main: match targets.len() {
212-
1 => true,
213-
_ => target.name == package.name,
214-
},
215-
})
203+
// Auto-detect binaries if none were explicitly configured
204+
if config.binaries.is_empty() {
205+
let targets = package
206+
.targets
207+
.iter()
208+
.filter(|t| t.is_bin())
209+
.collect::<Vec<_>>();
210+
for target in &targets {
211+
config.binaries.push(Binary {
212+
path: target.name.clone().into(),
213+
main: match targets.len() {
214+
1 => true,
215+
_ => target.name == package.name,
216+
},
217+
})
218+
}
216219
}
217220
configs.push((
218221
Some(package.manifest_path.as_std_path().to_path_buf()),

0 commit comments

Comments
 (0)