| OLD | NEW |
| 1 # Copyright 2013 The Chromium Authors. All rights reserved. | 1 # Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 # Use of this source code is governed by a BSD-style license that can be | 2 # Use of this source code is governed by a BSD-style license that can be |
| 3 # found in the LICENSE file. | 3 # found in the LICENSE file. |
| 4 | 4 |
| 5 # This script locates the Android compilers given the bin directory of the | 5 # This script locates the Android compilers given the bin directory of the |
| 6 # android toolchain. | 6 # android toolchain. |
| 7 | 7 |
| 8 import glob | 8 import glob |
| 9 import subprocess | 9 import subprocess |
| 10 import sys | 10 import sys |
| 11 | 11 |
| 12 if len(sys.argv) != 2: | 12 if len(sys.argv) != 2: |
| 13 print "Error: expecting one argument of the android toolchain dir." | 13 print "Error: expecting one argument of the android toolchain dir." |
| 14 sys.exit(1) | 14 sys.exit(1) |
| 15 | 15 |
| 16 # TODO(brettw) this logic seems like a bad idea. It was copied from | 16 # TODO(brettw) this logic seems like a bad idea. It was copied from |
| 17 # common.gypi. It seems like the toolchain should just know the name given the | 17 # common.gypi. It seems like the toolchain should just know the name given the |
| 18 # current platform rather than having to rely on glob. | 18 # current platform rather than having to rely on glob. |
| 19 android_toolchain = sys.argv[1] | 19 android_toolchain = sys.argv[1] |
| 20 cc = glob.glob(android_toolchain + "/*-gcc") | 20 cc = glob.glob(android_toolchain + "/*-gcc") |
| 21 cxx = glob.glob(android_toolchain + "/*-g++") | 21 cxx = glob.glob(android_toolchain + "/*-g++") |
| 22 |
| 23 # We tolerate "no matches." In the Android AOSP WebView build, it runs this |
| 24 # logic and the directory doesn't exist, giving no matches. But that build runs |
| 25 # GYP to generate Android Makefiles which specify the compiler separately. So |
| 26 # all we need to do in this case is ignore the error and continue with empty |
| 27 # target compilers. |
| 28 if len(cc) == 0: |
| 29 cc = [""] |
| 30 if len(cxx) == 0: |
| 31 cxx = [""] |
| 22 if len(cc) != 1 or len(cxx) != 1: | 32 if len(cc) != 1 or len(cxx) != 1: |
| 23 print "Either none or more than one matching compiler." | 33 print "More than one matching compiler." |
| 24 sys.exit(1) | 34 sys.exit(1) |
| 25 | 35 |
| 26 # Get the host compilers from the current path. | 36 # Get the host compilers from the current path. |
| 27 which_gcc = subprocess.check_output(["which gcc"], shell=True).strip() | 37 which_gcc = subprocess.check_output(["which gcc"], shell=True).strip() |
| 28 which_gxx = subprocess.check_output(["which g++"], shell=True).strip() | 38 which_gxx = subprocess.check_output(["which g++"], shell=True).strip() |
| 29 | 39 |
| 30 print ('["' + cc[0] + '","' + cxx[0] + '","' + which_gcc + '","' + | 40 print ('["' + cc[0] + '","' + cxx[0] + '","' + which_gcc + '","' + |
| 31 which_gxx + '"]') | 41 which_gxx + '"]') |
| OLD | NEW |