1
1
mirror of https://github.com/wez/wezterm.git synced 2024-11-23 23:21:08 +03:00
wezterm/config/build.rs
Wez Furlong e866e9390a colorschemes: expand to include Gogh color schemes
This commit expands the toml file definition to include
metadata for the origin url, author and name.

A new sync utility fills out that metadata when it pulls from the iterm2
color schemes repo.

The utility also pulls down the scheme data json maintained by
the Gogh project: https://gogh-co.github.io/Gogh/ and converts
it to wezterm's format.

About 50% of Gogh overlaps with iterm2; we take the iterm2 versions
of those schemes by default because the iterm2 data has more info
about things like cursor and selection colors.

The sync utility is responsible for compiling the de-duplicated
set of scheme data into a form that is used by wezterm and its
docs.
2022-07-10 13:32:17 -07:00

62 lines
2.1 KiB
Rust

use std::path::Path;
fn main() {
println!("cargo:rerun-if-changed=build.rs");
// If a file named `.tag` is present, we'll take its contents for the
// version number that we report in wezterm -h.
let mut ci_tag = String::new();
if let Ok(tag) = std::fs::read("../.tag") {
if let Ok(s) = String::from_utf8(tag) {
ci_tag = s.trim().to_string();
println!("cargo:rerun-if-changed=../.tag");
}
} else {
// Otherwise we'll derive it from the git information
if let Ok(repo) = git2::Repository::discover(".") {
if let Ok(ref_head) = repo.find_reference("HEAD") {
let repo_path = repo.path().to_path_buf();
if let Ok(resolved) = ref_head.resolve() {
if let Some(name) = resolved.name() {
let path = repo_path.join(name);
if path.exists() {
println!(
"cargo:rerun-if-changed={}",
path.canonicalize().unwrap().display()
);
}
}
}
}
}
let head = Path::new("../.git/HEAD");
if head.exists() {
let head = head.canonicalize().unwrap();
println!("cargo:rerun-if-changed={}", head.display());
if let Ok(output) = std::process::Command::new("git")
.args(&[
"-c",
"core.abbrev=8",
"show",
"-s",
"--format=%cd-%h",
"--date=format:%Y%m%d-%H%M%S",
])
.output()
{
let info = String::from_utf8_lossy(&output.stdout);
ci_tag = info.trim().to_string();
}
}
}
let target = std::env::var("TARGET").unwrap_or_else(|_| "unknown".to_string());
println!("cargo:rustc-env=WEZTERM_TARGET_TRIPLE={}", target);
println!("cargo:rustc-env=WEZTERM_CI_TAG={}", ci_tag);
println!("cargo:rustc-env=MACOSX_DEPLOYMENT_TARGET=10.9");
}