Super Mario 64s source code (from a leak on 4chan so be careful)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

36 lines
1.2 KiB

6 years ago
  1. #!/usr/bin/env python3
  2. import sys
  3. import os
  4. import shlex
  5. import subprocess
  6. import tempfile
  7. dir_path = os.path.dirname(os.path.realpath(__file__))
  8. asm_processor = ['python3', os.path.join(dir_path, "asm-processor.py")]
  9. prelude = os.path.join(dir_path, "prelude.inc")
  10. all_args = sys.argv[1:]
  11. sep1 = all_args.index('--')
  12. sep2 = all_args.index('--', sep1+1)
  13. compiler = all_args[:sep1]
  14. assembler = all_args[sep1+1:sep2]
  15. assembler_sh = ' '.join(shlex.quote(x) for x in assembler)
  16. compile_args = all_args[sep2+1:]
  17. in_file = compile_args[-1]
  18. out_ind = compile_args.index('-o')
  19. out_file = compile_args[out_ind + 1]
  20. del compile_args[-1]
  21. del compile_args[out_ind + 1]
  22. del compile_args[out_ind]
  23. in_dir = os.path.split(os.path.realpath(in_file))[0]
  24. opt_flags = [x for x in compile_args if x in ['-g', '-O2', '-framepointer']]
  25. preprocessed_file = tempfile.NamedTemporaryFile(prefix='preprocessed', suffix='.c')
  26. subprocess.check_call(asm_processor + opt_flags + [in_file], stdout=preprocessed_file)
  27. subprocess.check_call(compiler + compile_args + ['-I', in_dir, '-o', out_file, preprocessed_file.name])
  28. subprocess.check_call(asm_processor + opt_flags + [in_file, '--post-process', out_file, '--assembler', assembler_sh, '--asm-prelude', prelude])