homebrew-core/Formula/souffle.rb

56 lines
1.9 KiB
Ruby
Raw Normal View History

class Souffle < Formula
desc "Logic Defined Static Analysis"
homepage "https://souffle-lang.github.io"
url "https://github.com/souffle-lang/souffle/archive/refs/tags/2.3.tar.gz"
sha256 "db03f2d7a44dffb6ad5bc65637e5ba2b7c8ae6f326d83bcccb17986beadc4a31"
license "UPL-1.0"
depends_on "bison" => :build # Bison included in macOS is out of date.
depends_on "cmake" => :build
depends_on "mcpp" => :build
depends_on "pkg-config" => :build
uses_from_macos "flex" => :build
uses_from_macos "libffi"
uses_from_macos "ncurses"
uses_from_macos "sqlite"
uses_from_macos "zlib"
def install
cmake_args = [
"-DSOUFFLE_DOMAIN_64BIT=ON",
"-DSOUFFLE_GIT=OFF",
"-DSOUFFLE_BASH_COMPLETION=ON",
"-DBASH_COMPLETION_COMPLETIONSDIR=#{bash_completion}",
"-DSOUFFLE_VERSION=#{version}",
"-DPACKAGE_VERSION=#{version}",
]
system "cmake", "-S", ".", "-B", "build", *cmake_args, *std_cmake_args
inreplace "#{buildpath}/build/src/souffle-compile.py" do |s|
s.gsub!(/"compiler": ".*?"/, "\"compiler\": \"/usr/bin/c++\"")
s.gsub!(%r{-I.*?/src/include }, "")
s.gsub!(%r{"source_include_dir": ".*?/src/include"}, "\"source_include_dir\": \"#{include}\"")
end
system "cmake", "--build", "build", "-j", "--target", "install"
include.install Dir["src/include/*"]
man1.install Dir["man/*"]
end
test do
(testpath/"example.dl").write <<~EOS
.decl edge(x:number, y:number)
.input edge(delimiter=",")
.decl path(x:number, y:number)
.output path(delimiter=",")
path(x, y) :- edge(x, y).
EOS
(testpath/"edge.facts").write <<~EOS
1,2
EOS
system "#{bin}/souffle", "-F", "#{testpath}/.", "-D", "#{testpath}/.", "#{testpath}/example.dl"
assert_predicate testpath/"path.csv", :exist?
assert_equal "1,2\n", shell_output("cat #{testpath}/path.csv")
end
end