-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbuild.rs
More file actions
27 lines (22 loc) · 842 Bytes
/
build.rs
File metadata and controls
27 lines (22 loc) · 842 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
extern crate nuuro_build;
use std::env;
use std::path::Path;
use nuuro_build::AssetPacker;
// build script packs image assets into atlases and generates enums to reference assets
fn main() {
let is_wasm = env::var("TARGET")
.map(|t| t.starts_with("wasm32"))
.unwrap_or(false);
let out_dir = env::var("OUT_DIR").unwrap();
let gen_code_path = Path::new(&out_dir).join("asset_id.rs");
let assets_dir = if is_wasm { "html" } else { "assets" };
let mut packer = AssetPacker::new(Path::new(assets_dir));
packer.cargo_rerun_if_changed();
packer.sprites(Path::new("src_assets/sprites"));
packer.music(Path::new("src_assets/music"));
packer.sounds(Path::new("src_assets/sounds"));
if is_wasm {
packer.gen_javascript_and_html();
}
packer.gen_asset_id_code(&gen_code_path);
}