obj_generator.py 523 B

12345678910111213141516171819
  1. #!/usr/bin/env python3
  2. # Mimic a binary that generates an object file (e.g. windres).
  3. import sys, subprocess
  4. if __name__ == '__main__':
  5. if len(sys.argv) != 4:
  6. print(sys.argv[0], 'compiler input_file output_file')
  7. sys.exit(1)
  8. compiler = sys.argv[1]
  9. ifile = sys.argv[2]
  10. ofile = sys.argv[3]
  11. if compiler.endswith('cl'):
  12. cmd = [compiler, '/nologo', '/MDd', '/Fo' + ofile, '/c', ifile]
  13. else:
  14. cmd = [compiler, '-c', ifile, '-o', ofile]
  15. sys.exit(subprocess.call(cmd))