Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

clang-format@15 #4

Closed
wants to merge 15 commits into from
2 changes: 1 addition & 1 deletion .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ on:
jobs:
pr-pull:
if: contains(github.event.pull_request.labels.*.name, 'pr-pull')
runs-on: ubuntu-latest
runs-on: ubuntu-22.04
steps:
- name: Set up Homebrew
uses: Homebrew/actions/setup-homebrew@master
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ jobs:
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
# - ubuntu-22.04
- macos-12
runs-on: ${{ matrix.os }}
steps:
- name: Set up Homebrew
Expand Down Expand Up @@ -43,4 +43,4 @@ jobs:
uses: actions/upload-artifact@main
with:
name: bottles
path: "*.bottle.*"
path: '*.bottle.*'
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
tags
82 changes: 82 additions & 0 deletions Formula/clang-format@15.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
class ClangFormatAT15 < Formula
desc "Formatting tools for C, C++, Obj-C, Java, JavaScript, TypeScript"
homepage "https://clang.llvm.org/docs/ClangFormat.html"
# The LLVM Project is under the Apache License v2.0 with LLVM Exceptions
license "Apache-2.0"
version_scheme 1
head "https://github.com/llvm/llvm-project.git", branch: "main"

stable do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/llvm-15.0.7.src.tar.xz"
sha256 "4ad8b2cc8003c86d0078d15d987d84e3a739f24aae9033865c027abae93ee7a4"

resource "clang" do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/clang-15.0.7.src.tar.xz"
sha256 "a6b673ef15377fb46062d164e8ddc4d05c348ff8968f015f7f4af03f51000067"
end

resource "cmake" do
url "https://github.com/llvm/llvm-project/releases/download/llvmorg-15.0.7/cmake-15.0.7.src.tar.xz"
sha256 "8986f29b634fdaa9862eedda78513969fe9788301c9f2d938f4c10a3e7a3e7ea"
end
end

livecheck do
url :stable
regex(%r{href=.*?/tag/llvmorg[._-]v?(\d+(?:\.\d+)+)}i)
strategy :github_latest
end

depends_on "cmake" => [:build, :test]

uses_from_macos "python" => [:build, :test], since: :catalina
uses_from_macos "libxml2"
uses_from_macos "ncurses"
uses_from_macos "zlib"

on_linux do
keg_only "it conflicts with llvm"
end

def install
llvmpath = if build.head?
ln_s buildpath/"clang", buildpath/"llvm/tools/clang"

buildpath/"llvm"
else
(buildpath/"src").install buildpath.children
(buildpath/"src/tools/clang").install resource("clang")
(buildpath/"cmake").install resource("cmake")

buildpath/"src"
end

system "cmake", "-S", llvmpath, "-B", "build",
"-DLLVM_EXTERNAL_PROJECTS=clang",
"-DLLVM_INCLUDE_BENCHMARKS=OFF",
*std_cmake_args
system "cmake", "--build", "build", "--target", "clang-format"

bin.install "build/bin/clang-format" => "clang-format-15"
bin.install llvmpath/"tools/clang/tools/clang-format/git-clang-format" => "git-clang-format-15"
# (share/"clang").install llvmpath.glob("tools/clang/tools/clang-format/clang-format*")
end

test do
system "git", "init"
system "git", "commit", "--allow-empty", "-m", "initial commit", "--quiet"

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

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

# Fails with 'error: cannot find executable "clang-format"'.
# ENV.prepend_path "PATH", bin
# assert_match "test.c", shell_output("git clang-format-15", 1)
end
end
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Psiori Psiori
# psiori homebrew tap

## How do I install these formulae?

Expand Down