1#!/usr/bin/env python
2# Copyright (c) 2012 The Chromium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style license that can be
4# found in the LICENSE file.
5"""NaCl gcc wrapper that presents glibc and newlib as a single
6toolchain.
7
8This wraps the newlib and glibc compilers and allows users
9to choose which one they really want by passed in --glibc
10or --newlib on the command line.
11
12We need this when using gyp to generator build files since
13gyp only support one target toolchain and one host toolchain
14(for now).
15"""
16import sys
17import os
18
19def main():
20  args = sys.argv[1:]
21  if '--glibc' in args:
22    variant = 'glibc'
23    args.remove('--glibc')
24  elif '--newlib' in args:
25    variant = 'newlib'
26    args.remove('--newlib')
27  else:
28    sys.exit("Expected --glibc or --newlib in arg list")
29  compiler = os.path.abspath(sys.argv[0])
30  compiler = compiler.replace("linux_x86", "linux_x86_%s" % variant)
31  args = [compiler] + args
32  os.execv(compiler, args)
33
34if __name__ == '__main__':
35  main()
36