kmensah created this revision.
kmensah added a reviewer: djasper.
kmensah added a subscriber: cfe-commits.
kmensah set the repository for this revision to rL LLVM.

A command line option that lets users of the script specify which clang-format 
binary to use. Useful if clang-format is not on PATH or you want more control 
over which binary gets chosen.

Repository:
  rL LLVM

http://reviews.llvm.org/D16363

Files:
  clang-format-diff.py

Index: clang-format-diff.py
===================================================================
--- clang-format-diff.py
+++ clang-format-diff.py
@@ -30,11 +30,8 @@
 import StringIO
 import sys
 
+binary_default = 'clang-format'
 
-# Change this to the full path if clang-format is not on the path.
-binary = 'clang-format'
-
-
 def main():
   parser = argparse.ArgumentParser(description=
                                    'Reformat changed lines in diff. Without -i 
'
@@ -60,6 +57,11 @@
       '-style',
       help=
       'formatting style to apply (LLVM, Google, Chromium, Mozilla, WebKit)')
+  parser.add_argument(
+      '-binary',
+      default=binary_default,
+      help=
+      'location of binary to use for clang-format')
   args = parser.parse_args()
 
   # Extract changed lines for each file.
@@ -95,7 +97,7 @@
   for filename, lines in lines_by_file.iteritems():
     if args.i and args.verbose:
       print 'Formatting', filename
-    command = [binary, filename]
+    command = [args.binary, filename]
     if args.i:
       command.append('-i')
     if args.sort_includes:


Index: clang-format-diff.py
===================================================================
--- clang-format-diff.py
+++ clang-format-diff.py
@@ -30,11 +30,8 @@
 import StringIO
 import sys
 
+binary_default = 'clang-format'
 
-# Change this to the full path if clang-format is not on the path.
-binary = 'clang-format'
-
-
 def main():
   parser = argparse.ArgumentParser(description=
                                    'Reformat changed lines in diff. Without -i '
@@ -60,6 +57,11 @@
       '-style',
       help=
       'formatting style to apply (LLVM, Google, Chromium, Mozilla, WebKit)')
+  parser.add_argument(
+      '-binary',
+      default=binary_default,
+      help=
+      'location of binary to use for clang-format')
   args = parser.parse_args()
 
   # Extract changed lines for each file.
@@ -95,7 +97,7 @@
   for filename, lines in lines_by_file.iteritems():
     if args.i and args.verbose:
       print 'Formatting', filename
-    command = [binary, filename]
+    command = [args.binary, filename]
     if args.i:
       command.append('-i')
     if args.sort_includes:
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to