homebrew-core/Formula/comby.rb

66 lines
1.8 KiB
Ruby

class Comby < Formula
desc "Tool for changing code across many languages"
homepage "https://comby.dev"
url "https://github.com/comby-tools/comby/archive/0.14.0.tar.gz"
sha256 "3b34b0aa2dda3d10ceee727b7784a24a227c400de0a1baee293dfaa92212fb65"
bottle do
cellar :any
sha256 "a70894b2d2837fb54d36e662f986e7cb4da6cc23e1024beec8038a3f1d7f6eec" => :catalina
sha256 "27da7f10348f831b02af4999e02fc3a4b14379365d7d651d849d274ec4b8b1f0" => :mojave
sha256 "1ad5b4430298020b63c7f4011001dc83f471dc96fc1b739d3f8174d534ac3b9c" => :high_sierra
end
depends_on "gmp" => :build
depends_on "ocaml" => :build
depends_on "opam" => :build
depends_on "pcre"
depends_on "pkg-config"
uses_from_macos "m4"
uses_from_macos "unzip"
uses_from_macos "zlib"
def install
ENV.deparallelize
opamroot = buildpath/".opam"
ENV["OPAMROOT"] = opamroot
ENV["OPAMYES"] = "1"
system "opam", "init", "--no-setup", "--disable-sandboxing"
system "opam", "config", "exec", "--", "opam", "install", ".", "--deps-only", "-y"
ENV.prepend_path "LIBRARY_PATH", opamroot/"default/lib/hack_parallel" # for -lhp
system "opam", "config", "exec", "--", "make", "release"
bin.install "_build/default/src/main.exe" => "comby"
end
test do
assert_equal version.to_s, shell_output("#{bin}/comby -version").strip
expect = <<~EXPECT
--- /dev/null
+++ /dev/null
@@ -1,3 +1,3 @@
int main(void) {
- printf("hello world!");
+ printf("comby, hello!");
}
EXPECT
input = <<~INPUT
EOF
int main(void) {
printf("hello world!");
}
EOF
INPUT
match = 'printf(":[1] :[2]!")'
rewrite = 'printf("comby, :[1]!")'
assert_equal expect, shell_output("#{bin}/comby '#{match}' '#{rewrite}' .c -stdin -diff << #{input}")
end
end