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

Side by Side Diff: build/compiler_version.py

Issue 195923004: Fixing compiler_version for Fedora. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 9 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
« 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 """
11 11
12 import os 12 import os
13 import re 13 import re
14 import subprocess 14 import subprocess
15 import sys 15 import sys
16 16
17 17
18 def GetVersion(compiler, tool): 18 def GetVersion(compiler, tool):
19 tool_output = tool_error = None 19 tool_output = tool_error = None
20 try: 20 try:
21 # Note that compiler could be something tricky like "distcc g++". 21 # Note that compiler could be something tricky like "distcc g++".
22 if tool == "compiler": 22 if tool == "compiler":
23 compiler = compiler + " -dumpversion" 23 compiler = compiler + " -dumpversion"
24 # 4.6 24 # 4.6
25 version_re = re.compile(r"(\d+)\.(\d+)") 25 version_re = re.compile(r"(\d+)\.(\d+)")
26 elif tool == "assembler": 26 elif tool == "assembler":
27 compiler = compiler + " -Xassembler --version -x assembler -c /dev/null" 27 compiler = compiler + " -Xassembler --version -x assembler -c /dev/null"
28 # GNU assembler (GNU Binutils for Ubuntu) 2.22 28 # Unmodified: GNU assembler (GNU Binutils) 2.24
29 version_re = re.compile(r"GNU [^ ]+ \(.*\) (\d+).(\d+)") 29 # Ubuntu: GNU assembler (GNU Binutils for Ubuntu) 2.22
30 # Fedora: GNU assembler version 2.23.2
31 version_re = re.compile(r"^GNU [^ ]+ .* (\d+).(\d+).*?$", re.M)
30 elif tool == "linker": 32 elif tool == "linker":
31 compiler = compiler + " -Xlinker --version" 33 compiler = compiler + " -Xlinker --version"
32 # GNU gold (GNU Binutils for Ubuntu 2.22) 1.11 34 # Using BFD linker
33 version_re = re.compile(r"GNU [^ ]+ \(.*\) (\d+).(\d+)") 35 # Unmodified: GNU ld (GNU Binutils) 2.24
36 # Ubuntu: GNU ld (GNU Binutils for Ubuntu) 2.22
37 # Fedora: GNU ld version 2.23.2
38 # Using Gold linker
39 # Unmodified: GNU gold (GNU Binutils 2.24) 1.11
40 # Ubuntu: GNU gold (GNU Binutils for Ubuntu 2.22) 1.11
41 # Fedora: GNU gold (version 2.23.2) 1.11
42 version_re = re.compile(r"^GNU [^ ]+ .* (\d+).(\d+).*?$", re.M)
34 else: 43 else:
35 raise Exception("Unknown tool %s" % tool) 44 raise Exception("Unknown tool %s" % tool)
36 45
37 pipe = subprocess.Popen(compiler, shell=True, 46 pipe = subprocess.Popen(compiler, shell=True,
38 stdout=subprocess.PIPE, stderr=subprocess.PIPE) 47 stdout=subprocess.PIPE, stderr=subprocess.PIPE)
39 tool_output, tool_error = pipe.communicate() 48 tool_output, tool_error = pipe.communicate()
40 if pipe.returncode: 49 if pipe.returncode:
41 raise subprocess.CalledProcessError(pipe.returncode, compiler) 50 raise subprocess.CalledProcessError(pipe.returncode, compiler)
42 51
43 result = version_re.match(tool_output) 52 result = version_re.match(tool_output)
(...skipping 26 matching lines...) Expand all
70 gccversion = GetVersion("g++", tool) 79 gccversion = GetVersion("g++", tool)
71 if gccversion != "": 80 if gccversion != "":
72 print gccversion 81 print gccversion
73 return 0 82 return 0
74 83
75 return 1 84 return 1
76 85
77 86
78 if __name__ == "__main__": 87 if __name__ == "__main__":
79 sys.exit(main(sys.argv[1:])) 88 sys.exit(main(sys.argv[1:]))
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