fix: Workaround for incorrect cargo fingerprints
Note: This is a silly hack to prevent temporary artifacts to be tracked by cargo. This behaviour depends on cargo's internal implementation, and thus this workaround may suddenly stop working in the future. Another better option should be considered.
This commit is contained in:
parent
000e971fa3
commit
7bab7ac0a5
|
@ -9,6 +9,18 @@ dependencies = [
|
||||||
"winapi",
|
"winapi",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bitflags"
|
||||||
|
version = "1.2.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "cf1de2fe8c75bc145a2f577add951f8134889b4795d47466a54a5c846d691693"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ctor"
|
name = "ctor"
|
||||||
version = "0.1.14"
|
version = "0.1.14"
|
||||||
|
@ -25,6 +37,18 @@ version = "2.0.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
|
checksum = "524cbf6897b527295dff137cec09ecf3a05f4fddffd7dfcd1585403449e74198"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "filetime"
|
||||||
|
version = "0.2.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1d34cfa13a63ae058bfa601fe9e313bbdb3746427c1459185464ce0fcf62e1e8"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"winapi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "glob"
|
name = "glob"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
|
@ -70,6 +94,12 @@ version = "1.4.0"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
checksum = "e2abad23fbc42b3700f2f279844dc832adb2b2eb069b2df918f455c4e18cc646"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "libc"
|
||||||
|
version = "0.2.82"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "89203f3fba0a3795506acaad8ebce3c80c0af93f994d5a1d7a0b1eeb23271929"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linked-hash-map"
|
name = "linked-hash-map"
|
||||||
version = "0.5.3"
|
version = "0.5.3"
|
||||||
|
@ -121,6 +151,15 @@ dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.2.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05ec8ca9416c5ea37062b502703cd7fcb207736bc294f6e0cf367ac6fc234570"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ryu"
|
name = "ryu"
|
||||||
version = "1.0.5"
|
version = "1.0.5"
|
||||||
|
@ -143,6 +182,7 @@ dependencies = [
|
||||||
name = "sailfish-compiler"
|
name = "sailfish-compiler"
|
||||||
version = "0.3.0"
|
version = "0.3.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"filetime",
|
||||||
"home",
|
"home",
|
||||||
"memchr",
|
"memchr",
|
||||||
"pretty_assertions",
|
"pretty_assertions",
|
||||||
|
|
|
@ -26,6 +26,7 @@ memchr = "2.3.3"
|
||||||
quote = { version = "1.0.6", default-features = false }
|
quote = { version = "1.0.6", default-features = false }
|
||||||
yaml-rust = { version = "0.4.4", optional = true }
|
yaml-rust = { version = "0.4.4", optional = true }
|
||||||
home = "0.5.3"
|
home = "0.5.3"
|
||||||
|
filetime = "0.2.14"
|
||||||
|
|
||||||
[dependencies.syn]
|
[dependencies.syn]
|
||||||
version = "1.0.21"
|
version = "1.0.21"
|
||||||
|
|
|
@ -11,7 +11,7 @@ use crate::optimizer::Optimizer;
|
||||||
use crate::parser::Parser;
|
use crate::parser::Parser;
|
||||||
use crate::resolver::Resolver;
|
use crate::resolver::Resolver;
|
||||||
use crate::translator::{TranslatedSource, Translator};
|
use crate::translator::{TranslatedSource, Translator};
|
||||||
use crate::util::{read_to_string, rustfmt_block};
|
use crate::util::{copy_filetimes, read_to_string, rustfmt_block};
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
pub struct Compiler {
|
pub struct Compiler {
|
||||||
|
@ -81,6 +81,12 @@ impl Compiler {
|
||||||
.chain_err(|| format!("Failed to create artifact: {:?}", output))?;
|
.chain_err(|| format!("Failed to create artifact: {:?}", output))?;
|
||||||
writeln!(f, "{}", rustfmt_block(&*string).unwrap_or(string))
|
writeln!(f, "{}", rustfmt_block(&*string).unwrap_or(string))
|
||||||
.chain_err(|| format!("Failed to write artifact into {:?}", output))?;
|
.chain_err(|| format!("Failed to write artifact into {:?}", output))?;
|
||||||
|
drop(f);
|
||||||
|
|
||||||
|
// FIXME: This is a silly hack to prevent output file from being tracking by
|
||||||
|
// cargo. Another better solution should be considered.
|
||||||
|
let _ = copy_filetimes(input, output);
|
||||||
|
|
||||||
Ok(report)
|
Ok(report)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1,3 +1,4 @@
|
||||||
|
use filetime::FileTime;
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use std::io::{self, Write};
|
use std::io::{self, Write};
|
||||||
use std::path::{Path, PathBuf};
|
use std::path::{Path, PathBuf};
|
||||||
|
@ -76,3 +77,11 @@ pub fn rustfmt_block(source: &str) -> io::Result<String> {
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn copy_filetimes(input: &Path, output: &Path) -> io::Result<()> {
|
||||||
|
let mtime = fs::metadata(input)
|
||||||
|
.and_then(|metadata| metadata.modified())
|
||||||
|
.map_or(FileTime::zero(), |time| FileTime::from_system_time(time));
|
||||||
|
|
||||||
|
filetime::set_file_times(output, mtime, mtime)
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue