commit
bc5fbd6ba9
180 files changed
+63750
No files matched your search
@@ -0,0 +1,58 @@
|
||||
use std::{env, fs, path::PathBuf};
|
||||
|
||||
fn main() {
|
||||
let root = PathBuf::from(env::var_os("CARGO_MANIFEST_DIR").expect("CARGO_MANIFEST_DIR"));
|
||||
let out = PathBuf::from(env::var_os("OUT_DIR").expect("OUT_DIR"));
|
||||
let css_dir = root.join("src/web/css");
|
||||
let manifest = css_dir.join("manifest.txt");
|
||||
|
||||
println!("cargo:rerun-if-changed={}", manifest.display());
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
root.join("src/web/index.html").display()
|
||||
);
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
root.join("src/web/app.js").display()
|
||||
);
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
root.join("src/web/icons.svg").display()
|
||||
);
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
root.join("src/web/i18n/en.json").display()
|
||||
);
|
||||
println!(
|
||||
"cargo:rerun-if-changed={}",
|
||||
root.join("src/web/i18n/pl.json").display()
|
||||
);
|
||||
|
||||
let manifest_text = fs::read_to_string(&manifest).expect("read src/web/css/manifest.txt");
|
||||
let mut bundle = String::from("/* RustBox UI bundle - generated by build.rs */\n");
|
||||
|
||||
for raw in manifest_text.lines() {
|
||||
let name = raw.trim();
|
||||
if name.is_empty() || name.starts_with('#') {
|
||||
continue;
|
||||
}
|
||||
assert!(
|
||||
name.ends_with(".css")
|
||||
&& !name.contains('/')
|
||||
&& !name.contains('\\')
|
||||
&& !name.contains(".."),
|
||||
"invalid CSS manifest entry: {name}"
|
||||
);
|
||||
let path = css_dir.join(name);
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
let css =
|
||||
fs::read_to_string(&path).unwrap_or_else(|error| panic!("{}: {error}", path.display()));
|
||||
bundle.push_str("\n/* ");
|
||||
bundle.push_str(name);
|
||||
bundle.push_str(" */\n");
|
||||
bundle.push_str(&css);
|
||||
bundle.push('\n');
|
||||
}
|
||||
|
||||
fs::write(out.join("rustbox-ui.css"), bundle).expect("write RustBox CSS bundle");
|
||||
}
|
||||
Reference in new issue
Block a user