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
3 # found in the LICENSE file.
5 # This script locates the Android compilers given the bin directory of the
12 if len(sys
.argv
) != 2:
13 print "Error: expecting one argument of the android toolchain dir."
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
18 # current platform rather than having to rely on glob.
19 android_toolchain
= sys
.argv
[1]
20 cc
= glob
.glob(android_toolchain
+ "/*-gcc")
21 cxx
= glob
.glob(android_toolchain
+ "/*-g++")
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
32 if len(cc
) != 1 or len(cxx
) != 1:
33 print "More than one matching compiler."
36 # Get the host compilers from the current path.
37 which_gcc
= subprocess
.check_output(["which gcc"], shell
=True).strip()
38 which_gxx
= subprocess
.check_output(["which g++"], shell
=True).strip()
40 print ('["' + cc
[0] + '","' + cxx
[0] + '","' + which_gcc
+ '","' +