From a79287da881ac659c46ca84c7a29405befce2fdc Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 10 May 2026 02:41:37 +0800 Subject: [PATCH 1/2] feat: add lua 5.4.7 (C library) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Pure-C scripting library; relies on mcpp's C compile rule. Form B descriptor enumerates the 32 library translation units (CORE_O + LIB_O from upstream's src/Makefile) into a single `liblua.a` static archive. The two binary entry points (src/lua.c interpreter, src/luac.c bytecode compiler) are intentionally excluded — both define `int main()` and aren't part of the embeddable library. Tarball: https://www.lua.org/ftp/lua-5.4.7.tar.gz SHA256: 9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30 Verified end-to-end with a small consumer that calls lua_State / luaL_openlibs / luaL_dostring("return 1+2") — outputs "3", links clean against liblua.a, no main() collision. --- pkgs/l/lua.lua | 86 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 pkgs/l/lua.lua diff --git a/pkgs/l/lua.lua b/pkgs/l/lua.lua new file mode 100644 index 0000000..d496b19 --- /dev/null +++ b/pkgs/l/lua.lua @@ -0,0 +1,86 @@ +-- M6.x glob-aware Form B descriptor for Lua 5.4. +-- +-- 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). Builds the +-- 32 library translation units (CORE_O + LIB_O from upstream's +-- src/Makefile) into a single static archive `liblua.a`. The two +-- binary entry points (`src/lua.c` for the interpreter and +-- `src/luac.c` for the bytecode compiler) are intentionally excluded — +-- both define `int main()` and aren't part of the embeddable library. +-- Consumers `#include ` and link against liblua.a. + +package = { + spec = "1", + name = "lua", + description = "A powerful, efficient, lightweight, embeddable scripting language", + licenses = {"MIT"}, + repo = "https://www.lua.org", + type = "package", + + xpm = { + linux = { + ["5.4.7"] = { + url = "https://www.lua.org/ftp/lua-5.4.7.tar.gz", + sha256 = "9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30", + }, + }, + macosx = { + ["5.4.7"] = { + url = "https://www.lua.org/ftp/lua-5.4.7.tar.gz", + sha256 = "9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30", + }, + }, + windows = { + ["5.4.7"] = { + url = "https://www.lua.org/ftp/lua-5.4.7.tar.gz", + sha256 = "9fbf5e28ef86c69858f6d3d34eccc32e911c1a28b4120ff3e84aaa70cfbf1e30", + }, + }, + }, + + -- Form B `mcpp` segment: paths are globs relative to the verdir + -- (~/.mcpp/registry/data/xpkgs/-x-lua//). The leading + -- `*/` absorbs the upstream tarball's `lua-5.4.7/` wrap layer. + mcpp = { + language = "c++23", -- top-level [package].standard knob; mcpp drives a c++23 toolchain even for pure-C deps. + import_std = false, -- pure C — no `import std;`. + c_standard = "c99", -- Lua's reference build is c99-clean; matches upstream src/Makefile. + include_dirs = { "*/src" }, -- public headers (lua.h, lualib.h, lauxlib.h, luaconf.h) live next to .c files. + sources = { + "*/src/lapi.c", + "*/src/lauxlib.c", + "*/src/lbaselib.c", + "*/src/lcode.c", + "*/src/lcorolib.c", + "*/src/lctype.c", + "*/src/ldblib.c", + "*/src/ldebug.c", + "*/src/ldo.c", + "*/src/ldump.c", + "*/src/lfunc.c", + "*/src/lgc.c", + "*/src/linit.c", + "*/src/liolib.c", + "*/src/llex.c", + "*/src/lmathlib.c", + "*/src/lmem.c", + "*/src/loadlib.c", + "*/src/lobject.c", + "*/src/lopcodes.c", + "*/src/loslib.c", + "*/src/lparser.c", + "*/src/lstate.c", + "*/src/lstring.c", + "*/src/lstrlib.c", + "*/src/ltable.c", + "*/src/ltablib.c", + "*/src/ltm.c", + "*/src/lundump.c", + "*/src/lutf8lib.c", + "*/src/lvm.c", + "*/src/lzio.c", + }, + targets = { ["lua"] = { kind = "lib" } }, + deps = { }, + }, +} From 52300750eaa5edb8590121809ffec607f7f0f5d8 Mon Sep 17 00:00:00 2001 From: sunrisepeak Date: Sun, 10 May 2026 02:46:00 +0800 Subject: [PATCH 2/2] fix(ci): rewrite the package-descriptor lint MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The previous check insisted on `schema = "0.1"` and an inline `mcpp = { ... }` segment. Both are wrong for the actual xpkg V1 schema we use: - xpkg V1 names the version field `spec`, not `schema`. (None of the existing descriptors in this repo carry `schema = "0.1"`, so this check would have flagged every file the moment any pkgs/ change triggered the workflow.) - The inline `mcpp = {}` segment is Form B only; Form A descriptors (mcpplibs.tinyhttps, mcpplibs.llmapi after their upstream started shipping mcpp.toml) intentionally omit it. Replace both with the actual xpkg V1 baseline: - `package = { ... }` assignment present (via syntax-only `loadfile` parse — catches typos without executing user code) - required fields: `spec`, `name`, `xpm` - still flag the forbidden `function install(...)` hook Adds a `lua5.4` install step so the syntax check has an interpreter. --- .github/workflows/validate.yml | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index b32371d..0378b9f 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -2,7 +2,7 @@ name: validate on: pull_request: - paths: ["pkgs/**/*.lua"] + paths: ["pkgs/**/*.lua", ".github/workflows/validate.yml"] push: branches: [main] @@ -11,22 +11,33 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 + - name: Install lua + run: sudo apt-get install -y --no-install-recommends lua5.4 - name: Lint package descriptors run: | fail=0 for f in pkgs/*/*.lua; do + # 1. Forbidden install hook (security: descriptors must not run code) if grep -q "^function install" "$f"; then echo "::error file=$f::install hook is forbidden" fail=1 fi - if ! grep -q "mcpp = {" "$f"; then - echo "::error file=$f::missing mcpp = {} segment" - fail=1 - fi - if ! grep -q 'schema *= *"0\.1"' "$f"; then - echo "::error file=$f::missing schema = \"0.1\"" + # 2. Lua syntax check — load (= compile) without executing. + # `loadfile(name, 't')` rejects bytecode and parses text only. + if ! lua5.4 -e "assert(loadfile('$f', 't'))" >/dev/null 2>&1; then + echo "::error file=$f::lua syntax error" fail=1 fi + # 3. xpkg V1 baseline: the file has to populate `package = { ... }` + # with at least `spec`, `name`, and an `xpm` table. Form A vs + # Form B (mcpp = "" / mcpp = { ... }) is descriptor-author + # choice and not enforced here. + for needle in 'spec *=' 'name *=' 'xpm *='; do + if ! grep -q "$needle" "$f"; then + echo "::error file=$f::missing required field ($needle)" + fail=1 + fi + done done [ $fail -eq 0 ] && echo "All package files valid." exit $fail