From d2df0066b611507108893d036d4c7fc680cf8992 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sat, 9 May 2026 08:01:54 +0800 Subject: [PATCH] feat: add mbedtls 3.6.1 descriptor MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit xpkg V1 + mcpp Form B descriptor for `mbedtls 3.6.1`. Targets the C language compile rule introduced in mcpp 0.0.2: `library/*.c` (108 sources) compile via `c_object` (gcc/clang sibling driver, c11) and archive into a single `libmbedtls.a` covering crypto + x509 + ssl — matching what xmake's `add_packages("mbedtls")` produces. Glob-aware paths (`*/library/*.c`, `*/include`, `*/library`) absorb the GitHub tarball's `mbedtls-mbedtls-3.6.1/` wrap layer. Verified locally: a smoke project depending on `mbedtls = "3.6.1"` builds, links statically (musl), runs, and produces the FIPS 180-4 SHA-256 vector for "abc" correctly. First downstream consumer is mcpplibs/tinyhttps (parallel PR adds an `mcpp.toml` that depends on this descriptor). --- pkgs/m/mbedtls.lua | 50 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) create mode 100644 pkgs/m/mbedtls.lua diff --git a/pkgs/m/mbedtls.lua b/pkgs/m/mbedtls.lua new file mode 100644 index 0000000..633c4f6 --- /dev/null +++ b/pkgs/m/mbedtls.lua @@ -0,0 +1,50 @@ +-- M6.x glob-aware Form B descriptor for mbedtls. +-- +-- Pure-C library; relies on mcpp 0.0.2's C-language compile rule (`.c` +-- routed to `c_object` via the gcc/clang sibling driver). Produces a +-- single static archive `libmbedtls.a` that bundles all of mbedtls's +-- crypto + x509 + ssl translation units — the same arrangement xmake's +-- mbedtls package emits when used by `add_packages("mbedtls")`. + +package = { + spec = "1", + name = "mbedtls", + description = "An open source, portable, easy to use, readable and flexible TLS library, and reference implementation of the PSA Cryptography API", + licenses = {"Apache-2.0"}, + repo = "https://github.com/Mbed-TLS/mbedtls", + type = "package", + + xpm = { + linux = { + ["3.6.1"] = { + url = "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-3.6.1.tar.gz", + sha256 = "db75d2f7f35e29cf09f7bd6734d8ee3325f29c298ef071350c5e70a40dd4f0f9", + }, + }, + macosx = { + ["3.6.1"] = { + url = "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-3.6.1.tar.gz", + sha256 = "db75d2f7f35e29cf09f7bd6734d8ee3325f29c298ef071350c5e70a40dd4f0f9", + }, + }, + windows = { + ["3.6.1"] = { + url = "https://github.com/Mbed-TLS/mbedtls/archive/refs/tags/mbedtls-3.6.1.tar.gz", + sha256 = "db75d2f7f35e29cf09f7bd6734d8ee3325f29c298ef071350c5e70a40dd4f0f9", + }, + }, + }, + + -- Form B `mcpp` segment: paths are globs relative to the verdir + -- (~/.mcpp/registry/data/xpkgs/-x-mbedtls//). The leading + -- `*/` absorbs the GitHub tarball's `mbedtls-mbedtls-3.6.1/` wrap. + mcpp = { + language = "c++23", -- the [package].standard knob; mcpp uses it for the C++23 toolchain. + import_std = false, -- pure C lib — no std module. + sources = { "*/library/*.c" }, -- 108 sources, all of crypto + x509 + ssl. + include_dirs = { "*/include", "*/library" }, + c_standard = "c11", + targets = { ["mbedtls"] = { kind = "lib" } }, + deps = { }, + }, +}