@@ -22,33 +22,45 @@ class Beagle < Formula
2222 end
2323
2424 depends_on "cmake" => :build
25- depends_on "openjdk@11 " => [ :build , :test ]
25+ depends_on "openjdk" => [ :build , :test ]
2626
2727 def install
2828 # Avoid building Linux bottle with `-march=native`. Need to enable SSE4.1 for _mm_dp_pd
2929 # Issue ref: https://github.com/beagle-dev/beagle-lib/issues/189
3030 inreplace "CMakeLists.txt" , "-march=native" , "-msse4.1" if OS . linux? && build . bottle?
3131
32- ENV [ "JAVA_HOME" ] = Language ::Java . java_home ( "11" )
32+ ENV [ "JAVA_HOME" ] = Language ::Java . java_home
3333 system "cmake" , "-S" , "." , "-B" , "build" , *std_cmake_args
3434 system "cmake" , "--build" , "build"
3535 system "cmake" , "--install" , "build"
36+ pkgshare . install "examples/tinytest/tinytest.cpp"
3637 end
3738
3839 test do
39- ( testpath /"test.cpp" ) . write <<~CPP
40- #include "libhmsbeagle/platform.h"
41- int main() { return 0; }
42- CPP
40+ if OS . mac? && Hardware ::CPU . arm? && Hardware ::CPU . virtualized?
41+ # OpenCL is not supported on virtualized arm64 macOS which breaks all Beagle functionality
42+ ( testpath /"test.cpp" ) . write <<~CPP
43+ #include <iostream>
44+ #include "libhmsbeagle/beagle.h"
45+ int main() {
46+ std::cout << beagleGetVersion();
47+ return 0;
48+ }
49+ CPP
50+ system ENV . cxx , "test.cpp" , "-o" , "test" , "-I#{ include } /libhmsbeagle-1" , "-L#{ lib } " , "-lhmsbeagle"
51+ assert_match version . to_s , shell_output ( "./test" )
52+ else
53+ system ENV . cxx , pkgshare /"tinytest.cpp" , "-o" , "test" , "-I#{ include } /libhmsbeagle-1" , "-L#{ lib } " , "-lhmsbeagle"
54+ assert_match "sumLogL = -1498." , shell_output ( "./test" )
55+ end
56+
4357 ( testpath /"T.java" ) . write <<~JAVA
4458 class T {
4559 static { System.loadLibrary("hmsbeagle-jni"); }
4660 public static void main(String[] args) {}
4761 }
4862 JAVA
49- system ENV . cxx , "-I#{ include } /libhmsbeagle-1" , testpath /"test.cpp" , "-o" , "test"
50- system "./test"
51- system Formula [ "openjdk@11" ] . bin /"javac" , "T.java"
52- system Formula [ "openjdk@11" ] . bin /"java" , "-Djava.library.path=#{ lib } " , "T"
63+ system Formula [ "openjdk" ] . bin /"javac" , "T.java"
64+ system Formula [ "openjdk" ] . bin /"java" , "-Djava.library.path=#{ lib } " , "T"
5365 end
5466end
0 commit comments