Skip to content

Commit 19b622c

Browse files
committed
docs: plan GL runtime closure
1 parent 4ae6dbe commit 19b622c

1 file changed

Lines changed: 121 additions & 0 deletions

File tree

Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
# mcpp: GL Runtime Closure Plan
2+
3+
> 状态: active
4+
> 分支: `codex/gl-runtime-closure-mcpp`
5+
> PR: pending
6+
> Last updated: 2026-06-03
7+
> 目标: 让 mcpp 以标准工具链方式表达、解析、诊断并注入运行时闭包,使 GLFW/OpenGL 这类通过 `dlopen` 加载的运行库不再依赖用户手写环境变量。
8+
9+
## Scope
10+
11+
This repository owns the tool behavior. It should not hard-code one OpenGL
12+
vendor or one package index workaround. The expected model is closer to
13+
Conan/vcpkg run environments plus Nix-style runtime closure diagnostics:
14+
15+
- package metadata can declare runtime library directories, `dlopen` library
16+
names, and required system capabilities;
17+
- dependency resolution carries runtime requirements separately from compile
18+
includes and link flags;
19+
- `mcpp run`, `mcpp test`, `mcpp doctor`, and `mcpp pack` consume the same
20+
runtime model;
21+
- missing system capabilities produce actionable errors before a user only sees
22+
a failed GUI window.
23+
24+
## Current Problem
25+
26+
- `mcpp run` builds the selected binary and executes it directly.
27+
- Build/link propagation covers link-time shared libraries, but `dlopen`
28+
libraries such as `libGLX.so.0` and `libGL.so.1` do not appear in `DT_NEEDED`.
29+
- `mcpp pack` already has runtime closure logic, but it is oriented around
30+
loader-visible ELF dependencies. GLX/EGL/Mesa/vendor-driver cases need an
31+
explicit runtime metadata path rather than guessing from one executable.
32+
33+
## Proposed Manifest Surface
34+
35+
Keep compile, link, and runtime requirements separate. Initial names can be
36+
adjusted during implementation, but the semantics should remain stable:
37+
38+
```toml
39+
[runtime]
40+
library_dirs = ["relative/or/generated/runtime/lib"]
41+
dlopen_libs = ["libGLX.so.0", "libGL.so.1", "libGL.so"]
42+
capabilities = ["x11.display", "opengl.glx.driver"]
43+
```
44+
45+
For package descriptors coming from an index, the same data should be accepted
46+
from the package `mcpp` table:
47+
48+
```lua
49+
mcpp = {
50+
runtime = {
51+
library_dirs = {"mcpp_generated/runtime/lib"},
52+
dlopen_libs = {"libGLX.so.0", "libGL.so.1", "libGL.so"},
53+
capabilities = {"x11.display", "opengl.glx.driver"},
54+
},
55+
}
56+
```
57+
58+
Compatibility rule: packages that do not declare runtime metadata keep current
59+
behavior.
60+
61+
## Implementation Plan
62+
63+
- [x] Create this repository-level plan checkpoint.
64+
- [ ] Add manifest/runtime metadata parsing and validation.
65+
- Candidate files: `src/manifest.cppm`, manifest tests.
66+
- Invalid entries should fail early: empty library name, absolute path in
67+
package metadata unless explicitly allowed, duplicate capability strings.
68+
- [ ] Carry runtime requirements through the resolved package graph.
69+
- Candidate files: dependency resolution and `PackageRoot`/graph structures.
70+
- Runtime requirements must not be mixed into public include usage.
71+
- [ ] Teach `mcpp run` and `mcpp test` to build a run environment.
72+
- Candidate file: `src/cli.cppm`.
73+
- Linux: prepend resolved runtime directories to `LD_LIBRARY_PATH`.
74+
- macOS: use `DYLD_LIBRARY_PATH` only for local tool execution where allowed,
75+
otherwise prefer rpath/install-name behavior.
76+
- Windows: prepend resolved runtime directories to `PATH`.
77+
- [ ] Add runtime diagnostics.
78+
- Candidate commands: `mcpp self doctor`, or a new target-aware runtime
79+
doctor path if the existing command shape supports it.
80+
- Diagnostics should list the target, the package that required the runtime
81+
item, unresolved `dlopen` names, and missing capabilities.
82+
- [ ] Extend `mcpp pack` to consume runtime metadata.
83+
- Candidate file: `src/pack/pack.cppm`.
84+
- `pack` should include declared runtime directories/files when the mode
85+
requests a runnable bundle.
86+
- Keep system capabilities explicit; do not silently bundle host GPU drivers
87+
unless a package declares a redistributable runtime.
88+
- [ ] Add regression coverage with a small `dlopen` fixture.
89+
- Test should prove that a library loaded only via `dlopen` is found through
90+
mcpp runtime metadata during `mcpp run`.
91+
- A second pack-oriented test should prove runtime metadata is represented in
92+
the bundled executable environment.
93+
- [ ] Update docs.
94+
- Candidate files: `docs/02-pack-and-release.md`,
95+
`docs/05-mcpp-toml.md`, README snippets if needed.
96+
97+
## Verification
98+
99+
- [ ] `mcpp build`
100+
- [ ] `mcpp run -- --version`
101+
- [ ] `mcpp test`
102+
- [ ] `MCPP=<built-mcpp> bash tests/e2e/run_all.sh`
103+
- [ ] Focused runtime metadata e2e for `dlopen` resolution
104+
- [ ] Focused pack e2e for runtime metadata inclusion
105+
106+
## PR / CI / Merge Notes
107+
108+
- [ ] Commit this plan as the first checkpoint.
109+
- [ ] Open a PR with sanitized paths and no local machine details.
110+
- [ ] Include a test plan in the PR body.
111+
- [ ] Wait for Linux/macOS/Windows CI.
112+
- [ ] Squash merge after required checks pass.
113+
114+
## Cross-Repository Dependencies
115+
116+
- `mcpp-index` can only fully validate `compat.glfw` GLX runtime metadata after
117+
this repository supports runtime requirements in `mcpp run`.
118+
- `imgui-m` should not own tool runtime behavior; it only consumes the fixed
119+
behavior through its minimal window example.
120+
- `xim-pkgindex` participates only after a released mcpp version is needed by
121+
xlings or users.

0 commit comments

Comments
 (0)