aboutsummaryrefslogtreecommitdiff
path: root/xtask/src
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2019-11-06 09:40:28 +0000
committerAleksey Kladov <[email protected]>2019-11-06 09:40:28 +0000
commit5efd99a6e0a229d40106811188f6afd58dd97399 (patch)
tree0254b248a3d4faa09677287746ec58cbf01bc512 /xtask/src
parent4fbb36db9b4e7b3416daccc6b9a62f97ae12d6a3 (diff)
Ignore line-endings when checking generated files for freshness
closes #2184
Diffstat (limited to 'xtask/src')
-rw-r--r--xtask/src/codegen.rs8
1 files changed, 6 insertions, 2 deletions
diff --git a/xtask/src/codegen.rs b/xtask/src/codegen.rs
index 4ec8ab75a..770b55a9a 100644
--- a/xtask/src/codegen.rs
+++ b/xtask/src/codegen.rs
@@ -46,7 +46,7 @@ pub enum Mode {
46/// With verify = false, 46/// With verify = false,
47fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> { 47fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
48 match fs::read_to_string(path) { 48 match fs::read_to_string(path) {
49 Ok(ref old_contents) if old_contents == contents => { 49 Ok(ref old_contents) if normalize(old_contents) == normalize(contents) => {
50 return Ok(()); 50 return Ok(());
51 } 51 }
52 _ => (), 52 _ => (),
@@ -56,7 +56,11 @@ fn update(path: &Path, contents: &str, mode: Mode) -> Result<()> {
56 } 56 }
57 eprintln!("updating {}", path.display()); 57 eprintln!("updating {}", path.display());
58 fs::write(path, contents)?; 58 fs::write(path, contents)?;
59 Ok(()) 59 return Ok(());
60
61 fn normalize(s: &str) -> String {
62 s.replace("\r\n", "\n")
63 }
60} 64}
61 65
62fn reformat(text: impl std::fmt::Display) -> Result<String> { 66fn reformat(text: impl std::fmt::Display) -> Result<String> {