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 7
bottle do
sha256 cellar: :any, arm64_monterey: "277afc1ab6337583a9bb281adbeddd3be707f30e7c4398d868b858bb46ac10b8"
sha256 cellar: :any, arm64_big_sur: "8bf7bf1352f47de1d1a10a09aae695ece8959e2a3c0e6558aaac236c92ccebba"
sha256 cellar: :any, monterey: "7c67d680d0ebb915526c99baa908d292b60bc9e57d616ebc5ebca80f96798d4e"
sha256 cellar: :any, big_sur: "cdeb478bbaaaa1414ea8d5641423316f08b5aa5ce81e82708076769c60b0cb0b"
sha256 cellar: :any, catalina: "45aaf8a7a5e7943b1e1b981918e406810da90f96a8ca1e3fa9df88160ec2092d"
sha256 cellar: :any_skip_relocation, x86_64_linux: "08873aab2d2241ca041ab707c2b48a900b42af7db2af9f802573be675b412e79"
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