diff --git a/src/cargo_toml.rs b/src/cargo_toml.rs index 10c69b2b1..a6e382904 100644 --- a/src/cargo_toml.rs +++ b/src/cargo_toml.rs @@ -106,10 +106,24 @@ pub struct RemainingCoreMetadata { pub name: Option, /// The directory containing the wheel data pub data: Option, + /// Cargo compile targets + pub targets: Option>, #[serde(flatten)] pub other: HashMap, } +/// Cargo compile target +#[derive(Serialize, Deserialize, Debug, Clone, Default)] +#[serde(rename_all = "kebab-case")] +pub struct CargoTarget { + /// Name as given in the `Cargo.toml` or generated from the file name + pub name: String, + /// Kind of target ("bin", "lib") + pub kind: Option, + /// Bridge model, which kind of bindings to use + pub bindings: Option, +} + #[cfg(test)] mod test { use super::*; @@ -137,11 +151,20 @@ mod test { [package.metadata.maturin] classifiers = ["Programming Language :: Python"] requires-dist = ["flask~=1.1.0", "toml==0.10.0"] + + [[package.metadata.maturin.targets]] + name = "pyo3_pure" + kind = "lib" + bindings = "pyo3" "# ); let cargo_toml: Result = toml_edit::easy::from_str(cargo_toml); assert!(cargo_toml.is_ok()); + + let maturin = cargo_toml.unwrap().remaining_core_metadata(); + let targets = maturin.targets.unwrap(); + assert_eq!("pyo3_pure", targets[0].name); } #[test] diff --git a/test-crates/hello-world/Cargo.toml b/test-crates/hello-world/Cargo.toml index a5b03b869..c11820ea6 100644 --- a/test-crates/hello-world/Cargo.toml +++ b/test-crates/hello-world/Cargo.toml @@ -8,3 +8,10 @@ readme = "../../README.md" default-run = "hello-world" [dependencies] + +[[package.metadata.maturin.targets]] +name = "hello-world" +bindings = "bin" + +[[package.metadata.maturin.targets]] +name = "foo"