64 lines
2.1 KiB
Ruby
64 lines
2.1 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 "2018-08-24"
|
|
|
|
stable do
|
|
url "http://llvm.org/svn/llvm-project/llvm/tags/google/stable/2018-08-24/", :using => :svn
|
|
|
|
resource "clang" do
|
|
url "http://llvm.org/svn/llvm-project/cfe/tags/google/stable/2018-08-24/", :using => :svn
|
|
end
|
|
end
|
|
|
|
bottle do
|
|
cellar :any_skip_relocation
|
|
sha256 "044c2421bad8b1bf9ea7a46f24ed1d38b17a03026912d11123267a6e21158ccd" => :mojave
|
|
sha256 "70ef7442789f00efee33a1f8f9f19e0adbdfb7e12043116bb32d96c5fe193183" => :high_sierra
|
|
sha256 "1e161424469607f99788422ad8f9e85675c8a8842c30c585b0c0630a5da6a7d3" => :sierra
|
|
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
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "ninja" => :build
|
|
depends_on "subversion" => :build
|
|
|
|
resource "libcxx" do
|
|
url "https://releases.llvm.org/7.0.0/libcxx-7.0.0.src.tar.xz"
|
|
sha256 "9b342625ba2f4e65b52764ab2061e116c0337db2179c6bce7f9a0d70c52134f0"
|
|
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
|