@@ -12,35 +12,37 @@ and more.
12
12
13
13
## Subcommands
14
14
15
- Cargo is a single binary composed of a set of [ ` clap ` ] [ ] subcommands. All subcommands live in
15
+ Cargo is a single binary composed of a set of [ ` clap ` ] subcommands. All subcommands live in
16
16
` src/bin/cargo/commands ` directory. ` src/bin/cargo/main.rs ` is the entry point.
17
17
18
- Each subcommand, such as ` src/bin/cargo/commands/build.rs ` , has its own API
18
+ Each subcommand, such as [ ` src/bin/cargo/commands/build.rs ` ] , has its own API
19
19
interface, similarly to Git's, parsing command line options, reading the
20
20
configuration files, discovering the Cargo project in the current directory and
21
21
delegating the actual implementation to one
22
- of the functions in ` src/cargo/ops/mod.rs ` . This short file is a good
22
+ of the functions in [ ` src/cargo/ops/mod.rs ` ] . This short file is a good
23
23
place to find out about most of the things that Cargo can do.
24
24
Subcommands are designed to pipe to one another, and custom subcommands make
25
25
Cargo easy to extend and attach tools to.
26
26
27
27
[ `clap` ] : https://clap.rs/
28
+ [ `src/bin/cargo/commands/build.rs` ] : src/bin/cargo/commands/build.rs
29
+ [ `src/cargo/ops/mod.rs` ] : src/cargo/ops/mod.rs
28
30
29
31
30
32
## Important Data Structures
31
33
32
34
There are some important data structures which are used throughout
33
35
Cargo.
34
36
35
- ` Config ` is available almost everywhere and holds "global"
37
+ [ ` Config ` ] is available almost everywhere and holds "global"
36
38
information, such as ` CARGO_HOME ` or configuration from
37
- ` .cargo/config ` files. The ` shell ` method of ` Config ` is the entry
39
+ ` .cargo/config ` files. The [ ` shell ` ] method of [ ` Config ` ] is the entry
38
40
point for printing status messages and other info to the console.
39
41
40
- ` Workspace ` is the description of the workspace for the current
42
+ [ ` Workspace ` ] is the description of the workspace for the current
41
43
working directory. Each workspace contains at least one
42
- ` Package ` . Each package corresponds to a single ` Cargo.toml ` , and may
43
- define several ` Target ` s, such as the library, binaries, integration
44
+ [ ` Package ` ] . Each package corresponds to a single ` Cargo.toml ` , and may
45
+ define several [ ` Target ` ] s, such as the library, binaries, integration
44
46
test or examples. Targets are crates (each target defines a crate
45
47
root, like ` src/lib.rs ` or ` examples/foo.rs ` ) and are what is actually
46
48
compiled by ` rustc ` .
@@ -50,18 +52,26 @@ auxiliary ones. Packages are a unit of dependency in Cargo, and when
50
52
package ` foo ` depends on package ` bar ` , that means that each target
51
53
from ` foo ` needs the library target from ` bar ` .
52
54
53
- ` PackageId ` is the unique identifier of a (possibly remote)
55
+ [ ` PackageId ` ] is the unique identifier of a (possibly remote)
54
56
package. It consist of three components: name, version and source
55
57
id. Source is the place where the source code for package comes
56
58
from. Typical sources are crates.io, a git repository or a folder on
57
59
the local hard drive.
58
60
59
- ` Resolve ` is the representation of a directed acyclic graph of package
60
- dependencies, which uses ` PackageId ` s for nodes. This is the data
61
+ [ ` Resolve ` ] is the representation of a directed acyclic graph of package
62
+ dependencies, which uses [ ` PackageId ` ] s for nodes. This is the data
61
63
structure that is saved to the lock file. If there is no lock file,
62
64
Cargo constructs a resolve by finding a graph of packages which
63
65
matches declared dependency specification according to semver.
64
66
67
+ [ `Config` ] : https://docs.rs/cargo/latest/cargo/util/config/struct.Config.html
68
+ [ `shell` ] : https://docs.rs/cargo/latest/cargo/util/config/struct.Config.html#method.shell
69
+ [ `Workspace` ] : https://docs.rs/cargo/latest/cargo/core/struct.Workspace.html
70
+ [ `Package` ] : https://docs.rs/cargo/latest/cargo/core/package/struct.Package.html
71
+ [ `Target` ] : https://docs.rs/cargo/latest/cargo/core/manifest/struct.Target.html
72
+ [ `PackageId` ] : https://docs.rs/cargo/latest/cargo/core/package_id/struct.PackageId.html
73
+ [ `Resolve` ] : https://docs.rs/cargo/latest/cargo/core/struct.Resolve.html
74
+
65
75
66
76
## Persistence
67
77
@@ -70,9 +80,11 @@ the information used by Cargo must be persisted on the hard drive. The
70
80
main sources of information are ` Cargo.toml ` and ` Cargo.lock ` files,
71
81
` .cargo/config ` configuration files and the globally shared registry
72
82
of packages downloaded from crates.io, usually located at
73
- ` ~/.cargo/registry ` . See ` src/sources/registry ` for the specifics of
83
+ ` ~/.cargo/registry ` . See [ ` src/cargo/ sources/registry ` ] for the specifics of
74
84
the registry storage format.
75
85
86
+ [ `src/cargo/sources/registry` ] : src/cargo/sources/registry
87
+
76
88
77
89
## Concurrency
78
90
@@ -108,15 +120,18 @@ p.cargo("run").stream().run();
108
120
109
121
Alternatively to build and run a custom version of cargo simply run ` cargo build `
110
122
and execute ` target/debug/cargo ` . Note that ` +nightly ` /` +stable ` (and variants),
111
- being [ rustup] ( https://rustup.rs/ ) features, won't work when executing the locally
123
+ being [ rustup] features, won't work when executing the locally
112
124
built cargo binary directly, you have to instead build with ` cargo +nightly build `
113
125
and run with ` rustup run ` (e.g `rustup run nightly
114
126
<path-to-cargo >/target/debug/cargo <args >..` ) (or set the ` RUSTC` env var to point
115
127
to nightly rustc).
116
128
129
+ [ rustup ] : https://rustup.rs/
130
+
131
+
117
132
## Logging
118
133
119
- Cargo uses [ ` env_logger ` ] ( https://docs.rs/env_logger/*/env_logger/ ) , so you can set
134
+ Cargo uses [ ` env_logger ` ] , so you can set
120
135
` RUST_LOG ` environment variable to get the logs. This is useful both for diagnosing
121
136
bugs in stable Cargo and for local development. Cargo also has internal hierarchical
122
137
profiling infrastructure, which is activated via ` CARGO_PROFILE ` variable
@@ -131,3 +146,5 @@ $ RUST_LOG=cargo::core::resolver=trace cargo generate-lockfile
131
146
# Output first three levels of profiling info
132
147
$ CARGO_PROFILE=3 cargo generate-lockfile
133
148
```
149
+
150
+ [ `env_logger` ] : https://docs.rs/env_logger/*/env_logger/
0 commit comments