64 lines
1.7 KiB
Ruby
64 lines
1.7 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.15.0.tar.gz"
|
|
sha256 "6f7304c1644f6212c3b86542f8325e6f76cd268b787fbfbbe3cc0de61ddec14a"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "64591a0ced2e6ecd71e43e773ec1ae8dd8f0a1fe3507ecb121e665db02a8f21c" => :catalina
|
|
sha256 "7f8b23196d449a572f0e7061d33a509c479c7f526fae9a9754388f645e601bcc" => :mojave
|
|
sha256 "87c8b380a96b5f9cfe0ee6de72f837ee5f1b61fc5777a0cb35d538b262f4ba01" => :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
|