mirror of
https://github.com/typst/typst
synced 2025-07-26 22:07:54 +08:00
Prescient
This commit is contained in:
parent
8d7898fc6f
commit
e42e497ae8
5
Cargo.lock
generated
5
Cargo.lock
generated
@ -451,7 +451,7 @@ checksum = "5b63caa9aa9397e2d9480a9b13673856c78d8ac123288526c37d7839f2a86990"
|
||||
[[package]]
|
||||
name = "comemo"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/typst/comemo?rev=70c0307#70c03075453deda2b2cc592ee8676edfe7962804"
|
||||
source = "git+https://github.com/typst/comemo?rev=499bce5#499bce59ae44af9e61dc106b6b1663a45669b87e"
|
||||
dependencies = [
|
||||
"bumpalo",
|
||||
"comemo-macros",
|
||||
@ -463,7 +463,7 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "comemo-macros"
|
||||
version = "0.4.0"
|
||||
source = "git+https://github.com/typst/comemo?rev=70c0307#70c03075453deda2b2cc592ee8676edfe7962804"
|
||||
source = "git+https://github.com/typst/comemo?rev=499bce5#499bce59ae44af9e61dc106b6b1663a45669b87e"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
@ -2935,6 +2935,7 @@ dependencies = [
|
||||
"dirs",
|
||||
"ecow",
|
||||
"fs_extra",
|
||||
"memmap2",
|
||||
"notify",
|
||||
"open",
|
||||
"parking_lot",
|
||||
|
@ -165,4 +165,4 @@ uninlined_format_args = "warn"
|
||||
wildcard_in_or_patterns = "allow"
|
||||
|
||||
[patch.crates-io]
|
||||
comemo = { git = "https://github.com/typst/comemo", rev = "70c0307" }
|
||||
comemo = { git = "https://github.com/typst/comemo", rev = "499bce5" }
|
||||
|
@ -56,6 +56,7 @@ toml = { workspace = true }
|
||||
ureq = { workspace = true }
|
||||
xz2 = { workspace = true, optional = true }
|
||||
zip = { workspace = true, optional = true }
|
||||
memmap2 = "*"
|
||||
|
||||
[build-dependencies]
|
||||
chrono = { workspace = true }
|
||||
|
@ -47,6 +47,13 @@ static ARGS: LazyLock<CliArguments> = LazyLock::new(|| {
|
||||
|
||||
/// Entry point.
|
||||
fn main() -> ExitCode {
|
||||
let mut prescient = false;
|
||||
if let Ok(file) = std::fs::File::open("comemo-sink") {
|
||||
let mmap = Box::leak(Box::new(unsafe { memmap2::Mmap::map(&file).unwrap() }));
|
||||
comemo::put_prescience(&*mmap);
|
||||
prescient = true;
|
||||
}
|
||||
|
||||
// Handle SIGPIPE
|
||||
// https://stackoverflow.com/questions/65755853/simple-word-count-rust-program-outputs-valid-stdout-but-panicks-when-piped-to-he/65760807
|
||||
sigpipe::reset();
|
||||
@ -58,6 +65,12 @@ fn main() -> ExitCode {
|
||||
print_error(msg.message()).expect("failed to print error");
|
||||
}
|
||||
|
||||
if !prescient {
|
||||
let file = std::fs::File::create("comemo-sink").unwrap();
|
||||
let sink = std::io::BufWriter::new(file);
|
||||
comemo::write_prescience(sink);
|
||||
}
|
||||
|
||||
EXIT.with(|cell| cell.get())
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user