Where are clang-format and clang-format.py in Mac OS X with Xcode Command Line Tools installed?

Ahmed Fasih picture Ahmed Fasih · Jan 16, 2014 · Viewed 27.2k times · Source

I am having a hard time finding clang-format and clang-format.py on my Mac OS 10.8.5 with Xcode 5 and its Command Line Tools. I tried find / -name "clang-format.py" without luck. Are they already here somewhere hiding, or how would I get this toolchain?

(I'm surprised it doesn't seem readily available since clang is Apple's compiler---in that Apple uses it.)

Answer

user289841 picture user289841 · Jan 17, 2014

Seems like Apple doesn't ship clang-format with the Command Line Tools. Right now you have at least three options:

  • Using Homebrew (That's the way to go)
  • Using prebuild packages
  • Build it yourself

Homebrew

As user johnhaley81 pointed out, clang-format is now in homebrew:

clang-format is now on brew. brew install clang-format

Please consider upvoting his post if you find this answer useful.


Prebuild packages

Pre-build bundles are available at llvm.org. For Mac OSX, you need to download the darwin package.


Build instructions:

Here's an instruction on how to do this: http://nacho4d-nacho4d.blogspot.de/2013/11/clang-format.html

And here's another one: http://blog.hardcodes.de/articles/63/building-clang-format-and-friends-on-osx-mountain-lion