import os import shlex import subprocess import sys def expand_args(args): expanded = [] for arg in args: if arg.startswith("@") and os.path.exists(arg[1:]): with open(arg[1:], "r", encoding="utf-8") as file: content = file.read() expanded.extend(shlex.split(content, posix=False)) else: expanded.append(arg) return expanded def output_path(args): for index, arg in enumerate(args): if arg == "-o" and index + 1 < len(args): return args[index + 1].strip('"') return None def main(): args = sys.argv[1:] expanded = expand_args(args) output = output_path(expanded) result = subprocess.run(["x86_64-w64-mingw32-gcc.exe", *args]) if result.returncode != 0: return result.returncode if output and os.path.exists(output): subprocess.run(["strip.exe", "--strip-debug", output], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) if output.lower().endswith(".exe"): subprocess.run(["strip.exe", output], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL) return 0 if __name__ == "__main__": raise SystemExit(main())