diff --git a/bytebeat_compiler.py b/bytebeat_compiler.py index fa78b7b..f3ffcb7 100644 --- a/bytebeat_compiler.py +++ b/bytebeat_compiler.py @@ -42,7 +42,7 @@ DEFAULT_PARAMETERS = { def fetch(name: str): if from_env := environ.get(name): return from_env - else: + elif name != "CFLAGS_EXTRA": return DEFAULT_PARAMETERS[name] def read_file(path: str) -> str: @@ -82,13 +82,15 @@ CC = fetch("CC") CFLAGS = fetch("CFLAGS") INPUT_FILE = fetch("INPUT_FILE") OUTPUT_FILE = fetch("OUTPUT_FILE") +if extra := fetch("CFLAGS_EXTRA"): + CFLAGS += " " + extra if __name__ == "__main__": parser = ArgumentParser(description=\ "Substitutes supplied C (non-JavaScript!) bytebeat into the template, " "then attempts to compile the instance of the template. Accepts " - "environmental variables `CC`, `CFLAGS`, `INPUT_FILE`, " - "`OUTPUT_FILE`.") + "environmental variables `CC`, `CFLAGS`, `INPUT_FILE`, `OUTPUT_FILE`. " + "`CFLAGS_EXTRA` can be used to add to default `CFLAGS`.") parser.add_argument("file", type=str, help="bytebeat formula file (use `-` to read from stdin)") parser.add_argument("-o", "--output", default="output.wav", type=str,