b/c...py: extract function run_command
This commit is contained in:
parent
dee6773080
commit
75ede327d6
@ -88,6 +88,11 @@ def substitute_vars(replacements: Dict[str, Union[bool, str]], text: str,
|
|||||||
print()
|
print()
|
||||||
return text
|
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"
|
preprocessor_bool = lambda value: "1" if value else "0"
|
||||||
C_str_repr = lambda s: '"' + s.replace("\\", "\\\\").replace(r'"', r'\"') + '"'
|
C_str_repr = lambda s: '"' + s.replace("\\", "\\\\").replace(r'"', r'\"') + '"'
|
||||||
|
|
||||||
@ -281,23 +286,14 @@ if __name__ == "__main__":
|
|||||||
# Compile
|
# Compile
|
||||||
print("Compiling")
|
print("Compiling")
|
||||||
|
|
||||||
command = [
|
run_command(
|
||||||
CC,
|
CC,
|
||||||
*command_line_split(CFLAGS),
|
*command_line_split(CFLAGS),
|
||||||
INPUT_FILE,
|
INPUT_FILE,
|
||||||
PATHS["fwrite_le"],
|
PATHS["fwrite_le"],
|
||||||
"-o", OUTPUT_FILE,
|
"-o", OUTPUT_FILE,
|
||||||
"-I" + PATHS["include_directory"]
|
"-I" + PATHS["include_directory"]
|
||||||
]
|
)
|
||||||
print(" ".join(command), flush=True)
|
run_command(OUTPUT_FILE)
|
||||||
|
|
||||||
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)
|
|
||||||
|
|
||||||
exit(EXIT_SUCCESS)
|
exit(EXIT_SUCCESS)
|
||||||
|
Loading…
Reference in New Issue
Block a user