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

added template for exam main file and its Makefile

parent 5bf0ff83
Branches
No related tags found
No related merge requests found
...@@ -49,6 +49,23 @@ pub fn template_for_main(path_to_hfile: String) -> CodeBuffer { ...@@ -49,6 +49,23 @@ pub fn template_for_main(path_to_hfile: String) -> CodeBuffer {
return buffer; return buffer;
} }
pub fn template_for_examfile() -> CodeBuffer {
let mut buffer = CodeBuffer::new(4);
buffer.println("#include <stdio.h>");
buffer.println("#include <stdlib.h>");
buffer.println("#include <stdbool.h>");
buffer.println("#include <string.h>");
buffer.println("");
buffer.println("int main()");
buffer.println("{");
buffer.println("");
buffer.println_right("return 0;");
buffer.println_left("}");
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);
...@@ -92,3 +109,31 @@ pub fn template_for_makefile_algo(mut hfile_name: String, mut main_name: String) ...@@ -92,3 +109,31 @@ pub fn template_for_makefile_algo(mut hfile_name: String, mut main_name: String)
return buffer; return buffer;
} }
pub fn template_for_makefile_exam(mut main_filename: String) -> CodeBuffer {
let mut buffer = CodeBuffer::new(4);
// Removing extensions
for _ in 0..2 {
// hfile_name.pop();
main_filename.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!("{0}: {0}.c", main_filename.to_lowercase()).as_str());
buffer.println_right("$(CC) $(CFLAGS) $(LIBS) $^ -o $@");
buffer.println_left("");
buffer.println("clean:");
buffer.println_right(format!("rm -f *.o {}", main_filename.to_lowercase()).as_str());
return buffer;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment