1 // Copyright 2017-2018 Matthew D. Michelotti
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
7 // http://www.apache.org/licenses/LICENSE-2.0
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
15 extern crate gate_build;
19 use gate_build::AssetPacker;
22 let is_wasm = env::var("TARGET").map(|t| t.starts_with("wasm32")).unwrap_or(false);
23 let out_dir = env::var("OUT_DIR").unwrap();
24 let gen_code_path = Path::new(&out_dir).join("asset_id.rs");
26 let assets_dir = if is_wasm { "html" } else { "assets" };
27 let mut packer = AssetPacker::new(Path::new(assets_dir));
28 packer.cargo_rerun_if_changed();
29 packer.sprites(Path::new("src_assets/sprites"));
30 packer.tiles(Path::new("src_assets/tiles"));
31 packer.music(Path::new("src_assets/music"));
32 packer.sounds(Path::new("src_assets/sounds"));
33 if is_wasm { packer.gen_javascript_and_html(); }
34 packer.gen_asset_id_code(&gen_code_path);