Skip to content

Commit 50cd218

Browse files
committed
auto merge of #5920 : catamorphism/rust/rustpkg, r=catamorphism
r? @graydon
2 parents b19c644 + 1aebf30 commit 50cd218

File tree

20 files changed

+526
-238
lines changed

20 files changed

+526
-238
lines changed

src/librustpkg/path_util.rs

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
// rustpkg utilities having to do with paths and directories
1212

1313
use core::path::*;
14-
use core::os;
14+
use core::{os, str};
15+
use core::option::*;
1516
use util::PkgId;
1617

1718
/// Returns the output directory to use.
@@ -50,6 +51,24 @@ pub fn default_dest_dir(pkg_dir: &Path) -> Path {
5051
}
5152
}
5253

54+
/// Replace all occurrences of '-' in the stem part of path with '_'
55+
/// This is because we treat rust-foo-bar-quux and rust_foo_bar_quux
56+
/// as the same name
57+
pub fn normalize(p: ~Path) -> ~Path {
58+
match p.filestem() {
59+
None => p,
60+
Some(st) => {
61+
let replaced = str::replace(st, "-", "_");
62+
if replaced != st {
63+
~p.with_filestem(replaced)
64+
}
65+
else {
66+
p
67+
}
68+
}
69+
}
70+
}
71+
5372
#[cfg(test)]
5473
mod test {
5574
use core::{os, rand};

0 commit comments

Comments
 (0)