Skip to content

Commit 1b49fd6

Browse files
committed
fix: handle universal2-apple-darwin target in workspace projects
Use workspace_members instead of root_package() to collect artifacts for the universal2 fat binary merge. root_package() returns None in workspace projects causing a panic. Fixes #230.
1 parent dfa9a42 commit 1b49fd6

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

src/build.rs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,16 @@ impl Build {
6868
use std::io::BufReader;
6969
use std::path::Path;
7070

71-
// Find root crate package id
71+
// Find workspace member package ids
7272
let manifest_path = self
7373
.manifest_path
7474
.as_deref()
7575
.unwrap_or_else(|| Path::new("Cargo.toml"));
7676
let mut metadata_cmd = cargo_metadata::MetadataCommand::new();
7777
metadata_cmd.manifest_path(manifest_path);
7878
let metadata = metadata_cmd.exec()?;
79-
let root_pkg = metadata.root_package().expect("Should have a root package");
79+
let member_ids: std::collections::HashSet<_> =
80+
metadata.workspace_members.iter().collect();
8081

8182
let mut x86_64_artifacts = Vec::new();
8283
let mut aarch64_artifacts = Vec::new();
@@ -89,7 +90,7 @@ impl Build {
8990
let message = message.context("Failed to parse cargo metadata message")?;
9091
match message {
9192
Message::CompilerArtifact(artifact) => {
92-
if artifact.package_id == root_pkg.id {
93+
if member_ids.contains(&artifact.package_id) {
9394
for filename in artifact.filenames {
9495
if filename.as_str().contains("x86_64-apple-darwin") {
9596
x86_64_artifacts.push(filename);

0 commit comments

Comments
 (0)