mirror of
https://github.com/zeldaret/ph
synced 2026-06-21 07:52:34 -04:00
Exclude duplicate macros in m2ctx
This commit is contained in:
+8
-1
@@ -66,7 +66,7 @@ while i < len(sys.argv):
|
||||
|
||||
|
||||
try:
|
||||
ctx = subprocess.check_output(['gcc', '-E', '-P', '-undef', '-dD', *CXX_FLAGS, in_file], cwd=root_dir, encoding=encoding)
|
||||
ctx: str = subprocess.check_output(['gcc', '-E', '-P', '-undef', '-dD', *CXX_FLAGS, in_file], cwd=root_dir, encoding=encoding)
|
||||
except subprocess.CalledProcessError as e:
|
||||
eprint(f"Failed to preprocess '{in_file}'")
|
||||
if verbose: eprint(e)
|
||||
@@ -74,6 +74,13 @@ except subprocess.CalledProcessError as e:
|
||||
exit(1)
|
||||
|
||||
|
||||
lines = ctx.splitlines(True)
|
||||
for i in reversed(range(len(lines))):
|
||||
if lines[i].startswith('#define __cplusplus'): lines.pop(i)
|
||||
elif lines[i].startswith('#define __STDC_HOSTED__'): lines.pop(i)
|
||||
|
||||
ctx = ''.join(lines)
|
||||
|
||||
if out_file:
|
||||
try:
|
||||
with open(out_file, "w") as file:
|
||||
|
||||
Reference in New Issue
Block a user