Skip to content

Commit

Permalink
Auto merge of #4938 - ehuss:ws-meta, r=alexcrichton
Browse files Browse the repository at this point in the history
Add workspace root to metadata command.

Fixes #4933

@alexcrichton, you mentioned using `"workspace_manifest"`, but the `Workspace.root` function already strips off `Cargo.toml`.  It would be easy to append it back, though I'm uncertain if that's really necessary since I think for most use cases it will just need to be stripped off again.  Also, I feel like it might be confusing for non-workspace packages since `workspace_manifest` would be the same as the package `manifest_path` (and in that case it isn't really a workspace manifest).  I can easily change it, just let me know.
  • Loading branch information
bors committed Jan 13, 2018
2 parents a8f4078 + fef215d commit 6a8eb71
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 8 deletions.
3 changes: 3 additions & 0 deletions src/cargo/ops/cargo_output_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ fn metadata_no_deps(ws: &Workspace,
resolve: None,
target_directory: ws.target_dir().display().to_string(),
version: VERSION,
workspace_root: ws.root().display().to_string(),
})
}

Expand Down Expand Up @@ -66,6 +67,7 @@ fn metadata_full(ws: &Workspace,
}),
target_directory: ws.target_dir().display().to_string(),
version: VERSION,
workspace_root: ws.root().display().to_string(),
})
}

Expand All @@ -76,6 +78,7 @@ pub struct ExportInfo {
resolve: Option<MetadataResolve>,
target_directory: String,
version: u32,
workspace_root: String,
}

/// Newtype wrapper to provide a custom `Serialize` implementation.
Expand Down
24 changes: 16 additions & 8 deletions tests/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ fn cargo_metadata_simple() {
"root": "foo 0.5.0 (path+file:[..]foo)"
},
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#));
}

Expand Down Expand Up @@ -125,7 +126,8 @@ crate-type = ["lib", "staticlib"]
"root": "foo 0.5.0 (path+file:[..]foo)"
},
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#));
}

Expand Down Expand Up @@ -275,7 +277,8 @@ fn cargo_metadata_with_deps_and_version() {
"root": "foo 0.5.0 (path+file:[..]foo)"
},
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#));
}

Expand Down Expand Up @@ -337,7 +340,8 @@ name = "ex"
]
},
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#));
}

Expand Down Expand Up @@ -400,7 +404,8 @@ crate-type = ["rlib", "dylib"]
]
},
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#));
}

Expand Down Expand Up @@ -476,7 +481,8 @@ fn workspace_metadata() {
"root": null
},
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#))
}

Expand Down Expand Up @@ -540,7 +546,8 @@ fn workspace_metadata_no_deps() {
"workspace_members": ["baz 0.5.0 (path+file:[..]baz)", "bar 0.5.0 (path+file:[..]bar)"],
"resolve": null,
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#))
}

Expand Down Expand Up @@ -582,7 +589,8 @@ const MANIFEST_OUTPUT: &'static str=
"workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ],
"resolve": null,
"target_directory": "[..]foo[/]target",
"version": 1
"version": 1,
"workspace_root": "[..][/]foo"
}"#;

#[test]
Expand Down

0 comments on commit 6a8eb71

Please sign in to comment.