mirror of
https://github.com/ducaale/xh.git
synced 2025-05-14 19:54:32 +00:00
We were asking cargo to rebuild if assets/xhs or assets/xhs.1.gz
changed. Those are dead symlinks, so cargo always errors and
[assumes they changed]
(e475fe4a17/src/cargo/core/compiler/fingerprint.rs (L1733)
).
That caused a lot of unnecessary rebuilds. I found the problem by
running with `CARGO_LOG=cargo::core::compiler::fingerprint=info`.
Asking cargo to watch only the files we actually care about fixes it.
55 lines
1.5 KiB
Rust
55 lines
1.5 KiB
Rust
use std::env;
|
|
use std::fs::read_dir;
|
|
use std::path::Path;
|
|
|
|
use syntect::dumps::*;
|
|
use syntect::highlighting::ThemeSet;
|
|
use syntect::parsing::SyntaxSetBuilder;
|
|
|
|
fn build_syntax(dir: &str, out: &str) {
|
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
|
let mut builder = SyntaxSetBuilder::new();
|
|
builder.add_from_folder(dir, true).unwrap();
|
|
let ss = builder.build();
|
|
dump_to_file(&ss, Path::new(&out_dir).join(out)).unwrap();
|
|
}
|
|
|
|
fn feature_status(feature: &str) -> String {
|
|
if env::var_os(format!(
|
|
"CARGO_FEATURE_{}",
|
|
feature.to_uppercase().replace("-", "_")
|
|
))
|
|
.is_some()
|
|
{
|
|
format!("+{}", feature)
|
|
} else {
|
|
format!("-{}", feature)
|
|
}
|
|
}
|
|
|
|
fn features() -> String {
|
|
feature_status("native-tls")
|
|
}
|
|
|
|
fn main() {
|
|
for dir in &["assets", "assets/basic", "assets/large"] {
|
|
println!("cargo:rerun-if-changed={}", dir);
|
|
for entry in read_dir(dir).unwrap() {
|
|
let path = entry.unwrap().path();
|
|
let path = path.to_str().unwrap();
|
|
if path.ends_with(".sublime-syntax") || path.ends_with(".tmTheme") {
|
|
println!("cargo:rerun-if-changed={}", path);
|
|
}
|
|
}
|
|
}
|
|
|
|
build_syntax("assets/basic", "basic.packdump");
|
|
build_syntax("assets/large", "large.packdump");
|
|
|
|
let out_dir = env::var_os("OUT_DIR").unwrap();
|
|
let ts = ThemeSet::load_from_folder("assets").unwrap();
|
|
dump_to_file(&ts, Path::new(&out_dir).join("themepack.themedump")).unwrap();
|
|
|
|
println!("cargo:rustc-env=XH_FEATURES={}", features());
|
|
}
|