homebrew-core/Formula/comby.rb

65 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.18.3.tar.gz"
sha256 "554ec0fa7c8da8aa9ae74bdd6d3f7ba32e0f553ff9bb12c7add6541cd4ec27d8"
license "Apache-2.0"
bottle do
cellar :any
sha256 "959812e91094978e5373616ed3063ba60d3c931cb9aa01d25423f63afda70aa0" => :catalina
sha256 "f939a6986d210cdd1c670f22c43ea2cb0826e57efc3b62a192e2b4271a7505e8" => :mojave
sha256 "fcd39a3f32104e6fe6141ea87c93c334f2c30c57f44500070f8a8a0045e0e785" => :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
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