From 1df7b47df3d3042c942ca354c9ed1bb780932e6b Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 17 Nov 2026 05:24:39 +0900 Subject: [PATCH 1/2] platform_rows: openkal-platform's rows, derived from its manifest by tools/platform_rows.py, and the lint's check --- .github/workflows/validate.yml | 4 + docs/repository-and-schema.md | 10 ++ docs/zh/repository-and-schema.md | 7 ++ pkgs/o/openkal-platform.lua | 3 + tools/platform_rows.py | 200 +++++++++++++++++++++++++++++++ 5 files changed, 224 insertions(+) create mode 100644 tools/platform_rows.py diff --git a/.github/workflows/validate.yml b/.github/workflows/validate.yml index c466c280..5ca8c594 100644 --- a/.github/workflows/validate.yml +++ b/.github/workflows/validate.yml @@ -558,6 +558,10 @@ jobs: # release that republished an old tag would leave no other trace. - name: Lint duplicate versions run: lua5.4 tests/check_duplicate_versions.lua pkgs/*/*.lua + # A platform entry's `platform_rows` is derived from the manifest of its newest + # version (mcpp SPEC-013 §14): the list matches it, and a row has one platform. + - name: Platform rows match their manifests, one platform a row + run: python3 tools/platform_rows.py check - name: Check Quill install hook boundaries run: lua5.4 tests/check_quill_install.lua # The compatibility measurement's classifier decides a PUBLISHED figure diff --git a/docs/repository-and-schema.md b/docs/repository-and-schema.md index 654b89c3..c9ca2617 100644 --- a/docs/repository-and-schema.md +++ b/docs/repository-and-schema.md @@ -88,6 +88,16 @@ resolves. - `url`: a string, or a `{ GLOBAL=…, CN=… }` table (this repository uses the table form throughout). - `sha256`: required, and equal to the digest of the actual downloaded bytes. +`platform_rows` (a platform package's entry; mcpp >= 2026.11.17.1 reads it, an earlier mcpp ignores it): the rows +the platform serves, for the rows mcpp's own target table has no platform for (mcpp SPEC-013 §14) — a row the engine +does not know, a `planned` row, a row no built-in provider serves on the host. A build that names such a row and no +platform takes the one whose entry lists it. The list is derived, never written by hand: +`python3 tools/platform_rows.py write pkgs//.lua` reads the manifest of the newest version and lists +`[platform] targets`, `[[platform.define]]` and `[[platform.provider]] serves` (a pattern stands for the rows it +matches), and of `[platform.hosted] targets` only the rows the engine does not know or holds as `planned`, so no +entry claims a host's own row. The lint job runs `tools/platform_rows.py check`: every list matches its manifest, and +a row has one platform. + `mcpp` (common keys): | Key | Description | diff --git a/docs/zh/repository-and-schema.md b/docs/zh/repository-and-schema.md index 847cc35a..4522f566 100644 --- a/docs/zh/repository-and-schema.md +++ b/docs/zh/repository-and-schema.md @@ -72,6 +72,13 @@ namespace = "mcpplibs", name = "capi.lua" -- 短名仍带点 - `url`:字符串,或 `{ GLOBAL=…, CN=… }` 表(本仓统一使用表形式)。 - `sha256`:必填,等于实际下载字节的摘要。 +`platform_rows`(平台包的条目;mcpp >= 2026.11.17.1 读取,更早的 mcpp 忽略):平台服务的行,用于 mcpp 自身的目标表 +没有平台的行(mcpp SPEC-013 §14)——引擎不认识的行、`planned` 行、本机没有内置提供者服务的行。构建指名这样的行而没有 +指定平台时,采用条目列出它的平台。列表是派生数据,不手写:`python3 tools/platform_rows.py write pkgs//.lua` +读取最新版本的清单,列出 `[platform] targets`、`[[platform.define]]` 与 `[[platform.provider]] serves`(模式代表它 +匹配到的行),`[platform.hosted] targets` 中只列入引擎不认识或登记为 `planned` 的行,所以没有条目认领宿主自己的行。 +lint 作业运行 `tools/platform_rows.py check`:每份列表与清单一致,且一行只有一个平台。 + `mcpp`(常用键): | 键 | 说明 | diff --git a/pkgs/o/openkal-platform.lua b/pkgs/o/openkal-platform.lua index 9c2cd318..4e5ac750 100644 --- a/pkgs/o/openkal-platform.lua +++ b/pkgs/o/openkal-platform.lua @@ -17,6 +17,9 @@ package = { repo = "https://github.com/mcpplibs/openkal-platform", type = "package", + -- The rows this platform serves, for mcpp's platform column (SPEC-013 §14): derived + -- from the newest version's manifest by tools/platform_rows.py, never written by hand. + platform_rows = { "aarch64-freebsd-musl", "aarch64-openkal", "i686-dos-musl", "i686-linux-musl", "i686-openkal", "x86_64-freebsd-musl", "x86_64-macos", "x86_64-openkal", "x86_64-uefi", "x86_64-windows-musl" }, extensions = { autoupdate = { tag = "${version}", diff --git a/tools/platform_rows.py b/tools/platform_rows.py new file mode 100644 index 00000000..98ea8df3 --- /dev/null +++ b/tools/platform_rows.py @@ -0,0 +1,200 @@ +#!/usr/bin/env python3 +"""The rows a platform package's entry lists (`platform_rows`, mcpp SPEC-013 §14). + +mcpp's target table answers its platform column from the engine's own data; for a +row it has no answer for, it reads the rows that the index's platform entries list. +That list is derived data: it is what the platform's own manifest serves, at the +entry's newest version, and is never written by hand. + + platform_rows.py write pkgs/o/openkal-platform.lua [...] derive and write the list + platform_rows.py check [pkgs/*/*.lua ...] every list matches its manifest, + and no row has two platforms + +A row is listed when the manifest serves it: `[platform] targets`, +`[[platform.define]] triple`, and `[[platform.provider]] serves`, where a pattern +(`*-linux-musl`) stands for the rows it matches among the platform's own and the +engine's (mcpp's builtin.toml at the release the index's CI pins, $MCPP_VERSION). +`[platform.hosted] targets` are the rows its hosted arrangement applies to once the +platform is chosen, host rows among them; of those, only a row the engine does not +hold or holds as `planned` (`i686-linux-musl`) is listed, so the index never names +a platform for a host's own row. +The manifest is read from the GLOBAL archive of the newest version, at the entry's +`mcpp` path; archives are kept under $PLATFORM_ROWS_CACHE (default +~/.cache/mcpp-index-platform-rows), keyed by sha256. +""" +import fnmatch, hashlib, io, os, re, sys, tarfile, tomllib, urllib.request +from pathlib import Path + +CACHE = Path(os.environ.get("PLATFORM_ROWS_CACHE", Path.home() / ".cache" / "mcpp-index-platform-rows")) +ENGINE_ROWS = "https://raw.githubusercontent.com/mcpp-community/mcpp/v{}/modules/toolchain-model/data/builtin.toml" + + +def mcpp_version() -> str: + if v := os.environ.get("MCPP_VERSION"): + return v + m = re.search(r'^\s*MCPP_VERSION:\s*"([^"]+)"', Path(".github/workflows/validate.yml").read_text(), re.M) + if not m: + raise SystemExit("MCPP_VERSION is neither set nor found in .github/workflows/validate.yml") + return m.group(1) + + +def engine_rows() -> dict[str, str]: + """The rows of mcpp's built-in table and their tiers, at the release the index pins.""" + version = mcpp_version() + path = CACHE / f"builtin-{version}.toml" + if not path.is_file(): + CACHE.mkdir(parents=True, exist_ok=True) + path.write_bytes(urllib.request.urlopen(ENGINE_ROWS.format(version), timeout=60).read()) + doc = tomllib.loads(path.read_text()) + return {d["triple"]: d.get("tier", "") for d in doc.get("platform", {}).get("define", []) if "triple" in d} +ROWS_LINE = re.compile(r'^(\s*)platform_rows\s*=\s*\{([^}]*)\},?\s*$', re.M) + + +def lua_field(text: str, key: str) -> str | None: + m = re.search(rf'^\s*{key}\s*=\s*"([^"]*)"', text, re.M) + return m.group(1) if m else None + + +def newest(text: str) -> tuple[str, str, str] | None: + """(version, GLOBAL url, sha256) of the newest version under `linux`.""" + block = re.search(r'\blinux\s*=\s*\{(.*?)\n\s{8}\},', text, re.S) + if not block: + return None + best = None + for m in re.finditer(r'\["(\d+(?:\.\d+)*)"\]\s*=\s*\{(.*?)sha256\s*=\s*"([0-9a-f]{64})"', block.group(1), re.S): + version, body, sha = m.groups() + url = re.search(r'GLOBAL\s*=\s*"([^"]+)"', body) or re.search(r'url\s*=\s*"([^"]+)"', body) + if not url: + continue + key = tuple(int(x) for x in version.split(".")) + if best is None or key > best[0]: + best = (key, version, url.group(1), sha) + return best[1:] if best else None + + +def archive(url: str, sha: str) -> bytes: + path = CACHE / sha + if path.is_file(): + return path.read_bytes() + data = urllib.request.urlopen(url, timeout=120).read() + if hashlib.sha256(data).hexdigest() != sha: + raise SystemExit(f"{url}: sha256 differs from the entry's") + CACHE.mkdir(parents=True, exist_ok=True) + path.write_bytes(data) + return data + + +def toml_1_0(text: str) -> str: + """An inline table written over several lines (TOML 1.1) on one line, for tomllib.""" + out, depth, quote, comment = [], 0, None, False + for ch in text: + if comment: + if ch == "\n": + comment = False + out.append(" " if depth else ch) + continue + if quote: + out.append(ch) + if ch == quote: + quote = None + continue + if ch in "\"'": + quote = ch + elif ch == "#": + comment = True + continue + elif ch == "{": + depth += 1 + elif ch == "}": + depth -= 1 + elif ch == "\n" and depth: + ch = " " + out.append(ch) + return re.sub(r",\s*}", " }", "".join(out)) + + +def manifest_rows(data: bytes, pattern: str) -> list[str]: + with tarfile.open(fileobj=io.BytesIO(data)) as tar: + names = [n for n in tar.getnames() if fnmatch.fnmatch(n, pattern)] + if not names: + raise SystemExit(f"no manifest {pattern} in the archive") + text = tar.extractfile(min(names, key=len)).read().decode() + doc = tomllib.loads(toml_1_0(text)) + platform = doc.get("platform", {}) + rows = set(platform.get("targets", [])) + rows |= {d["triple"] for d in platform.get("define", []) if "triple" in d} + engine = engine_rows() + rows |= {r for r in platform.get("hosted", {}).get("targets", []) if engine.get(r, "planned") == "planned"} + known = rows | set(engine) + for p in platform.get("provider", []): + for s in p.get("serves", []): + rows |= {r for r in known if fnmatch.fnmatchcase(r, s)} if any(c in s for c in "*?[") else {s} + return sorted(rows) + + +def derive(path: Path) -> list[str]: + text = path.read_text() + found = newest(text) + pattern = lua_field(text, "mcpp") + if not found or not pattern: + raise SystemExit(f"{path}: no version with an archive, or no `mcpp` manifest path") + version, url, sha = found + return manifest_rows(archive(url, sha), pattern) + + +def written(text: str) -> list[str] | None: + m = ROWS_LINE.search(text) + return sorted(re.findall(r'"([^"]+)"', m.group(2))) if m else None + + +def write(path: Path) -> None: + rows = derive(path) + text = path.read_text() + line = " platform_rows = { " + ", ".join(f'"{r}"' for r in rows) + " }," + if ROWS_LINE.search(text): + text = ROWS_LINE.sub(line, text, count=1) + else: + text = re.sub(r'^(\s*type\s*=\s*"package",\s*)$', lambda m: m.group(1) + "\n" + line, text, count=1, flags=re.M) + path.write_text(text) + print(f"{path}: {len(rows)} rows") + + +def check(paths: list[Path]) -> int: + claims: dict[str, list[str]] = {} + fail = 0 + for path in paths: + text = path.read_text() + listed = written(text) + if listed is None: + continue + name = f"{lua_field(text, 'namespace') or 'mcpp'}.{lua_field(text, 'name')}" + for row in listed: + claims.setdefault(row, []).append(name) + derived = derive(path) + if listed != derived: + print(f"::error file={path}::platform_rows is {listed}; the manifest of the newest version serves {derived} " + f"(tools/platform_rows.py write {path})") + fail = 1 + for row, who in sorted(claims.items()): + if len(who) > 1: + print(f"::error::{row} is listed by {', '.join(who)}: a row has one platform") + fail = 1 + if not fail: + print(f"platform_rows: {len(claims)} rows, each with one platform and matching its manifest") + return fail + + +def main(argv: list[str]) -> int: + if len(argv) < 2 or argv[1] not in ("write", "check"): + print(__doc__) + return 2 + paths = [Path(a) for a in argv[2:]] or sorted(Path("pkgs").glob("*/*.lua")) + if argv[1] == "write": + for p in paths: + write(p) + return 0 + return check(paths) + + +if __name__ == "__main__": + sys.exit(main(sys.argv)) From 2bb0228dcd3c21f10f8a48fd15eb0bda45c79c31 Mon Sep 17 00:00:00 2001 From: Sunrisepeak Date: Tue, 17 Nov 2026 05:55:52 +0900 Subject: [PATCH 2/2] mcpp.plugins 0.22.1: mcpplibs.os 0.4.4, so a graph whose openkal is 0.25 holds the plugins --- CHANGELOG.md | 1 + pkgs/m/mcpp.plugins.lua | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f212a23d..42bbcd79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -9,6 +9,7 @@ ### Added +- **mcpp.plugins 0.22.1。** 成员经 mcpplibs.os 0.4.4 访问系统:0.4.0 钉住 openkal 0.24.0,与含 openkal 0.25 的依赖图(openkal-platform 0.29)不能协调。包的下限仍为 mcpp 2026.10.30.1;`latest` 指向 0.22.1(mcpp-community/mcpp-plugins#55)。 - **openkal-platform 0.29.0。** 启动机器或创建前缀的运行器声明 `enabled = false`(UEFI、DOS 与新增的宿主行运行器),由项目或本机启用;`x86_64-freebsd-musl`、`aarch64-freebsd-musl` 经 dirun 在 xim 的 FreeBSD 磁盘映像中运行, `x86_64-windows-musl` 在 x86_64 Linux 上经 Wine 运行;UEFI 运行器传递 `--` 之后的参数,并要求 dirun 0.5.0 与 ovmf 9.2.4-3(其配置陈述 UEFI Shell 的引用规则,含空白的参数作为一个参数到达程序); okrun 增加宿主 `macos-x86_64` 与 `linux-i686`。版本组随 openkal-musl 0.29.8 与 openkal-uefi 0.11.0;需要 mcpp 2026.11.16.1(mcpplibs/openkal-platform#33)。 diff --git a/pkgs/m/mcpp.plugins.lua b/pkgs/m/mcpp.plugins.lua index 1d4a560f..523bc4e9 100644 --- a/pkgs/m/mcpp.plugins.lua +++ b/pkgs/m/mcpp.plugins.lua @@ -2,12 +2,16 @@ -- each member selected by a feature. -- -- [dependencies.mcpp] --- plugins = { version = "0.22.0", features = ["rules-spirv"], host-module = true } +-- plugins = { version = "0.22.1", features = ["rules-spirv"], host-module = true } -- -- // build.mcpp -- import mcpp; -- import mcpp.rules.spirv; -- +-- 0.22.1 (package floor mcpp 2026.10.30.1): the members reach the system +-- through mcpplibs.os 0.4.4, so a graph whose openkal is 0.25 (openkal-platform +-- 0.29) holds the plugins; 0.4.0 pinned openkal 0.24.0. +-- -- 0.22.0 (package floor mcpp 2026.10.30.1): dist-web's page is the format's -- one distributable and a long-lived runner named `web` serves it (emrun); a -- declined request is a warning; with mcpp 2026.11.16.1 dist-web states the @@ -671,6 +675,13 @@ package = { xpm = { linux = { + ["0.22.1"] = { + url = { + GLOBAL = "https://github.com/mcpp-community/mcpp-plugins/archive/refs/tags/v0.22.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/mcpp-plugins/releases/download/0.22.1/mcpp-plugins-0.22.1.tar.gz", + }, + sha256 = "ac43e6eb4fb2135bd91b3f8dcd08ceb3c77c24ed116811cd5adbe443458a8650", + }, ["0.22.0"] = { url = { GLOBAL = "https://github.com/mcpp-community/mcpp-plugins/archive/refs/tags/v0.22.0.tar.gz", @@ -965,9 +976,16 @@ package = { }, sha256 = "adf1f9d6691a5d05a8a4a94e83c733ea39caee1510ce2c9af4cb23bebabea9f5", }, - ["latest"] = { ref = "0.22.0" }, + ["latest"] = { ref = "0.22.1" }, }, macosx = { + ["0.22.1"] = { + url = { + GLOBAL = "https://github.com/mcpp-community/mcpp-plugins/archive/refs/tags/v0.22.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/mcpp-plugins/releases/download/0.22.1/mcpp-plugins-0.22.1.tar.gz", + }, + sha256 = "ac43e6eb4fb2135bd91b3f8dcd08ceb3c77c24ed116811cd5adbe443458a8650", + }, ["0.22.0"] = { url = { GLOBAL = "https://github.com/mcpp-community/mcpp-plugins/archive/refs/tags/v0.22.0.tar.gz", @@ -1262,9 +1280,16 @@ package = { }, sha256 = "adf1f9d6691a5d05a8a4a94e83c733ea39caee1510ce2c9af4cb23bebabea9f5", }, - ["latest"] = { ref = "0.22.0" }, + ["latest"] = { ref = "0.22.1" }, }, windows = { + ["0.22.1"] = { + url = { + GLOBAL = "https://github.com/mcpp-community/mcpp-plugins/archive/refs/tags/v0.22.1.tar.gz", + CN = "https://gitcode.com/mcpp-res/mcpp-plugins/releases/download/0.22.1/mcpp-plugins-0.22.1.tar.gz", + }, + sha256 = "ac43e6eb4fb2135bd91b3f8dcd08ceb3c77c24ed116811cd5adbe443458a8650", + }, ["0.22.0"] = { url = { GLOBAL = "https://github.com/mcpp-community/mcpp-plugins/archive/refs/tags/v0.22.0.tar.gz", @@ -1559,7 +1584,7 @@ package = { }, sha256 = "adf1f9d6691a5d05a8a4a94e83c733ea39caee1510ce2c9af4cb23bebabea9f5", }, - ["latest"] = { ref = "0.22.0" }, + ["latest"] = { ref = "0.22.1" }, }, },