blob: 3c2af63a3d1a2bd1371bbac9b5e4acfc49feb7aa (
plain)
| 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
 | class ClangFormat < Formula
  homepage "http://clang.llvm.org/docs/ClangFormat.html"
  version "2015-04-02"
  bottle do
    cellar :any
    sha256 "79a12aaabc9806d374c21ca8b53a21e3bc1e13b039fd41ad2325a8bd269bb329" => :yosemite
    sha256 "f08ca4d9150aa7dcec0c2facfddea992c642d8014e41445000172d7737a61f29" => :mavericks
    sha256 "a9c87c981a293db81d04f520ac6602bcf77a43d69312533311c9dd1da3dc98c0" => :mountain_lion
  end
  stable do
    url "http://llvm.org/svn/llvm-project/llvm/tags/google/testing/2015-04-02/", :using => :svn
    resource "clang" do
      url "http://llvm.org/svn/llvm-project/cfe/tags/google/testing/2015-04-02/", :using => :svn
    end
    resource "libcxx" do
      url "http://llvm.org/releases/3.6.0/libcxx-3.6.0.src.tar.xz"
      sha1 "5445194366ae2291092fd2204030cb3d01ad6272"
    end
  end
  head do
    url "http://llvm.org/svn/llvm-project/llvm/trunk/", :using => :svn
    resource "clang" do
      url "http://llvm.org/svn/llvm-project/cfe/trunk/", :using => :svn
    end
    resource "libcxx" do
      url "http://llvm.org/releases/3.6.0/libcxx-3.6.0.src.tar.xz"
      sha1 "5445194366ae2291092fd2204030cb3d01ad6272"
    end
  end
  depends_on "cmake" => :build
  depends_on "ninja" => :build
  depends_on "subversion" => :build
  def install
    (buildpath/"projects/libcxx").install resource("libcxx")
    (buildpath/"tools/clang").install resource("clang")
    mkdir "build" do
      args = std_cmake_args
      args << "-DLLVM_ENABLE_LIBCXX=ON"
      args << ".."
      system "cmake", "-G", "Ninja", *args
      system "ninja", "clang-format"
      bin.install "bin/clang-format"
    end
    bin.install "tools/clang/tools/clang-format/git-clang-format"
  end
  test do
    # NB: below C code is messily formatted on purpose.
    (testpath/"test.c").write <<-EOS
      int         main(char *args) { \n   \t printf("hello"); }
    EOS
    assert_equal "int main(char *args) { printf(\"hello\"); }\n",
        shell_output("#{bin}/clang-format -style=Google test.c")
  end
end
 |