]> granicus.if.org Git - clang/commitdiff
Make ccc work with older Python versions. Patch by Sam Bishop.
authorSeo Sanghyeon <sanxiyn@gmail.com>
Sun, 3 Feb 2008 03:40:41 +0000 (03:40 +0000)
committerSeo Sanghyeon <sanxiyn@gmail.com>
Sun, 3 Feb 2008 03:40:41 +0000 (03:40 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@46675 91177308-0d34-0410-b5e6-96231b3b80d8

utils/ccc

index 015c0318d40c733f905268b758c9e1a11246b54c..eff184392da8ae81d40b85afde5a7c22bbc953c2 100755 (executable)
--- a/utils/ccc
+++ b/utils/ccc
 #
 ##===----------------------------------------------------------------------===##
 
+import os
 import sys
-import subprocess
 
 def error(message):
     print >> sys.stderr, 'ccc: ' + message
     sys.exit(1)
 
 def run(args):
-    print >> sys.stderr, ' '.join(args)
-    code = subprocess.call(args)
+    cmd = ' '.join(args)
+    print >> sys.stderr, cmd
+    code = os.system(cmd)
     if code:
         sys.exit(code)
 
 def preprocess(args):
-    command = 'clang -E'.split()
-    run(command + args)
+    run(['clang -E'] + args)
 
 def compile(args):
-    command = 'clang -emit-llvm-bc'.split()
-    run(command + args)
+    run(['clang -emit-llvm-bc'] + args)
 
 def link(args):
-    command = 'llvm-ld -native'.split()
-    run(command + args)
+    run(['llvm-ld -native'] + args)
 
 def extension(path):
-    return path.rpartition(".")[2]
+    return path.split(".")[-1]
 
 def changeextension(path, newext):
-    components = path.rpartition(".")
-    return "".join([components[0], components[1], newext])
+    i = path.rfind('.')
+    if i < 0:
+        return path
+    return path[:i] + newext
 
 def inferlanguage(extension):
     if extension == "c":