|
| 1 | +class Libblastrampoline < Formula |
| 2 | + desc "Using PLT trampolines to provide a BLAS and LAPACK demuxing library" |
| 3 | + homepage "https://github.com/JuliaLinearAlgebra/libblastrampoline" |
| 4 | + url "https://github.com/JuliaLinearAlgebra/libblastrampoline/archive/refs/tags/v5.11.0.tar.gz" |
| 5 | + sha256 "4ea6c134843bd868f78d7ee0c61bf8bdda5334f20deaa6d3cd5bc6caafc4af17" |
| 6 | + license all_of: [ |
| 7 | + "MIT", |
| 8 | + "BSD-2-Clause-Views", # include/common/f77blas.h |
| 9 | + "BSD-3-Clause", # include/common/lapacke* |
| 10 | + ] |
| 11 | + |
| 12 | + bottle do |
| 13 | + sha256 cellar: :any, arm64_sonoma: "70c25f76601949269e21048be82f671ca0d97bf5b71c11eddae338b3916b198f" |
| 14 | + sha256 cellar: :any, arm64_ventura: "51cee0c324df3077f746332e9a428d0ca1b7d81faab257e371b2d92147b02973" |
| 15 | + sha256 cellar: :any, arm64_monterey: "254d9acb9cfb8be58703c06e621cd4df120bac6c1464eb6bdc73325b0e3002d8" |
| 16 | + sha256 cellar: :any, sonoma: "48f2f7813d5b7c04267e924fed7ba578acb8e4e139d70df80a2dc8cb4ebbfdd7" |
| 17 | + sha256 cellar: :any, ventura: "84e50ef11eb134a5822d1f765f91ce8235c6ff675020b3bc33a8b6951b0f64c9" |
| 18 | + sha256 cellar: :any, monterey: "f3fb195e78ad38bdcdf6d5e68f3290e72ff435d85a9bc9052f5db1bd4bcccfa5" |
| 19 | + sha256 cellar: :any_skip_relocation, x86_64_linux: "5b45c0f742c4f3699842d75b19438efc8a49816ab82b46352a4a197ce63fed42" |
| 20 | + end |
| 21 | + |
| 22 | + depends_on "openblas" => :test |
| 23 | + |
| 24 | + def install |
| 25 | + system "make", "-C", "src", "install", "prefix=#{prefix}" |
| 26 | + (pkgshare/"test").install "test/dgemm_test/dgemm_test.c" |
| 27 | + end |
| 28 | + |
| 29 | + test do |
| 30 | + cp pkgshare/"test/dgemm_test.c", testpath |
| 31 | + |
| 32 | + (testpath/"api_test.c").write <<~EOS |
| 33 | + #include <assert.h> |
| 34 | + #include <stdio.h> |
| 35 | + #include <libblastrampoline.h> |
| 36 | +
|
| 37 | + int main() { |
| 38 | + const lbt_config_t * config = lbt_get_config(); |
| 39 | + assert(config != NULL); |
| 40 | +
|
| 41 | + lbt_library_info_t ** libs = config->loaded_libs; |
| 42 | + assert(libs != NULL); |
| 43 | + assert(sizeof(libs) == sizeof(lbt_library_info_t *)); |
| 44 | + assert(libs[0] != NULL); |
| 45 | +
|
| 46 | + printf("%s", libs[0]->libname); |
| 47 | + return 0; |
| 48 | + } |
| 49 | + EOS |
| 50 | + |
| 51 | + system ENV.cc, "dgemm_test.c", "-I#{include}", "-L#{lib}", "-lblastrampoline", "-o", "dgemm_test" |
| 52 | + system ENV.cc, "api_test.c", "-I#{include}", "-L#{lib}", "-lblastrampoline", "-o", "api_test" |
| 53 | + |
| 54 | + test_libs = [shared_library("libopenblas")] |
| 55 | + if OS.mac? |
| 56 | + test_libs << "/System/Library/Frameworks/Accelerate.framework/Accelerate" |
| 57 | + ENV["DYLD_LIBRARY_PATH"] = Formula["openblas"].opt_lib.to_s |
| 58 | + end |
| 59 | + |
| 60 | + test_libs.each do |test_lib| |
| 61 | + with_env(LBT_DEFAULT_LIBS: test_lib) do |
| 62 | + assert_equal test_lib, shell_output("./api_test") |
| 63 | + system "./dgemm_test" |
| 64 | + end |
| 65 | + end |
| 66 | + end |
| 67 | +end |
0 commit comments