forked from ahmadia/homebrew-science
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmlpack.rb
73 lines (62 loc) · 2.45 KB
/
mlpack.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
class Mlpack < Formula
homepage "http://www.mlpack.org"
# doi "arXiv:1210.6293"
url "http://www.mlpack.org/files/mlpack-1.0.12.tar.gz"
sha256 "f47abfc2ab75f1d7f4c73a3368c4428223f025cc6fbc6703735df6a2734a838c"
bottle do
cellar :any
sha256 "38230ff4a36fe2aae5eaaeef91078aed3ae03d8c95799f8ddbf1dddeac67e815" => :yosemite
sha256 "3a644c1c52c1bc935844768791fd76c27af995ca0c79a3a2bbf7833ed6e1d16e" => :mavericks
sha256 "9b8fd8ca8c7c001a73a83796a3e200d445861c4f3aa1a9cba7c5bfa9f023cc96" => :mountain_lion
end
needs :cxx11
cxx11dep = MacOS.version < :mavericks ? ["c++11"] : []
depends_on "cmake" => :build
depends_on "libxml2"
depends_on "armadillo" => ["with-hdf5"] + cxx11dep
depends_on "boost" => cxx11dep
depends_on "txt2man" => :optional
option "with-debug", "Compile with debug options"
option "with-profile", "Compile with profile options"
option "with-check", "Run build-time tests"
def install
ENV.cxx11
dylib = OS.mac? ? "dylib" : "so"
cmake_args = std_cmake_args
cmake_args << "-DDEBUG=" + ((build.with? "debug") ? "ON" : "OFF")
cmake_args << "-DPROFILE=" + ((build.with? "profile") ? "ON" : "OFF")
cmake_args << "-DBOOST_ROOT=#{Formula["boost"].opt_prefix}"
cmake_args << "-DARMADILLO_INCLUDE_DIR=#{Formula["armadillo"].opt_include}"
cmake_args << "-DARMADILLO_LIBRARY=#{Formula["armadillo"].opt_lib}/libarmadillo.#{dylib}"
mkdir "build" do
system "cmake", "..", *cmake_args
system "make", "test" if build.with? "check"
system "make", "install"
end
doc.install Dir["doc/*"]
(share / "mlpack").install "src/mlpack/tests" # Includes test data.
end
test do
cd testpath do
system "#{bin}/allknn",
"-r", "#{share}/mlpack/tests/data/GroupLens100k.csv",
"-n", "neighbors.csv",
"-d", "distances.csv",
"-k", "5", "-v"
end
(testpath / "test.cpp").write <<-EOS
#include <mlpack/core.hpp>
using namespace mlpack;
int main(int argc, char** argv) {
CLI::ParseCommandLine(argc, argv);
Log::Debug << "Compiled with debugging symbols." << std::endl;
Log::Info << "Some test informational output." << std::endl;
Log::Warn << "A false alarm!" << std::endl;
}
EOS
system ENV.cxx, "-stdlib=libc++", "test.cpp",
"-I#{include}", "-I#{Formula["libxml2"].opt_include}/libxml2",
"-L#{lib}", "-lmlpack", "-o", "test"
system "./test", "--verbose"
end
end