-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakefile_gen.py
More file actions
34 lines (24 loc) · 810 Bytes
/
makefile_gen.py
File metadata and controls
34 lines (24 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import os
MKFILE_FILENAME = "Makefile"
MKFILE_TEMPLATE_DIR = "templates"
MKFILE_TEMPLATE_FILENAME = f"{MKFILE_TEMPLATE_DIR}/"
if os.name == "nt":
MKFILE_TEMPLATE_FILENAME += "Makefile_nt"
EXECUTE_STR = "nmake all"
elif os.name == "posix":
MKFILE_TEMPLATE_FILENAME += "Makefile_posix"
HELP_STR = "make help"
EXECUTE_STR = "make all"
def read_file(filename: str) -> str:
with open(filename, "r") as f:
data = f.read()
return data
def write_file(data: str, filename: str = MKFILE_FILENAME) -> int:
with open(filename, "w") as f:
return f.write(data)
def gen_makefile():
data = read_file(MKFILE_TEMPLATE_FILENAME)
written = write_file(data)
print(f"[+] Wrote {written} bytes to {MKFILE_FILENAME}")
if __name__ == "__main__":
gen_makefile()