1use std::{io::Write, path::Path};
2
3use walkdir::WalkDir;
4
5pub fn build_library() {
7 let out_dir = std::env::var_os("OUT_DIR").unwrap();
8 let dest_path = Path::new(&out_dir).join("all.rs");
9 let mut file = std::fs::File::create(&dest_path).unwrap();
10 for entry in WalkDir::new("./src").into_iter().filter_map(|e| e.ok()) {
11 if entry.metadata().unwrap().is_file() {
12 let source = std::fs::read_to_string(entry.path()).unwrap();
13 file.write_all(source.as_bytes()).unwrap();
14 }
15 }
16}
17
18pub fn build_frontend() {
20 let target = std::env::var_os("OUT_DIR").unwrap();
21 let target_dir = Path::new(&target).parent().unwrap().parent().unwrap();
22 std::process::Command::new("tailwindcss")
23 .arg("--content")
24 .arg(format!(
25 "{}/**/*.rs,./src/**/*.{{html,rs}},./index.html",
26 target_dir.display(),
27 ))
28 .arg("-o")
29 .arg("./tailwind.css")
30 .arg("--minify")
31 .output()
32 .expect("failed to execute process");
33
34 println!("cargo:rerun-if-changed=./src");
35}