Skip to content

Commit e8f0840

Browse files
committed
模块名带上拥有接口的组织,并修好 wayland 因重切 tag 而失效的 sha256
⚠ 这个提交修复 main 上的一处失效:mcpplibs/wayland 的 v1.26.0 被重切以承载模块 重命名,于是已合并描述符里的 sha256 不再匹配,freedesktop.wayland@1.26.0 目前 装不下来。四个 wayland 描述符的 sha256 都已更新,合并即恢复。 模块重命名: wayland.client → freedesktop.wayland.client wayland.server → freedesktop.wayland.server wayland.util → freedesktop.wayland.util egl → khronos.egl 规则是「模块名跟拥有**接口**的组织,而不是发实现代码的人」。freedesktop 确实拥有 wayland 协议;EGL 则是 Khronos 的规范,libglvnd 只是实现之一、freedesktop 只是托管方 —— 所以包仍叫 freedesktop.egl,导出的模块叫 khronos.egl。 mcpplibs.openkal 已经为这条规则付过学费:它的 0.1.0 是被撤回而不是保留的,原因写在 描述符里 —— "placed the module a consumer imports under the control of the implementation, which contradicts what the specification is for"。 模块名是全局且长期的,包名不是。换实现不该逼消费者改 import,否则一个「除了 include 那一行什么都不改」的包装层就失去了意义。副作用是好的:两个 EGL 提供方现在会在模块名 上硬冲突,而不是静默共存 —— 这正是 GLVND「一个进程一个 dispatch 点」想要的。 索引里既有的惯例本来就是「namespace 不进模块名」(chriskohlhoff.asio → import asio, fmtlib.fmt → import fmt,compat.opencv → import opencv.cv),这次是把它推进一步: 不是随便一个名字,而是接口所有者的名字。
1 parent cc94a86 commit e8f0840

7 files changed

Lines changed: 42 additions & 22 deletions

File tree

‎pkgs/f/freedesktop.egl.lua‎

Lines changed: 29 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
-- freedesktop.egl — libEGL.so.1, plus `import egl;`.
1+
-- freedesktop.egl — libEGL.so.1, plus `import khronos.egl;`.
22
--
33
-- EGL is the window-system binding: `eglGetPlatformDisplay`,
44
-- `eglCreateContext`, `eglCreateWindowSurface`, `eglMakeCurrent`, and the
@@ -42,13 +42,33 @@
4242
-- other than libEGL needs it — `libGL` and `libGLX` would.
4343
--
4444
-- ─────────────────────────────────────────────────────────────────────────
45-
-- THE MODULE ADDS NO API
46-
--
47-
-- `import egl;` replaces `#include <EGL/egl.h>` and changes nothing else:
48-
-- every exported name is upstream's, spelled upstream's way. Unlike wayland's
49-
-- module this one needed no forwarders — EGL's entry points are declared
50-
-- `EGLAPI … EGLAPIENTRY` with external linkage rather than `static inline`, so
51-
-- `using ::name;` reaches all of them.
45+
-- THE MODULE ADDS NO API, AND IS NAMED FOR THE SPECIFICATION
46+
--
47+
-- `import khronos.egl;` replaces `#include <EGL/egl.h>` and changes nothing
48+
-- else: every exported name is upstream's, spelled upstream's way. Unlike
49+
-- wayland's module this one needed no forwarders — EGL's entry points are
50+
-- declared `EGLAPI … EGLAPIENTRY` with external linkage rather than
51+
-- `static inline`, so `using ::name;` reaches all of them.
52+
--
53+
-- `khronos.` AND NOT `freedesktop.`, even though the package is
54+
-- `freedesktop.egl`. EGL is a Khronos SPECIFICATION with several
55+
-- implementations; libglvnd is one, and freedesktop is only where it is
56+
-- hosted. A module name is global and permanent in a way a package name is
57+
-- not, so it should name the INTERFACE's owner rather than whoever supplies
58+
-- the definitions — otherwise swapping implementations forces every consumer
59+
-- to edit its imports, which defeats a wrapper whose whole promise is that it
60+
-- changes nothing but the include line.
61+
--
62+
-- `mcpplibs.openkal` paid for this lesson already: its 0.1.0 was withdrawn
63+
-- rather than kept because it "placed the module a consumer imports under the
64+
-- control of the implementation, which contradicts what the specification is
65+
-- for". `freedesktop.wayland` resolves the other way for the same reason —
66+
-- freedesktop DOES own the wayland protocol, so those modules are
67+
-- `freedesktop.wayland.{client,server,util}`.
68+
--
69+
-- A side effect worth having: two EGL providers in one build now collide on
70+
-- the module name instead of coexisting silently, which is what GLVND's
71+
-- one-dispatch-point design wants anyway.
5272
--
5373
-- ONE CONSEQUENCE WORTH KNOWING: the module interface unit is compiled INTO
5474
-- `libEGL.so.1`, because mcpp links every library target against all of a
@@ -108,7 +128,7 @@ package = {
108128
GLOBAL = "https://github.com/mcpplibs/libglvnd/archive/refs/tags/v1.7.0.tar.gz",
109129
CN = "https://gitcode.com/mcpp-res/libglvnd/releases/download/1.7.0/libglvnd-1.7.0.tar.gz",
110130
},
111-
sha256 = "2bc59cb214ac2750cf09764f9b5822132be96f1c4f6fe40a2553dae8efb36663",
131+
sha256 = "d50579071c5e0b883cddae82fac3f8d7c575b6523c9ea64b855a3d6f50951d47",
112132
},
113133
},
114134
},

‎pkgs/f/freedesktop.wayland-scanner.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ package = {
3636
GLOBAL = "https://github.com/mcpplibs/wayland/archive/refs/tags/v1.26.0.tar.gz",
3737
CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0.tar.gz",
3838
},
39-
sha256 = "0a5dd54ab01e675c9a150774ade0c1262a7ad4285e0362327f26e5612d0a2f47",
39+
sha256 = "961a900dafe76e713c2e46d9a064ff3a6375622f4057013472a04c44d8bcb6e8",
4040
},
4141
},
4242
},

‎pkgs/f/freedesktop.wayland-server.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ package = {
3636
GLOBAL = "https://github.com/mcpplibs/wayland/archive/refs/tags/v1.26.0.tar.gz",
3737
CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0.tar.gz",
3838
},
39-
sha256 = "0a5dd54ab01e675c9a150774ade0c1262a7ad4285e0362327f26e5612d0a2f47",
39+
sha256 = "961a900dafe76e713c2e46d9a064ff3a6375622f4057013472a04c44d8bcb6e8",
4040
},
4141
},
4242
},

‎pkgs/f/freedesktop.wayland-util.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ package = {
3636
GLOBAL = "https://github.com/mcpplibs/wayland/archive/refs/tags/v1.26.0.tar.gz",
3737
CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0.tar.gz",
3838
},
39-
sha256 = "0a5dd54ab01e675c9a150774ade0c1262a7ad4285e0362327f26e5612d0a2f47",
39+
sha256 = "961a900dafe76e713c2e46d9a064ff3a6375622f4057013472a04c44d8bcb6e8",
4040
},
4141
},
4242
},

‎pkgs/f/freedesktop.wayland.lua‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ package = {
3636
GLOBAL = "https://github.com/mcpplibs/wayland/archive/refs/tags/v1.26.0.tar.gz",
3737
CN = "https://gitcode.com/mcpp-res/wayland/releases/download/1.26.0/wayland-1.26.0.tar.gz",
3838
},
39-
sha256 = "0a5dd54ab01e675c9a150774ade0c1262a7ad4285e0362327f26e5612d0a2f47",
39+
sha256 = "961a900dafe76e713c2e46d9a064ff3a6375622f4057013472a04c44d8bcb6e8",
4040
},
4141
},
4242
},

‎tests/examples/egl/tests/egl.cpp‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// freedesktop.egl — behavioral test, runnable with no GPU and no display.
22
//
3-
// Every FUNCTION and TYPE below comes from `import egl;`. <EGL/egl.h> is
3+
// Every FUNCTION and TYPE below comes from `import khronos.egl;`. <EGL/egl.h> is
44
// included for the EGL_* CONSTANTS only: they are macros, and no module can
55
// export a macro. So the file compiling is itself the first assertion — the
66
// module's export list has to cover everything used here — and the file
@@ -39,7 +39,7 @@
3939
#include <cstring>
4040
#include <string>
4141

42-
import egl;
42+
import khronos.egl;
4343

4444
namespace {
4545

‎tests/examples/wayland/tests/modules.cpp‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
// The module wrappers, used the way a consumer would.
22
//
3-
// The claim they make is narrow and testable: `import wayland.client;` gives
3+
// The claim they make is narrow and testable: `import freedesktop.wayland.client;` gives
44
// you the same entities `#include <wayland-client.h>` does, spelled the same
55
// way. So this file includes NOTHING from wayland — no header — and still
66
// calls the stock API. If an export were missing, this would not compile; if a
@@ -15,9 +15,9 @@
1515
#include <string>
1616
#include <vector>
1717

18-
import wayland.client;
19-
import wayland.server;
20-
import wayland.util;
18+
import freedesktop.wayland.client;
19+
import freedesktop.wayland.server;
20+
import freedesktop.wayland.util;
2121

2222
namespace {
2323

@@ -46,15 +46,15 @@ int main()
4646

4747
// A protocol interface object: generated code, exported by the module.
4848
check(std::string(wl_registry_interface.name) == "wl_registry",
49-
"wl_registry_interface arrives through wayland.client");
49+
"wl_registry_interface arrives through freedesktop.wayland.client");
5050
check(std::string(wl_compositor_interface.name) == "wl_compositor",
5151
"so does wl_compositor_interface");
5252
}
5353

5454
// ── 2. Server entities ───────────────────────────────────────────────
5555
{
5656
wl_display *s = wl_display_create();
57-
check(s != nullptr, "wl_display_create through wayland.server");
57+
check(s != nullptr, "wl_display_create through freedesktop.wayland.server");
5858
if (s != nullptr) {
5959
wl_event_loop *loop = wl_display_get_event_loop(s);
6060
check(loop != nullptr, "wl_display_get_event_loop returns a loop");
@@ -63,7 +63,7 @@ int main()
6363
}
6464

6565
// ── 3. The macros, as entities ───────────────────────────────────────
66-
// These are the names a module cannot export as macros; wayland.util
66+
// These are the names a module cannot export as macros; freedesktop.wayland.util
6767
// carries them as a constant, a template and ranges. Exercised here in a
6868
// consumer rather than only in the package's own test.
6969
{

0 commit comments

Comments
 (0)