93 lines
2.7 KiB
Ruby
93 lines
2.7 KiB
Ruby
class Gecode < Formula
|
|
desc "Toolkit for developing constraint-based systems and applications"
|
|
homepage "http://www.gecode.org/"
|
|
url "https://github.com/Gecode/gecode/archive/release-6.0.1.tar.gz"
|
|
sha256 "8bef2fd195a99d28c83018255bd88e30f033007859cccee26f20e9e2683dcc82"
|
|
|
|
bottle do
|
|
cellar :any
|
|
sha256 "9f2ce554a2852d01938f6e87f078eff106ae6e6fc4f57de2847d0ad37a504129" => :mojave
|
|
sha256 "da783568e09b883d70dd917593545d8031468d6315ec7a26294f11b3c31e223b" => :high_sierra
|
|
sha256 "32c20941d3c2fd4f4aa215e5e2b1986592f0d823a10eb2ff9caf97ed779802fe" => :sierra
|
|
sha256 "f75705cf2c1313eeb00e99c4699bb631b0c8ff4911ea322bc53c424e502d68cb" => :el_capitan
|
|
end
|
|
|
|
deprecated_option "with-qt5" => "with-qt"
|
|
|
|
depends_on "qt" => :optional
|
|
|
|
def install
|
|
args = %W[
|
|
--prefix=#{prefix}
|
|
--disable-examples
|
|
]
|
|
ENV.cxx11
|
|
if build.with? "qt"
|
|
args << "--enable-qt"
|
|
ENV.append_path "PKG_CONFIG_PATH", "#{HOMEBREW_PREFIX}/opt/qt/lib/pkgconfig"
|
|
else
|
|
args << "--disable-qt"
|
|
end
|
|
system "./configure", *args
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
(testpath/"test.cpp").write <<~EOS
|
|
#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(Test& s) : Script(s) {
|
|
v.update(*this, s.v);
|
|
}
|
|
virtual Space* copy() {
|
|
return new Test(*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/qt/include
|
|
-I#{include}
|
|
-lgecodedriver
|
|
-lgecodesearch
|
|
-lgecodeint
|
|
-lgecodekernel
|
|
-lgecodesupport
|
|
-L#{lib}
|
|
-o test
|
|
]
|
|
args << "-lgecodegist" if build.with? "qt"
|
|
system ENV.cxx, "test.cpp", *args
|
|
assert_match "{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}", shell_output("./test")
|
|
end
|
|
end
|