Skip to content
This repository has been archived by the owner. It is now read-only.
Browse files

clang-format 2014-12-03 (new formula)

clang-format is a versatile source code formatter, part of the clang
(and thus llvm) project. It can be used for C++, ObjC, Java, and

The build is using cmake and ninja for speed; building all of llvm or
using configure and make is very slow.

clang-format is released in roughly monthly testing pushes, tracked by
the subversion tags in "google/testing/yyyy-MM-dd". This formula uses
tarballs from github that correspond to the resolved tags.

Closes #35777.

Signed-off-by: Mike McQuaid <>
  • Loading branch information
mprobst authored and MikeMcQuaid committed Jan 9, 2015
1 parent bc27b18 commit 08e363cd65a20f27cc2980a9f75c2db1f7c11723
Showing with 47 additions and 0 deletions.
  1. +47 −0 Library/Formula/clang-format.rb
@@ -0,0 +1,47 @@
class ClangFormat < Formula
homepage ""
version "2014-12-03"

stable do
url "", :using => :svn

resource "clang" do
url "", :using => :svn

resource "libcxx" do
url ""
sha1 "c98beed86ae1adf9ab7132aeae8fd3b0893ea995"

depends_on "cmake" => :build
depends_on "ninja" => :build
depends_on "subversion" => :build

fails_with :clang do
build 503
cause "Host Clang must be able to find libstdc++4.7 or newer!"

def install
(buildpath/"projects/libcxx").install resource("libcxx")
(buildpath/"tools/clang").install resource("clang")

mkdir "build" do
system "cmake", "..", "-G", "Ninja", *std_cmake_args
system "ninja", "clang-format"
bin.install "bin/clang-format"

test do
# NB: below C code is messily formatted on purpose.
(testpath/"test.c").write <<-EOS
int main(char *args) { \n \t printf("hello"); }

assert_equal "int main(char *args) { printf(\"hello\"); }\n",
shell_output("#{bin}/clang-format -style=Google test.c")

3 comments on commit 08e363c


This comment has been minimized.

Copy link

alexeagle replied Feb 24, 2015

[I'm working with Martin]

@MikeMcQuaid is there a particular reason -DCMAKE_BUILD_TYPE=None is in *std_cmake_args ?

When I build this formula with -DCMAKE_BUILD_TYPE=Release I get a 1.4MB binary, but the current formula produces a 3MB binary. I'd like to send a PR to change it, but want to understand if there is a reason for this comment:
"Setting it to Release would ignore our flags."



This comment has been minimized.

Copy link

MikeMcQuaid replied Feb 25, 2015

We want to set our own e.g. CFLAGS and CMAKE_BUILD_TYPE=Release sets the flags to the CMake defaults.


This comment has been minimized.

Copy link

alexeagle replied Feb 25, 2015

It seems like that results in this (and probably other) binaries being larger than needed. I wonder if some are even compiled with debug instead of opt?
I'm no expert on C++ compilation, and I've built my own smaller clang-format for my own needs, so I'll just drop this thread.

Please sign in to comment.
You can’t perform that action at this time.