Skip to content

Commit

Permalink
Blah
Browse files Browse the repository at this point in the history
TODO: Works fine for leafs, but not for workspaces themselves.

the manifest-path logic is badly broken IMO: when you specify a
workspace member all members of the workspace will actually be rebuilt.
  • Loading branch information
d-e-s-o committed Jan 22, 2025
1 parent c6c7e57 commit d435ba3
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions libbpf-cargo/src/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,15 @@ fn get_package(package: &Package, workspace_target_dir: &Path) -> Result<Vec<Unp
pub(crate) fn get(manifest_path: Option<&Path>) -> Result<(PathBuf, Vec<UnprocessedObj>)> {
let mut cmd = MetadataCommand::new();

if let Some(path) = manifest_path {
let manifest_path = if let Some(path) = manifest_path {
let normalized = path
.canonicalize()
.with_context(|| format!("failed to canonicalize path `{}`", path.display()))?;
cmd.manifest_path(path);
}
Some(normalized)
} else {
None
};

let metadata = cmd.exec().context("Failed to get cargo metadata")?;
if metadata.workspace_members.is_empty() {
Expand All @@ -148,7 +154,10 @@ pub(crate) fn get(manifest_path: Option<&Path>) -> Result<(PathBuf, Vec<Unproces
let mut v: Vec<UnprocessedObj> = Vec::new();
for id in &metadata.workspace_members {
for package in &metadata.packages {
if id == &package.id {
if id == &package.id
&& (manifest_path.is_none()
|| Some(package.manifest_path.as_std_path()) == manifest_path.as_deref())
{
let vv = &mut get_package(package, target_directory)
.with_context(|| format!("Failed to process package={}", package.name))?;
let () = v.append(vv);
Expand Down

0 comments on commit d435ba3

Please sign in to comment.