1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56
|
#!/usr/bin/env python
"""bgp_gcc.py is a wrapper for the BGP gcc compiler,
converting/removing incompatible gcc args. """
from __future__ import print_function
import sys
from subprocess import call
from glob import glob
args2change = {"-fno-strict-aliasing":"",
"-fmessage-length=0":"",
"-Wall":"",
"-std=c99":"",
"-fPIC":"",
"-g":"",
"-D_FORTIFY_SOURCE=2":"",
"-DNDEBUG":"",
"-UNDEBUG":"",
"-pthread":"",
"-shared":"",
"-Xlinker":"",
"-export-dynamic":"",
"-Wstrict-prototypes":"",
"-dynamic":"",
"-O3":"",
"-O2":"",
"-O1":""}
fragile_files = ["test.c"]
non_c99files = glob('c/libxc/src/*.c')
cmd = ""
opt = 1
for arg in sys.argv[1:]:
cmd += " "
t = arg.strip()
if t in fragile_files:
opt = 2
if t in non_c99files:
opt = 3
if t in args2change:
cmd += args2change[t]
else:
cmd += arg
flags_list = {1: "-g -O3 -std=c99 -fPIC",
2: "-g -O2 -std=c99 -fPIC",
3: "-g -O3 -fPIC",
}
flags = flags_list[opt]
cmd = "/bgsys/drivers/ppcfloor/gnu-linux/bin/powerpc-bgp-linux-gcc %s %s"%(flags, cmd)
print("\nexecmd: %s\n"%cmd)
call(cmd, shell=True)
|