Expand description
In rust-analyzer, we maintain a strict separation between pure abstract semantic project model and a concrete model of a particular build system.
Pure model is represented by the base_db::CrateGraph from another crate.
In this crate, we are concerned with “real world” project models.
Specifically, here we have a representation for a Cargo project
(CargoWorkspace) and for manually specified layout (ProjectJson).
Roughly, the things we do here are:
- Project discovery (where’s the relevant Cargo.toml for the current dir).
- Custom build steps (
build.rscode generation and compilation of procedural macros). - Lowering of concrete model to a
base_db::CrateGraph
Re-exports§
pub use crate::project_json::ProjectJson;pub use crate::project_json::ProjectJsonData;
Modules§
- build_
dependencies 🔒 - Logic to invoke
cargofor building build-dependencies (build scripts and proc-macros) as well as executing the build scripts to fetch required dependency information (OUT_DIRenv var, extra cfg flags, etc). - cargo_
config_ 🔒file - Read
.cargo/config.tomlas a TOML table - cargo_
workspace 🔒 - See
CargoWorkspace. - env 🔒
- Cargo-like environment variables injection.
- manifest_
path 🔒 - See
ManifestPath. - project_
json rust-project.jsonfile format.- sysroot 🔒
- Loads “sysroot” crate.
- toolchain_
info - workspace 🔒
- Handles lowering of build-system specific workspace information (
cargo metadataorrust-project.json) into representation stored in the salsa database –CrateGraph.
Structs§
- Cargo
Config - Cargo
Metadata Config - Cargo
Workspace CargoWorkspacerepresents the logical structure of, well, a Cargo workspace. It pretty closely mirrorscargo metadataoutput.- CfgOverrides
- A set of cfg-overrides per crate.
- Manifest
Path - More or less [
AbsPathBuf] with non-None parent. - Metadata
- Starting point for metadata returned by
cargo metadata - Package
Data - Information associated with a cargo crate
- Package
Dependency - Package
Root PackageRootdescribes a package root folder. Which may be an external dependency, or a member of the current workspace.- Project
Json From Command - Project
Workspace - Sysroot
- Target
Data - Information associated with a package’s target
- Workspace
Build Scripts - Output of the build script and proc-macro building steps for a workspace.
Enums§
- Cargo
Features - Invocation
Strategy - Proc
Macro Dylib Path - Project
Manifest - Project
Workspace Kind - Rust
LibSource - Describes how to set the rustc source directory.
- Rust
Source Workspace Config - Target
Directory Config - Target
Kind
Functions§
- parse_
cfg 🔒 - utf8_
stdout 🔒