From 7c3e163e90624bcc90a28119f06d5f38878ae432 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Tue, 5 Jan 2021 19:02:13 +0100 Subject: Make `PackageData`, `TargetData` and `PackageDependency` public This makes them discoverable through documentation. They were already publicly accessible through `Package` and `Target`. --- crates/project_model/src/lib.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'crates/project_model/src') diff --git a/crates/project_model/src/lib.rs b/crates/project_model/src/lib.rs index 24aa9b8fa..aabb7a47d 100644 --- a/crates/project_model/src/lib.rs +++ b/crates/project_model/src/lib.rs @@ -1,9 +1,9 @@ //! FIXME: write short doc here mod cargo_workspace; +mod cfg_flag; mod project_json; mod sysroot; -mod cfg_flag; mod workspace; use std::{ @@ -17,7 +17,10 @@ use paths::{AbsPath, AbsPathBuf}; use rustc_hash::FxHashSet; pub use crate::{ - cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind}, + cargo_workspace::{ + CargoConfig, CargoWorkspace, Package, PackageData, PackageDependency, Target, TargetData, + TargetKind, + }, project_json::{ProjectJson, ProjectJsonData}, sysroot::Sysroot, workspace::{PackageRoot, ProjectWorkspace}, -- cgit v1.2.3 From 0abe487f1cf5d31c4d6b44961cd8b3e8fe49ed30 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 6 Jan 2021 16:39:19 +0100 Subject: Document `project_model::PackageData` This adds a description for `PackageData` and all its fields. --- crates/project_model/src/cargo_workspace.rs | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'crates/project_model/src') diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index 1700cb8a7..006c66ae7 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs @@ -80,19 +80,35 @@ pub type Package = Idx; pub type Target = Idx; +/// Information associated with a cargo crate #[derive(Debug, Clone, Eq, PartialEq)] pub struct PackageData { + /// Version given in the `Cargo.toml` pub version: String, + /// Name as given in the `Cargo.toml` pub name: String, + /// Path containing the `Cargo.toml` pub manifest: AbsPathBuf, + /// Targets provided by the crate (lib, bin, example, test, ...) pub targets: Vec, + /// Is this package a member of the current workspace pub is_member: bool, + /// List of packages this package depends on pub dependencies: Vec, + /// Rust edition for this package pub edition: Edition, + /// List of features to activate pub features: Vec, + /// List of config flags defined by this package's build script pub cfgs: Vec, + /// List of cargo-related environment variables with their value + /// + /// If the package has a build script which defines environment variables, + /// they can also be found here. pub envs: Vec<(String, String)>, + /// Directory where a build script might place its output pub out_dir: Option, + /// Path to the proc-macro library file if this package exposes proc-macros pub proc_macro_dylib_path: Option, } -- cgit v1.2.3 From ef636ba346582db196cd52a694ac9fe71fc36019 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Wed, 6 Jan 2021 16:39:44 +0100 Subject: Document `project_model::TargetData` This adds a description for `TargetData` and all its fields. --- crates/project_model/src/cargo_workspace.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'crates/project_model/src') diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index 006c66ae7..0e6679542 100644 --- a/crates/project_model/src/cargo_workspace.rs +++ b/crates/project_model/src/cargo_workspace.rs @@ -118,12 +118,18 @@ pub struct PackageDependency { pub name: String, } +/// Information associated with a package's target #[derive(Debug, Clone, Eq, PartialEq)] pub struct TargetData { + /// Package that provided this target pub package: Package, + /// Name as given in the `Cargo.toml` or generated from the file name pub name: String, + /// Path to the main source file of the target pub root: AbsPathBuf, + /// Kind of target pub kind: TargetKind, + /// Is this target a proc-macro pub is_proc_macro: bool, } -- cgit v1.2.3