From 9150ce272e15c2c9153bc194db79eb38eaff7195 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Sat, 8 Oct 2022 12:20:32 -0700 Subject: [PATCH] Pull out static generated file heading into one string literal --- generate/src/write.rs | 39 +++++++++++++++++---------------------- 1 file changed, 17 insertions(+), 22 deletions(-) diff --git a/generate/src/write.rs b/generate/src/write.rs index ad657ac..fb7f450 100644 --- a/generate/src/write.rs +++ b/generate/src/write.rs @@ -1,30 +1,25 @@ use crate::output::Output; use crate::{is_xid_continue, is_xid_start, CHUNK}; +const HEAD: &str = "\ +// \x40generated by ../generate. To regenerate, run the following in the repo root: +// +// $ curl -LO https://www.unicode.org/Public/zipped/14.0.0/UCD.zip +// $ unzip UCD.zip -d UCD +// $ cargo run --manifest-path generate/Cargo.toml + +const T: bool = true; +const F: bool = false; + +#[repr(C, align(8))] +pub(crate) struct Align8(pub(crate) T); +#[repr(C, align(64))] +pub(crate) struct Align64(pub(crate) T); +"; + pub fn output(index_start: &[u8], index_continue: &[u8], halfdense: &[u8]) -> Output { let mut out = Output::new(); - writeln!( - out, - "// \x40generated by ../generate. To regenerate, run the following in the repo root:", - ); - writeln!(out, "//"); - writeln!( - out, - "// $ curl -LO https://www.unicode.org/Public/zipped/14.0.0/UCD.zip", - ); - writeln!(out, "// $ unzip UCD.zip -d UCD"); - writeln!(out, "// $ cargo run --manifest-path generate/Cargo.toml"); - writeln!(out); - - writeln!(out, "const T: bool = true;"); - writeln!(out, "const F: bool = false;"); - writeln!(out); - - writeln!(out, "#[repr(C, align(8))]"); - writeln!(out, "pub(crate) struct Align8(pub(crate) T);"); - writeln!(out, "#[repr(C, align(64))]"); - writeln!(out, "pub(crate) struct Align64(pub(crate) T);"); - writeln!(out); + writeln!(out, "{}", HEAD); writeln!( out,