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

Add initial formula for Choco's FlatZinc solver #3

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
36 changes: 36 additions & 0 deletions Formula/fzn-choco.rb
@@ -0,0 +1,36 @@
class FznChoco < Formula
desc "Open-Source Java library for Constraint Programming"
homepage "https://choco-solver.org"
url "https://github.com/chocoteam/choco-solver/archive/4.10.5.tar.gz"
sha256 "c0e28db042c6f8199778243bd9fd2f3f5b9392ef493d5028e3a170e8d4b68b8c"
license "BSD-4-Clause"

depends_on "maven" => :build
depends_on "openjdk"

def install
cd "parsers" do
system "mvn", "clean", "package", "-DskipTests=true", "-Dmaven.javadoc.skip=true"
libexec.install "target/choco-parsers-#{version}-jar-with-dependencies.jar"
bin.write_jar_script libexec/"choco-parsers-#{version}-jar-with-dependencies.jar", "fzn-choco"

(share / "minizinc").mkpath
(share / "minizinc").install "src/main/minizinc/mzn_lib" => "choco"

inreplace "src/main/minizinc/choco.msc" do |s|
s.gsub! /"executable":\s+"[^"]*"/, "\"executable\": \"#{bin}/fzn-choco\""
s.gsub! /"mznlib":\s+"[^"]*"/, "\"mznlib\": \"#{share}/minizinc/choco\""
end
(share / "minizinc/solvers").mkpath
(share / "minizinc/solvers").install "src/main/minizinc/choco.msc"
end
end

test do
(testpath/"test.fzn").write <<~EOS
var bool: x1;
solve satisfy;
EOS
assert_match "----------", shell_output("#{bin}/fzn-choco test.fzn").strip
end
end