1 parent
96a32ea8fb
commit
a643e7e3ab
106 files changed
+2223
-4669
No files matched your search
@@ -14,18 +14,11 @@ fn fnv1a64(parts: &[&[u8]]) -> u64 {
|
||||
hash
|
||||
}
|
||||
|
||||
fn bundle_manifest(
|
||||
root: &Path,
|
||||
directory: &Path,
|
||||
manifest: &Path,
|
||||
extension: &str,
|
||||
banner: &str,
|
||||
) -> String {
|
||||
fn bundle_manifest(root: &Path, directory: &Path, manifest: &Path, extension: &str) -> String {
|
||||
println!("cargo:rerun-if-changed={}", manifest.display());
|
||||
let manifest_text = fs::read_to_string(manifest)
|
||||
.unwrap_or_else(|error| panic!("{}: {error}", manifest.display()));
|
||||
let mut bundle = String::from(banner);
|
||||
bundle.push('\n');
|
||||
let mut bundle = String::new();
|
||||
|
||||
for raw in manifest_text.lines() {
|
||||
let name = raw.trim();
|
||||
@@ -48,9 +41,9 @@ fn bundle_manifest(
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
let source =
|
||||
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");
|
||||
if !bundle.is_empty() {
|
||||
bundle.push('\n');
|
||||
}
|
||||
bundle.push_str(&source);
|
||||
if !source.ends_with('\n') {
|
||||
bundle.push('\n');
|
||||
@@ -75,20 +68,8 @@ fn main() {
|
||||
println!("cargo:rerun-if-changed={}", path.display());
|
||||
}
|
||||
|
||||
let css_bundle = bundle_manifest(
|
||||
&root,
|
||||
&css_dir,
|
||||
&css_dir.join("manifest.txt"),
|
||||
".css",
|
||||
"/* RustBox UI CSS bundle - generated by build.rs */",
|
||||
);
|
||||
let js_bundle = bundle_manifest(
|
||||
&root,
|
||||
&js_dir,
|
||||
&js_dir.join("manifest.txt"),
|
||||
".js",
|
||||
"/* RustBox UI JavaScript bundle - generated by build.rs; edit src/web/js/*.js */",
|
||||
);
|
||||
let css_bundle = bundle_manifest(&root, &css_dir, &css_dir.join("manifest.txt"), ".css");
|
||||
let js_bundle = bundle_manifest(&root, &js_dir, &js_dir.join("manifest.txt"), ".js");
|
||||
|
||||
let asset_id = fnv1a64(&[css_bundle.as_bytes(), js_bundle.as_bytes()]);
|
||||
println!("cargo:rustc-env=RUSTBOX_ASSET_ID={asset_id:016x}");
|
||||
|
||||
Reference in new issue
Block a user