-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathchriskohlhoff.asio.lua
More file actions
280 lines (269 loc) · 10.8 KB
/
Copy pathchriskohlhoff.asio.lua
File metadata and controls
280 lines (269 loc) · 10.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
-- asio -- 将独立版 Asio 1.38.1 暴露为 C++23 模块 `asio`
-- (Form B inline descriptor, separate-compilation mode)。
--
-- 注意事项
-- * 使用 `mcpp add chriskohlhoff.asio@1.38.1` 引入;消费者需显式写
-- `import std; import asio;`,因为本包设置 import_std = false。
-- * 本包只支持模块方式消费。同一 translation unit 不要混用
-- `#include <asio.hpp>` 和 `import asio;`,避免 inline 定义与模块 BMI
-- 的 separate-compilation 定义产生 ODR 差异。
-- * 默认 feature 显式传播 ASIO_STANDALONE、ASIO_SEPARATE_COMPILATION、
-- ASIO_DISABLE_BOOST_CONTEXT_FIBER 和 ASIO_HAS_THREADS。Asio 头文件内部
-- 自动检测的其他 ASIO_HAS_* 宏不会由 `import asio;` 导出。
--
-- 与 header-only Asio 的区别/限制
-- * 上游 1.38.x 没有模块接口单元。本描述生成 `asio.cppm`,并只编译一次
-- `*/src/asio.cpp` 中的非模板实现;首次构建需生成 BMI,增量构建可避免
-- 每个消费者 translation unit 重复解析整组 Asio 头文件。
-- * 模块只暴露 wrapper 中明确 export 的声明,不等同于
-- `#include <asio.hpp>` 的完整 API 表面。
-- * asio::error_code 是 std::error_code 的别名;wrapper 导出
-- asio::use_future 变量,但未导出 asio::use_future_t<Alloc> 类模板。
-- * 依赖未导出 ASIO_HAS_* 宏、平台专用头文件或 Boost 扩展的代码,需要
-- 改用标准/操作系统能力检测或另行扩展模块 wrapper。
--
-- 未导出的组件
-- * SSL/TLS (`asio/ssl/*.hpp`):需要 OpenSSL/wolfSSL 等外部依赖。
-- * Unix 域套接字、POSIX 描述符和 Windows 句柄:
-- `asio/local/*.hpp`、`asio/posix/*.hpp`、`asio/windows/*.hpp`。
-- * 串口、pipe 和文件 I/O:`asio/serial_port.hpp`、
-- `asio/*able_pipe.hpp`、`asio/stream_file.hpp`、
-- `asio/random_access_file.hpp`。
-- * spawn()/yield_context 有栈协程:需要 Boost.Context;本包禁用其自动
-- 检测,应改用 co_spawn + awaitable + use_awaitable。
-- * deadline_timer、generic protocol、execution、traits、遗留宏式协程和
-- streambuf:对应 `asio/deadline_timer.hpp`、`asio/generic/*.hpp`、
-- `asio/execution/*.hpp`、`asio/traits/*.hpp`、`asio/yield.hpp`、
-- `asio/coroutine.hpp`、`asio/streambuf.hpp`。
package = {
spec = "1",
namespace = "chriskohlhoff",
-- `name` MUST be the fully-qualified `<namespace>.<short>`: xlings keys its
-- index on this literal (libxpkg build_index → entries[package.name]),
-- while mcpp asks for the FQN it reconstructs from the consumer's
-- `[dependencies.<ns>] <short>`. Writing the split form ("asio") is legal
-- per mcpp's own descriptor spec (manifest/xpkg.cppm canonical_xpkg_
-- identity normalizes both spellings) but registers the index entry under
-- `asio`, which no consumer request can ever hit → E_NOT_FOUND at install.
-- See mcpp-community/mcpp#278; the lint in validate.yml enforces this.
name = "chriskohlhoff.asio",
description = "Standalone asio exposed as the C++23 module `asio` (separate compilation)",
licenses = {"BSL-1.0"},
repo = "https://github.com/chriskohlhoff/asio",
type = "package",
xpm = {
linux = {
["1.38.1"] = {
url = {
GLOBAL = "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-38-1.tar.gz",
CN = "https://gitcode.com/mcpp-res/asio/releases/download/1.38.1/asio-1.38.1.tar.gz",
},
sha256 = "2827b229972be80cdb14e5497962fa393d1adf036b5869e2b9c99f644daadacc",
},
},
macosx = {
["1.38.1"] = {
url = {
GLOBAL = "https://github.com/chriskohlhoff/asio/archive/refs/tags/asio-1-38-1.tar.gz",
CN = "https://gitcode.com/mcpp-res/asio/releases/download/1.38.1/asio-1.38.1.tar.gz",
},
sha256 = "2827b229972be80cdb14e5497962fa393d1adf036b5869e2b9c99f644daadacc",
},
},
windows = {
-- Upstream tag archives carry two POSIX symlinks
-- (asio/include -> ../include, asio/src -> ../src) that tar.exe
-- cannot materialize on the Windows runner. This uses the existing
-- symlink-free repack documented by xlings-res/asio.
["1.38.1"] = {
url = {
GLOBAL = "https://github.com/xlings-res/asio/releases/download/1.38.1/asio-1.38.1-nosymlinks.tar.gz",
CN = "https://gitcode.com/mcpp-res/asio/releases/download/1.38.1/asio-1.38.1-nosymlinks.tar.gz",
},
sha256 = "77f74094bb12cd867a6edbf5736bbed816c6ce0906e880de8573097a81714d89",
},
},
},
mcpp = {
schema = "0.1",
language = "c++23",
import_std = false,
modules = { "asio" },
-- GitHub wraps the tag as asio-asio-1-38-1/; expose its include root
-- so the wrapper's `#include <asio/*.hpp>` resolve.
include_dirs = { "*/include" },
generated_files = {
["mcpp_generated/asio.cppm"] = [==[
module;
#include <asio/io_context.hpp>
#include <asio/post.hpp>
#include <asio/executor_work_guard.hpp>
#include <asio/dispatch.hpp>
#include <asio/defer.hpp>
#include <asio/steady_timer.hpp>
#include <asio/thread_pool.hpp>
#include <asio/strand.hpp>
#include <asio/ip/tcp.hpp>
#include <asio/ip/address_v4.hpp>
#include <asio/buffer.hpp>
#include <asio/awaitable.hpp>
#include <asio/this_coro.hpp>
#include <asio/use_awaitable.hpp>
#include <asio/co_spawn.hpp>
#include <asio/cancellation_signal.hpp>
#include <asio/cancellation_type.hpp>
#include <asio/bind_cancellation_slot.hpp>
#include <asio/execution_context.hpp>
#include <asio/any_io_executor.hpp>
#include <asio/system_executor.hpp>
#include <asio/system_context.hpp>
#include <asio/associated_executor.hpp>
#include <asio/associated_allocator.hpp>
#include <asio/associated_cancellation_slot.hpp>
#include <asio/error_code.hpp>
#include <asio/detached.hpp>
#include <asio/use_future.hpp>
#include <asio/deferred.hpp>
#include <asio/redirect_error.hpp>
#include <asio/bind_executor.hpp>
#include <asio/signal_set.hpp>
#include <asio/system_timer.hpp>
#include <asio/bind_allocator.hpp>
#include <asio/append.hpp>
#include <asio/prepend.hpp>
#include <asio/consign.hpp>
#include <asio/as_tuple.hpp>
#include <asio/socket_base.hpp>
#include <asio/connect.hpp>
#include <asio/read.hpp>
#include <asio/write.hpp>
#include <asio/read_until.hpp>
#include <asio/ip/udp.hpp>
#include <asio/ip/address.hpp>
#include <asio/ip/address_v6.hpp>
#include <asio/experimental/promise.hpp>
#include <asio/experimental/channel_error.hpp>
#include <asio/experimental/channel.hpp>
#include <asio/experimental/concurrent_channel.hpp>
#include <asio/experimental/use_promise.hpp>
#include <asio/experimental/parallel_group.hpp>
#include <asio/experimental/awaitable_operators.hpp>
export module asio;
export namespace asio::detail {
using ::std::chrono::operator==;
using ::std::chrono::operator<;
using ::std::chrono::operator>=;
using ::std::chrono::operator+;
using ::std::chrono::operator-;
using ::std::coroutine_traits;
}
export namespace asio::error {
using ::asio::error::make_error_code;
using ::asio::error::operation_aborted;
}
export namespace asio {
using ::asio::io_context;
using ::asio::post;
using ::asio::make_work_guard;
using ::asio::dispatch;
using ::asio::defer;
using ::asio::steady_timer;
using ::asio::thread_pool;
using ::asio::make_strand;
using ::asio::mutable_buffer;
using ::asio::const_buffer;
using ::asio::buffer;
using ::asio::awaitable;
using ::asio::use_awaitable;
using ::asio::co_spawn;
using ::asio::cancellation_signal;
using ::asio::cancellation_type;
using ::asio::bind_cancellation_slot;
using ::asio::execution_context;
using ::asio::any_io_executor;
using ::asio::system_executor;
using ::asio::system_context;
using ::asio::associated_executor;
using ::asio::associated_allocator;
using ::asio::associated_cancellation_slot;
using ::asio::error_code;
using ::asio::detached;
using ::asio::detached_t;
using ::asio::use_future;
using ::asio::deferred;
using ::asio::deferred_t;
using ::asio::redirect_error;
using ::asio::bind_executor;
using ::asio::signal_set;
using ::asio::system_timer;
using ::asio::bind_allocator;
using ::asio::append;
using ::asio::prepend;
using ::asio::consign;
using ::asio::as_tuple;
using ::asio::socket_base;
using ::asio::connect;
using ::asio::async_read;
using ::asio::async_write;
using ::asio::read;
using ::asio::write;
using ::asio::read_until;
}
export namespace asio::experimental {
using ::asio::experimental::channel;
using ::asio::experimental::concurrent_channel;
using ::asio::experimental::use_promise;
}
export namespace asio::experimental::error {
using ::asio::experimental::error::make_error_code;
}
export namespace asio::ip {
using ::asio::ip::tcp;
using ::asio::ip::udp;
using ::asio::ip::address;
using ::asio::ip::address_v4;
using ::asio::ip::address_v6;
}
export namespace asio::this_coro {
using ::asio::this_coro::executor;
using ::asio::this_coro::cancellation_state;
using ::asio::this_coro::throw_if_cancelled;
using ::asio::this_coro::reset_cancellation_state;
}
]==],
},
sources = {
"mcpp_generated/asio.cppm",
"*/src/asio.cpp",
},
targets = { ["asio"] = { kind = "lib" } },
-- `separate-compilation` is a default feature so its defines propagate
-- to every consumer TU (the module BMI and the consumer must agree on
-- ASIO_SEPARATE_COMPILATION or the inline/extern split miscompiles).
--
-- ASIO_HAS_THREADS: asio's detection keys off CRT macros
-- (_MT/_REENTRANT/_POSIX_THREADS) that the workspace's llvm-on-Windows
-- toolchain does not define, otherwise silently selecting null_thread.
-- Pin the known multithreaded package contract; POSIX pthread selection
-- still runs beneath this define where applicable.
features = {
["default"] = { implies = { "separate-compilation" } },
["separate-compilation"] = {
defines = {
"ASIO_STANDALONE",
"ASIO_SEPARATE_COMPILATION",
"ASIO_DISABLE_BOOST_CONTEXT_FIBER",
"ASIO_HAS_THREADS",
},
},
},
deps = {},
-- POSIX threading is detected by asio from unistd.h feature macros;
-- retain the portable driver-level thread link contract on Linux.
linux = {
ldflags = { "-pthread" },
},
-- On the supported desktop MSVC-ABI route, asio autolinks ws2_32.lib
-- and mswsock.lib. Do not inject GNU -l flags into native link.exe.
},
}