2015-09-18 18:05:55 +08:00
|
|
|
// build.rs
|
|
|
|
|
2016-12-31 16:07:59 +08:00
|
|
|
extern crate includedir_codegen;
|
|
|
|
|
|
|
|
use includedir_codegen::Compression;
|
|
|
|
|
2015-09-18 18:05:55 +08:00
|
|
|
use std::process::Command;
|
|
|
|
use std::env;
|
|
|
|
use std::path::Path;
|
|
|
|
|
|
|
|
fn main() {
|
|
|
|
|
2016-12-31 16:07:59 +08:00
|
|
|
includedir_codegen::start("FILES")
|
|
|
|
.dir("data", Compression::Gzip)
|
|
|
|
.build("data.rs")
|
|
|
|
.unwrap();
|
|
|
|
|
|
|
|
// TODO this using cargo as a Makefile. This is only for development, it
|
|
|
|
// doesn't have to be part of the production auto-build. Use either a
|
|
|
|
// Makefile or an npm command if stylus comes from npm anyway.
|
|
|
|
|
2015-09-24 21:37:20 +08:00
|
|
|
if let Ok(_) = env::var("CARGO_FEATURE_REGENERATE_CSS") {
|
2015-09-18 18:05:55 +08:00
|
|
|
|
2015-09-24 21:37:20 +08:00
|
|
|
// Compile stylus stylesheet to css
|
|
|
|
let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap();
|
2015-09-18 18:05:55 +08:00
|
|
|
|
2017-01-10 14:35:56 +08:00
|
|
|
let template_dir = Path::new(&manifest_dir).join("data/_html-template/");
|
2016-12-31 16:07:59 +08:00
|
|
|
let stylus_dir = template_dir.join("_stylus/book.styl");
|
2015-09-24 21:37:20 +08:00
|
|
|
|
|
|
|
if !Command::new("stylus")
|
|
|
|
.arg(format!("{}", stylus_dir.to_str().unwrap()))
|
|
|
|
.arg("--out")
|
2016-12-31 16:07:59 +08:00
|
|
|
.arg(format!("{}", template_dir.to_str().unwrap()))
|
2015-09-24 21:37:20 +08:00
|
|
|
.arg("--use")
|
|
|
|
.arg("nib")
|
|
|
|
.status().unwrap()
|
|
|
|
.success() {
|
|
|
|
panic!("Stylus encoutered an error");
|
|
|
|
}
|
2015-09-19 04:13:55 +08:00
|
|
|
}
|
2015-09-18 18:05:55 +08:00
|
|
|
|
|
|
|
}
|