|
1 | 1 | # Codebase Overview
|
2 | 2 |
|
3 |
| -This is a very high-level overview of the Cargo codebase. |
4 |
| - |
5 |
| -* [`src/bin/cargo`](https://github.com/rust-lang/cargo/tree/master/src/bin/cargo) |
6 |
| - --- Cargo is split in a library and a binary. This is the binary side that |
7 |
| - handles argument parsing, and then calls into the library to perform the |
8 |
| - appropriate subcommand. Each Cargo subcommand is a separate module here. See |
9 |
| - [SubCommands](subcommands.md). |
10 |
| - |
11 |
| -* [`src/cargo/ops`](https://github.com/rust-lang/cargo/tree/master/src/cargo/ops) |
12 |
| - --- Every major operation is implemented here. This is where the binary CLI |
13 |
| - usually calls into to perform the appropriate action. |
14 |
| - |
15 |
| - * [`src/cargo/ops/cargo_compile/mod.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/cargo_compile/mod.rs) |
16 |
| - --- This is the entry point for all the compilation commands. This is a |
17 |
| - good place to start if you want to follow how compilation starts and |
18 |
| - flows to completion. |
19 |
| - |
20 |
| -* [`src/cargo/core/resolver`](https://github.com/rust-lang/cargo/tree/master/src/cargo/core/resolver) |
21 |
| - --- This is the dependency and feature resolvers. |
22 |
| - |
23 |
| -* [`src/cargo/core/compiler`](https://github.com/rust-lang/cargo/tree/master/src/cargo/core/compiler) |
24 |
| - --- This is the code responsible for running `rustc` and `rustdoc`. |
25 |
| - |
26 |
| - * [`src/cargo/core/compiler/build_context/mod.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/build_context/mod.rs) |
27 |
| - --- The `BuildContext` is the result of the "front end" of the build |
28 |
| - process. This contains the graph of work to perform and any settings |
29 |
| - necessary for `rustc`. After this is built, the next stage of building |
30 |
| - is handled in `Context`. |
31 |
| - |
32 |
| - * [`src/cargo/core/compiler/context`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/context/mod.rs) |
33 |
| - --- The `Context` is the mutable state used during the build process. This |
34 |
| - is the core of the build process, and everything is coordinated through |
35 |
| - this. |
36 |
| - |
37 |
| - * [`src/cargo/core/compiler/fingerprint.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/compiler/fingerprint.rs) |
38 |
| - --- The `fingerprint` module contains all the code that handles detecting |
39 |
| - if a crate needs to be recompiled. |
40 |
| - |
41 |
| -* [`src/cargo/core/source`](https://github.com/rust-lang/cargo/tree/master/src/cargo/core/source) |
42 |
| - --- The `Source` trait is an abstraction over different sources of packages. |
43 |
| - Sources are uniquely identified by a `SourceId`. Sources are implemented in |
44 |
| - the |
45 |
| - [`src/cargo/sources`](https://github.com/rust-lang/cargo/tree/master/src/cargo/sources) |
46 |
| - directory. |
47 |
| - |
48 |
| -* [`src/cargo/util`](https://github.com/rust-lang/cargo/tree/master/src/cargo/util) |
49 |
| - --- This directory contains generally-useful utility modules. |
50 |
| - |
51 |
| -* [`src/cargo/util/config`](https://github.com/rust-lang/cargo/tree/master/src/cargo/util/config) |
52 |
| - --- This directory contains the config parser. It makes heavy use of |
53 |
| - [serde](https://serde.rs/) to merge and translate config values. The |
54 |
| - `Config` is usually accessed from the |
55 |
| - [`Workspace`](https://github.com/rust-lang/cargo/blob/master/src/cargo/core/workspace.rs), |
56 |
| - though references to it are scattered around for more convenient access. |
57 |
| - |
58 |
| -* [`src/cargo/util/toml`](https://github.com/rust-lang/cargo/tree/master/src/cargo/util/toml) |
59 |
| - --- This directory contains the code for parsing `Cargo.toml` files. |
60 |
| - |
61 |
| - * [`src/cargo/ops/lockfile.rs`](https://github.com/rust-lang/cargo/blob/master/src/cargo/ops/lockfile.rs) |
62 |
| - --- This is where `Cargo.lock` files are loaded and saved. |
63 |
| - |
64 |
| -* [`src/doc`](https://github.com/rust-lang/cargo/tree/master/src/doc) |
65 |
| - --- This directory contains Cargo's documentation and man pages. |
66 |
| - |
67 |
| -* [`src/etc`](https://github.com/rust-lang/cargo/tree/master/src/etc) |
68 |
| - --- These are files that get distributed in the `etc` directory in the Rust release. |
69 |
| - The man pages are auto-generated by a script in the `src/doc` directory. |
70 |
| - |
71 |
| -* [`crates`](https://github.com/rust-lang/cargo/tree/master/crates) |
72 |
| - --- A collection of independent crates used by Cargo. |
73 |
| - |
74 |
| -## Extra crates |
75 |
| - |
76 |
| -Some functionality is split off into separate crates, usually in the |
77 |
| -[`crates`](https://github.com/rust-lang/cargo/tree/master/crates) directory. |
78 |
| - |
79 |
| -* [`cargo-platform`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-platform) |
80 |
| - --- This library handles parsing `cfg` expressions. |
81 |
| -* [`cargo-test-macro`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-macro) |
82 |
| - --- This is a proc-macro used by the test suite to define tests. More |
83 |
| - information can be found at [`cargo_test` |
84 |
| - attribute](../tests/writing.md#cargo_test-attribute). |
85 |
| -* [`cargo-test-support`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-test-support) |
86 |
| - --- This contains a variety of code to support [writing |
87 |
| - tests](../tests/writing.md). |
88 |
| -* [`cargo-util`](https://github.com/rust-lang/cargo/tree/master/crates/cargo-util) |
89 |
| - --- This contains general utility code that is shared between cargo and the |
90 |
| - testsuite. |
91 |
| -* [`crates-io`](https://github.com/rust-lang/cargo/tree/master/crates/crates-io) |
92 |
| - --- This contains code for accessing the crates.io API. |
93 |
| -* [`credential`](https://github.com/rust-lang/cargo/tree/master/crates/credential) |
94 |
| - --- This subdirectory contains several packages for implementing the |
95 |
| - experimental |
96 |
| - [credential-process](https://doc.rust-lang.org/nightly/cargo/reference/unstable.html#credential-process) |
97 |
| - feature. |
98 |
| -* [`home`](https://github.com/rust-lang/cargo/tree/master/crates/home) --- This library is shared between cargo and rustup and is used for finding their home directories. |
99 |
| - This is not directly depended upon with a `path` dependency; cargo uses the version from crates.io. |
100 |
| - It is intended to be versioned and published independently of Rust's release system. |
101 |
| - Whenever a change needs to be made, bump the version in Cargo.toml and `cargo publish` it manually, and then update cargo's `Cargo.toml` to depend on the new version. |
102 |
| -* [`mdman`](https://github.com/rust-lang/cargo/tree/master/crates/mdman) |
103 |
| - --- This is a utility for generating cargo's man pages. See [Building the man |
104 |
| - pages](https://github.com/rust-lang/cargo/tree/master/src/doc#building-the-man-pages) |
105 |
| - for more information. |
106 |
| -* [`resolver-tests`](https://github.com/rust-lang/cargo/tree/master/crates/resolver-tests) |
107 |
| - --- This is a dedicated package that defines tests for the [dependency |
108 |
| - resolver](../architecture/packages.md#resolver). |
| 3 | +See [nightly docs](https://doc.rust-lang.org/nightly/nightly-rustc/cargo/index.html) |
0 commit comments