homebrew-core/Formula/mlpack.rb

93 lines
3.3 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 6
bottle do
sha256 cellar: :any, arm64_monterey: "f819a5f6a724607ea5bc22e057174099315224c3210f05418717ec02b3df3808"
sha256 cellar: :any, arm64_big_sur: "1c6f8957881baf10be4fd9f49136cabdb9e6c11abb7f6ebd8f2e9edd7d4e6b2f"
sha256 cellar: :any, monterey: "97fafd8126eaddf030ef0a133769811b28fa45b35893328549b958bc93b527b5"
sha256 cellar: :any, big_sur: "36240afc0fa036df0c62b85eb20c8702acea453d34ddf0650de8ce29e0ef046b"
sha256 cellar: :any, catalina: "3830ec71257a2e29c7dfc308751516ac74cf5f2cbd29d9acba6c1c7249d054d9"
sha256 cellar: :any_skip_relocation, x86_64_linux: "557eec90ea9f626616de32918a7ef41cb8fcf55a86b97edee422c7a2a73a10ca"
end
head do
url "https://github.com/mlpack/mlpack.git", branch: "master"
depends_on "cereal"
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