-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathbuild.rs
30 lines (21 loc) · 1.03 KB
/
build.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
// Read in the syntaxes under assets/syntaxes and dump them
use std::env;
fn main() {
// Get a path to which we can safely write the compressed files
let out_dir = env::var("OUT_DIR").unwrap();
// Define to recreate when syntax folder is changed
println!("cargo:rerun-if-changed=assets/syntaxes");
// Read in all the syntaxes
let mut syntax_builder = syntect::parsing::SyntaxSetBuilder::new();
syntax_builder.add_plain_text_syntax();
syntax_builder.add_from_folder("assets/syntaxes/", true).unwrap();
// Dump the created structure
let mut syntaxes = syntax_builder.build();
syntect::dumps::dump_to_file(&mut syntaxes, &format!("{}/compressed_syntaxes", &out_dir)).unwrap();
// Define to recreate when the theme is changed
println!("cargo:rerun-if-changed=assets/theme.xml");
// Read in the theme
let mut theme = syntect::highlighting::ThemeSet::get_theme("assets/theme.xml").unwrap();
// Dump the created structure
syntect::dumps::dump_to_file(&mut theme, &format!("{}/compressed_theme", &out_dir)).unwrap();
}