1
0

b/c..py: use word "output" only for audio

This commit is contained in:
Intel A80486DX2-66 2024-09-22 21:59:11 +03:00
parent b3efc7a12c
commit e810309303
Signed by: 80486DX2-66
GPG Key ID: 83631EF27054609B

View File

@ -24,7 +24,7 @@ PATHS = {
"bin_dir": "bin",
"template": "template.c",
"substitute": "substituted.c",
"output": "render_bytebeat",
"executable": "render_bytebeat",
"fwrite_le_header": "fwrite_le.h",
"fwrite_le": "fwrite_le.c",
"include_directory": "include"
@ -38,7 +38,7 @@ for key in ["src_dir", "bin_dir", "include_directory"]:
# Resolve paths
PATHS["template"] = path_join(PATHS["src_dir"], PATHS["template"])
PATHS["substitute_kept"] = path_join(PATHS["bin_dir"], PATHS["substitute"])
PATHS["output_kept"] = path_join(PATHS["bin_dir"], PATHS["output"])
PATHS["executable_kept"] = path_join(PATHS["bin_dir"], PATHS["executable"])
PATHS["fwrite_le"] = path_join(PATHS["src_dir"], PATHS["fwrite_le"])
# Default parameters
@ -93,7 +93,7 @@ def run_command(*command: list[str]) -> None:
print("An error occured during rendering!")
raise SystemExit(EXIT_FAILURE)
def compile_substituted_file(input_file: str, output_file: str) -> None:
def compile_substituted_file(input_file: str, executable_file: str) -> None:
print("Compiling")
run_command(
@ -101,15 +101,15 @@ def compile_substituted_file(input_file: str, output_file: str) -> None:
*command_line_split(CFLAGS),
input_file,
PATHS["fwrite_le"],
"-o", output_file,
"-o", executable_file,
"-I" + PATHS["include_directory"]
)
run_command(output_file)
run_command(executable_file)
def main_workflow(input_file: str, output_file: str, \
def main_workflow(input_file: str, executable_file: str, \
substitute_contents: Dict[str, str]) -> None:
overwrite_file(input_file, substitute_contents)
compile_substituted_file(input_file, output_file)
compile_substituted_file(input_file, executable_file)
preprocessor_bool = lambda value: "1" if value else "0"
C_str_repr = lambda s: '"' + s.replace("\\", "\\\\").replace(r'"', r'\"') + '"'
@ -299,14 +299,14 @@ if __name__ == "__main__":
makedirs(PATHS["bin_dir"], exist_ok=True)
substitute_file = PATHS["substitute_kept"]
output_file = PATHS["output_kept"]
executable_file = PATHS["executable_kept"]
main_workflow(substitute_file, output_file, substitute_contents)
main_workflow(substitute_file, executable_file, substitute_contents)
else:
with TemporaryDirectory() as tmpdirname:
temporary_path = lambda path: path_join(tmpdirname, path)
substitute_temp = temporary_path(PATHS["substitute"])
output_temp = temporary_path(PATHS["output"])
executable_temp = temporary_path(PATHS["executable"])
main_workflow(substitute_temp, output_temp, substitute_contents)
main_workflow(substitute_temp, executable_temp, substitute_contents)