69 lines
2.2 KiB
Ruby
69 lines
2.2 KiB
Ruby
class Libmatio < Formula
|
|
desc "C library for reading and writing MATLAB MAT files"
|
|
homepage "https://matio.sourceforge.io/"
|
|
url "https://downloads.sourceforge.net/project/matio/matio/1.5.21/matio-1.5.21.tar.gz"
|
|
sha256 "21809177e55839e7c94dada744ee55c1dea7d757ddaab89605776d50122fb065"
|
|
license "BSD-2-Clause"
|
|
|
|
bottle do
|
|
sha256 cellar: :any, arm64_big_sur: "fb9d717a8f88e9235218c3976be38b7ed0c5cab0ca43b8e6374355a85af435ba"
|
|
sha256 cellar: :any, big_sur: "98a891d294f382a85d61c8d57381e02d1ecb0139af46c08335c8f2eaf5727d7d"
|
|
sha256 cellar: :any, catalina: "bcb2ae92ff978e644dcc7c1469d452a5f65a1d1587c9a2f68de4ac88d0d8dbcb"
|
|
sha256 cellar: :any, mojave: "a19666b0812ccbe6b83193694677075ec678433af8cd2aa6b8f728c0dab46700"
|
|
end
|
|
|
|
depends_on "hdf5"
|
|
|
|
resource "homebrew-test_mat_file" do
|
|
url "https://web.uvic.ca/~monahana/eos225/poc_data.mat.sfx"
|
|
sha256 "a29df222605476dcfa660597a7805176d7cb6e6c60413a3e487b62b6dbf8e6fe"
|
|
end
|
|
|
|
def install
|
|
args = %W[
|
|
--prefix=#{prefix}
|
|
--enable-extended-sparse=yes
|
|
--enable-mat73=yes
|
|
--with-hdf5=#{Formula["hdf5"].opt_prefix}
|
|
--with-zlib=/usr
|
|
]
|
|
|
|
system "./configure", *args
|
|
system "make", "install"
|
|
end
|
|
|
|
test do
|
|
testpath.install resource("homebrew-test_mat_file")
|
|
(testpath/"mat.c").write <<~'EOS'
|
|
#include <stdlib.h>
|
|
#include <matio.h>
|
|
|
|
size_t dims[2] = {5, 5};
|
|
double data[25] = {0.0, };
|
|
mat_t *mat;
|
|
matvar_t *matvar;
|
|
|
|
int main(int argc, char **argv) {
|
|
if (!(mat = Mat_Open(argv[1], MAT_ACC_RDONLY)))
|
|
abort();
|
|
Mat_Close(mat);
|
|
|
|
mat = Mat_CreateVer("test_writenan.mat", NULL, MAT_FT_DEFAULT);
|
|
if (mat) {
|
|
matvar = Mat_VarCreate("foo", MAT_C_DOUBLE, MAT_T_DOUBLE, 2,
|
|
dims, data, MAT_F_DONT_COPY_DATA);
|
|
Mat_VarWrite(mat, matvar, MAT_COMPRESSION_NONE);
|
|
Mat_VarFree(matvar);
|
|
Mat_Close(mat);
|
|
} else {
|
|
abort();
|
|
}
|
|
mat = Mat_CreateVer("foo", NULL, MAT_FT_MAT73);
|
|
return EXIT_SUCCESS;
|
|
}
|
|
EOS
|
|
system ENV.cc, "mat.c", "-o", "mat", "-I#{include}", "-L#{lib}", "-lmatio"
|
|
system "./mat", "poc_data.mat.sfx"
|
|
end
|
|
end
|