fixed directory structure and changed build message
This commit is contained in:
parent
6eb94ff3d8
commit
676c1d91a8
1 changed files with 13 additions and 15 deletions
28
src/main.rs
28
src/main.rs
|
@ -39,7 +39,7 @@ fn print_table(table: &Table, depth: usize) {
|
|||
}
|
||||
|
||||
fn target_generator(name: &str, config_table: &Table) -> String {
|
||||
let mut ret = String::from("");
|
||||
let mut ret = String::from("\n");
|
||||
|
||||
let clang = Value::String(String::from("clang"));
|
||||
let blank = Value::String(String::from(""));
|
||||
|
@ -68,20 +68,17 @@ fn target_generator(name: &str, config_table: &Table) -> String {
|
|||
|
||||
ret.push_str(&format!(
|
||||
r#"# BEGIN TARGET {name}
|
||||
cflags_{name} = {compiler_flags}
|
||||
linker_flags_{name} = {linker_flags}
|
||||
linker_libs_{name} = {linker_libs}
|
||||
|
||||
rule cc_{name}
|
||||
deps = gcc
|
||||
depfile = $out.d
|
||||
command = {compiler} $cflags_{name} -MD -MF $out.d -o $out -c $in
|
||||
description = Building [{name}] object $out
|
||||
depfile = $dep
|
||||
command = {compiler} {compiler_flags} -MD -MF $dep -o $out -c $in
|
||||
description = Building object $out
|
||||
rule link_{name}
|
||||
command = {linker} $linker_flags_{name} -o $out $in $linker_libs_{name}
|
||||
description = Linking [{name}] $out
|
||||
command = {linker} {linker_flags} -o $out $in {linker_libs}
|
||||
description = Linking $out
|
||||
|
||||
build $builddir/{name}: mkdir
|
||||
build $builddir/{name}/obj: mkdir
|
||||
build $builddir/{name}/dep: mkdir
|
||||
"#
|
||||
));
|
||||
let sources = config_table
|
||||
|
@ -95,9 +92,11 @@ build $builddir/{name}: mkdir
|
|||
for elem in a {
|
||||
match elem {
|
||||
Value::String(s) => {
|
||||
let obj_name = format!("$builddir/{name}/{s}.o");
|
||||
let s = s.replace("/", "-");
|
||||
let obj_name = format!("$builddir/{name}/obj/{s}.o");
|
||||
let dep_name = format!("$builddir/{name}/dep/{s}.o.d");
|
||||
ret.push_str(&format!(
|
||||
"build {obj_name}: cc_{name} {s} | build.ninja || $builddir/{name}\n"
|
||||
"build {obj_name}: cc_{name} {s} | build.ninja || $builddir/{name}/obj $builddir/{name}/dep\n dep = {dep_name}\n"
|
||||
));
|
||||
source_list.push(obj_name);
|
||||
}
|
||||
|
@ -113,7 +112,7 @@ build $builddir/{name}: mkdir
|
|||
ret.push_str(&format!("\nbuild $builddir/{name}/{name}: link_{name} "));
|
||||
ret.push_str(&source_list.join(" "));
|
||||
ret.push_str(&format!(" \nbuild {name}: phony $builddir/{name}/{name}\n"));
|
||||
ret.push_str(&format!("# END TARGET {name}\n\n"));
|
||||
ret.push_str(&format!("# END TARGET {name}\n"));
|
||||
|
||||
ret
|
||||
}
|
||||
|
@ -140,7 +139,6 @@ rule regen
|
|||
|
||||
build build.ninja: regen ngen.toml
|
||||
pool = console
|
||||
|
||||
"#,
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in a new issue