1pub mod cli;
10pub mod build_data;
11pub mod user_config;
12
13use std::fmt;
14
15use crate::build_data::BuildData;
16
17#[derive(PartialEq, Debug)]
19pub struct StringVector(Vec<String>);
20
21impl StringVector {
22 pub fn new() -> StringVector {
24 StringVector(Vec::new())
25 }
26}
27
28impl fmt::Display for StringVector {
29 fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
30 write!(f, "{}", self.0.join(" "))?;
31 Ok(())
32 }
33}
34
35pub fn generate_makefile(file_names: &BuildData) -> String {
45 let makefile = format!("\
46# Compiler and flags
47CC = {}
48FLAGS = -g -c -Wall
49LFLAGS = {}
50
51# Source files and object files
52OBJS = {}
53SOURCE = {}
54HEADER = {}
55OUT = {}
56
57# Libraries
58LDLIBS = {}
59
60# Default target
61all: $(OUT)
62
63# Linking rules
64$(OUT): $(OBJS)
65\t$(CC) -g $(OBJS) -o $(OUT) $(LFLAGS) $(LDLIBS)
66
67# Compilation rules
68%.o: %.cpp $(HEADER)
69\t$(CC) $(FLAGS) -o $@ $<
70
71# Clean rule
72clean:
73\trm -f $(OBJS) $(OUT)\n",
74file_names.compiler, file_names.lflags,
75file_names.get_cpp_compiled_files(), file_names.get_cpp_source_files(),
76file_names.header_files, file_names.executable, file_names.ldlibs);
77
78 makefile
79}
80
81pub fn generate_java_makefile(file_names: &BuildData) -> String {
91 let makefile = format!("\
92# Compiler and flags
93JC = javac
94JFLAGS = -g
95
96# Source files and compiled classes
97SOURCE = {}
98CLASSES = {}
99
100# Default target
101default: $(CLASSES)
102
103# Compilation rule
104%.class: %.java
105\t$(JC) $(JFLAGS) $<
106
107# Clean rule to remove generated .class files
108clean:
109\trm -f $(CLASSES)\n",
110file_names.get_java_source_files(), file_names.get_java_compiled_files());
111
112 makefile
113}