-
-
Notifications
You must be signed in to change notification settings - Fork 12.6k
/
Copy pathmbedtls.rb
66 lines (59 loc) · 3.11 KB
/
mbedtls.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
class Mbedtls < Formula
desc "Cryptographic & SSL/TLS library"
homepage "https://tls.mbed.org/"
url "https://github.com/Mbed-TLS/mbedtls/releases/download/mbedtls-3.6.2/mbedtls-3.6.2.tar.bz2"
sha256 "8b54fb9bcf4d5a7078028e0520acddefb7900b3e66fec7f7175bb5b7d85ccdca"
license "Apache-2.0"
head "https://github.com/Mbed-TLS/mbedtls.git", branch: "development"
livecheck do
url :stable
regex(/(?:mbedtls[._-])?v?(\d+(?:\.\d+)+)/i)
strategy :github_latest
end
bottle do
sha256 cellar: :any, arm64_sequoia: "451fa9222bdfef8a77fc116ed9d4c7d060e39e07f7f71a12cacb7747f077f38f"
sha256 cellar: :any, arm64_sonoma: "57cc0f45f4fb406f0b4e28b21c3f9694c9867f6ef469086803e97519b4008d08"
sha256 cellar: :any, arm64_ventura: "7b09a07c271d4ea1f91d084e95118793d1ea9cc54d49124b975786ebe43ad820"
sha256 cellar: :any, sonoma: "ce7b2b5556e35cb94435e318e93d4878d36d3ef78d271aba6fa1cdb842d44d1f"
sha256 cellar: :any, ventura: "696fabe2b3da431fe4852751ef036a790cb4ea4d27f3c5bf22a397dece28c0f3"
sha256 cellar: :any_skip_relocation, x86_64_linux: "0591255d3f83ef14d18eadf4383876d2826cdd913477e4dba7f7539a11155ce1"
end
depends_on "cmake" => :build
depends_on "python@3.13" => :build
def install
inreplace "include/mbedtls/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"
# enable DTLS-SRTP extension
s.gsub! "//#define MBEDTLS_SSL_DTLS_SRTP", "#define MBEDTLS_SSL_DTLS_SRTP"
end
system "cmake", "-S", ".", "-B", "build",
"-DUSE_SHARED_MBEDTLS_LIBRARY=On",
"-DPython3_EXECUTABLE=#{which("python3.13")}",
"-DCMAKE_INSTALL_RPATH=#{rpath}",
"-DGEN_FILES=OFF",
*std_cmake_args
system "cmake", "--build", "build"
# We run CTest because this is a crypto library. Running tests in parallel causes failures.
# https://github.com/Mbed-TLS/mbedtls/issues/4980
with_env(CC: DevelopmentTools.locate(DevelopmentTools.default_compiler)) do
system "ctest", "--parallel", "1", "--test-dir", "build", "--rerun-failed", "--output-on-failure"
end
system "cmake", "--install", "build"
# Why does Mbedtls ship with a "Hello World" executable. Let's remove that.
rm(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