Skip to content

Commit bf2cc7c

Browse files
committed
docs(fingerprint): document the format of depinfo files
1 parent f95eeb6 commit bf2cc7c

File tree

1 file changed

+31
-0
lines changed
  • src/cargo/core/compiler/fingerprint

1 file changed

+31
-0
lines changed

src/cargo/core/compiler/fingerprint/mod.rs

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2220,6 +2220,8 @@ pub fn translate_dep_info(
22202220
#[derive(Default)]
22212221
pub struct RustcDepInfo {
22222222
/// The list of files that the main target in the dep-info file depends on.
2223+
///
2224+
/// The optional checksums are parsed from the special `# checksum:...` comments.
22232225
pub files: HashMap<PathBuf, Option<(u64, Checksum)>>,
22242226
/// The list of environment variables we found that the rustc compilation
22252227
/// depends on.
@@ -2228,6 +2230,8 @@ pub struct RustcDepInfo {
22282230
/// item is the value. `Some` means that the env var was set, and `None`
22292231
/// means that the env var wasn't actually set and the compilation depends
22302232
/// on it not being set.
2233+
///
2234+
/// These are from the special `# env-var:...` comments.
22312235
pub env: Vec<(String, Option<String>)>,
22322236
}
22332237

@@ -2236,6 +2240,33 @@ pub struct RustcDepInfo {
22362240
///
22372241
/// This is also stored in an optimized format to make parsing it fast because
22382242
/// Cargo will read it for crates on all future compilations.
2243+
///
2244+
/// Currently the format looks like:
2245+
///
2246+
/// ```text
2247+
/// +------------+------------+---------------+---------------+
2248+
/// | # of files | file paths | # of env vars | env var pairs |
2249+
/// +------------+------------+---------------+---------------+
2250+
/// ```
2251+
///
2252+
/// Each field represents
2253+
///
2254+
/// * _Number of files/envs_ --- A `u32` representing the number of things.
2255+
/// * _File paths_ --- Zero or more paths of files the dep-info file depends on.
2256+
/// Each path is encoded as the following:
2257+
///
2258+
/// ```text
2259+
/// +-----------+-------------+------------+---------------+-----------+-------+
2260+
/// | Path type | len of path | path bytes | cksum exists? | file size | cksum |
2261+
/// +-----------+-------------+------------+---------------+-----------+-------+
2262+
/// ```
2263+
/// * _Env var pairs_ --- Zero or more env vars the dep-info file depends on.
2264+
/// Each env key-value pair is encoded as the following:
2265+
/// ```text
2266+
/// +------------+-----------+---------------+--------------+-------------+
2267+
/// | len of key | key bytes | value exists? | len of value | value bytes |
2268+
/// +------------+-----------+---------------+--------------+-------------+
2269+
/// ```
22392270
#[derive(Default)]
22402271
struct EncodedDepInfo {
22412272
files: Vec<(DepInfoPathType, PathBuf, Option<(u64, String)>)>,

0 commit comments

Comments
 (0)