diff --git a/src/cargo/ops/cargo_output_metadata.rs b/src/cargo/ops/cargo_output_metadata.rs index 9d52fa09ad7..c0a63aa75a2 100644 --- a/src/cargo/ops/cargo_output_metadata.rs +++ b/src/cargo/ops/cargo_output_metadata.rs @@ -43,6 +43,7 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo Ok(ExportInfo { packages, workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(), + workspace_default_members: ws.default_members().map(|pkg| pkg.package_id()).collect(), resolve, target_directory: ws.target_dir().into_path_unlocked(), version: VERSION, @@ -58,6 +59,7 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo pub struct ExportInfo { packages: Vec, workspace_members: Vec, + workspace_default_members: Vec, resolve: Option, target_directory: PathBuf, version: u32, diff --git a/src/doc/man/cargo-metadata.md b/src/doc/man/cargo-metadata.md index 4f9032d56cc..0027a20b1f4 100644 --- a/src/doc/man/cargo-metadata.md +++ b/src/doc/man/cargo-metadata.md @@ -212,6 +212,12 @@ The output has the following format: "workspace_members": [ "my-package 0.1.0 (path+file:///path/to/my-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my-package 0.1.0 (path+file:///path/to/my-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/src/doc/man/generated_txt/cargo-metadata.txt b/src/doc/man/generated_txt/cargo-metadata.txt index be8bed7c66f..d9d48fd9a74 100644 --- a/src/doc/man/generated_txt/cargo-metadata.txt +++ b/src/doc/man/generated_txt/cargo-metadata.txt @@ -207,6 +207,12 @@ OUTPUT FORMAT "workspace_members": [ "my-package 0.1.0 (path+file:///path/to/my-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my-package 0.1.0 (path+file:///path/to/my-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/src/doc/src/commands/cargo-metadata.md b/src/doc/src/commands/cargo-metadata.md index ebde0ea101c..e9aeac7dfa7 100644 --- a/src/doc/src/commands/cargo-metadata.md +++ b/src/doc/src/commands/cargo-metadata.md @@ -212,6 +212,12 @@ The output has the following format: "workspace_members": [ "my-package 0.1.0 (path+file:///path/to/my-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my-package 0.1.0 (path+file:///path/to/my-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/src/etc/man/cargo-metadata.1 b/src/etc/man/cargo-metadata.1 index 8549290cde5..f2ebb63c7eb 100644 --- a/src/etc/man/cargo-metadata.1 +++ b/src/etc/man/cargo-metadata.1 @@ -209,6 +209,12 @@ The output has the following format: "workspace_members": [ "my\-package 0.1.0 (path+file:///path/to/my\-package)", ], + /* Array of default members of the workspace. + Each entry is the Package ID for the package. + */ + "workspace_default_members": [ + "my\-package 0.1.0 (path+file:///path/to/my\-package)", + ], // The resolved dependency graph for the entire workspace. The enabled // features are based on the enabled features for the "current" package. // Inactivated optional dependencies are not listed. diff --git a/tests/testsuite/alt_registry.rs b/tests/testsuite/alt_registry.rs index e9dd0071e06..ac60ca92fa8 100644 --- a/tests/testsuite/alt_registry.rs +++ b/tests/testsuite/alt_registry.rs @@ -902,6 +902,9 @@ fn alt_reg_metadata() { "workspace_members": [ "foo 0.0.1 (path+file:[..]/foo)" ], + "workspace_default_members": [ + "foo 0.0.1 (path+file:[..]/foo)" + ], "resolve": null, "target_directory": "[..]/foo/target", "version": 1, @@ -1102,6 +1105,9 @@ fn alt_reg_metadata() { "workspace_members": [ "foo 0.0.1 (path+file:[..]/foo)" ], + "workspace_default_members": [ + "foo 0.0.1 (path+file:[..]/foo)" + ], "resolve": "{...}", "target_directory": "[..]/foo/target", "version": 1, @@ -1265,6 +1271,9 @@ fn unknown_registry() { "workspace_members": [ "foo 0.0.1 (path+file://[..]/foo)" ], + "workspace_default_members": [ + "foo 0.0.1 (path+file://[..]/foo)" + ], "resolve": "{...}", "target_directory": "[..]/foo/target", "version": 1, diff --git a/tests/testsuite/features_namespaced.rs b/tests/testsuite/features_namespaced.rs index d090235d5ab..a6047231beb 100644 --- a/tests/testsuite/features_namespaced.rs +++ b/tests/testsuite/features_namespaced.rs @@ -609,6 +609,7 @@ fn json_exposed() { } ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": null, "target_directory": "[..]foo/target", "version": 1, diff --git a/tests/testsuite/git.rs b/tests/testsuite/git.rs index 32d0730c129..09119203783 100644 --- a/tests/testsuite/git.rs +++ b/tests/testsuite/git.rs @@ -3337,6 +3337,9 @@ fn metadata_master_consistency() { "workspace_members": [ "foo 0.1.0 [..]" ], + "workspace_default_members": [ + "foo 0.1.0 [..]" + ], "resolve": { "nodes": [ { diff --git a/tests/testsuite/metadata.rs b/tests/testsuite/metadata.rs index 547916e7a77..ac2cec39661 100644 --- a/tests/testsuite/metadata.rs +++ b/tests/testsuite/metadata.rs @@ -65,6 +65,7 @@ fn cargo_metadata_simple() { } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], + "workspace_default_members": ["foo 0.5.0 (path+file:[..]foo)"], "resolve": { "nodes": [ { @@ -164,6 +165,7 @@ crate-type = ["lib", "staticlib"] } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], + "workspace_default_members": ["foo 0.5.0 (path+file:[..]foo)"], "resolve": { "nodes": [ { @@ -257,6 +259,7 @@ optional_feat = [] } ], "workspace_members": ["foo 0.5.0 (path+file:[..]foo)"], + "workspace_default_members": ["foo 0.5.0 (path+file:[..]foo)"], "resolve": { "nodes": [ { @@ -587,6 +590,9 @@ fn cargo_metadata_with_deps_and_version() { "workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ], + "workspace_default_members": [ + "foo 0.5.0 (path+file:[..]foo)" + ], "workspace_root": "[..]/foo", "metadata": null }"#, @@ -668,6 +674,9 @@ name = "ex" "workspace_members": [ "foo 0.1.0 (path+file:[..]foo)" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..]foo)" + ], "resolve": { "root": "foo 0.1.0 (path+file://[..]foo)", "nodes": [ @@ -762,6 +771,9 @@ crate-type = ["rlib", "dylib"] ], "workspace_members": [ "foo 0.1.0 (path+file:[..]foo)" + ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..]foo)" ], "resolve": { "root": "foo 0.1.0 (path+file://[..]foo)", @@ -892,6 +904,7 @@ fn workspace_metadata() { } ], "workspace_members": ["bar 0.5.0 (path+file:[..]bar)", "baz 0.5.0 (path+file:[..]baz)"], + "workspace_default_members": ["bar 0.5.0 (path+file:[..]bar)", "baz 0.5.0 (path+file:[..]baz)"], "resolve": { "nodes": [ { @@ -1123,6 +1136,11 @@ fn workspace_metadata_with_dependencies_no_deps() { "artifact 0.5.0 (path+file:[..]/foo/artifact)", "baz 0.5.0 (path+file:[..]baz)" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file:[..]bar)", + "artifact 0.5.0 (path+file:[..]/foo/artifact)", + "baz 0.5.0 (path+file:[..]baz)" + ], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -1755,6 +1773,12 @@ fn workspace_metadata_with_dependencies_and_resolve() { "bin-only-artifact 0.5.0 (path+file://[..]/foo/bin-only-artifact)", "non-artifact 0.5.0 (path+file://[..]/foo/non-artifact)" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file://[..]/foo/bar)", + "artifact 0.5.0 (path+file://[..]/foo/artifact)", + "bin-only-artifact 0.5.0 (path+file://[..]/foo/bin-only-artifact)", + "non-artifact 0.5.0 (path+file://[..]/foo/non-artifact)" + ], "workspace_root": "[..]/foo" } "#, @@ -1953,6 +1977,7 @@ const MANIFEST_OUTPUT: &str = r#" "documentation": null }], "workspace_members": [ "foo 0.5.0 (path+file:[..]foo)" ], + "workspace_default_members": [ "foo 0.5.0 (path+file:[..]foo)" ], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -2147,6 +2172,7 @@ fn package_metadata() { } ], "workspace_members": ["foo[..]"], + "workspace_default_members": ["foo[..]"], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -2222,6 +2248,7 @@ fn package_publish() { } ], "workspace_members": ["foo[..]"], + "workspace_default_members": ["foo[..]"], "resolve": null, "target_directory": "[..]foo/target", "version": 1, @@ -2317,6 +2344,9 @@ fn cargo_metadata_path_to_cargo_toml_project() { "workspace_members": [ "bar 0.5.0 (path+file:[..])" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file:[..])" + ], "workspace_root": "[..]", "metadata": null } @@ -2405,6 +2435,9 @@ fn package_edition_2018() { "workspace_members": [ "foo 0.1.0 (path+file:[..])" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..])" + ], "workspace_root": "[..]", "metadata": null } @@ -2553,6 +2586,9 @@ fn target_edition_2018() { "workspace_members": [ "foo 0.1.0 (path+file:[..])" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..])" + ], "workspace_root": "[..]", "metadata": null } @@ -2789,6 +2825,9 @@ fn rename_dependency() { "workspace_members": [ "foo 0.0.1[..]" ], + "workspace_default_members": [ + "foo 0.0.1[..]" + ], "workspace_root": "[..]", "metadata": null }"#, @@ -2889,6 +2928,9 @@ fn metadata_links() { "workspace_members": [ "foo 0.5.0 [..]" ], + "workspace_default_members": [ + "foo 0.5.0 [..]" + ], "workspace_root": "[..]/foo", "metadata": null } @@ -2979,6 +3021,9 @@ fn deps_with_bin_only() { "workspace_members": [ "foo 0.1.0 ([..])" ], + "workspace_default_members": [ + "foo 0.1.0 ([..])" + ], "resolve": { "nodes": [ { @@ -3358,6 +3403,9 @@ fn filter_platform() { "workspace_members": [ "foo 0.1.0 (path+file:[..]foo)" ], + "workspace_default_members": [ + "foo 0.1.0 (path+file:[..]foo)" + ], "resolve": { "nodes": [ { @@ -3477,6 +3525,7 @@ fn filter_platform() { $NORMAL_DEP ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": { "nodes": [ { @@ -3558,6 +3607,7 @@ fn filter_platform() { $NORMAL_DEP ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": { "nodes": [ { @@ -3642,6 +3692,7 @@ fn filter_platform() { $NORMAL_DEP ], "workspace_members": "{...}", + "workspace_default_members": "{...}", "resolve": { "nodes": [ { @@ -3756,6 +3807,7 @@ fn dep_kinds() { { "packages": "{...}", "workspace_members": "{...}", + "workspace_default_members": "{...}", "target_directory": "{...}", "version": 1, "workspace_root": "{...}", @@ -3871,6 +3923,7 @@ fn dep_kinds_workspace() { { "packages": "{...}", "workspace_members": "{...}", + "workspace_default_members": "{...}", "target_directory": "[..]/foo/target", "version": 1, "workspace_root": "[..]/foo", @@ -4184,6 +4237,11 @@ fn workspace_metadata_with_dependencies_no_deps_artifact() { "artifact 0.5.0 (path+file://[..]/foo/artifact)", "baz 0.5.0 (path+file://[..]/foo/baz)" ], + "workspace_default_members": [ + "bar 0.5.0 (path+file://[..]/foo/bar)", + "artifact 0.5.0 (path+file://[..]/foo/artifact)", + "baz 0.5.0 (path+file://[..]/foo/baz)" + ], "workspace_root": "[..]/foo" } "#, diff --git a/tests/testsuite/update.rs b/tests/testsuite/update.rs index 057c8fca4a3..1d3ee05b702 100644 --- a/tests/testsuite/update.rs +++ b/tests/testsuite/update.rs @@ -633,6 +633,9 @@ fn update_precise_first_run() { "workspace_members": [ "bar 0.0.1 (path+file://[..]/foo)" ], + "workspace_default_members": [ + "bar 0.0.1 (path+file://[..]/foo)" + ], "workspace_root": "[..]/foo", "metadata": null }"#,