mirror of
https://github.com/rojo-rbx/rojo.git
synced 2026-04-22 05:35:10 +00:00
Implement build command, shuffle around some internals to make it easier
This commit is contained in:
@@ -1,5 +1,15 @@
|
||||
use std::{
|
||||
path::PathBuf,
|
||||
fs::File,
|
||||
process,
|
||||
};
|
||||
|
||||
use rbxmx;
|
||||
|
||||
use crate::{
|
||||
rbx_session::construct_oneoff_tree,
|
||||
project::Project,
|
||||
imfs::Imfs,
|
||||
};
|
||||
|
||||
#[derive(Debug)]
|
||||
@@ -9,5 +19,27 @@ pub struct BuildOptions {
|
||||
}
|
||||
|
||||
pub fn build(options: &BuildOptions) {
|
||||
println!("build {:#?}", options);
|
||||
info!("Looking for project at {}", options.fuzzy_project_path.display());
|
||||
|
||||
let project = match Project::load_fuzzy(&options.fuzzy_project_path) {
|
||||
Ok(project) => project,
|
||||
Err(error) => {
|
||||
error!("{}", error);
|
||||
process::exit(1);
|
||||
},
|
||||
};
|
||||
|
||||
info!("Found project at {}", project.file_location.display());
|
||||
info!("Using project {:#?}", project);
|
||||
|
||||
let imfs = Imfs::new(&project)
|
||||
.expect("Could not create in-memory filesystem");
|
||||
|
||||
let tree = construct_oneoff_tree(&project, &imfs);
|
||||
let root_id = tree.get_root_id();
|
||||
|
||||
let mut file = File::create(&options.output_file)
|
||||
.expect("Could not open output file for write");
|
||||
|
||||
rbxmx::encode(&tree, &[root_id], &mut file);
|
||||
}
|
||||
Reference in New Issue
Block a user