Skip to content

Commit

Permalink
fix: don't require whiskers in build.rs
Browse files Browse the repository at this point in the history
  • Loading branch information
Stonks3141 committed Apr 22, 2024
1 parent 00ddd54 commit 73e0d2e
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ repository = "https://github.com/catppuccin/egui"
license = "MIT"
keywords = ["egui", "catppuccin", "theme", "gui"]
categories = ["gui"]
exclude = ["assets/"]
exclude = ["assets/", "src/themes.rs.tera"]

[dependencies]
egui26 = { version = "0.26", package = "egui", default-features = false, optional = true }
Expand Down
30 changes: 23 additions & 7 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,16 +1,32 @@
use std::{fs::OpenOptions, process::Command};
use std::{fs, path::Path, process::{Command, ExitCode}};

fn main() {
fn main() -> ExitCode {
println!("cargo::rerun-if-changed=src/themes.rs.tera");
let fh = OpenOptions::new()

// src/themes.rs.tera is excluded from the distributed crate so whiskers is
// not run if the crate is used as a dependency.
if !Path::new("src/themes.rs.tera").exists() {
return ExitCode::SUCCESS;
}

let outfile = fs::OpenOptions::new()
.write(true)
.create(true)
.open("src/themes.rs")
.unwrap();
let stat = Command::new("whiskers")

let Ok(stat) = Command::new("whiskers")
.arg("src/themes.rs.tera")
.stdout(fh)
.stdout(outfile)
.status()
.unwrap();
assert!(stat.success());
else {
println!("cargo::warning=Failed to run whiskers (https://github.com/catppuccin/toolbox/tree/main/whiskers). Is it installed?");
return ExitCode::SUCCESS;
};

if !stat.success() {
println!("cargo::warning=whiskers exited nonzero");
return ExitCode::FAILURE;
}
return ExitCode::SUCCESS;
}

0 comments on commit 73e0d2e

Please sign in to comment.