1
0

b/c...py: extract function run_command

This commit is contained in:
Intel A80486DX2-66 2024-08-26 17:36:09 +03:00
parent 27246e1b8b
commit 6a1f10111d
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -89,6 +89,11 @@ def substitute_vars(replacements: Dict[str, Union[bool, str]], text: str,
print()
return text
def run_command(*command: list[str]) -> None:
print(" ".join(command), flush=True)
if subprocess.run(command).returncode != EXIT_SUCCESS:
exit(EXIT_FAILURE)
preprocessor_bool = lambda value: "1" if value else "0"
C_str_repr = lambda s: '"' + s.replace("\\", "\\\\").replace(r'"', r'\"') + '"'
@ -376,23 +381,14 @@ if __name__ == "__main__":
# Compile
print("Compiling")
command = [
run_command(
CC,
*command_line_split(CFLAGS),
INPUT_FILE,
PATHS["fwrite_le"],
"-o", OUTPUT_FILE,
"-I" + PATHS["include_directory"]
]
print(" ".join(command), flush=True)
if subprocess.run(command).returncode != EXIT_SUCCESS:
exit(EXIT_FAILURE)
command = [OUTPUT_FILE]
print(" ".join(command), flush=True)
if subprocess.run(command).returncode != EXIT_SUCCESS:
exit(EXIT_FAILURE)
)
run_command(OUTPUT_FILE)
exit(EXIT_SUCCESS)