diff --git a/mcpp.toml b/mcpp.toml index 8b091848..60f54db2 100644 --- a/mcpp.toml +++ b/mcpp.toml @@ -18,6 +18,7 @@ members = [ "tests/examples/boost-config", "tests/examples/boost-ext.ut", "tests/examples/boost-family", + "tests/examples/boost-module", "tests/examples/boost-throw-exception", "tests/examples/boost-type-traits", "tests/examples/boost-uuid", diff --git a/pkgs/z/ZheFeng7110.boost.lua b/pkgs/z/ZheFeng7110.boost.lua new file mode 100644 index 00000000..f3465008 --- /dev/null +++ b/pkgs/z/ZheFeng7110.boost.lua @@ -0,0 +1,46 @@ +-- Form A descriptor: boost-module ships its own mcpp.toml at the archive root, +-- and that manifest IS the build. The `mcpp` field therefore points at it +-- rather than inlining a Form B descriptor, because the package needs things an +-- inline descriptor cannot express: a build.mcpp umbrella generator, the +-- vendored Boost source tree (deps/boost/), and the committed generator output +-- under src/gen_exports/. +-- +-- Version naming is upstream's wrapper scheme `v.` (this release is Boost 1.91.0 x modules wrapper 0.1.0). Upstream +-- tags are bare semver, so the xpm key carries that string verbatim. +-- +-- No mcpp-res mirror is configured yet (no CN access): the plain-string GLOBAL +-- url is the documented fallback for CN consumers until a maintainer creates +-- the mirror. +package = { + spec = "1", + namespace = "ZheFeng7110", + name = "boost", + description = "Boost 1.91.0 as C++23 named modules — import boost.; or the umbrella import boost;", + licenses = {"BSL-1.0"}, + repo = "https://github.com/ZheFeng7110/boost-module", + type = "package", + + xpm = { + linux = { + ["1.91.0.0.1.0"] = { + url = "https://github.com/ZheFeng7110/boost-module/releases/download/v1.91.0.0.1.0/boost-module-v1.91.0.0.1.0.tar.xz", + sha256 = "63a9aae63140f22e518a4ee758332afd5b5037d916731dc9c8339dea1a1e1010", + }, + }, + macosx = { + ["1.91.0.0.1.0"] = { + url = "https://github.com/ZheFeng7110/boost-module/releases/download/v1.91.0.0.1.0/boost-module-v1.91.0.0.1.0.tar.xz", + sha256 = "63a9aae63140f22e518a4ee758332afd5b5037d916731dc9c8339dea1a1e1010", + }, + }, + windows = { + ["1.91.0.0.1.0"] = { + url = "https://github.com/ZheFeng7110/boost-module/releases/download/v1.91.0.0.1.0/boost-module-v1.91.0.0.1.0.tar.xz", + sha256 = "63a9aae63140f22e518a4ee758332afd5b5037d916731dc9c8339dea1a1e1010", + }, + }, + }, + + mcpp = "*/mcpp.toml", +} diff --git a/tests/examples/boost-module/mcpp.toml b/tests/examples/boost-module/mcpp.toml new file mode 100644 index 00000000..2d4def77 --- /dev/null +++ b/tests/examples/boost-module/mcpp.toml @@ -0,0 +1,25 @@ +# boost.boost C++23-module package test: selective feature consumption of the +# Boost named-modules wrapper — `import boost.optional;` plus the umbrella +# `import boost;`. The package is Form A (upstream ships its own mcpp.toml), so +# this member is also the only place the descriptor's `mcpp = "*/mcpp.toml"` +# default lookup is exercised. +# +# Overrides the workspace-root redirect: root declares `compat`, this member +# needs `ZheFeng7110`. The table is keyed by NAMESPACE, so the key must be the +# dependency's namespace (`ZheFeng7110`), not the package name (`boost`). A +# member-level [indices] REPLACES the inherited table rather than merging with +# it, which keeps this to ONE project index repo — two repos pointing at the +# same tree make every lookup ambiguous. +[indices] +ZheFeng7110 = { path = "../../.." } + +[package] +name = "boost-module-tests" +version = "0.1.0" + +# Selective, NOT the package's 49-library default closure: opt out of the +# default set and pick a core sample (header-only optional/type_traits, the +# compiled json, and the version constants). This keeps index CI on the +# validated module surface without building the whole wrapper. +[dependencies.ZheFeng7110] +boost = { version = "1.91.0.0.1.0", default-features = false, features = ["optional", "type_traits", "json", "version"] } diff --git a/tests/examples/boost-module/tests/boost_module.cpp b/tests/examples/boost-module/tests/boost_module.cpp new file mode 100644 index 00000000..9e2df623 --- /dev/null +++ b/tests/examples/boost-module/tests/boost_module.cpp @@ -0,0 +1,55 @@ +// Public boost.boost module-package end-to-end assertion: consume the Boost +// named-modules wrapper by import only (no `#include ` at all). +// +// * `import boost.optional;` — a classic header-only library +// * `import boost.json;` — a compiled library (library TU linked in) +// * `import boost.version;` — the version constants module +// * `import boost;` — the umbrella, re-exporting the active set + +import std; + +import boost.optional; +import boost.json; +import boost.version; +import boost; + +int main() { + int failures = 0; + auto check = [&failures](bool ok, const char* what) { + if (!ok) { + std::println("FAIL: {}", what); + ++failures; + } + }; + + // optional (header-only module) + boost::optional empty; + check(!empty.has_value(), "optional: empty has no value"); + boost::optional v(42); + check(v.has_value() && *v == 42, "optional: value round-trip"); + check(v.value_or(0) == 42, "optional: value_or hits the value"); + empty = 7; + check(empty.value_or(0) == 7, "optional: assignment activates"); + + // json (compiled library) + boost::json::value j = boost::json::parse(R"({"lib":"boost","ok":true})"); + check(j.is_object(), "json: parsed to an object"); + boost::json::object& o = j.as_object(); + check(o["lib"].as_string() == "boost", "json: string member"); + check(o["ok"].as_bool(), "json: bool member"); + const std::string ser = boost::json::serialize(j); + check(boost::json::parse(ser).as_object()["lib"].as_string() == "boost", + "json: serialize/parse round-trip"); + + // version constants + check(boost::BOOST_VERSION == 109100, "version: BOOST_VERSION == 109100"); + check(boost::BOOST_LIB_VERSION[0] == '1', "version: BOOST_LIB_VERSION"); + + // type_traits (reached through the umbrella's active set as well) + check(boost::is_same::value, "type_traits: is_same"); + + if (failures == 0) { + std::println("boost.boost modules ok: BOOST_VERSION={}", boost::BOOST_VERSION); + } + return failures == 0 ? 0 : 1; +}