Permalink
Browse files

clang-format detection cleanup.

  • Loading branch information...
1 parent 741685d commit 73d48e188b849a718a7c11a79338a745e5a0d0fd @benvanik committed Aug 1, 2015
Showing with 31 additions and 20 deletions.
  1. +6 −0 .travis.yml
  2. +24 −19 xenia-build
  3. +1 −1 xeniarc
View
@@ -10,6 +10,12 @@ os:
- linux
# - osx
+addons:
+ apt:
+ packages:
+ - clang-3.7
+ - clang-format-3.7
+
git:
# We handle submodules ourselves in xenia-build setup.
submodules: false
View
@@ -215,6 +215,27 @@ def git_submodule_update():
])
+def get_clang_format_binary():
+ """Finds a clang-format binary. Aborts if none is found.
+
+ Returns:
+ A path to the clang-format executable.
+ """
+ attempts = [
+ 'C:\\Program Files (x86)\\LLVM\\bin\\clang-format.exe',
+ 'clang-format-3.7',
+ 'clang-format',
+ ]
+ for binary in attempts:
+ if os.path.exists(binary):
+ return binary
+ print 'ERROR: clang-format is not on PATH'
+ print 'LLVM is available from http://llvm.org/releases/download.html'
+ print 'At least version 3.7 is required.'
+ print 'See docs/style_guide.md for instructions on how to get it.'
+ sys.exit(1)
+
+
def run_premake(target_os, action):
"""Runs premake on the main project with the given format.
@@ -744,15 +765,7 @@ class LintCommand(Command):
help='Lints all files changed relative to origin/master.')
def execute(self, args, pass_args, cwd):
- clang_format_binary = 'clang-format'
- win32_binary = 'C:\\Program Files (x86)\\LLVM\\bin\\clang-format.exe'
- if os.path.exists(win32_binary):
- clang_format_binary = win32_binary
- if not has_bin(clang_format_binary):
- print 'ERROR: clang-format is not on PATH'
- print 'LLVM is available from http://llvm.org/releases/download.html'
- print 'See docs/style_guide.md for instructions on how to get it'
- return 1
+ clang_format_binary = get_clang_format_binary()
difftemp = '.difftemp.txt'
@@ -791,7 +804,7 @@ class LintCommand(Command):
difftemp,
])
shell_call([
- 'type',
+ 'type' if sys.platform=='win32' else 'cat',
difftemp,
])
if os.path.exists(difftemp): os.remove(difftemp)
@@ -851,15 +864,7 @@ class FormatCommand(Command):
help='Formats all files changed relative to origin/master.')
def execute(self, args, pass_args, cwd):
- clang_format_binary = 'clang-format'
- win32_binary = 'C:\\Program Files (x86)\\LLVM\\bin\\clang-format.exe'
- if os.path.exists(win32_binary):
- clang_format_binary = win32_binary
- if not has_bin(clang_format_binary):
- print 'ERROR: clang-format is not on PATH'
- print 'LLVM is available from http://llvm.org/releases/download.html'
- print 'See docs/style_guide.md for instructions on how to get it'
- return 1
+ clang_format_binary = get_clang_format_binary()
if args['all']:
all_files = [os.path.join(root, name)
View
@@ -2,4 +2,4 @@
#
# Useful bash aliases and completions.
-alias xb='python xenia-build.py'
+alias xb='python xenia-build'

0 comments on commit 73d48e1

Please sign in to comment.