Skip to content
Snippets Groups Projects
Commit 74e80ad6 authored by iliya.saroukha's avatar iliya.saroukha
Browse files

created new template for algo Makefile

parent 0755efc5
No related branches found
No related tags found
No related merge requests found
...@@ -66,46 +66,86 @@ pub fn template_for_examfile() -> CodeBuffer { ...@@ -66,46 +66,86 @@ pub fn template_for_examfile() -> CodeBuffer {
return buffer; return buffer;
} }
pub fn template_for_makefile_algo(mut hfile_name: String, mut main_name: String) -> CodeBuffer { // pub fn template_for_makefile_algo(mut hfile_name: String, mut main_name: String) -> CodeBuffer {
let mut buffer = CodeBuffer::new(4); // let mut buffer = CodeBuffer::new(4);
// Removing extensions // // Removing extensions
for _ in 0..2 { // for _ in 0..2 {
hfile_name.pop(); // hfile_name.pop();
main_name.pop(); // main_name.pop();
} // }
// buffer.println("# This file was automatically generated by `create-prog-app`");
// buffer.println("CC:=gcc");
// buffer.println("CFLAGS:=-Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak");
// buffer.println("LIBS:=-lm");
// buffer.println("VPATH:=struct");
// buffer.println("# Due to the oddity of MAKE and the fact you cannot generate \"true\" tabs,");
// buffer.println("# the \"tab\" character is replaced by spaces.");
// buffer.println("# `create-prog-app` STRONGLY advises you not to change/modify the line below");
// buffer.println(".RECIPEPREFIX:=$(.RECIPEPREFIX) ");
// buffer.println("");
// buffer.println(
// format!(
// "{}: {}.o {}.o",
// main_name.to_lowercase(),
// main_name.to_lowercase(),
// hfile_name.to_lowercase()
// )
// .as_str(),
// );
// buffer.println_right("$(CC) $(CFLAGS) $(LIBS) $^ -o $@");
// buffer.println_left("");
// buffer.println(format!("{0}.o: {0}.c", main_name.to_lowercase()).as_str());
// buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<");
// buffer.println_left("");
// buffer.println(format!("{0}.o: {0}.c {0}.h", hfile_name.to_lowercase()).as_str());
// buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<");
// buffer.println_left("");
// buffer.println("clean:");
// buffer.println_right(format!("rm -f *.o {}", main_name.to_lowercase()).as_str());
// buffer.println_left("");
// buffer.println(format!("rebuild: clean {}", main_name.to_lowercase()).as_str());
// return buffer;
// }
pub fn template_for_makefile_algo_v2(impl_name: String, mut main_name: String) -> CodeBuffer {
let mut buffer = CodeBuffer::new(4);
buffer.println("# This file was automatically generated by `create-prog-app`"); buffer.println("# This file was automatically generated by `create-prog-app`");
buffer.println("CC := gcc"); buffer.println("CC := gcc");
buffer.println("CFLAGS := -Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak"); buffer.println("CFLAGS := -Wall -Wextra -g -pedantic -fsanitize=address -fsanitize=leak");
buffer.println("LIBS:=-lm"); buffer.println("LDFLAGS := -lm");
buffer.println("VPATH := struct"); buffer.println("VPATH := struct");
buffer.println("# Due to the oddity of MAKE and the fact you cannot generate \"true\" tabs,");
buffer.println("# the \"tab\" character is replaced by spaces.");
buffer.println("# `create-prog-app` STRONGLY advises you not to change/modify the line below");
buffer.println(".RECIPEPREFIX:=$(.RECIPEPREFIX) ");
buffer.println(""); buffer.println("");
buffer.println( buffer.println(
format!( format!(
"{}: {}.o {}.o", "SOURCES := {} {}",
main_name.to_lowercase(),
main_name.to_lowercase(), main_name.to_lowercase(),
hfile_name.to_lowercase() impl_name.to_lowercase()
) )
.as_str(), .as_str(),
); );
buffer.println_right("$(CC) $(CFLAGS) $(LIBS) $^ -o $@");
buffer.println_left(""); for _ in 0..2 {
buffer.println(format!("{0}.o: {0}.c", main_name.to_lowercase()).as_str()); main_name.pop();
buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<"); }
buffer.println_left("");
buffer.println(format!("{0}.o: {0}.c {0}.h", hfile_name.to_lowercase()).as_str()); buffer.println("OBJECTS := $(patsubst %.c, %.o, $(SOURCES))");
buffer.println_right("$(CC) $(CFLAGS) $(LIBS) -c $<"); buffer.println(format!("TARGET := {}", main_name).as_str());
buffer.println("# Due to the oddity of MAKE and the fact you cannot generate \"true\" tabs,");
buffer.println("# the \"tab\" character is replaced by spaces.");
buffer.println("# `create-prog-app` STRONGLY advises you not to change/modify the line below");
buffer.println(".RECIPEPREFIX:=$(.RECIPEPREFIX) ");
buffer.println("");
buffer.println("$(TARGET): $(OBJECTS)");
buffer.println_right("$(CC) $(CFLAGS) $^ -o $@ $(LDFLAGS)");
buffer.println_left(""); buffer.println_left("");
buffer.println(".PHONY: clean");
buffer.println("");
buffer.println("clean:"); buffer.println("clean:");
buffer.println_right(format!("rm -f *.o {}", main_name.to_lowercase()).as_str()); buffer.println_right("rm -f $(OBJECTS) $(TARGET)");
buffer.println_left("");
buffer.println(format!("rebuild: clean {}", main_name.to_lowercase()).as_str());
return buffer; return buffer;
} }
......
...@@ -49,8 +49,12 @@ fn algo_template() { ...@@ -49,8 +49,12 @@ fn algo_template() {
File::create(&(root.to_owned().into_os_string().into_string().unwrap() + "Makefile")) File::create(&(root.to_owned().into_os_string().into_string().unwrap() + "Makefile"))
.expect("Cannot create Makefile!"); .expect("Cannot create Makefile!");
// let makefile_template =
// code_templates::template_for_makefile_algo(header_filename.clone(), main_filename.clone())
// .to_string();
let makefile_template = let makefile_template =
code_templates::template_for_makefile_algo(header_filename.clone(), main_filename.clone()) code_templates::template_for_makefile_algo_v2(impl_filename.clone(), main_filename.clone())
.to_string(); .to_string();
makefile makefile
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment