homebrew-core/Formula/onnxruntime.rb

55 lines
1.7 KiB
Ruby

class Onnxruntime < Formula
desc "Cross-platform, high performance scoring engine for ML models"
homepage "https://github.com/microsoft/onnxruntime"
url "https://github.com/microsoft/onnxruntime.git",
tag: "v1.5.3",
revision: "7bcf796a0d3208b0c193d1758708495b09281e0a"
license "MIT"
livecheck do
url "https://github.com/microsoft/onnxruntime/releases/latest"
regex(%r{href=.*?/tag/v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
cellar :any
sha256 "7c06aa23f92080bef06db9b6b1d4e48bd51a5444bc289c27e095b5d38e986f05" => :big_sur
sha256 "a41b686ad0849a7fb6814fbbebfc18686fce539a77c52ae7968f63a799b22d20" => :catalina
sha256 "7b76307e0d98e604ce75a035444aeb1949df34a753eb49ddd84f1edff1f881b3" => :mojave
end
depends_on "cmake" => :build
depends_on "python@3.9" => :build
def install
cmake_args = %W[
-Donnxruntime_RUN_ONNX_TESTS=OFF
-Donnxruntime_GENERATE_TEST_REPORTS=OFF
-DPYTHON_EXECUTABLE=#{Formula["python@3.9"].opt_bin}/python3
-Donnxruntime_BUILD_SHARED_LIB=ON
-Donnxruntime_BUILD_UNIT_TESTS=OFF
-DCMAKE_BUILD_TYPE=Release
]
mkdir "build" do
system "cmake", "../cmake", *std_cmake_args, *cmake_args
system "make", "install"
end
end
test do
(testpath/"test.c").write <<~EOS
#include <onnxruntime/core/session/onnxruntime_c_api.h>
#include <stdio.h>
int main()
{
printf("%s\\n", OrtGetApiBase()->GetVersionString());
return 0;
}
EOS
system ENV.cc, "-I#{include}", "-L#{lib}", "-lonnxruntime",
testpath/"test.c", "-o", testpath/"test"
assert_equal version, shell_output("./test").strip
end
end