Skip to content

Commit 36137ae

Browse files
committed
Don't graft subdirectories, rely solely on source directory hashes.
1 parent 434f3db commit 36137ae

File tree

1 file changed

+4
-21
lines changed

1 file changed

+4
-21
lines changed

src/lib.rs

Lines changed: 4 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1025,23 +1025,8 @@ impl Build {
10251025
let mut objects = Vec::new();
10261026
for file in self.files.iter() {
10271027
let obj = if file.has_root() {
1028-
// If `file` is an absolute path, try to remove the part
1029-
// common with the destination directory, and graft the
1030-
// remaining part. Most common outcome would be removal
1031-
// of the home directory, next common - removal of the root
1032-
// directory.
1033-
let mut pre = dst.components();
1034-
let mut dst = dst.clone();
1035-
for comp in file.components() {
1036-
if comp != pre.next().unwrap_or(Component::CurDir) {
1037-
match comp {
1038-
Component::Normal(c) => dst.push(c),
1039-
_ => (),
1040-
};
1041-
}
1042-
}
1043-
// ... and prefix the `basename` with the `dirname`'s hash
1044-
// to ensure name uniqueness.
1028+
// If `file` is an absolute path, prefix the `basename`
1029+
// with the `dirname`'s hash to ensure name uniqueness.
10451030
let basename = file
10461031
.file_name()
10471032
.ok_or_else(|| Error::new(ErrorKind::InvalidArgument, "file_name() failure"))?
@@ -1052,10 +1037,8 @@ impl Build {
10521037
.to_string_lossy();
10531038
let mut hasher = hash_map::DefaultHasher::new();
10541039
hasher.write(dirname.to_string().as_bytes());
1055-
if dst.pop() {
1056-
dst.push(format!("{:016x}-{}", hasher.finish(), basename));
1057-
}
1058-
dst.with_extension("o")
1040+
dst.join(format!("{:016x}-{}", hasher.finish(), basename))
1041+
.with_extension("o")
10591042
} else {
10601043
dst.join(file).with_extension("o")
10611044
};

0 commit comments

Comments
 (0)