homebrew-core/Formula/mlpack.rb

91 lines
3.4 KiB
Ruby

class Mlpack < Formula
desc "Scalable C++ machine learning library"
homepage "https://www.mlpack.org"
url "https://mlpack.org/files/mlpack-4.0.0.tar.gz"
sha256 "041d9eee96445667d2f7b970d2a799592027f1f8818cd96a65dcce1ac0745773"
license all_of: ["BSD-3-Clause", "MPL-2.0", "BSL-1.0", "MIT"]
head "https://github.com/mlpack/mlpack.git", branch: "master"
bottle do
sha256 cellar: :any, arm64_ventura: "0147db21acec6dc808bf4c601fa608fccd3d31355c9634bbe64273b0cbb33f3b"
sha256 cellar: :any, arm64_monterey: "7aaefeb77e4ceb98b68b6be8d4bf8553dd9f5dd76b885792af41c86c3f2c7544"
sha256 cellar: :any, arm64_big_sur: "f3afdac9b956f551a4179bdd7ceedd03e531d43763131e4530a5e6e3154eed42"
sha256 cellar: :any, ventura: "8d01ee119424878cbfd7c54f347e9a9699a46def632e07c3b3db094ea3a904f6"
sha256 cellar: :any, monterey: "895b4623a8c0dbb324e08f55bcec9faf15f6c92748f53764a28a43d8bcc435ec"
sha256 cellar: :any, big_sur: "d6428549ab2db68e0d062fe6cf897cd9ba49719caabb1bdb81f5a2c5e3d49322"
sha256 cellar: :any_skip_relocation, x86_64_linux: "a403f137bd793252c4e99b8221ffc5aee5af3d36ba68b6bf3511803c427a09ab"
end
depends_on "cmake" => :build
depends_on "doxygen" => :build
depends_on "pkg-config" => :build
depends_on "armadillo"
depends_on "boost"
depends_on "cereal"
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
args = %W[
-DDEBUG=OFF
-DPROFILE=OFF
-DBUILD_TESTS=OFF
-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}
]
system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args
system "cmake", "--build", "build"
system "cmake", "--install", "build"
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++14", "-I#{include}", "-L#{Formula["armadillo"].opt_lib}",
"-larmadillo", "-L#{lib}", "-o", "test"
system "./test", "--verbose"
end
end