| OLD | NEW |
| 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 10 matching lines...) Expand all Loading... |
| 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 # Unmodified: GNU assembler (GNU Binutils) 2.24 | 28 # Unmodified: GNU assembler (GNU Binutils) 2.24 |
| 29 # Ubuntu: GNU assembler (GNU Binutils for Ubuntu) 2.22 | 29 # Ubuntu: GNU assembler (GNU Binutils for Ubuntu) 2.22 |
| 30 # Fedora: GNU assembler version 2.23.2 | 30 # Fedora: GNU assembler version 2.23.2 |
| 31 version_re = re.compile(r"^GNU [^ ]+ .* (\d+)\.(\d+)\.*?$", re.M) | 31 version_re = re.compile(r"^GNU [^ ]+ .* (\d+).(\d+).*?$", re.M) |
| 32 elif tool == "linker": | 32 elif tool == "linker": |
| 33 compiler = compiler + " -Xlinker --version" | 33 compiler = compiler + " -Xlinker --version" |
| 34 # Using BFD linker | 34 # Using BFD linker |
| 35 # Unmodified: GNU ld (GNU Binutils) 2.24 | 35 # Unmodified: GNU ld (GNU Binutils) 2.24 |
| 36 # Ubuntu: GNU ld (GNU Binutils for Ubuntu) 2.22 | 36 # Ubuntu: GNU ld (GNU Binutils for Ubuntu) 2.22 |
| 37 # Fedora: GNU ld version 2.23.2 | 37 # Fedora: GNU ld version 2.23.2 |
| 38 # Using Gold linker | 38 # Using Gold linker |
| 39 # Unmodified: GNU gold (GNU Binutils 2.24) 1.11 | 39 # Unmodified: GNU gold (GNU Binutils 2.24) 1.11 |
| 40 # Ubuntu: GNU gold (GNU Binutils for Ubuntu 2.22) 1.11 | 40 # Ubuntu: GNU gold (GNU Binutils for Ubuntu 2.22) 1.11 |
| 41 # Fedora: GNU gold (version 2.23.2) 1.11 | 41 # Fedora: GNU gold (version 2.23.2) 1.11 |
| 42 version_re = re.compile(r"^GNU [^ ]+ .* (\d+)\.(\d+)\.*?$", re.M) | 42 version_re = re.compile(r"^GNU [^ ]+ .* (\d+).(\d+).*?$", re.M) |
| 43 else: | 43 else: |
| 44 raise Exception("Unknown tool %s" % tool) | 44 raise Exception("Unknown tool %s" % tool) |
| 45 | 45 |
| 46 pipe = subprocess.Popen(compiler, shell=True, | 46 pipe = subprocess.Popen(compiler, shell=True, |
| 47 stdout=subprocess.PIPE, stderr=subprocess.PIPE) | 47 stdout=subprocess.PIPE, stderr=subprocess.PIPE) |
| 48 tool_output, tool_error = pipe.communicate() | 48 tool_output, tool_error = pipe.communicate() |
| 49 if pipe.returncode: | 49 if pipe.returncode: |
| 50 raise subprocess.CalledProcessError(pipe.returncode, compiler) | 50 raise subprocess.CalledProcessError(pipe.returncode, compiler) |
| 51 | 51 |
| 52 result = version_re.match(tool_output) | 52 result = version_re.match(tool_output) |
| (...skipping 26 matching lines...) Expand all Loading... |
| 79 gccversion = GetVersion("g++", tool) | 79 gccversion = GetVersion("g++", tool) |
| 80 if gccversion != "": | 80 if gccversion != "": |
| 81 print gccversion | 81 print gccversion |
| 82 return 0 | 82 return 0 |
| 83 | 83 |
| 84 return 1 | 84 return 1 |
| 85 | 85 |
| 86 | 86 |
| 87 if __name__ == "__main__": | 87 if __name__ == "__main__": |
| 88 sys.exit(main(sys.argv[1:])) | 88 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |