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

Side by Side Diff: build/compiler_version.py

Issue 341085: linux: compiler_version.py tweak to work on gcc 4.4 (Closed)
Patch Set: Created 11 years, 1 month 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
« 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/python 1 #!/usr/bin/python
2 2
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved. 3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be 4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file. 5 # found in the LICENSE file.
6 6
7 """Compiler version checking tool for gcc 7 """Compiler version checking tool for gcc
8 8
9 Print gcc version as XY if you are running gcc X.Y.*. 9 Print gcc version as XY if you are running gcc X.Y.*.
10 This is used to tweak build flags for gcc 4.4. 10 This is used to tweak build flags for gcc 4.4.
11 """ 11 """
12 12
13 import os 13 import os
14 import re 14 import re
15 import subprocess 15 import subprocess
16 import sys 16 import sys
17 17
18 def GetVersion(compiler): 18 def GetVersion(compiler):
19 try: 19 try:
20 # Note that compiler could be something tricky like "distcc g++". 20 # Note that compiler could be something tricky like "distcc g++".
21 compiler = compiler + " -dumpversion" 21 compiler = compiler + " -dumpversion"
22 pipe = subprocess.Popen(compiler, stdout=subprocess.PIPE, shell=True) 22 pipe = subprocess.Popen(compiler, stdout=subprocess.PIPE, shell=True)
23 gcc_output = pipe.communicate()[0] 23 gcc_output = pipe.communicate()[0]
24 result = re.match(r"(\d+)\.(\d+)\..*", gcc_output) 24 result = re.match(r"(\d+)\.(\d+)", gcc_output)
25 return result.group(1) + result.group(2) 25 return result.group(1) + result.group(2)
26 except Exception, e: 26 except Exception, e:
27 print >> sys.stderr, "compiler_version.py failed to execute:", compiler 27 print >> sys.stderr, "compiler_version.py failed to execute:", compiler
28 print >> sys.stderr, e 28 print >> sys.stderr, e
29 return "" 29 return ""
30 30
31 def main(): 31 def main():
32 # Check if CXX environment variable exists and 32 # Check if CXX environment variable exists and
33 # if it does use that compiler. 33 # if it does use that compiler.
34 cxx = os.getenv("CXX", None) 34 cxx = os.getenv("CXX", None)
35 if cxx: 35 if cxx:
36 cxxversion = GetVersion(cxx) 36 cxxversion = GetVersion(cxx)
37 if cxxversion != "": 37 if cxxversion != "":
38 print cxxversion 38 print cxxversion
39 return 0 39 return 0
40 else: 40 else:
41 # Otherwise we check the g++ version. 41 # Otherwise we check the g++ version.
42 gccversion = GetVersion("g++") 42 gccversion = GetVersion("g++")
43 if gccversion != "": 43 if gccversion != "":
44 print gccversion 44 print gccversion
45 return 0 45 return 0
46 46
47 return 1 47 return 1
48 48
49 if __name__ == "__main__": 49 if __name__ == "__main__":
50 sys.exit(main()) 50 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