homebrew-core/Formula/gecode.rb

93 lines
2.6 KiB
Ruby

class Gecode < Formula
desc "Toolkit for developing constraint-based systems and applications"
homepage "http://www.gecode.org/"
url "http://www.gecode.org/download/gecode-5.0.0.tar.gz"
sha256 "f4ff2fa115fed8c09a049b2d8520363b1f9b1a39d80461f597e29dab2ba9e77b"
bottle do
cellar :any
sha256 "b07a271d4087f7816cce5123c74f0e543527cd315ae5a9fd8d2f2ff31950cbfd" => :sierra
sha256 "5069485f83581c158bdc1d0a79fa89daaf044cc4fef6967a595d09e8c77c7466" => :el_capitan
sha256 "b02d94fdeb69e26e4de952c62d3955586cf23cd8b15bca7d3caa018ecd9848db" => :yosemite
end
depends_on "qt5" => :optional
def install
args = %W[
--prefix=#{prefix}
--disable-examples
]
ENV.cxx11
if build.with? "qt5"
args << "--enable-qt"
ENV.append_path "PKG_CONFIG_PATH", "#{HOMEBREW_PREFIX}/opt/qt5/lib/pkgconfig"
else
args << "--disable-qt"
end
system "./configure", *args
system "make", "install"
end
test do
(testpath/"test.cpp").write <<-EOS.undent
#include <gecode/driver.hh>
#include <gecode/int.hh>
#if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
#include <QtGui/QtGui>
#if QT_VERSION >= 0x050000
#include <QtWidgets/QtWidgets>
#endif
#endif
using namespace Gecode;
class Test : public Script {
public:
IntVarArray v;
Test(const Options& o) : Script(o) {
v = IntVarArray(*this, 10, 0, 10);
distinct(*this, v);
branch(*this, v, INT_VAR_NONE(), INT_VAL_MIN());
}
Test(bool share, Test& s) : Script(share, s) {
v.update(*this, share, s.v);
}
virtual Space* copy(bool share) {
return new Test(share, *this);
}
virtual void print(std::ostream& os) const {
os << v << std::endl;
}
};
int main(int argc, char* argv[]) {
Options opt("Test");
opt.iterations(500);
#if defined(GECODE_HAS_QT) && defined(GECODE_HAS_GIST)
Gist::Print<Test> p("Print solution");
opt.inspect.click(&p);
#endif
opt.parse(argc, argv);
Script::run<Test, DFS, Options>(opt);
return 0;
}
EOS
args = %W[
-std=c++11
-I#{HOMEBREW_PREFIX}/opt/qt5/include
-I#{include}
-lgecodedriver
-lgecodesearch
-lgecodeint
-lgecodekernel
-lgecodesupport
-L#{lib}
-o test
]
if build.with? "qt5"
args << "-lgecodegist"
end
system ENV.cxx, "test.cpp", *args
assert_match "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}", shell_output("./test")
end
end