Skip to content

Commit

Permalink
Remove profiles information from the package structure.
Browse files Browse the repository at this point in the history
Signed-off-by: David Calavera <david.calavera@gmail.com>
  • Loading branch information
calavera committed Sep 1, 2023
1 parent 78c108f commit 30af6de
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 36 deletions.
4 changes: 0 additions & 4 deletions src/cargo/core/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ use crate::util::network::http::http_handle_and_timeout;
use crate::util::network::http::HttpTimeout;
use crate::util::network::retry::{Retry, RetryResult};
use crate::util::network::sleep::SleepTracker;
use crate::util::toml::TomlProfiles;
use crate::util::PartialVersion;
use crate::util::{self, internal, Config, Progress, ProgressStyle};

Expand Down Expand Up @@ -106,8 +105,6 @@ pub struct SerializedPackage {
metabuild: Option<Vec<String>>,
default_run: Option<String>,
rust_version: Option<PartialVersion>,
#[serde(skip_serializing_if = "Option::is_none")]
profiles: Option<TomlProfiles>,
}

impl Package {
Expand Down Expand Up @@ -267,7 +264,6 @@ impl Package {
publish: self.publish().as_ref().cloned(),
default_run: self.manifest().default_run().map(|s| s.to_owned()),
rust_version: self.rust_version(),
profiles: self.manifest().profiles().cloned(),
}
}
}
Expand Down
11 changes: 3 additions & 8 deletions src/cargo/ops/cargo_output_metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use crate::core::compiler::{CompileKind, RustcTargetData};
use crate::core::dependency::DepKind;
use crate::core::package::SerializedPackage;
use crate::core::resolver::{features::CliFeatures, HasDevUnits, Resolve};
use crate::core::{MaybePackage, Package, PackageId, Workspace};
use crate::core::{Package, PackageId, Workspace};
use crate::ops::{self, Packages};
use crate::util::interning::InternedString;
use crate::util::toml::TomlProfiles;
Expand Down Expand Up @@ -41,11 +41,6 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo
(packages, Some(resolve))
};

let workspace_profiles = match ws.root_maybe() {
MaybePackage::Virtual(vm) => vm.profiles().cloned(),
_ => None, // regular packages include the profile information under their package section
};

Ok(ExportInfo {
packages,
workspace_members: ws.members().map(|pkg| pkg.package_id()).collect(),
Expand All @@ -55,7 +50,7 @@ pub fn output_metadata(ws: &Workspace<'_>, opt: &OutputMetadataOptions) -> Cargo
version: VERSION,
workspace_root: ws.root().to_path_buf(),
metadata: ws.custom_metadata().cloned(),
workspace_profiles,
profiles: ws.profiles().cloned(),
})
}

Expand All @@ -73,7 +68,7 @@ pub struct ExportInfo {
workspace_root: PathBuf,
metadata: Option<toml::Value>,
#[serde(skip_serializing_if = "Option::is_none")]
workspace_profiles: Option<TomlProfiles>,
profiles: Option<TomlProfiles>,
}

#[derive(Serialize)]
Expand Down
22 changes: 11 additions & 11 deletions tests/testsuite/metadata.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4322,15 +4322,7 @@ lto = "thin"
"features": {},
"manifest_path": "[..]Cargo.toml",
"metadata": null,
"publish": null,
"profiles": {
"custom-lto": {
"lto": "thin"
},
"release": {
"strip": "symbols"
}
}
"publish": null
}
],
"workspace_members": ["foo 0.5.0 (path+file:[..]foo)"],
Expand All @@ -4349,7 +4341,15 @@ lto = "thin"
"target_directory": "[..]foo/target",
"version": 1,
"workspace_root": "[..]/foo",
"metadata": null
"metadata": null,
"profiles": {
"custom-lto": {
"lto": "thin"
},
"release": {
"strip": "symbols"
}
}
}"#,
)
.run();
Expand Down Expand Up @@ -4484,7 +4484,7 @@ fn workspace_metadata_with_profiles() {
"version": 1,
"workspace_root": "[..]/foo",
"metadata": null,
"workspace_profiles": {
"profiles": {
"custom-lto": {
"lto": "thin"
},
Expand Down
21 changes: 8 additions & 13 deletions tests/testsuite/script.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1061,12 +1061,7 @@ fn cmd_metadata_with_embedded() {
"features": {},
"manifest_path": "[..]script.rs",
"metadata": null,
"publish": [],
"profiles": {
"release": {
"strip": true
}
}
"publish": []
}
],
"workspace_members": ["script 0.0.0 (path+file:[..]foo)"],
Expand All @@ -1085,7 +1080,12 @@ fn cmd_metadata_with_embedded() {
"target_directory": "[ROOT]/home/.cargo/target/[..]",
"version": 1,
"workspace_root": "[..]/foo",
"metadata": null
"metadata": null,
"profiles": {
"release": {
"strip": true
}
}
}"#,
)
.with_stderr(
Expand Down Expand Up @@ -1141,12 +1141,7 @@ fn cmd_read_manifest_with_embedded() {
"features":{},
"manifest_path":"[..]script.rs",
"metadata": null,
"publish": [],
"profiles": {
"release": {
"strip": true
}
}
"publish": []
}"#,
)
.with_stderr(
Expand Down

0 comments on commit 30af6de

Please sign in to comment.