diff options
author | bors[bot] <26634292+bors[bot]@users.noreply.github.com> | 2021-01-06 16:41:22 +0000 |
---|---|---|
committer | GitHub <[email protected]> | 2021-01-06 16:41:22 +0000 |
commit | c9cec381bcfd97e5f3536e31a9c546ab5c0665e6 (patch) | |
tree | 6ed39837e3adb17ca5700a53e3a4b3b4e331ad68 /crates/project_model/src | |
parent | 1b2d80dfa753b4fa834ab6987399738064cfd7a4 (diff) | |
parent | ef636ba346582db196cd52a694ac9fe71fc36019 (diff) |
Merge #7181
7181: Document project_model::PackageData and project_model::TargetData r=arnaudgolfouse a=arnaudgolfouse
This PR adds some documentation for the `project_model` crate.
Some of the field descriptions were taken directly from their `cargo_metadata` counterpart :
- `PackageData` -> `cargo_metadata::Package`
- `TargetData` -> `cargo_metadata::Target`
Co-authored-by: Arnaud <[email protected]>
Diffstat (limited to 'crates/project_model/src')
-rw-r--r-- | crates/project_model/src/cargo_workspace.rs | 22 | ||||
-rw-r--r-- | crates/project_model/src/lib.rs | 7 |
2 files changed, 27 insertions, 2 deletions
diff --git a/crates/project_model/src/cargo_workspace.rs b/crates/project_model/src/cargo_workspace.rs index 1700cb8a7..0e6679542 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<PackageData>; | |||
80 | 80 | ||
81 | pub type Target = Idx<TargetData>; | 81 | pub type Target = Idx<TargetData>; |
82 | 82 | ||
83 | /// Information associated with a cargo crate | ||
83 | #[derive(Debug, Clone, Eq, PartialEq)] | 84 | #[derive(Debug, Clone, Eq, PartialEq)] |
84 | pub struct PackageData { | 85 | pub struct PackageData { |
86 | /// Version given in the `Cargo.toml` | ||
85 | pub version: String, | 87 | pub version: String, |
88 | /// Name as given in the `Cargo.toml` | ||
86 | pub name: String, | 89 | pub name: String, |
90 | /// Path containing the `Cargo.toml` | ||
87 | pub manifest: AbsPathBuf, | 91 | pub manifest: AbsPathBuf, |
92 | /// Targets provided by the crate (lib, bin, example, test, ...) | ||
88 | pub targets: Vec<Target>, | 93 | pub targets: Vec<Target>, |
94 | /// Is this package a member of the current workspace | ||
89 | pub is_member: bool, | 95 | pub is_member: bool, |
96 | /// List of packages this package depends on | ||
90 | pub dependencies: Vec<PackageDependency>, | 97 | pub dependencies: Vec<PackageDependency>, |
98 | /// Rust edition for this package | ||
91 | pub edition: Edition, | 99 | pub edition: Edition, |
100 | /// List of features to activate | ||
92 | pub features: Vec<String>, | 101 | pub features: Vec<String>, |
102 | /// List of config flags defined by this package's build script | ||
93 | pub cfgs: Vec<CfgFlag>, | 103 | pub cfgs: Vec<CfgFlag>, |
104 | /// List of cargo-related environment variables with their value | ||
105 | /// | ||
106 | /// If the package has a build script which defines environment variables, | ||
107 | /// they can also be found here. | ||
94 | pub envs: Vec<(String, String)>, | 108 | pub envs: Vec<(String, String)>, |
109 | /// Directory where a build script might place its output | ||
95 | pub out_dir: Option<AbsPathBuf>, | 110 | pub out_dir: Option<AbsPathBuf>, |
111 | /// Path to the proc-macro library file if this package exposes proc-macros | ||
96 | pub proc_macro_dylib_path: Option<AbsPathBuf>, | 112 | pub proc_macro_dylib_path: Option<AbsPathBuf>, |
97 | } | 113 | } |
98 | 114 | ||
@@ -102,12 +118,18 @@ pub struct PackageDependency { | |||
102 | pub name: String, | 118 | pub name: String, |
103 | } | 119 | } |
104 | 120 | ||
121 | /// Information associated with a package's target | ||
105 | #[derive(Debug, Clone, Eq, PartialEq)] | 122 | #[derive(Debug, Clone, Eq, PartialEq)] |
106 | pub struct TargetData { | 123 | pub struct TargetData { |
124 | /// Package that provided this target | ||
107 | pub package: Package, | 125 | pub package: Package, |
126 | /// Name as given in the `Cargo.toml` or generated from the file name | ||
108 | pub name: String, | 127 | pub name: String, |
128 | /// Path to the main source file of the target | ||
109 | pub root: AbsPathBuf, | 129 | pub root: AbsPathBuf, |
130 | /// Kind of target | ||
110 | pub kind: TargetKind, | 131 | pub kind: TargetKind, |
132 | /// Is this target a proc-macro | ||
111 | pub is_proc_macro: bool, | 133 | pub is_proc_macro: bool, |
112 | } | 134 | } |
113 | 135 | ||
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 @@ | |||
1 | //! FIXME: write short doc here | 1 | //! FIXME: write short doc here |
2 | 2 | ||
3 | mod cargo_workspace; | 3 | mod cargo_workspace; |
4 | mod cfg_flag; | ||
4 | mod project_json; | 5 | mod project_json; |
5 | mod sysroot; | 6 | mod sysroot; |
6 | mod cfg_flag; | ||
7 | mod workspace; | 7 | mod workspace; |
8 | 8 | ||
9 | use std::{ | 9 | use std::{ |
@@ -17,7 +17,10 @@ use paths::{AbsPath, AbsPathBuf}; | |||
17 | use rustc_hash::FxHashSet; | 17 | use rustc_hash::FxHashSet; |
18 | 18 | ||
19 | pub use crate::{ | 19 | pub use crate::{ |
20 | cargo_workspace::{CargoConfig, CargoWorkspace, Package, Target, TargetKind}, | 20 | cargo_workspace::{ |
21 | CargoConfig, CargoWorkspace, Package, PackageData, PackageDependency, Target, TargetData, | ||
22 | TargetKind, | ||
23 | }, | ||
21 | project_json::{ProjectJson, ProjectJsonData}, | 24 | project_json::{ProjectJson, ProjectJsonData}, |
22 | sysroot::Sysroot, | 25 | sysroot::Sysroot, |
23 | workspace::{PackageRoot, ProjectWorkspace}, | 26 | workspace::{PackageRoot, ProjectWorkspace}, |