Skip to content

Commit 5a558a4

Browse files
authored
Add muduo and required Boost compat packages (#502)
* Add muduo and required Boost packages * Fix muduo Linux support and C++23 compatibility
1 parent c0c5e01 commit 5a558a4

17 files changed

Lines changed: 346 additions & 0 deletions

File tree

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# muduo compat and Boost dependencies
2+
3+
- muduo upstream: `chenshuo/muduo`, release `v2.0.3`, BSD-3-Clause.
4+
- muduo is packaged as Form B **Linux-only** from the GitHub release archive: upstream poller uses `sys/epoll.h` and timer queue uses `sys/timerfd.h`. The only `xpm` section is `linux`; consumers gate it with `cfg(linux)`. Direct source compilation includes muduo base/network/poller units and excludes optional examples, protobuf/RPC, and contrib targets. The upstream empty `boilerplate.cc` is excluded because its referenced `BoilerPlate.h` is absent from the archive.
5+
- muduo archive SHA-256: `5e90c2f07074ed5ab9347959edc8d387e40a57fbffb92e4a99cfb9a230851371` (two matching calculations).
6+
- Dependency research from the actual compiler errors and upstream include tree found `boost/operators.hpp`, `boost/any.hpp`, and `boost/circular_buffer.hpp`. `boost/operators.hpp` is provided by Boost.Utility; that descriptor already existed. Added `compat.boost-any` and `compat.boost-circular-buffer`; the latter's transitive include closure also required adding `compat.boost-concept-check`.
7+
- Added Boost component versions all follow the index's 1.92.0 train:
8+
- `compat.boost-any`, upstream `boostorg/any`, BSL-1.0; SHA-256 `335090455387b06b356bbc317d4949f6e7455165942bd7f50dbfe9cab96d624a`.
9+
- `compat.boost-circular-buffer`, upstream `boostorg/circular_buffer`, BSL-1.0; SHA-256 `0845c8f06fe5a40ef5955360f37054bd8bb856d2ecd4ae5daa8c04252358e34e`.
10+
- `compat.boost-concept-check`, upstream `boostorg/concept_check`, BSL-1.0; SHA-256 `8dbd2385b0045eddb4c0f071f3c9740c1e61fa3c4cb50d29e139b4b05f55b7e8`.
11+
- SHA-256 values above were computed twice per archive. CN mirrors are not configured; descriptors use plain upstream URL strings until matching GitCode assets are available.
12+
- muduo depends on `compat.boost-any`, `compat.boost-circular-buffer`, and existing `compat.boost-utility`.
13+
- Workspace tests: `boost-any` checks value storage/cast/clear; `boost-circular-buffer` checks bounded overwrite; `boost-concept-check` compiles concept assertions; `muduo` checks Buffer behavior.
14+
- CI exposed three unsupported assumptions: macOS lacks Linux `epoll`/`timerfd`, Windows lacks POSIX `pthread.h`/`netinet/in.h`, and LLVM/libc++ at C++23 does not provide `shared_ptr::unique()` (removed in C++20). The first two are fixed by publishing muduo only on Linux and gating its member dependency; the last by an install hook replacing the single upstream `connection_.unique()` call with `connection_.use_count() == 1`, preserving its meaning. LLVM's Linux sysroot also requires an explicit `<time.h>` in `Timestamp.cc` for `struct tm`; the same hook inserts that include. Each edit checks an exact-one match and retains the upstream archive SHA.
15+
- Verification: `mcpp xpkg parse --all-os pkgs/c/compat.muduo.lua` reports Linux only; after a cold local install, `mcpp test -p muduo` passed under GCC 16.1.0 and `mcpp test -p muduo --toolchain llvm@22.1.8` passed under LLVM 22.1.8. The three Boost component members passed the original macOS and Windows CI checks. The local environment emitted a default-SubOS-description warning; it did not fail the runs.
16+
- With the CI-pinned mcpp 2026.10.1.2 and LLVM 22.1.8, a fresh muduo install plus `mcpp test -p muduo --toolchain llvm@22.1.8 --cache off` passed (`buffer ... ok; test result ok. 1 passed; 0 failed`). macOS and Windows gates need confirmation from the next CI run.

‎CHANGELOG.md‎

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,12 @@
99

1010
### Added
1111

12+
- **`compat.muduo` 2.0.3 与 Boost 头组件。** muduo 仅支持 Linux;内联构建
13+
`muduo_base`/`muduo_net` 源码,按上游 2.0.3 的依赖补充 `compat.boost-any`、
14+
`compat.boost-circular-buffer`、`compat.boost-concept-check` 并复用既有 `compat.boost-utility`。
15+
三个新增 Boost 包各有 workspace 成员;muduo 的成员按 Linux 门控。上游归档使用 GLOBAL 地址,
16+
CN 镜像待补。安装钩子仅修补 C++20 移除的 `shared_ptr::unique()` 与缺失的 `<time.h>`。
17+
1218
- **`compat.yaml-cpp` 0.8.0 与 0.9.0。** YAML 1.2 解析与生成,按上游 CMake 目标原样编译
1319
(`src/*.cpp` + `src/contrib/*.cpp`),GLOBAL + GitCode CN 镜像字节一致。上游把
1420
`YAML_CPP_STATIC_DEFINE` 作为静态构建的 PUBLIC 定义;描述符的 `defines` 到不了消费者,

‎README.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,9 @@ One descriptor per common shape:
3838
| Native module library (Form A) | [`mcpplibs.tinyhttps`](pkgs/t/tinyhttps.lua) · [`gzj-creator.galay`](pkgs/g/gzj-creator.galay.lua) |
3939
| C sources + `features` | [`compat.cjson`](pkgs/c/compat.cjson.lua) |
4040
| C++ sources, several versions | [`compat.yaml-cpp`](pkgs/c/compat.yaml-cpp.lua) |
41+
| Boost header-only components | [`compat.boost-any`](pkgs/c/compat.boost-any.lua) · [`compat.boost-circular-buffer`](pkgs/c/compat.boost-circular-buffer.lua) · [`compat.boost-concept-check`](pkgs/c/compat.boost-concept-check.lua) · [`compat.boost-utility`](pkgs/c/compat.boost-utility.lua) |
4142
| Header-only | [`compat.gtl`](pkgs/c/compat.gtl.lua) |
43+
| Linux-only C++ network library | [`compat.muduo`](pkgs/c/compat.muduo.lua) |
4244
| Generated config header | [`compat.c-ares`](pkgs/c/compat.c-ares.lua) |
4345
| C++23 module wrapper | [`nlohmann.json`](pkgs/n/nlohmann.json.lua) |
4446
| C++23 module shipped by upstream | [`khronos.vulkan-hpp`](pkgs/k/khronos.vulkan-hpp.lua) |

‎README.zh-CN.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,8 @@ mcpp self config --mirror CN # 切换至国内镜像,默认使用 GLOBAL 上
3737
| 原生模块库(Form A) | [`mcpplibs.tinyhttps`](pkgs/t/tinyhttps.lua) · [`gzj-creator.galay`](pkgs/g/gzj-creator.galay.lua) |
3838
| C 源码 + `features` | [`compat.cjson`](pkgs/c/compat.cjson.lua) |
3939
| C++ 源码,多版本 | [`compat.yaml-cpp`](pkgs/c/compat.yaml-cpp.lua) |
40+
| Boost 头文件组件 | [`compat.boost-any`](pkgs/c/compat.boost-any.lua) · [`compat.boost-circular-buffer`](pkgs/c/compat.boost-circular-buffer.lua) · [`compat.boost-concept-check`](pkgs/c/compat.boost-concept-check.lua) · [`compat.boost-utility`](pkgs/c/compat.boost-utility.lua) |
41+
| 仅 Linux 的 C++ 网络库 | [`compat.muduo`](pkgs/c/compat.muduo.lua) |
4042
| header-only | [`compat.gtl`](pkgs/c/compat.gtl.lua) |
4143
| 生成 config 头 | [`compat.c-ares`](pkgs/c/compat.c-ares.lua) |
4244
| C++23 module wrapper | [`nlohmann.json`](pkgs/n/nlohmann.json.lua) |

‎mcpp.toml‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ members = [
1313
"tests/examples/asio-module",
1414
"tests/examples/asio-ssl",
1515
"tests/examples/boost-asio",
16+
"tests/examples/boost-any",
17+
"tests/examples/boost-circular-buffer",
18+
"tests/examples/boost-concept-check",
1619
"tests/examples/boost-assert",
1720
"tests/examples/boost-beast",
1821
"tests/examples/boost-config",
@@ -73,6 +76,7 @@ members = [
7376
"tests/examples/marzer.tomlplusplus",
7477
"tests/examples/mcpp-plugins",
7578
"tests/examples/mio",
79+
"tests/examples/muduo",
7680
"tests/examples/libmysqlclient",
7781
"tests/examples/mysql-connector-cpp",
7882
"tests/examples/nlohmann.json",

‎pkgs/c/compat.boost-any.lua‎

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package = {
2+
spec = "1",
3+
namespace = "compat",
4+
name = "boost-any",
5+
description = "Boost.Any 1.92.0 — a type-safe container for single values of different types",
6+
licenses = {"BSL-1.0"},
7+
repo = "https://github.com/boostorg/any",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["1.92.0"] = {
13+
url = "https://github.com/boostorg/any/archive/refs/tags/boost-1.92.0.tar.gz",
14+
sha256 = "335090455387b06b356bbc317d4949f6e7455165942bd7f50dbfe9cab96d624a",
15+
},
16+
},
17+
macosx = {
18+
["1.92.0"] = {
19+
url = "https://github.com/boostorg/any/archive/refs/tags/boost-1.92.0.tar.gz",
20+
sha256 = "335090455387b06b356bbc317d4949f6e7455165942bd7f50dbfe9cab96d624a",
21+
},
22+
},
23+
windows = {
24+
["1.92.0"] = {
25+
url = "https://github.com/boostorg/any/archive/refs/tags/boost-1.92.0.tar.gz",
26+
sha256 = "335090455387b06b356bbc317d4949f6e7455165942bd7f50dbfe9cab96d624a",
27+
},
28+
},
29+
},
30+
31+
mcpp = {
32+
language = "c++23",
33+
import_std = false,
34+
include_dirs = { "*/include" },
35+
generated_files = {
36+
["mcpp_generated/boost_any_anchor.cpp"] = "int mcpp_compat_boost_any_anchor(void) { return 0; }\n",
37+
},
38+
sources = { "mcpp_generated/boost_any_anchor.cpp" },
39+
targets = { ["boost_any"] = { kind = "lib" } },
40+
deps = {
41+
["compat.boost-config"] = "1.92.0",
42+
["compat.boost-throw-exception"] = "1.92.0",
43+
["compat.boost-type-index"] = "1.92.0",
44+
},
45+
},
46+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
package = {
2+
spec = "1",
3+
namespace = "compat",
4+
name = "boost-circular-buffer",
5+
description = "Boost.CircularBuffer 1.92.0 — a STL-compatible ring buffer container",
6+
licenses = {"BSL-1.0"},
7+
repo = "https://github.com/boostorg/circular_buffer",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["1.92.0"] = {
13+
url = "https://github.com/boostorg/circular_buffer/archive/refs/tags/boost-1.92.0.tar.gz",
14+
sha256 = "0845c8f06fe5a40ef5955360f37054bd8bb856d2ecd4ae5daa8c04252358e34e",
15+
},
16+
},
17+
macosx = {
18+
["1.92.0"] = {
19+
url = "https://github.com/boostorg/circular_buffer/archive/refs/tags/boost-1.92.0.tar.gz",
20+
sha256 = "0845c8f06fe5a40ef5955360f37054bd8bb856d2ecd4ae5daa8c04252358e34e",
21+
},
22+
},
23+
windows = {
24+
["1.92.0"] = {
25+
url = "https://github.com/boostorg/circular_buffer/archive/refs/tags/boost-1.92.0.tar.gz",
26+
sha256 = "0845c8f06fe5a40ef5955360f37054bd8bb856d2ecd4ae5daa8c04252358e34e",
27+
},
28+
},
29+
},
30+
31+
mcpp = {
32+
language = "c++23",
33+
import_std = false,
34+
include_dirs = { "*/include" },
35+
generated_files = {
36+
["mcpp_generated/boost_circular_buffer_anchor.cpp"] = "int mcpp_compat_boost_circular_buffer_anchor(void) { return 0; }\n",
37+
},
38+
sources = { "mcpp_generated/boost_circular_buffer_anchor.cpp" },
39+
targets = { ["boost_circular_buffer"] = { kind = "lib" } },
40+
deps = {
41+
["compat.boost-concept-check"] = "1.92.0",
42+
["compat.boost-config"] = "1.92.0",
43+
["compat.boost-core"] = "1.92.0",
44+
["compat.boost-move"] = "1.92.0",
45+
["compat.boost-throw-exception"] = "1.92.0",
46+
["compat.boost-type-traits"] = "1.92.0",
47+
},
48+
},
49+
}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package = {
2+
spec = "1",
3+
namespace = "compat",
4+
name = "boost-concept-check",
5+
description = "Boost.ConceptCheck 1.92.0 — compile-time checks for C++ concepts and requirements",
6+
licenses = {"BSL-1.0"},
7+
repo = "https://github.com/boostorg/concept_check",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["1.92.0"] = {
13+
url = "https://github.com/boostorg/concept_check/archive/refs/tags/boost-1.92.0.tar.gz",
14+
sha256 = "8dbd2385b0045eddb4c0f071f3c9740c1e61fa3c4cb50d29e139b4b05f55b7e8",
15+
},
16+
},
17+
macosx = {
18+
["1.92.0"] = {
19+
url = "https://github.com/boostorg/concept_check/archive/refs/tags/boost-1.92.0.tar.gz",
20+
sha256 = "8dbd2385b0045eddb4c0f071f3c9740c1e61fa3c4cb50d29e139b4b05f55b7e8",
21+
},
22+
},
23+
windows = {
24+
["1.92.0"] = {
25+
url = "https://github.com/boostorg/concept_check/archive/refs/tags/boost-1.92.0.tar.gz",
26+
sha256 = "8dbd2385b0045eddb4c0f071f3c9740c1e61fa3c4cb50d29e139b4b05f55b7e8",
27+
},
28+
},
29+
},
30+
31+
mcpp = {
32+
language = "c++23",
33+
import_std = false,
34+
include_dirs = { "*/include" },
35+
generated_files = {
36+
["mcpp_generated/boost_concept_check_anchor.cpp"] = "int mcpp_compat_boost_concept_check_anchor(void) { return 0; }\n",
37+
},
38+
sources = { "mcpp_generated/boost_concept_check_anchor.cpp" },
39+
targets = { ["boost_concept_check"] = { kind = "lib" } },
40+
deps = {
41+
["compat.boost-assert"] = "1.92.0",
42+
["compat.boost-config"] = "1.92.0",
43+
["compat.boost-type-traits"] = "1.92.0",
44+
["compat.boost-preprocessor"] = "1.92.0",
45+
},
46+
},
47+
}

‎pkgs/c/compat.muduo.lua‎

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
package = {
2+
spec = "1",
3+
namespace = "compat",
4+
name = "muduo",
5+
description = "A reactor-based C++ network library for Linux",
6+
licenses = {"BSD-3-Clause"},
7+
repo = "https://github.com/chenshuo/muduo",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["2.0.3"] = {
13+
url = "https://github.com/chenshuo/muduo/archive/refs/tags/v2.0.3.tar.gz",
14+
sha256 = "5e90c2f07074ed5ab9347959edc8d387e40a57fbffb92e4a99cfb9a230851371",
15+
},
16+
},
17+
},
18+
19+
mcpp = {
20+
language = "c++23",
21+
import_std = false,
22+
include_dirs = { "*" },
23+
sources = {
24+
"*/muduo/base/*.cc",
25+
"*/muduo/net/poller/DefaultPoller.cc",
26+
"*/muduo/net/poller/EPollPoller.cc",
27+
"*/muduo/net/poller/PollPoller.cc",
28+
"*/muduo/net/Acceptor.cc",
29+
"*/muduo/net/Buffer.cc",
30+
"*/muduo/net/Channel.cc",
31+
"*/muduo/net/Connector.cc",
32+
"*/muduo/net/EventLoop.cc",
33+
"*/muduo/net/EventLoopThread.cc",
34+
"*/muduo/net/EventLoopThreadPool.cc",
35+
"*/muduo/net/InetAddress.cc",
36+
"*/muduo/net/Poller.cc",
37+
"*/muduo/net/Socket.cc",
38+
"*/muduo/net/SocketsOps.cc",
39+
"*/muduo/net/TcpClient.cc",
40+
"*/muduo/net/TcpConnection.cc",
41+
"*/muduo/net/TcpServer.cc",
42+
"*/muduo/net/Timer.cc",
43+
"*/muduo/net/TimerQueue.cc",
44+
},
45+
targets = {
46+
["muduo"] = { kind = "lib" },
47+
},
48+
deps = {
49+
["compat.boost-circular-buffer"] = "1.92.0",
50+
["compat.boost-any"] = "1.92.0",
51+
["compat.boost-utility"] = "1.92.0",
52+
},
53+
},
54+
}
55+
56+
import("xim.libxpkg.pkginfo")
57+
import("xim.libxpkg.log")
58+
59+
function install()
60+
local wrap = "muduo-" .. pkginfo.version()
61+
if not os.isfile(path.join(wrap, "muduo/net/TcpClient.cc")) then
62+
log.error("compat.muduo: expected %s/muduo/net/TcpClient.cc", wrap)
63+
return false
64+
end
65+
66+
local prefix = pkginfo.install_dir()
67+
os.tryrm(prefix)
68+
os.mkdir(prefix)
69+
local srcroot = path.join(prefix, wrap)
70+
os.mv(wrap, srcroot)
71+
72+
-- shared_ptr::unique() was removed in C++20; the upstream C++17 code
73+
-- uses it before copying connection_. Preserve its exact meaning.
74+
local source = path.join(srcroot, "muduo/net/TcpClient.cc")
75+
local content = io.readfile(source)
76+
local patched, count = content:gsub("connection_%.unique%(%);", "connection_.use_count() == 1;")
77+
if count ~= 1 then
78+
log.error("compat.muduo: expected exactly one shared_ptr::unique() call, got %d", count)
79+
return false
80+
end
81+
io.writefile(source, patched)
82+
-- sys/time.h does not promise the definition of struct tm. Clang's
83+
-- Linux sysroot needs the explicit time.h include for gmtime_r().
84+
source = path.join(srcroot, "muduo/base/Timestamp.cc")
85+
content = io.readfile(source)
86+
patched, count = content:gsub("#include <sys/time%.h>\n", "#include <sys/time.h>\n#include <time.h>\n")
87+
if count ~= 1 then
88+
log.error("compat.muduo: expected exactly one sys/time.h include, got %d", count)
89+
return false
90+
end
91+
io.writefile(source, patched)
92+
return true
93+
end

‎tests/examples/boost-any/mcpp.toml‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# compat.boost-any test project.
2+
[package]
3+
name = "boost-any-tests"
4+
version = "0.1.0"
5+
6+
[dependencies.compat]
7+
boost-any = "1.92.0"

0 commit comments

Comments
 (0)