Skip to content

Commit 388217d

Browse files
committed
feat: per-build resolution.json manifest artifact
Writes a machine-readable resolution manifest (toolchain/abi, runtime closure library_dirs, dlopen_libs, capability->provider) next to build outputs — the serialized capability->plan, same data as `mcpp why`, usable by CI/tooling.
1 parent 2eb076c commit 388217d

1 file changed

Lines changed: 43 additions & 0 deletions

File tree

src/cli.cppm

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3157,6 +3157,49 @@ prepare_build(bool print_fingerprint,
31573157
}
31583158
}
31593159

3160+
// Per-build resolution manifest artifact: a machine-readable record of the
3161+
// resolved plan (toolchain/abi, runtime closure, capabilities+providers,
3162+
// deps) written next to the build outputs. Same data as `mcpp why`; usable
3163+
// by CI/tooling. (capability -> plan, serialized.)
3164+
{
3165+
const std::string tcAbi =
3166+
ctx.tc.targetTriple.find("musl") != std::string::npos ? "musl"
3167+
: ctx.tc.stdlibId == "libc++" ? "libc++"
3168+
: ctx.tc.compiler == mcpp::toolchain::CompilerId::MSVC ? "msvc"
3169+
: "glibc";
3170+
auto jstr = [](std::string_view s) {
3171+
std::string o = "\"";
3172+
for (char c : s) { if (c == '\\' || c == '"') o += '\\'; o += c; }
3173+
return o + "\"";
3174+
};
3175+
std::error_code ec;
3176+
std::filesystem::create_directories(ctx.plan.outputDir, ec);
3177+
std::ofstream js(ctx.plan.outputDir / "resolution.json");
3178+
if (js) {
3179+
js << "{\n";
3180+
js << " \"toolchain\": {\"spec\": " << jstr(ctx.tc.label())
3181+
<< ", \"abi\": " << jstr(tcAbi)
3182+
<< ", \"triple\": " << jstr(ctx.tc.targetTriple)
3183+
<< ", \"stdlib\": " << jstr(ctx.tc.stdlibId) << "},\n";
3184+
js << " \"runtime\": {\n";
3185+
js << " \"library_dirs\": [";
3186+
for (std::size_t i = 0; i < ctx.plan.runtimeLibraryDirs.size(); ++i)
3187+
js << (i ? ", " : "") << jstr(ctx.plan.runtimeLibraryDirs[i].string());
3188+
js << "],\n";
3189+
js << " \"dlopen_libs\": [";
3190+
for (std::size_t i = 0; i < ctx.plan.runtimeDlopenLibs.size(); ++i)
3191+
js << (i ? ", " : "") << jstr(ctx.plan.runtimeDlopenLibs[i]);
3192+
js << "],\n";
3193+
js << " \"capabilities\": [";
3194+
for (std::size_t i = 0; i < ctx.plan.runtimeProviders.size(); ++i) {
3195+
auto& [cap, prov] = ctx.plan.runtimeProviders[i];
3196+
js << (i ? ", " : "") << "{\"capability\": " << jstr(cap)
3197+
<< ", \"provider\": " << jstr(prov) << "}";
3198+
}
3199+
js << "]\n }\n}\n";
3200+
}
3201+
}
3202+
31603203
return ctx;
31613204
}
31623205

0 commit comments

Comments
 (0)