tuner-as3525v2.c: only build what's needed
[maemo-rb.git] / tools / thumb-cc.py
blob2c83474695cdf05666875e351694bb9587f429fc
1 #!/usr/bin/python
2 # -*- coding: utf8 -*-
3 # __________ __ ___.
4 # Open \______ \ ____ ____ | | _\_ |__ _______ ___
5 # Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
6 # Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
7 # Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
8 # \/ \/ \/ \/ \/
10 # Copyright © 2010-2011 Rafaël Carré <rafael.carre@gmail>
12 # This program is free software; you can redistribute it and/or
13 # modify it under the terms of the GNU General Public License
14 # as published by the Free Software Foundation; either version 2
15 # of the License, or (at your option) any later version.
17 # This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 # KIND, either express or implied.
20 from sys import argv, stderr, stdout
21 from subprocess import Popen, PIPE
22 from os import execv
24 args = argv[1:] # remove script path
26 for opt in ['-E', '-MM', '-v', '--version']:
27 if opt in args:
28 execv(args[0], args) # not actually compiling
30 if '-o' in args and args.index('-o') < len(args) - 1:
31 if len(args[args.index('-o') + 1].rsplit('.o', 1)) == 1:
32 execv(args[0], args) # output doesn't end in .o
34 args.append('-mthumb-interwork') # thumb-interwork is required
35 gcc = Popen(args + ['-mthumb'], stdout=PIPE, stderr=PIPE)
36 (out, err) = gcc.communicate()
38 if gcc.returncode != 0: # thumb failed, try outputting arm
39 execv(args[0], args)
41 stdout.write(out)
42 stderr.write(err)