Setup the loading of the resource manifest file.
This commit is contained in:
85
examples/build.rs
Normal file
85
examples/build.rs
Normal file
@ -0,0 +1,85 @@
|
||||
#[macro_use]
|
||||
extern crate scribe;
|
||||
|
||||
extern crate mason;
|
||||
|
||||
|
||||
|
||||
use std::path::PathBuf;
|
||||
|
||||
use mason::Processor;
|
||||
|
||||
|
||||
pub const RESOURCES_DIR: &'static str = "resources";
|
||||
pub const MANIFEST_FILENAME: &'static str = "resources.msnr";
|
||||
|
||||
|
||||
|
||||
pub fn main()
|
||||
{
|
||||
let task_count: u64;
|
||||
let output_dir: PathBuf;
|
||||
let mut resources_dir: PathBuf;
|
||||
let mut processor: Processor;
|
||||
|
||||
// Get the cargo manifest directory and then append the
|
||||
// resource directory name to it.
|
||||
match option_env!("CARGO_MANIFEST_DIR")
|
||||
{
|
||||
Some(dir) =>
|
||||
{
|
||||
resources_dir = PathBuf::from(dir);
|
||||
}
|
||||
|
||||
None =>
|
||||
{
|
||||
resources_dir = PathBuf::new();
|
||||
}
|
||||
}
|
||||
resources_dir.push(RESOURCES_DIR);
|
||||
|
||||
// Get the output directory for the build.
|
||||
match option_env!("OUT_DIR")
|
||||
{
|
||||
Some(dir) =>
|
||||
{
|
||||
output_dir = PathBuf::from(dir);
|
||||
}
|
||||
|
||||
None =>
|
||||
{
|
||||
output_dir = PathBuf::new();
|
||||
}
|
||||
}
|
||||
|
||||
// Get how many compile tasks should be run at one time.
|
||||
match option_env!("NUM_JOBS")
|
||||
{
|
||||
Some(count) =>
|
||||
{
|
||||
match count.parse::<u64>()
|
||||
{
|
||||
Ok(val) =>
|
||||
{
|
||||
task_count = val;
|
||||
}
|
||||
|
||||
Err(error) =>
|
||||
{
|
||||
error!("{}", error);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None =>
|
||||
{
|
||||
task_count = 1u64;
|
||||
}
|
||||
}
|
||||
|
||||
processor = Processor::new();
|
||||
processor.set_resources_dir(resources_dir.as_path());
|
||||
processor.set_output_dir(output_dir.as_path());
|
||||
processor.set_task_count(task_count);
|
||||
processor.process_manifest_file();
|
||||
}
|
Reference in New Issue
Block a user