@@ -213,7 +213,7 @@ use super::job::{
213
213
Freshness :: { Dirty , Fresh } ,
214
214
Job , Work ,
215
215
} ;
216
- use super :: { BuildContext , Context , FileFlavor , Kind , Unit } ;
216
+ use super :: { BuildContext , Context , FileFlavor , Unit } ;
217
217
218
218
/// Determines if a `unit` is up-to-date, and if not prepares necessary work to
219
219
/// update the persisted fingerprint.
@@ -1014,7 +1014,7 @@ fn calculate<'a, 'cfg>(
1014
1014
1015
1015
// After we built the initial `Fingerprint` be sure to update the
1016
1016
// `fs_status` field of it.
1017
- let target_root = target_root ( cx, unit ) ;
1017
+ let target_root = target_root ( cx) ;
1018
1018
fingerprint. check_filesystem ( unit. pkg . root ( ) , & target_root) ?;
1019
1019
1020
1020
let fingerprint = Arc :: new ( fingerprint) ;
@@ -1046,7 +1046,7 @@ fn calculate_normal<'a, 'cfg>(
1046
1046
// correctly, but otherwise upstream packages like from crates.io or git
1047
1047
// get bland fingerprints because they don't change without their
1048
1048
// `PackageId` changing.
1049
- let target_root = target_root ( cx, unit ) ;
1049
+ let target_root = target_root ( cx) ;
1050
1050
let local = if use_dep_info ( unit) {
1051
1051
let dep_info = dep_info_loc ( cx, unit) ;
1052
1052
let dep_info = dep_info. strip_prefix ( & target_root) . unwrap ( ) . to_path_buf ( ) ;
@@ -1219,8 +1219,8 @@ fn build_script_local_fingerprints<'a, 'cfg>(
1219
1219
// package. Remember that the fact that this is an `Option` is a bug, but a
1220
1220
// longstanding bug, in Cargo. Recent refactorings just made it painfully
1221
1221
// obvious.
1222
- let script_root = cx. files ( ) . build_script_run_dir ( unit) ;
1223
1222
let pkg_root = unit. pkg . root ( ) . to_path_buf ( ) ;
1223
+ let target_dir = target_root ( cx) ;
1224
1224
let calculate =
1225
1225
move |deps : & BuildDeps , pkg_fingerprint : Option < & dyn Fn ( ) -> CargoResult < String > > | {
1226
1226
if deps. rerun_if_changed . is_empty ( ) && deps. rerun_if_env_changed . is_empty ( ) {
@@ -1247,7 +1247,7 @@ fn build_script_local_fingerprints<'a, 'cfg>(
1247
1247
// Ok so now we're in "new mode" where we can have files listed as
1248
1248
// dependencies as well as env vars listed as dependencies. Process
1249
1249
// them all here.
1250
- Ok ( Some ( local_fingerprints_deps ( deps, & script_root , & pkg_root) ) )
1250
+ Ok ( Some ( local_fingerprints_deps ( deps, & target_dir , & pkg_root) ) )
1251
1251
} ;
1252
1252
1253
1253
// Note that `false` == "not overridden"
@@ -1346,17 +1346,10 @@ pub fn dep_info_loc<'a, 'cfg>(cx: &mut Context<'a, 'cfg>, unit: &Unit<'a>) -> Pa
1346
1346
. join ( & format ! ( "dep-{}" , filename( cx, unit) ) )
1347
1347
}
1348
1348
1349
- /// Returns an absolute path that the `unit`'s outputs should always be relative
1350
- /// to. This `target_root` variable is used to store relative path names in
1351
- /// `Fingerprint` instead of absolute pathnames (see module comment).
1352
- fn target_root < ' a , ' cfg > ( cx : & mut Context < ' a , ' cfg > , unit : & Unit < ' a > ) -> PathBuf {
1353
- if unit. mode . is_run_custom_build ( ) {
1354
- cx. files ( ) . build_script_run_dir ( unit)
1355
- } else if unit. kind == Kind :: Host {
1356
- cx. files ( ) . host_root ( ) . to_path_buf ( )
1357
- } else {
1358
- cx. files ( ) . target_root ( ) . to_path_buf ( )
1359
- }
1349
+ /// Returns an absolute path that target directory.
1350
+ /// All paths are rewritten to be relative to this.
1351
+ fn target_root ( cx : & Context < ' _ , ' _ > ) -> PathBuf {
1352
+ cx. bcx . ws . target_dir ( ) . into_path_unlocked ( )
1360
1353
}
1361
1354
1362
1355
fn compare_old_fingerprint (
@@ -1565,10 +1558,10 @@ pub fn translate_dep_info(
1565
1558
let mut new_contents = Vec :: new ( ) ;
1566
1559
for file in deps {
1567
1560
let file = rustc_cwd. join ( file) ;
1568
- let ( ty, path) = if let Ok ( stripped) = file. strip_prefix ( pkg_root) {
1569
- ( DepInfoPathType :: PackageRootRelative , stripped)
1570
- } else if let Ok ( stripped) = file. strip_prefix ( target_root) {
1561
+ let ( ty, path) = if let Ok ( stripped) = file. strip_prefix ( target_root) {
1571
1562
( DepInfoPathType :: TargetRootRelative , stripped)
1563
+ } else if let Ok ( stripped) = file. strip_prefix ( pkg_root) {
1564
+ ( DepInfoPathType :: PackageRootRelative , stripped)
1572
1565
} else {
1573
1566
// It's definitely not target root relative, but this is an absolute path (since it was
1574
1567
// joined to rustc_cwd) and as such re-joining it later to the target root will have no
0 commit comments