Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 59 additions & 19 deletions pkgs/c/cmdline.lua
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
-- Form B (inline mcpp = { ... }) carries the build info for ALL listed versions.
-- 0.0.2+ ships an upstream `mcpp.toml`, but `mcpp` is a package-level field
-- (not per-version) in xpkg.lua, so to keep 0.0.1 installable we keep the
-- workaround table here. The src/**/*.cppm layout is the same across 0.0.1,
-- 0.0.2, 0.0.3, 0.0.4, 0.0.5, 0.0.6 and 0.0.7 (0.0.3 adds src/completions*.cppm, which the glob takes in;
-- 0.0.6 replaces src/completions/ with src/complete.cppm; 0.0.7 changes src/cmdline.cppm only),
-- so a single Form B block describes every version correctly.
-- When 0.0.1 is dropped, this can be replaced with `mcpp = "*/mcpp.toml"`.
import("xim.libxpkg.pkginfo")
import("xim.libxpkg.log")

-- Form A: the upstream `mcpp.toml` carries every version from 0.0.2 on. The
-- 0.1.0 manifest also carries the agent-skills feature and the
-- `[build-dependencies]` path re-export of the mcpp/cmdline build package,
-- which a Form B table cannot state. 0.0.1 (the only version without a
-- manifest) is dropped.
--
-- M6.x: Form B paths are globs relative to the verdir (the untouched
-- xlings extract dir). The leading `*/` absorbs the GitHub tarball's
-- The leading `*/` in the manifest glob absorbs the GitHub tarball's
-- `cmdline-<tag>/` wrap layer.
package = {
spec = "1",
Expand All @@ -18,6 +17,12 @@ package = {
licenses = {"Apache-2.0"},
repo = "https://github.com/mcpplibs/cmdline",
type = "package",
extensions = {
autoupdate = {
tag = "v${version}",
url = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v${version}.tar.gz",
},
},

xpm = {
linux = {
Expand Down Expand Up @@ -70,6 +75,11 @@ package = {
},
sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49",
},
["0.1.0"] = {
-- No CN mirror yet: a plain-string url (see docs/cn-mirror.md).
url = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.1.0.tar.gz",
sha256 = "2167b41288d7bdfcd8a22c33fb3bbfa2a9df2d5900bb00b282a4260ad615971d",
},
},
macosx = {
["0.0.1"] = {
Expand Down Expand Up @@ -121,6 +131,11 @@ package = {
},
sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49",
},
["0.1.0"] = {
-- No CN mirror yet: a plain-string url (see docs/cn-mirror.md).
url = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.1.0.tar.gz",
sha256 = "2167b41288d7bdfcd8a22c33fb3bbfa2a9df2d5900bb00b282a4260ad615971d",
},
},
windows = {
["0.0.1"] = {
Expand Down Expand Up @@ -172,16 +187,41 @@ package = {
},
sha256 = "2e998d70953c0da856dc2131902414ab25bc9faafd0bae255290d833ad0e9b49",
},
["0.1.0"] = {
-- No CN mirror yet: a plain-string url (see docs/cn-mirror.md).
url = "https://github.com/mcpplibs/cmdline/archive/refs/tags/v0.1.0.tar.gz",
sha256 = "2167b41288d7bdfcd8a22c33fb3bbfa2a9df2d5900bb00b282a4260ad615971d",
},
},
},

mcpp = {
schema = "0.1",
language = "c++23",
import_std = true,
modules = { "mcpplibs.cmdline" },
sources = { "*/src/**/*.cppm" },
targets = { ["cmdline"] = { kind = "lib" } },
deps = { },
},
mcpp = "*/mcpp.toml",
}

-- 0.0.1 is the only archive without an upstream manifest. install() writes a
-- minimal one beside its sources so the `*/mcpp.toml` pointer resolves for it
-- too; every newer version ships its own and is left untouched.
local LEGACY_TOML = [==[
[package]
namespace = "mcpplibs"
name = "cmdline"
version = "0.0.1"
standard = "c++23"

[build]
sources = ["src/*.cppm"]

[modules]
exports = ["mcpplibs.cmdline"]
]==]

function install()
if pkginfo.version() ~= "0.0.1" then return true end
local layer = path.join(pkginfo.install_dir(), "cmdline-0.0.1")
if not os.isfile(path.join(layer, "src", "cmdline.cppm")) then
log.error("cmdline 0.0.1: no src/cmdline.cppm under %s after unpacking", layer)
return false
end
io.writefile(path.join(layer, "mcpp.toml"), LEGACY_TOML)
return true
end
2 changes: 1 addition & 1 deletion tests/examples/cmdline/mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ name = "cmdline-tests"
version = "0.1.0"

[dependencies]
mcpplibs.cmdline = "0.0.7"
mcpplibs.cmdline = "0.1.0"
Loading