Skip to content
Closed
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
1 change: 1 addition & 0 deletions mcpp.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ members = [
"tests/examples/cjson",
"tests/examples/core",
"tests/examples/eigen",
"tests/examples/fmt",
"tests/examples/gui-stack",
"tests/examples/imgui",
"tests/examples/imgui-window",
Expand Down
65 changes: 65 additions & 0 deletions pkgs/c/compat.fmt.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
-- Form B inline descriptor for {fmt} — a modern formatting library for C++.
-- C++-source compat build (same shape as compat.gtest): compile the library's
-- non-header translation units into a lib and expose the `include/` tree via
-- include_dirs, so consumers write `#include <fmt/core.h>` / `<fmt/format.h>`.
--
-- Sources: fmt's compiled implementation is `src/format.cc` (core formatting)
-- and `src/os.cc` (optional OS-specific I/O — fmt::ostream, file descriptors).
-- These two are exactly upstream CMake's `fmt` target sources. NOT globbed:
-- * `src/fmt.cc` — the C++20 named-module unit (starts with `module;`); it
-- must be compiled as a module interface, not a plain TU,
-- so it is deliberately excluded here.
-- * `src/fmt-c.cc` — the optional C API; gated behind the `c-api` feature
-- below (excluded by default, same pattern as compat.gtest
-- gating gtest_main behind `main`).
--
-- All `mcpp` paths are GLOBS relative to the verdir; the leading `*/` absorbs
-- the GitHub tarball's `fmt-<tag>/` wrap layer.
package = {
spec = "1",
namespace = "compat",
name = "compat.fmt",
description = "A modern formatting library for C++",
licenses = {"MIT"},
repo = "https://github.com/fmtlib/fmt",
type = "package",

xpm = {
linux = {
["12.2.0"] = {
url = "https://github.com/fmtlib/fmt/archive/refs/tags/12.2.0.tar.gz",
sha256 = "8b852bb5aa6e7d8564f9e81394055395dd1d1936d38dfd3a17792a02bebd7af0",
},
},
macosx = {
["12.2.0"] = {
url = "https://github.com/fmtlib/fmt/archive/refs/tags/12.2.0.tar.gz",
sha256 = "8b852bb5aa6e7d8564f9e81394055395dd1d1936d38dfd3a17792a02bebd7af0",
},
},
windows = {
["12.2.0"] = {
url = "https://github.com/fmtlib/fmt/archive/refs/tags/12.2.0.tar.gz",
sha256 = "8b852bb5aa6e7d8564f9e81394055395dd1d1936d38dfd3a17792a02bebd7af0",
},
},
},

mcpp = {
language = "c++23",
import_std = false,
include_dirs = { "*/include" },
sources = { "*/src/format.cc", "*/src/os.cc" },
targets = { ["fmt"] = { kind = "lib" } },
-- Optional C API (src/fmt-c.cc, <fmt/fmt-c.h>), source-gated like
-- compat.gtest's `main` / compat.cjson's `utils`. NOTE: mcpp 0.0.81 does
-- not yet propagate a feature requested on a DEPENDENCY into its compile
-- plan, so this object is not built and fmt_vformat is unresolved even
-- with the feature on — the same gap compat.eigen notes for `eigen_blas`.
-- Kept form-correct; lights up once mcpp propagates dependency features.
features = {
["c-api"] = { sources = { "*/src/fmt-c.cc" } },
},
deps = { },
},
}
12 changes: 12 additions & 0 deletions tests/examples/fmt/mcpp.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# {fmt} test project: depends on compat.fmt (built from source via this repo's
# own index) and asserts behavior under `mcpp test`. Part of the mcpp-index
# self-referential workspace.
[package]
name = "fmt-tests"
version = "0.1.0"

[indices]
compat = { path = "../../.." }

[dependencies.compat]
fmt = "12.2.0"
19 changes: 19 additions & 0 deletions tests/examples/fmt/tests/format_test.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
// Behavioral test: exercise {fmt}'s compiled implementation (src/format.cc via
// the fmt lib target) — not just header inlines — and assert the results.
// Returns non-zero on any mismatch.
#include <fmt/format.h>
#include <cmath>
#include <string>

int main() {
std::string a = fmt::format("{} + {} = {}", 2, 3, 2 + 3);
std::string b = fmt::format("{:08.3f}", 3.14159);
std::string c = fmt::format("{0}-{1}-{0}", "x", "y");
std::string d = fmt::format("{:#x}", 255);

bool ok = a == "2 + 3 = 5"
&& b == "0003.142"
&& c == "x-y-x"
&& d == "0xff";
return ok ? 0 : 1;
}
Loading