forked from tfdsoft/famidash
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdefines_to_asm.py
31 lines (29 loc) · 870 Bytes
/
defines_to_asm.py
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
#!/usr/bin/env python
def convertCFileToS(filename : str, outfilename : str):
infile = open(filename, "r")
outfile = open(outfilename, "w")
while (True):
line = infile.readline()
split = line.split()
# print(line)
if not line:
break
if len(split) == 0:
outfile.write("\n")
elif split[0] == "#define":
split[1] = "_" + split[1]
if len(split) >= 3 and (" ".join(split[2:])).isnumeric():
outfile.write(f"{split[1]} = " + " ".join(split[2:]) + "\n")
else:
split[0] = ".define"
outfile.write(" ".join(split) + "\n")
elif split[0].startswith("//"):
split[0] = ";" + split[0][2:]
outfile.write(" ".join(split) + "\n")
else:
outfile.write(";" + " ".join(split) + "\n")
infile.close()
outfile.close()
if __name__ == "__main__":
import sys
convertCFileToS(sys.path[0]+"/BUILD_FLAGS.h", sys.path[0]+"/TMP/BUILD_FLAGS.s")