@@ -63,6 +63,10 @@ pub struct CompilationFiles<'a, 'cfg> {
63
63
/// include dependencies).
64
64
roots : Vec < Unit < ' a > > ,
65
65
ws : & ' a Workspace < ' cfg > ,
66
+ /// Metadata hash to use for each unit.
67
+ ///
68
+ /// `None` if the unit should not use a metadata data hash (like rustdoc,
69
+ /// or some dylibs).
66
70
metas : HashMap < Unit < ' a > , Option < Metadata > > ,
67
71
/// For each Unit, a list all files produced.
68
72
outputs : HashMap < Unit < ' a > , LazyCell < Arc < Vec < OutputFile > > > > ,
@@ -133,12 +137,15 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
133
137
/// We build to the path `"{filename}-{target_metadata}"`.
134
138
/// We use a linking step to link/copy to a predictable filename
135
139
/// like `target/debug/libfoo.{a,so,rlib}` and such.
140
+ ///
141
+ /// Returns `None` if the unit should not use a metadata data hash (like
142
+ /// rustdoc, or some dylibs).
136
143
pub fn metadata ( & self , unit : & Unit < ' a > ) -> Option < Metadata > {
137
144
self . metas [ unit] . clone ( )
138
145
}
139
146
140
147
/// Gets the short hash based only on the `PackageId`.
141
- /// Used for the metadata when `target_metadata ` returns `None`.
148
+ /// Used for the metadata when `metadata ` returns `None`.
142
149
pub fn target_short_hash ( & self , unit : & Unit < ' _ > ) -> String {
143
150
let hashable = unit. pkg . package_id ( ) . stable_hash ( self . ws . root ( ) ) ;
144
151
util:: short_hash ( & hashable)
@@ -160,10 +167,12 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
160
167
}
161
168
}
162
169
170
+ /// Additional export directory from `--out-dir`.
163
171
pub fn export_dir ( & self ) -> Option < PathBuf > {
164
172
self . export_dir . clone ( )
165
173
}
166
174
175
+ /// Directory name to use for a package in the form `NAME-HASH`.
167
176
pub fn pkg_dir ( & self , unit : & Unit < ' a > ) -> String {
168
177
let name = unit. pkg . package_id ( ) . name ( ) ;
169
178
match self . metas [ unit] {
@@ -177,6 +186,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
177
186
self . host . dest ( )
178
187
}
179
188
189
+ /// Returns the host `deps` directory path.
180
190
pub fn host_deps ( & self ) -> & Path {
181
191
self . host . deps ( )
182
192
}
@@ -187,6 +197,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
187
197
self . layout ( unit. kind ) . deps ( )
188
198
}
189
199
200
+ /// Directory where the fingerprint for the given unit should go.
190
201
pub fn fingerprint_dir ( & self , unit : & Unit < ' a > ) -> PathBuf {
191
202
let dir = self . pkg_dir ( unit) ;
192
203
self . layout ( unit. kind ) . fingerprint ( ) . join ( dir)
@@ -241,7 +252,7 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
241
252
. map ( Arc :: clone)
242
253
}
243
254
244
- /// Returns the bin stem for a given target ( without metadata) .
255
+ /// Returns the bin filename for a given target, without extension and metadata.
245
256
fn bin_stem ( & self , unit : & Unit < ' _ > ) -> String {
246
257
if unit. target . allows_underscores ( ) {
247
258
unit. target . name ( ) . to_string ( )
@@ -250,11 +261,16 @@ impl<'a, 'cfg: 'a> CompilationFiles<'a, 'cfg> {
250
261
}
251
262
}
252
263
253
- /// Returns a tuple with the directory and name of the hard link we expect
254
- /// our target to be copied to. Eg, file_stem may be out_dir/deps/foo-abcdef
255
- /// and link_stem would be out_dir/foo
256
- /// This function returns it in two parts so the caller can add prefix/suffix
257
- /// to filename separately.
264
+ /// Returns a tuple `(hard_link_dir, filename_stem)` for the primary
265
+ /// output file for the given unit.
266
+ ///
267
+ /// `hard_link_dir` is the directory where the file should be hard-linked
268
+ /// ("uplifted") to. For example, `/path/to/project/target`.
269
+ ///
270
+ /// `filename_stem` is the base filename without an extension.
271
+ ///
272
+ /// This function returns it in two parts so the caller can add
273
+ /// prefix/suffix to filename separately.
258
274
///
259
275
/// Returns an `Option` because in some cases we don't want to link
260
276
/// (eg a dependent lib).
0 commit comments