[llvm-commits] [zorg] r101735 - /zorg/trunk/lnt/lnt/testing/util/compilers.py

Daniel Dunbar daniel at zuster.org
Sun Apr 18 12:18:30 PDT 2010


Author: ddunbar
Date: Sun Apr 18 14:18:30 2010
New Revision: 101735

URL: http://llvm.org/viewvc/llvm-project?rev=101735&view=rev
Log:
LNT: Refine compiler interrogation to get branch and tag information from gcc,
llvm-gcc, and clang, and to get source revision information from Clang.

Modified:
    zorg/trunk/lnt/lnt/testing/util/compilers.py

Modified: zorg/trunk/lnt/lnt/testing/util/compilers.py
URL: http://llvm.org/viewvc/llvm-project/zorg/trunk/lnt/lnt/testing/util/compilers.py?rev=101735&r1=101734&r2=101735&view=diff
==============================================================================
--- zorg/trunk/lnt/lnt/testing/util/compilers.py (original)
+++ zorg/trunk/lnt/lnt/testing/util/compilers.py Sun Apr 18 14:18:30 2010
@@ -40,42 +40,51 @@
         error("unable to determine compiler version: %r: %r" % (cc, version_ln))
     cc_name,cc_version_num,cc_build_string,cc_extra = m.groups()
 
-    # Compute normalized compiler name and type.
+    # Compute normalized compiler name and type. We try to grab source
+    # revisions, branches, and tags when possible.
     cc_build = None
+    cc_src_branch = None
+    cc_src_revision = None
+    cc_src_tag = None
     llvm_capable = False
     if (cc_name, cc_extra) == ('gcc',''):
         cc_norm_name = 'gcc'
-        m = re.match(r'\(Apple Inc. build [0-9]*\)', cc_build_string)
+        m = re.match(r'\(Apple Inc. build ([0-9]*)\)', cc_build_string)
         if m:
             cc_build = 'PROD'
+            cc_src_tag, = m.groups()
         else:
             error('unable to determine gcc build version: %r' % cc_build_string)
-    elif (cc_name, cc_extra) == ('clang',''):
+    elif (cc_name, cc_extra) in (('clang',''), ('Apple clang','')):
         llvm_capable = True
-        cc_norm_name = 'clang'
-        m = re.search('clang-([0-9]*)', cc_build_string)
-        if m:
-            cc_build = 'PROD'
+        if cc_name == 'Apple clang':
+            cc_norm_name = 'apple_clang'
         else:
-            # FIXME: Make this stricter.
-            # FIXME: Detect source versions.
-            cc_build = 'DEV'
-    elif (cc_name, cc_extra) == ('Apple clang',''):
-        llvm_capable = True
-        cc_norm_name = 'apple_clang'
+            cc_norm_name = 'clang'
         m = re.search('clang-([0-9]*)', cc_build_string)
         if m:
             cc_build = 'PROD'
+            cc_src_tag, = m.groups()
         else:
-            # FIXME: Make this stricter.
-            # FIXME: Detect source versions.
             cc_build = 'DEV'
+            m = re.match(r'\(([^ ]+) ([0-9]+)\)', cc_build_string)
+            if m:
+                cc_src_branch,cc_src_revision = m.groups()
+
+                # These show up with git-svn.
+                if cc_src_branch == '$URL$':
+                    cc_src_branch = None
+            else:
+                error('unable to determine Clang development build info: %r' % (
+                        (cc_name, cc_build_string),))
     elif cc_name == 'gcc' and 'LLVM build' in cc_extra:
         llvm_capable = True
         cc_norm_name = 'llvm-gcc'
-        m = re.match(r' \(LLVM build( [0-9]+)?\)', cc_extra)
+        m = re.match(r' \(LLVM build ([0-9.]+)\)', cc_extra)
         if m:
             llvm_build, = m.groups()
+            if llvm_build:
+                cc_src_tag = llvm_build.strip()
             cc_build = 'PROD'
         else:
             cc_build = 'DEV'
@@ -103,7 +112,7 @@
     cc1_exec_hash = hashlib.sha1()
     cc1_exec_hash.update(open(cc1_binary,'rb').read())
 
-    return { 'cc_build' : cc_build,
+    info = { 'cc_build' : cc_build,
              'cc_name' : cc_norm_name,
              'cc_version_number' : cc_version_num,
              'cc_target' : cc_target,
@@ -111,5 +120,16 @@
              'cc_exec_hash' : cc_exec_hash.hexdigest(),
              'cc1_exec_hash' : cc1_exec_hash.hexdigest(),
              }
+    if cc_src_tag is not None:
+        info['cc_src_tag'] = cc_src_tag
+    if cc_src_revision is not None:
+        info['cc_src_revision'] = cc_src_revision
+    if cc_src_branch is not None:
+        info['cc_src_branch'] = cc_src_branch
+    return info
 
 __all__ = [get_cc_info]
+
+if __name__ == '__main__':
+    import pprint, sys
+    pprint.pprint(get_cc_info(sys.argv[1], sys.argv[2:]))





More information about the llvm-commits mailing list