Cleanup build file

This commit is contained in:
Jake Howard 2017-11-26 14:23:49 +00:00
parent e663bfee4e
commit 16b75812b2
Signed by: jake
GPG key ID: 57AFB45680EDD477

View file

@ -13,16 +13,19 @@ const ASSET_KEY: &str = "SRC";
const STATIC_DIR: &str = "static"; const STATIC_DIR: &str = "static";
fn build_stylesheet() { fn build_stylesheet() {
let mut in_file = File::open("static/style.scss").expect("Failed to open scss file"); let mut in_file =
File::open(Path::new(STATIC_DIR).join("style.scss")).expect("Failed to open scss file");
let mut buffer = Vec::new(); let mut buffer = Vec::new();
in_file.read_to_end(&mut buffer).expect("Failed to read scss"); in_file.read_to_end(&mut buffer).expect("Failed to read scss");
let compiled = compile_scss(buffer.as_slice(), OutputStyle::Compressed).expect("SCSS compiler failed"); let compiled =
let mut out_file = File::create("assets/style.css").expect("Failed to open css file"); compile_scss(buffer.as_slice(), OutputStyle::Compressed).expect("SCSS compile failed");
let mut out_file =
File::create(Path::new(ASSETS_DIR).join("style.css")).expect("Failed to open css file");
out_file.write_all(&mut compiled.as_slice()).expect("Failed to write css to file"); out_file.write_all(&mut compiled.as_slice()).expect("Failed to write css to file");
} }
fn embed_assets() { fn embed_assets() {
let out_dir = env::var("OUT_DIR").unwrap(); let out_dir = env::var("OUT_DIR").expect("Missing output directory variable");
let dest_path = Path::new(&out_dir).join("assets.rs"); let dest_path = Path::new(&out_dir).join("assets.rs");
include_dir(ASSETS_DIR).as_variable(ASSET_KEY).to_file(dest_path).unwrap(); include_dir(ASSETS_DIR).as_variable(ASSET_KEY).to_file(dest_path).unwrap();
} }