homebrew-core/Formula/mbedtls.rb

55 lines
2.2 KiB
Ruby

class Mbedtls < Formula
desc "Cryptographic & SSL/TLS library"
homepage "https://tls.mbed.org/"
url "https://github.com/ARMmbed/mbedtls/archive/mbedtls-2.25.0.tar.gz"
sha256 "ea2049c2dd4868693998d5a9780e198194be5aea1706ff4a9d4f882f18c0a101"
license "Apache-2.0"
head "https://github.com/ARMmbed/mbedtls.git", branch: "development"
livecheck do
url :stable
strategy :github_latest
regex(%r{href=.*?/tag/(?:mbedtls[._-])?v?(\d+(?:\.\d+)+)["' >]}i)
end
bottle do
sha256 cellar: :any, arm64_big_sur: "785f8faddef2276f59790346f8841f4e330482d438e3bbfd9f4108dfb5ca279e"
sha256 cellar: :any, big_sur: "35a4787c9909ce5a07a2493a66f29a9c28b15adf22c1a11aed84fc4af473e51c"
sha256 cellar: :any, catalina: "62225a9f1f13ac7994b6fd5d842ff98177b5c91acbfeae9fdf1e6dd8d38ed767"
sha256 cellar: :any, mojave: "141066621c3a63f86614e3d13b781e33f80816119f8adf50a07c014537eb891d"
end
depends_on "cmake" => :build
depends_on "python@3.9" => :build
def install
inreplace "include/mbedtls/config.h" do |s|
# enable pthread mutexes
s.gsub! "//#define MBEDTLS_THREADING_PTHREAD", "#define MBEDTLS_THREADING_PTHREAD"
# allow use of mutexes within mbed TLS
s.gsub! "//#define MBEDTLS_THREADING_C", "#define MBEDTLS_THREADING_C"
end
system "cmake", "-DUSE_SHARED_MBEDTLS_LIBRARY=On",
"-DPython3_EXECUTABLE=#{Formula["python@3.9"].opt_bin}/python3",
*std_cmake_args
system "make"
system "make", "install"
# Why does Mbedtls ship with a "Hello World" executable. Let's remove that.
rm_f bin/"hello"
# Rename benchmark & selftest, which are awfully generic names.
mv bin/"benchmark", bin/"mbedtls-benchmark"
mv bin/"selftest", bin/"mbedtls-selftest"
# Demonstration files shouldn't be in the main bin
libexec.install bin/"mpi_demo"
end
test do
(testpath/"testfile.txt").write("This is a test file")
# Don't remove the space between the checksum and filename. It will break.
expected_checksum = "e2d0fe1585a63ec6009c8016ff8dda8b17719a637405a4e23c0ff81339148249 testfile.txt"
assert_equal expected_checksum, shell_output("#{bin}/generic_sum SHA256 testfile.txt").strip
end
end