91 lines
3.0 KiB
Ruby
91 lines
3.0 KiB
Ruby
class Mlpack < Formula
|
|
desc "Scalable C++ machine learning library"
|
|
homepage "https://www.mlpack.org"
|
|
url "https://mlpack.org/files/mlpack-3.4.2.tar.gz"
|
|
sha256 "9e5c4af5c276c86a0dcc553289f6fe7b1b340d61c1e59844b53da0debedbb171"
|
|
license all_of: ["BSD-3-Clause", "MPL-2.0", "BSL-1.0", "MIT"]
|
|
revision 2
|
|
|
|
livecheck do
|
|
url "https://mlpack.org/files/"
|
|
regex(/href=.*?mlpack[._-]v?(\d+(?:\.\d+)+)\.t/i)
|
|
end
|
|
|
|
bottle do
|
|
rebuild 1
|
|
sha256 cellar: :any, arm64_big_sur: "7d72d55cb3e88ee5ea2c2fb459c9677f9666d38c59cb9dbe9df40f9a12cc92d2"
|
|
sha256 cellar: :any, big_sur: "17810ae8730f736691263d205df67d013c812f00edf0ec5ecce7a18611b59716"
|
|
sha256 cellar: :any, catalina: "5980cb24352e2b3c2a42c21d0d58370efa5185e44571f01953dd986df3a9bdf1"
|
|
sha256 cellar: :any, mojave: "6de39cd1a291271dd254eeaa6056c64d315d2207e494605065b54a462b81e7c1"
|
|
end
|
|
|
|
depends_on "cmake" => :build
|
|
depends_on "doxygen" => :build
|
|
depends_on "pkg-config" => :build
|
|
depends_on "armadillo"
|
|
depends_on "boost"
|
|
depends_on "ensmallen"
|
|
depends_on "graphviz"
|
|
|
|
resource "stb_image" do
|
|
url "https://raw.githubusercontent.com/nothings/stb/e140649c/stb_image.h"
|
|
sha256 "8e5b0d717dfc8a834c97ef202d20e78d083d009586e1731c985817d0155d568c"
|
|
version "2.26"
|
|
end
|
|
|
|
resource "stb_image_write" do
|
|
url "https://raw.githubusercontent.com/nothings/stb/314d0a6f/stb_image_write.h"
|
|
sha256 "51998500e9519a85be1aa3291c6ad57deb454da98a1693ab5230f91784577479"
|
|
version "1.15"
|
|
end
|
|
|
|
def install
|
|
resources.each do |r|
|
|
r.stage do
|
|
(include/"stb").install "#{r.name}.h"
|
|
end
|
|
end
|
|
cmake_args = std_cmake_args + %W[
|
|
-DDEBUG=OFF
|
|
-DPROFILE=OFF
|
|
-DBUILD_TESTS=OFF
|
|
-DDISABLE_DOWNLOADS=ON
|
|
-DUSE_OPENMP=OFF
|
|
-DARMADILLO_INCLUDE_DIR=#{Formula["armadillo"].opt_include}
|
|
-DENSMALLEN_INCLUDE_DIR=#{Formula["ensmallen"].opt_include}
|
|
-DARMADILLO_LIBRARY=#{Formula["armadillo"].opt_lib}/#{shared_library("libarmadillo")}
|
|
-DSTB_IMAGE_INCLUDE_DIR=#{include/"stb"}
|
|
-DCMAKE_INSTALL_RPATH=#{rpath}
|
|
]
|
|
mkdir "build" do
|
|
system "cmake", "..", *cmake_args
|
|
system "make", "install"
|
|
end
|
|
doc.install Dir["doc/*"]
|
|
(pkgshare/"tests").install "src/mlpack/tests/data" # Includes test data.
|
|
end
|
|
|
|
test do
|
|
system "#{bin}/mlpack_knn",
|
|
"-r", "#{pkgshare}/tests/data/GroupLensSmall.csv",
|
|
"-n", "neighbors.csv",
|
|
"-d", "distances.csv",
|
|
"-k", "5", "-v"
|
|
|
|
(testpath/"test.cpp").write <<-EOS
|
|
#include <mlpack/core.hpp>
|
|
|
|
using namespace mlpack;
|
|
|
|
int main(int argc, char** 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, "test.cpp", "-std=c++11", "-I#{include}", "-L#{Formula["armadillo"].opt_lib}",
|
|
"-larmadillo", "-L#{lib}", "-lmlpack", "-o", "test"
|
|
system "./test", "--verbose"
|
|
end
|
|
end
|