File src/backend/build.rs changed (mode: 100644) (index 5c8a4db..c2d4f6c) |
... |
... |
pub fn build(config_file: PathBuf) -> Result<String, String> { |
25 |
25 |
Ok(String::from("Build succeeded!")) |
Ok(String::from("Build succeeded!")) |
26 |
26 |
} |
} |
27 |
27 |
|
|
|
28 |
|
pub fn build_rec(config_file: PathBuf) -> Result<String, String> { |
|
29 |
|
let dep_tree = super::deptree::print(&super::system::OS::current(), config_file); |
|
30 |
|
|
|
31 |
|
// Inconventient, should be changed later |
|
32 |
|
match &dep_tree { |
|
33 |
|
Ok(result) => println!("{}", result), |
|
34 |
|
Err(e) => return Err(e.to_string()) |
|
35 |
|
} |
|
36 |
|
|
|
37 |
|
let dep_tree = dep_tree.unwrap(); |
|
38 |
|
|
|
39 |
|
for node in &dep_tree.depends_on { |
|
40 |
|
println!("Building module '{}'..", &node.dep_name); |
|
41 |
|
match build_rec(node.path.clone()) { |
|
42 |
|
Ok(_) => {}, |
|
43 |
|
Err(e) => return Err(e) |
|
44 |
|
} |
|
45 |
|
} |
|
46 |
|
|
|
47 |
|
println!("Building current project '{}'..", &dep_tree.dep_name); |
|
48 |
|
match build(dep_tree.path) { |
|
49 |
|
Ok(result) => println!("{}", result), |
|
50 |
|
Err(e) => return Err(e) |
|
51 |
|
} |
|
52 |
|
|
|
53 |
|
Ok(String::from("Project built!")) |
|
54 |
|
} |
|
55 |
|
|
28 |
56 |
#[cfg(target_os="linux")] |
#[cfg(target_os="linux")] |
29 |
57 |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
30 |
|
println!("Building project.."); |
|
|
58 |
|
println!("Building module.."); |
31 |
59 |
|
|
32 |
60 |
let build_cmd = &config["build"]["linux"]; |
let build_cmd = &config["build"]["linux"]; |
33 |
61 |
|
|
|
... |
... |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
40 |
68 |
|
|
41 |
69 |
#[cfg(target_os="macos")] |
#[cfg(target_os="macos")] |
42 |
70 |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
43 |
|
println!("Building project.."); |
|
|
71 |
|
println!("Building module.."); |
44 |
72 |
|
|
45 |
73 |
let build_cmd = &config["build"]["os-x"]; |
let build_cmd = &config["build"]["os-x"]; |
46 |
74 |
|
|
|
... |
... |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
53 |
81 |
|
|
54 |
82 |
#[cfg(target_os="windows")] |
#[cfg(target_os="windows")] |
55 |
83 |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
fn build_module(config: serde_json::Value) -> Result<String, String> { |
56 |
|
println!("Building project.."); |
|
|
84 |
|
println!("Building module.."); |
57 |
85 |
|
|
58 |
86 |
let build_cmd = &config["build"]["windows"]; |
let build_cmd = &config["build"]["windows"]; |
59 |
87 |
|
|
File src/backend/dep.rs changed (mode: 100644) (index e3662f2..7643de3) |
... |
... |
use super::system::OS; |
6 |
6 |
pub fn json(config: String) -> Result<serde_json::Value, String> { |
pub fn json(config: String) -> Result<serde_json::Value, String> { |
7 |
7 |
let config_json: serde_json::Value; |
let config_json: serde_json::Value; |
8 |
8 |
|
|
9 |
|
println!("Reading module configuration.."); |
|
10 |
|
|
|
11 |
9 |
match serde_json::from_str(&config) { |
match serde_json::from_str(&config) { |
12 |
10 |
Ok(json) => config_json = json, |
Ok(json) => config_json = json, |
13 |
11 |
Err(e) => { |
Err(e) => { |
File src/backend/deptree.rs changed (mode: 100644) (index d3c6076..d38bc6a) |
... |
... |
use std::path::PathBuf; |
6 |
6 |
use std::fmt; |
use std::fmt; |
7 |
7 |
|
|
8 |
8 |
pub struct Node { |
pub struct Node { |
9 |
|
dep_name: String, |
|
10 |
|
path: PathBuf, |
|
11 |
|
depends_on: Vec<Node> |
|
|
9 |
|
pub dep_name: String, |
|
10 |
|
pub path: PathBuf, |
|
11 |
|
pub depends_on: Vec<Node> |
12 |
12 |
} |
} |
13 |
13 |
|
|
14 |
14 |
impl fmt::Display for Node { |
impl fmt::Display for Node { |
|
... |
... |
impl fmt::Display for Node { |
31 |
31 |
} |
} |
32 |
32 |
} |
} |
33 |
33 |
|
|
34 |
|
dependency = self.clone(); |
|
35 |
|
|
|
36 |
34 |
try!(write!(f, "{}", string)); |
try!(write!(f, "{}", string)); |
37 |
35 |
Ok(()) |
Ok(()) |
38 |
36 |
} |
} |
|
... |
... |
pub fn print(os: &OS, path: PathBuf) -> Result<Node, String> { |
71 |
69 |
|
|
72 |
70 |
let root = Node { |
let root = Node { |
73 |
71 |
dep_name: String::from(path.file_name().unwrap().to_str().unwrap()), |
dep_name: String::from(path.file_name().unwrap().to_str().unwrap()), |
74 |
|
path: super::filesystem::get_module_root().unwrap(), |
|
|
72 |
|
path: path, |
75 |
73 |
depends_on: nodes |
depends_on: nodes |
76 |
74 |
}; |
}; |
77 |
75 |
|
|
File src/backend/project.rs changed (mode: 100644) (index 9e611da..5333f3f) |
... |
... |
pub fn init(args: &mut env::Args) { |
16 |
16 |
} |
} |
17 |
17 |
} |
} |
18 |
18 |
|
|
19 |
|
pub fn build() -> Result<String, String> { |
|
20 |
|
match super::filesystem::get_project_root() { |
|
21 |
|
Some(dir) => super::build::build(dir), |
|
22 |
|
None => Err(String::from("not in a project (sub)directory.")) |
|
|
19 |
|
pub fn build(args: &mut env::Args) -> Result<String, String> { |
|
20 |
|
match args.next() { |
|
21 |
|
Some(ref module) if module.as_str() == "--module" => { |
|
22 |
|
match super::filesystem::get_module_root() { |
|
23 |
|
Some(dir) => super::build::build(dir), |
|
24 |
|
None => Err(String::from("not in a project (sub)directory.")) |
|
25 |
|
} |
|
26 |
|
}, |
|
27 |
|
Some(_) | None => { |
|
28 |
|
match super::filesystem::get_project_root() { |
|
29 |
|
Some(dir) => super::build::build_rec(dir), |
|
30 |
|
None => Err(String::from("not in a project (sub)directory.")) |
|
31 |
|
} |
|
32 |
|
} |
23 |
33 |
} |
} |
24 |
34 |
} |
} |
25 |
35 |
|
|
|
... |
... |
pub fn exe(args: &mut env::Args) -> Result<String, String> { |
76 |
86 |
pub fn run(args: &mut env::Args) -> Result<String, String> { |
pub fn run(args: &mut env::Args) -> Result<String, String> { |
77 |
87 |
println!("Building project.."); |
println!("Building project.."); |
78 |
88 |
|
|
79 |
|
match build() { |
|
|
89 |
|
match build(args) { |
80 |
90 |
Ok(output) => println!("{}", output), |
Ok(output) => println!("{}", output), |
81 |
91 |
Err(e) => return Err(e) |
Err(e) => return Err(e) |
82 |
92 |
} |
} |
|
... |
... |
pub fn help() { |
109 |
119 |
println!(""); |
println!(""); |
110 |
120 |
|
|
111 |
121 |
println!("init [DIRECTORY]\t\t Initialize new project in specified directory. Defaults to current directory."); |
println!("init [DIRECTORY]\t\t Initialize new project in specified directory. Defaults to current directory."); |
112 |
|
println!("build\t\t\t\t Build current project."); |
|
|
122 |
|
println!("build [--module]\t\t Build current project if module flag is not specified, otherwise only the module will be built."); |
113 |
123 |
println!("run [ARGUMENTS]\t\t\t Build and run current project with ARGUMENTS to run project with."); |
println!("run [ARGUMENTS]\t\t\t Build and run current project with ARGUMENTS to run project with."); |
114 |
124 |
println!("exe [ARGUMENTS]\t\t\t Run current project with ARGUMENTS. The project won't be built."); |
println!("exe [ARGUMENTS]\t\t\t Run current project with ARGUMENTS. The project won't be built."); |
115 |
125 |
println!("add NAME COMMAND [ARGUMENTS]\t Add dependency with NAME to module and is built through COMMAND with ARGUMENTS."); |
println!("add NAME COMMAND [ARGUMENTS]\t Add dependency with NAME to module and is built through COMMAND with ARGUMENTS."); |
File src/main.rs changed (mode: 100644) (index 6dcd39b..b4b1b95) |
... |
... |
fn parse() { |
27 |
27 |
backend::project::init(&mut argv); |
backend::project::init(&mut argv); |
28 |
28 |
} |
} |
29 |
29 |
else if &argument == "build" { |
else if &argument == "build" { |
30 |
|
match backend::project::build() { |
|
|
30 |
|
match backend::project::build(&mut argv) { |
31 |
31 |
Ok(result) => println!("{}", result), |
Ok(result) => println!("{}", result), |
32 |
32 |
Err(e) => println!("Build failed: {}", e) |
Err(e) => println!("Build failed: {}", e) |
33 |
33 |
} |
} |