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

Unified Diff: build/compiler_version.py

Issue 197013010: Enable debug fission for Chrome debug builds. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Rebase onto master. 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 side-by-side diff with in-line comments
Download patch
« build/common.gypi ('K') | « build/common.gypi ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: build/compiler_version.py
diff --git a/build/compiler_version.py b/build/compiler_version.py
index b349199992caeefc5c63b227083a98a5400fda3f..bc3bee55947e0ef009e03868eb1e9f3503e73901 100755
--- a/build/compiler_version.py
+++ b/build/compiler_version.py
@@ -14,42 +14,66 @@ import re
import subprocess
import sys
-def GetVersion(compiler):
+
+def GetVersion(compiler, tool):
+ tool_output = tool_error = None
try:
# Note that compiler could be something tricky like "distcc g++".
- compiler = compiler + " -dumpversion"
+ if tool == "compiler":
+ compiler = compiler + " -dumpversion"
+ # 4.6
+ version_re = re.compile(r"(\d+)\.(\d+)")
+ elif tool == "assembler":
+ compiler = compiler + " -Xassembler --version -x assembler -c /dev/null"
+ # GNU assembler (GNU Binutils for Ubuntu) 2.22
+ version_re = re.compile(r"GNU [^ ]+ \(.*\) (\d+).(\d+)")
+ elif tool == "linker":
+ compiler = compiler + " -Xlinker --version"
+ # GNU gold (GNU Binutils for Ubuntu 2.22) 1.11
+ version_re = re.compile(r"GNU [^ ]+ \(.*\) (\d+).(\d+)")
+ else:
+ raise Exception("Unknown tool %s" % tool)
+
pipe = subprocess.Popen(compiler, shell=True,
stdout=subprocess.PIPE, stderr=subprocess.PIPE)
- gcc_output, gcc_error = pipe.communicate()
+ tool_output, tool_error = pipe.communicate()
if pipe.returncode:
raise subprocess.CalledProcessError(pipe.returncode, compiler)
- result = re.match(r"(\d+)\.(\d+)", gcc_output)
+ result = version_re.match(tool_output)
return result.group(1) + result.group(2)
except Exception, e:
- if gcc_error:
- sys.stderr.write(gcc_error)
+ if tool_error:
+ sys.stderr.write(tool_error)
print >> sys.stderr, "compiler_version.py failed to execute:", compiler
print >> sys.stderr, e
return ""
-def main():
+
+def main(args):
+ tool = "compiler"
+ if len(args) == 1:
+ tool = args[0]
+ elif len(args) > 1:
+ print "Unknown arguments!"
Lei Zhang 2014/03/17 18:43:54 Probably should return 1 in this case?
+
# Check if CXX environment variable exists and
# if it does use that compiler.
cxx = os.getenv("CXX", None)
if cxx:
- cxxversion = GetVersion(cxx)
+ cxxversion = GetVersion(cxx, tool)
if cxxversion != "":
print cxxversion
return 0
else:
# Otherwise we check the g++ version.
- gccversion = GetVersion("g++")
+ gccversion = GetVersion("g++", tool)
if gccversion != "":
print gccversion
return 0
return 1
+
if __name__ == "__main__":
- sys.exit(main())
+ sys.exit(main(sys.argv[1:]))
« build/common.gypi ('K') | « build/common.gypi ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698