diff --git a/Formula/c/c-blosc2.rb b/Formula/c/c-blosc2.rb new file mode 100644 index 0000000000000..5ae35454f9ee6 --- /dev/null +++ b/Formula/c/c-blosc2.rb @@ -0,0 +1,39 @@ +class CBlosc2 < Formula + desc "Fast, compressed, persistent binary data store library for C" + homepage "https://www.blosc.org" + url "https://github.com/Blosc/c-blosc2/archive/refs/tags/v2.13.2.tar.gz" + sha256 "f2adcd9615f138d1bb16dc27feadab1bb1eab01d77e5e2323d14ad4ca8c3ca21" + license "BSD-3-Clause" + head "https://github.com/Blosc/c-blosc2.git", branch: "main" + + depends_on "cmake" => :build + depends_on "lz4" + depends_on "zstd" + + uses_from_macos "zlib" + + on_macos do + depends_on "llvm" => :build if DevelopmentTools.clang_build_version <= 1400 + end + + def install + ENV.llvm_clang if OS.mac? && DevelopmentTools.clang_build_version <= 1400 + + args = %w[ + -DPREFER_EXTERNAL_LZ4=ON + -DPREFER_EXTERNAL_ZLIB=ON + -DPREFER_EXTERNAL_ZSTD=ON + ] + + system "cmake", "-S", ".", "-B", "build", *args, *std_cmake_args + system "cmake", "--build", "build" + system "cmake", "--install", "build" + + pkgshare.install "examples/simple.c" + end + + test do + system ENV.cc, pkgshare/"simple.c", "-I#{include}", "-L#{lib}", "-lblosc2", "-o", "test" + assert_match "Successful roundtrip!", shell_output(testpath/"test") + end +end