80 lines
2.6 KiB
Ruby
80 lines
2.6 KiB
Ruby
class ClangFormat < Formula
|
|
desc "Formatting tools for C, C++, Obj-C, Java, JavaScript, TypeScript"
|
|
homepage "https://clang.llvm.org/docs/ClangFormat.html"
|
|
version "2017-06-22"
|
|
|
|
stable do
|
|
if MacOS.version >= :sierra
|
|
url "https://llvm.org/svn/llvm-project/llvm/tags/google/stable/2017-06-22/", :using => :svn
|
|
else
|
|
url "http://llvm.org/svn/llvm-project/llvm/tags/google/stable/2017-06-22/", :using => :svn
|
|
end
|
|
|
|
resource "clang" do
|
|
if MacOS.version >= :sierra
|
|
url "https://llvm.org/svn/llvm-project/cfe/tags/google/stable/2017-06-22/", :using => :svn
|
|
else
|
|
url "http://llvm.org/svn/llvm-project/cfe/tags/google/stable/2017-06-22/", :using => :svn
|
|
end
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "9d02a904e0d76bbb5f814d952a8c4b3e15e0f6d671c0c53a90272fcefb0ada88" => :sierra
|
|
sha256 "184425911fe753006214f0f1dcd9c87e0e7c171f737d916445eadc760eac9eb8" => :el_capitan
|
|
sha256 "4a2146f1fc5009e79d8ca10c6371c3443ac2069e851c29e08ee01f2e710c5ff0" => :yosemite
|
|
end
|
|
|
|
head do
|
|
if MacOS.version >= :sierra
|
|
url "https://llvm.org/svn/llvm-project/llvm/trunk/", :using => :svn
|
|
else
|
|
url "http://llvm.org/svn/llvm-project/llvm/trunk/", :using => :svn
|
|
end
|
|
|
|
resource "clang" do
|
|
if MacOS.version >= :sierra
|
|
url "https://llvm.org/svn/llvm-project/cfe/trunk/", :using => :svn
|
|
else
|
|
url "http://llvm.org/svn/llvm-project/cfe/trunk/", :using => :svn
|
|
end
|
|
end
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "ninja" => :build
|
|
depends_on "subversion" => :build
|
|
|
|
resource "libcxx" do
|
|
url "https://llvm.org/releases/4.0.0/libcxx-4.0.0.src.tar.xz"
|
|
sha256 "4f4d33c4ad69bf9e360eebe6b29b7b19486948b1a41decf89d4adec12473cf96"
|
|
end
|
|
|
|
def install
|
|
(buildpath/"projects/libcxx").install resource("libcxx")
|
|
(buildpath/"tools/clang").install resource("clang")
|
|
|
|
mkdir "build" do
|
|
args = std_cmake_args
|
|
args << "-DCMAKE_OSX_SYSROOT=/" unless MacOS::Xcode.installed?
|
|
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"
|
|
(share/"clang").install Dir["tools/clang/tools/clang-format/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
|