Pirama Arumuga Nainar | 4967a71 | 2016-09-19 22:19:55 -0700 | [diff] [blame] | 1 | #!/usr/bin/python |
| 2 | |
| 3 | import os |
| 4 | import sys |
| 5 | |
| 6 | flags_to_append = [] |
| 7 | flags_to_insert = [] |
| 8 | |
| 9 | myargs = sys.argv[1:] |
| 10 | |
| 11 | myargs = flags_to_insert + myargs + flags_to_append |
| 12 | |
| 13 | real_compiler = sys.argv[0] + '.real' |
| 14 | argv0 = real_compiler |
| 15 | |
| 16 | def get_gomacc_command(): |
| 17 | """Return the gomacc command if it is found in $GOMACC_PATH.""" |
| 18 | gomacc = os.environ.get('GOMACC_PATH') |
| 19 | if gomacc and os.path.isfile(gomacc): |
| 20 | return gomacc |
| 21 | return None |
| 22 | |
| 23 | execargs = [] |
| 24 | gomacc = get_gomacc_command() |
| 25 | if gomacc: |
| 26 | argv0 = gomacc |
| 27 | execargs += [gomacc] |
| 28 | |
| 29 | execargs += [real_compiler] + myargs |
| 30 | |
| 31 | os.execv(argv0, execargs) |