| 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 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 return result.group(1) + result.group(2) | 53 return result.group(1) + result.group(2) |
| 54 except Exception, e: | 54 except Exception, e: |
| 55 if tool_error: | 55 if tool_error: |
| 56 sys.stderr.write(tool_error) | 56 sys.stderr.write(tool_error) |
| 57 print >> sys.stderr, "compiler_version.py failed to execute:", compiler | 57 print >> sys.stderr, "compiler_version.py failed to execute:", compiler |
| 58 print >> sys.stderr, e | 58 print >> sys.stderr, e |
| 59 return "" | 59 return "" |
| 60 | 60 |
| 61 | 61 |
| 62 def main(args): | 62 def main(args): |
| 63 # Force the locale to C otherwise the version string could be localized |
| 64 # making regex matching fail. |
| 65 os.environ["LC_ALL"] = "C" |
| 66 |
| 63 tool = "compiler" | 67 tool = "compiler" |
| 64 if len(args) == 1: | 68 if len(args) == 1: |
| 65 tool = args[0] | 69 tool = args[0] |
| 66 elif len(args) > 1: | 70 elif len(args) > 1: |
| 67 print "Unknown arguments!" | 71 print "Unknown arguments!" |
| 68 | 72 |
| 69 # Check if CXX environment variable exists and | 73 # Check if CXX environment variable exists and |
| 70 # if it does use that compiler. | 74 # if it does use that compiler. |
| 71 cxx = os.getenv("CXX", None) | 75 cxx = os.getenv("CXX", None) |
| 72 if cxx: | 76 if cxx: |
| 73 cxxversion = GetVersion(cxx, tool) | 77 cxxversion = GetVersion(cxx, tool) |
| 74 if cxxversion != "": | 78 if cxxversion != "": |
| 75 print cxxversion | 79 print cxxversion |
| 76 return 0 | 80 return 0 |
| 77 else: | 81 else: |
| 78 # Otherwise we check the g++ version. | 82 # Otherwise we check the g++ version. |
| 79 gccversion = GetVersion("g++", tool) | 83 gccversion = GetVersion("g++", tool) |
| 80 if gccversion != "": | 84 if gccversion != "": |
| 81 print gccversion | 85 print gccversion |
| 82 return 0 | 86 return 0 |
| 83 | 87 |
| 84 return 1 | 88 return 1 |
| 85 | 89 |
| 86 | 90 |
| 87 if __name__ == "__main__": | 91 if __name__ == "__main__": |
| 88 sys.exit(main(sys.argv[1:])) | 92 sys.exit(main(sys.argv[1:])) |
| OLD | NEW |