isle/tools/makectx.py
Joshua Peisach db1910d81e
tools/makectx: Use subprocess to direct output file
This way it will appear in 'ctx.h' and not (blah).

Also update the .gitignore for *.obj files, which interestingly
the preprocessor spat out after testing locally.
2023-09-08 17:07:44 -04:00

30 lines
877 B
Python

#!/usr/bin/python3
import argparse
import os
import subprocess
parser = argparse.ArgumentParser(
allow_abbrev=False, description="Verify Exports: Compare the exports of two DLLs."
)
parser.add_argument(
"cppfile", metavar="cppfile", help="Path to the C++ File to preprocess."
)
parser.add_argument(
"--debug",
action="store_true",
help="Print debug information by showing the output from the preprocessor. THIS WILL TAKE A LONG TIME AS YOUR TERMINAL TRIES TO LOAD OVER 100K LINES OF TEXT. Use this if your context contains an error or is empty.",
)
args = parser.parse_args()
if not os.path.isfile(args.cppfile):
parser.error("Specified C++ file does not exist.")
output = subprocess.run(
"cl.exe /EP " + args.cppfile, capture_output=not args.debug, text=True
)
f = open("ctx.h", "w")
f.write(output.stdout)
print("Preprocessed file to ctx.h")