Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(21)

Side by Side Diff: build/compiler_version.py

Issue 10837005: Also detect the CXX_target enviroment vairiable for compiler version (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address the comment Created 8 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 3 # Use of this source code is governed by a BSD-style license that can be
4 # found in the LICENSE file. 4 # found in the LICENSE file.
5 5
6 """Compiler version checking tool for gcc 6 """Compiler version checking tool for gcc
7 7
8 Print gcc version as XY if you are running gcc X.Y.*. 8 Print gcc version as XY if you are running gcc X.Y.*.
9 This is used to tweak build flags for gcc 4.4. 9 This is used to tweak build flags for gcc 4.4.
10 """ 10 """
(...skipping 15 matching lines...) Expand all
26 26
27 result = re.match(r"(\d+)\.(\d+)", gcc_output) 27 result = re.match(r"(\d+)\.(\d+)", gcc_output)
28 return result.group(1) + result.group(2) 28 return result.group(1) + result.group(2)
29 except Exception, e: 29 except Exception, e:
30 if gcc_error: 30 if gcc_error:
31 sys.stderr.write(gcc_error) 31 sys.stderr.write(gcc_error)
32 print >> sys.stderr, "compiler_version.py failed to execute:", compiler 32 print >> sys.stderr, "compiler_version.py failed to execute:", compiler
33 print >> sys.stderr, e 33 print >> sys.stderr, e
34 return "" 34 return ""
35 35
36 def GetVersionFromEnvironment(compiler_env):
37 """ Returns the version of compiler
38
39 If the compiler was set by the given environment variable and exists,
40 return its version, otherwise None is returned.
41 """
42 cxx = os.getenv(compiler_env, None)
43 if cxx:
44 cxx_version = GetVersion(cxx)
45 if cxx_version != "":
46 return cxx_version
47 return None
48
36 def main(): 49 def main():
37 # Check if CXX environment variable exists and 50 # Check if CXX_target or CXX environment variable exists an if it does use
38 # if it does use that compiler. 51 # that compiler.
Nico 2012/08/06 19:03:03 Please file a bug (on crbug.com) about ninja getti
michaelbai 2012/08/06 20:50:35 Done.
39 cxx = os.getenv("CXX", None) 52 # In ninja's cross compile mode, the CXX_target is target compiler, while
40 if cxx: 53 # the CXX is host. The CXX_target needs be checked first, though the target
41 cxxversion = GetVersion(cxx) 54 # and host compiler have different version, there seems no issue to use the
42 if cxxversion != "": 55 # target compiler's version number as gcc_version in Android.
43 print cxxversion 56 cxx_version = GetVersionFromEnvironment("CXX_target")
44 return 0 57 if cxx_version:
45 else: 58 print cxx_version
46 # Otherwise we check the g++ version. 59 return 0
47 gccversion = GetVersion("g++") 60
48 if gccversion != "": 61 cxx_version = GetVersionFromEnvironment("CXX")
49 print gccversion 62 if cxx_version:
50 return 0 63 print cxx_version
64 return 0
65
66 # Otherwise we check the g++ version.
67 gccversion = GetVersion("g++")
68 if gccversion != "":
69 print gccversion
70 return 0
51 71
52 return 1 72 return 1
53 73
54 if __name__ == "__main__": 74 if __name__ == "__main__":
55 sys.exit(main()) 75 sys.exit(main())
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698