Skip to content

docs: how to publish a library to mcpp-index, and the generated= path asymmetry - #354

Merged
Sunrisepeak merged 1 commit into
mainfrom
docs/publishing-a-library
Aug 4, 2026
Merged

docs: how to publish a library to mcpp-index, and the generated= path asymmetry#354
Sunrisepeak merged 1 commit into
mainfrom
docs/publishing-a-library

Conversation

@Sunrisepeak

Copy link
Copy Markdown
Member

Two gaps found by walking the chain end to end while publishing libxpkg 0.0.48 (consumed by openxlings/xlings 2026.8.5.1).

1. Publishing a library was undocumented

mcpp publish and mcpp emit xpkg appear in --help and nowhere in docs/. 09 covers releasing mcpp itself, 02 covers mcpp pack bundling an application — neither says how a library becomes something [dependencies] can name.

New 10 - Publishing a Library to mcpp-index writes down the chain (tag → gitcode mirror → index entry → artifact → consumer bump) and, more usefully, the four places it fails quietly:

  • gitcode answers HEAD with 401. An asset checked with HEAD reads as broken; one checked by existence alone can still be the wrong bytes. GET it and cmp against the GitHub tarball.
  • An entry in one platform block resolves on that platform and fails on the others as "no such version" — which reads like a typo in the consumer's manifest, not a missing index row.
  • The index is an artifact, not a git clone. Merging to main publishes nothing until publish-artifact.yml runs, and clients hold a TTL on top of that. Hand-editing a cached pkgs/** does nothing.
  • A seeded local copy of the unreleased version is indistinguishable from a published one — and it is exactly what is still sitting there when the publish silently failed. Delete it before believing a cold resolve.

It also documents the seeding recipe for testing against an unreleased version (the build sandbox is network-isolated, so file:// and 127.0.0.1 index URLs cannot be fetched), and warns against the registry-pruning one-liner that deletes data/xpkgsxpkgs sits at depth 2 and is not named data, so a careless second pass takes the whole ~800 MB payload store with it.

2. generated= resolves against two different roots

The directive table said "relative to the project root". That is true for the root package; the dependency section separately says a dependency's build.mcpp resolves the same path against MCPP_OUT_DIR. Both statements are correct and the combination is a trap: a library plays both roles, so no relative path is right in both.

Writing into MCPP_OUT_DIR and emitting the bare filename works as a dependency and fails at the root with:

error: build.mcpp declared generated source 'foo.cppm' but it does not exist after the run

Documents the form that is correct in both roles (write to MCPP_OUT_DIR, emit out.string().c_str()mcpp::out_dir() is always absolute), and adds one line the examples were missing: a generated .cppm module interface works, since .cppm goes through the same scan as any other source.

Both files updated in docs/ and docs/zh/, and both READMEs indexed.

… asymmetry

Two gaps found by walking the chain end to end for libxpkg 0.0.48.

Publishing a library was undocumented entirely — `mcpp publish` and
`mcpp emit xpkg` appear in the CLI and nowhere in docs/. 09 covers releasing
mcpp itself and 02 covers `mcpp pack`; neither says how a library becomes
something `[dependencies]` can name. The new 10 writes down the chain and,
more usefully, the four places it fails quietly:

  * gitcode answers HEAD with 401, so an asset verified with HEAD reads as
    broken and one verified by existence alone can still be the wrong bytes —
    GET it and cmp it against the GitHub tarball;
  * an index entry in one platform block resolves on one platform and fails
    on the others as "no such version", which reads like a consumer typo;
  * the index is an artifact, so merging to main publishes nothing until
    publish-artifact.yml runs, and clients hold a TTL on top of that;
  * a seeded local copy of the unreleased version is indistinguishable from a
    published one — it is exactly what is still there when the publish failed.

The `generated=` row said "relative to the project root". True for the root
package; a dependency's build.mcpp resolves the same path against
MCPP_OUT_DIR. A library plays both roles, so no relative path is correct in
both: writing to MCPP_OUT_DIR and emitting the bare name fails at the root
with "declared generated source ... does not exist after the run". Documents
the absolute-path form, and that a generated .cppm module interface works —
the examples only showed .cpp.
@Sunrisepeak
Sunrisepeak merged commit 3f35d01 into main Aug 4, 2026
18 checks passed
@Sunrisepeak
Sunrisepeak deleted the docs/publishing-a-library branch August 4, 2026 22:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant