Format code

This commit is contained in:
Xeeynamo 2023-09-19 22:25:08 +00:00 committed by github-actions[bot]
parent bd65622556
commit 7009525a64

View File

@ -25,24 +25,29 @@ CPP_FLAGS = [
"-DM2CTX",
]
def import_c_file(in_file) -> str:
in_file = os.path.relpath(in_file, root_dir)
cpp_command = ["gcc", "-E", "-P", "-dM", *CPP_FLAGS, in_file]
cpp_command2 = ["gcc", "-E", "-P", *CPP_FLAGS, in_file]
with tempfile.NamedTemporaryFile(suffix=".c") as tmp:
stock_macros = subprocess.check_output(["gcc", "-E", "-P", "-dM", tmp.name], cwd=root_dir, encoding="utf-8")
stock_macros = subprocess.check_output(
["gcc", "-E", "-P", "-dM", tmp.name], cwd=root_dir, encoding="utf-8"
)
out_text = ""
try:
out_text += subprocess.check_output(cpp_command, cwd=root_dir, encoding="utf-8")
out_text += subprocess.check_output(cpp_command2, cwd=root_dir, encoding="utf-8")
out_text += subprocess.check_output(
cpp_command2, cwd=root_dir, encoding="utf-8"
)
except subprocess.CalledProcessError:
print(
"Failed to preprocess input file, when running command:\n"
+ ' '.join(cpp_command),
+ " ".join(cpp_command),
file=sys.stderr,
)
)
sys.exit(1)
if not out_text:
@ -53,6 +58,7 @@ def import_c_file(in_file) -> str:
out_text = out_text.replace(line + "\n", "")
return out_text
def main():
parser = argparse.ArgumentParser(
description="""Create a context file which can be used for m2c / decomp.me"""