Also detect the CXX_target enviroment vairiable for compiler version

The ninja's cross compile mode still uses CXX_target as the target compiler
which needs to be detected before the host one.

This CL might be reverted once the ninja use CXX as target compiler.

BUG=


Review URL: https://chromiumcodereview.appspot.com/10837005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@150300 0039d316-1c4b-4281-b951-d872f2087c98
parent fa39c6d8
...@@ -33,21 +33,42 @@ def GetVersion(compiler): ...@@ -33,21 +33,42 @@ def GetVersion(compiler):
print >> sys.stderr, e print >> sys.stderr, e
return "" return ""
def main(): def GetVersionFromEnvironment(compiler_env):
# Check if CXX environment variable exists and """ Returns the version of compiler
# if it does use that compiler.
cxx = os.getenv("CXX", None) If the compiler was set by the given environment variable and exists,
return its version, otherwise None is returned.
"""
cxx = os.getenv(compiler_env, None)
if cxx: if cxx:
cxxversion = GetVersion(cxx) cxx_version = GetVersion(cxx)
if cxxversion != "": if cxx_version != "":
print cxxversion return cxx_version
return 0 return None
else:
# Otherwise we check the g++ version. def main():
gccversion = GetVersion("g++") # Check if CXX_target or CXX environment variable exists an if it does use
if gccversion != "": # that compiler.
print gccversion # TODO: Fix ninja (see http://crbug.com/140900) instead and remove this code
return 0 # In ninja's cross compile mode, the CXX_target is target compiler, while
# the CXX is host. The CXX_target needs be checked first, though the target
# and host compiler have different version, there seems no issue to use the
# target compiler's version number as gcc_version in Android.
cxx_version = GetVersionFromEnvironment("CXX_target")
if cxx_version:
print cxx_version
return 0
cxx_version = GetVersionFromEnvironment("CXX")
if cxx_version:
print cxx_version
return 0
# Otherwise we check the g++ version.
gccversion = GetVersion("g++")
if gccversion != "":
print gccversion
return 0
return 1 return 1
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment