tools/makectx: Use cl.exe /EP /P for file preprocessing.

Creates a messy file with a lot of newlines but allows for adding DX structs.
This commit is contained in:
Joshua Peisach 2023-09-08 14:13:05 -04:00
parent 7ab43368f0
commit e7cdfa76dd
No known key found for this signature in database
GPG Key ID: 41C3D4189AFEDB5A
2 changed files with 10 additions and 37 deletions

1
.gitignore vendored
View File

@ -6,3 +6,4 @@ ISLE.EXE
LEGO1.DLL
build/
*.swp
*.i

View File

@ -1,43 +1,15 @@
#!/usr/bin/python3
# Tool to make simple context, currently the basic Mx* structures.
import argparse
import os
import shutil
ctxfile = open('ctx.h', 'w')
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.')
# These are the only files we can include, hopefully soon decomp.me can deal with DirectX files. There is no need to bundle all the thousands of lines DX5 headers have, its not like all of it is probably going to be used.
ctxfile.write('#include <string.h>\n')
ctxfile.write('#include <windows.h>\n')
args = parser.parse_args()
if not os.path.isfile(args.cppfile):
parser.error('Specified C++ file does not exist.')
# The order is important!
# In the future, *all* the files can be done - but there will always be some headers that need to be placed in before others.
# Later, when this initial list is complete, and DirectX header files are available on decomp.me, then we can bundle in everything that is not order-dependent (that isn't already in the list.)
# This will periodically need updating depending on what classes include stuff from others - for now, these are the most likely basics.
# This context should be enough to match basic functions, once manually adding in context for the intended class.
# This pastebin shows class inheritance. This can help us a lot: https://pastebin.com/AQAiurwC
headerfiles = [
# Basic definitions/types/base classes
'LEGO1/compat.h',
'LEGO1/mxtypes.h',
os.system('cl.exe /EP /P ' + args.cppfile)
'LEGO1/mxcore.h',
'LEGO1/mxstring.h',
'LEGO1/mxhashtable.h',
'LEGO1/mxvariable.h',
'LEGO1/mxvariabletable.h',
'LEGO1/mxcriticalsection.h',
'LEGO1/mxomni.h',
'LEGO1/legostate.h',
'LEGO1/mxentity.h',
'LEGO1/legoentity.h',
]
for i in headerfiles:
ctxfile.write('\n// Start of ' + i + '\n')
for line in open(i):
if not line.startswith('#include'):
ctxfile.write(line)
ctxfile.write('\n// End of ' + i + '\n')
print('Preprocessed file. It will be in the directory you executed in this command as "(filename).i".')