1
+ //! See [`CompilationFiles`].
2
+
1
3
use std:: collections:: HashMap ;
2
4
use std:: env;
3
5
use std:: fmt;
@@ -16,7 +18,9 @@ use crate::util::{self, CargoResult, StableHasher};
16
18
/// This is a generic version number that can be changed to make
17
19
/// backwards-incompatible changes to any file structures in the output
18
20
/// directory. For example, the fingerprint files or the build-script
19
- /// output files. Normally cargo updates ship with rustc updates which will
21
+ /// output files.
22
+ ///
23
+ /// Normally cargo updates ship with rustc updates which will
20
24
/// cause a new hash due to the rustc version changing, but this allows
21
25
/// cargo to be extra careful to deal with different versions of cargo that
22
26
/// use the same rustc version.
@@ -41,7 +45,7 @@ const METADATA_VERSION: u8 = 2;
41
45
///
42
46
/// This also acts as the main layer of caching provided by Cargo.
43
47
/// For example, we want to cache `cargo build` and `cargo doc` separately, so that running one
44
- /// does not invalidate the artifacts for the other. We do this by including `CompileMode` in the
48
+ /// does not invalidate the artifacts for the other. We do this by including [ `CompileMode`] in the
45
49
/// hash, thus the artifacts go in different folders and do not override each other.
46
50
/// If we don't add something that we should have, for this reason, we get the
47
51
/// correct output but rebuild more than is needed.
@@ -170,7 +174,9 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
170
174
171
175
/// Gets the metadata for the given unit.
172
176
///
173
- /// See module docs for more details.
177
+ /// See [`Metadata`] and [`fingerprint`] module for more.
178
+ ///
179
+ /// [`fingerprint`]: ../../fingerprint/index.html#fingerprints-and-metadata
174
180
pub fn metadata ( & self , unit : & Unit ) -> Metadata {
175
181
self . metas [ unit] . meta_hash
176
182
}
@@ -421,6 +427,9 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
421
427
Some ( uplift_path)
422
428
}
423
429
430
+ /// Calculates the filenames that the given unit will generate.
431
+ /// Should use [`CompilationFiles::outputs`] instead
432
+ /// as it caches the result of this function.
424
433
fn calc_outputs (
425
434
& self ,
426
435
unit : & Unit ,
@@ -537,6 +546,11 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
537
546
}
538
547
}
539
548
549
+ /// Gets the metadata hash for the given [`Unit`].
550
+ ///
551
+ /// Whne a metadata hash doesn't exist for the given unit,
552
+ /// this calls itself recursively to compute metadata hashes of all its dependencies.
553
+ /// See [`compute_metadata`] for how a single metadata hash is computed.
540
554
fn metadata_of < ' a > (
541
555
unit : & Unit ,
542
556
cx : & Context < ' _ , ' _ > ,
@@ -552,6 +566,7 @@ fn metadata_of<'a>(
552
566
& metas[ unit]
553
567
}
554
568
569
+ /// Computes the metadata hash for the given [`Unit`].
555
570
fn compute_metadata (
556
571
unit : & Unit ,
557
572
cx : & Context < ' _ , ' _ > ,
@@ -632,6 +647,7 @@ fn compute_metadata(
632
647
}
633
648
}
634
649
650
+ /// Hash the version of rustc being used during the build process.
635
651
fn hash_rustc_version ( bcx : & BuildContext < ' _ , ' _ > , hasher : & mut StableHasher ) {
636
652
let vers = & bcx. rustc ( ) . version ;
637
653
if vers. pre . is_empty ( ) || bcx. config . cli_unstable ( ) . separate_nightlies {
0 commit comments