Skip to content

Commit c02bedc

Browse files
committed
feat(compat): add xlings compression packages
1 parent 26960bb commit c02bedc

9 files changed

Lines changed: 583 additions & 14 deletions

.agents/docs/2026-05-30-xlings-compat-packages-plan.md

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,17 @@
11
# mcpp-index: xlings Native Dependency Packages Plan
22

3-
> 状态: pending on mcpp core support
3+
> 状态: in progress
44
> 分支: `codex/xlings-mcpp-compat-packages`
55
> 目标: 把 xlings 当前本地 mcpp index 中的通用 C/C++ 依赖迁移到官方 mcpp-index,使 xlings 可以直接使用默认索引。
66
77
## 待新增包
88

9-
- [ ] `compat.zlib`
10-
- [ ] `compat.bzip2`
11-
- [ ] `compat.lz4`
12-
- [ ] `compat.zstd`
13-
- [ ] `compat.xz`
14-
- [ ] `compat.libarchive`
9+
- [x] `compat.zlib`
10+
- [x] `compat.bzip2`
11+
- [x] `compat.lz4`
12+
- [x] `compat.zstd`
13+
- [x] `compat.xz`
14+
- [x] `compat.libarchive`
1515

1616
## 命名判断
1717

@@ -28,6 +28,11 @@
2828

2929
迁移时需要把配置头和包级 flags 变成包自身资产,而不是要求消费者项目提供。
3030

31+
当前实现依赖 mcpp PR #88 中的两项能力:
32+
33+
- package-owned `cflags` / `cxxflags` 只作用到包自身源码。
34+
- Form B `generated_files` 在包解压目录中写入少量配置头。
35+
3136
## 依赖关系
3237

3338
```text
@@ -42,14 +47,15 @@ compat.libarchive
4247
## 验证要求
4348

4449
- [ ] `mcpp search libarchive` 能找到官方索引包。
45-
- [ ] 一个最小项目只声明 `libarchive`,无需根级第三方 C 库宏即可构建。
50+
- [x] 一个最小项目只声明 `compat.libarchive`,无需根级第三方 C 库宏即可构建。
4651
- [ ] xlings 改用默认 mcpp-index 后 `mcpp build` 通过。
47-
- [ ] musl static target 通过。
52+
- [x] musl static target 通过。
4853

4954
## Checkpoints
5055

51-
- [ ] 文档 checkpoint commit。
52-
- [ ] 等 mcpp 支持 package-owned flags 后迁移包描述。
53-
- [ ] 增加官方 index smoke test。
56+
- [x] 文档 checkpoint commit。
57+
- [x] 等 mcpp 支持 package-owned flags 后迁移包描述。
58+
- [x] 增加官方 index smoke test:
59+
- 临时项目 `compat.libarchive@3.8.7` default target 构建/运行通过。
60+
- 临时项目 `compat.libarchive@3.8.7` `x86_64-linux-musl` 静态构建/运行通过。
5461
- [ ] PR draft 创建并等待 CI。
55-

README.md

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,12 @@ mcpp build # 自动拉取源码 + 构建
3232
| `gtest` | 1.15.2 | Google Test 测试框架 |
3333
| `mbedtls` | 3.6.1 | TLS/加密库(纯 C) |
3434
| `lua` | 5.4.7 | Lua 脚本语言(纯 C 嵌入式库) |
35+
| `zlib` | v1.3.2 | DEFLATE 压缩库 |
36+
| `bzip2` | 1.0.8 | bzip2 压缩库 |
37+
| `lz4` | v1.10.0 | LZ4 压缩库 |
38+
| `zstd` | v1.5.7 | Zstandard 压缩库 |
39+
| `xz` | 5.8.3 | XZ Utils liblzma 压缩库 |
40+
| `libarchive` | 3.8.7 | 多格式归档与压缩库 |
3541

3642
### 依赖关系链
3743

@@ -43,6 +49,13 @@ mcpplibs.llmapi
4349
mcpplibs.xpkg
4450
└── mcpplibs.capi.lua
4551
└── lua ← 同上
52+
53+
libarchive
54+
├── zlib
55+
├── bzip2
56+
├── lz4
57+
├── zstd
58+
└── xz ← 压缩后端自动传递
4659
```
4760

4861
mcpp 0.0.3+ 的 transitive walker 自动沿链路传播头文件和依赖,消费者只需声明直接依赖。

pkgs/c/compat.bzip2.lua

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 = "compat.bzip2",
5+
description = "A freely available high-quality data compressor",
6+
licenses = {"bzip2-1.0.6"},
7+
repo = "https://sourceware.org/bzip2/",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["1.0.8"] = {
13+
url = "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz",
14+
sha256 = "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269",
15+
},
16+
},
17+
macosx = {
18+
["1.0.8"] = {
19+
url = "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz",
20+
sha256 = "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269",
21+
},
22+
},
23+
windows = {
24+
["1.0.8"] = {
25+
url = "https://sourceware.org/pub/bzip2/bzip2-1.0.8.tar.gz",
26+
sha256 = "ab5a03176ee106d3f0fa90e381da478ddae405918153cca248e682cd0c4a2269",
27+
},
28+
},
29+
},
30+
31+
mcpp = {
32+
language = "c++23",
33+
import_std = false,
34+
c_standard = "c11",
35+
include_dirs = {"*"},
36+
cflags = { "-D_GNU_SOURCE" },
37+
sources = {
38+
"*/blocksort.c",
39+
"*/bzlib.c",
40+
"*/compress.c",
41+
"*/crctable.c",
42+
"*/decompress.c",
43+
"*/huffman.c",
44+
"*/randtable.c",
45+
},
46+
targets = { ["bzip2"] = { kind = "lib" } },
47+
deps = {},
48+
},
49+
}

pkgs/c/compat.libarchive.lua

Lines changed: 183 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,183 @@
1+
package = {
2+
spec = "1",
3+
namespace = "compat",
4+
name = "compat.libarchive",
5+
description = "Multi-format archive and compression library",
6+
licenses = {"BSD-2-Clause"},
7+
repo = "https://libarchive.org/",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["3.8.7"] = {
13+
url = "https://libarchive.org/downloads/libarchive-3.8.7.tar.gz",
14+
sha256 = "4b787cca6697a95c7725e45293c973c208cbdc71ae2279f30ef09f52472b9166",
15+
},
16+
},
17+
macosx = {
18+
["3.8.7"] = {
19+
url = "https://libarchive.org/downloads/libarchive-3.8.7.tar.gz",
20+
sha256 = "4b787cca6697a95c7725e45293c973c208cbdc71ae2279f30ef09f52472b9166",
21+
},
22+
},
23+
windows = {
24+
["3.8.7"] = {
25+
url = "https://github.com/libarchive/libarchive/archive/refs/tags/v3.8.7.zip",
26+
sha256 = "8e16ac8797510144ab71ead4181ea1efb28e036b9fed283e57490ea39b8180d2",
27+
},
28+
},
29+
},
30+
31+
mcpp = {
32+
language = "c++23",
33+
import_std = false,
34+
c_standard = "c11",
35+
include_dirs = {"*", "*/libarchive", "mcpp_generated/include"},
36+
cflags = {
37+
"-D_GNU_SOURCE",
38+
"-DLIBARCHIVE_STATIC",
39+
"-DPLATFORM_CONFIG_H=\\\"mcpp_libarchive_config.h\\\"",
40+
},
41+
generated_files = {
42+
["mcpp_generated/include/localcharset.h"] = "#pragma once\nstatic inline const char* locale_charset(void) { return \"UTF-8\"; }\n",
43+
["mcpp_generated/include/mcpp_libarchive_config.h"] = "#pragma once\n#if defined(_WIN32) && !defined(__CYGWIN__)\n#include \"contrib/android/config/windows_host.h\"\n#else\n#include \"contrib/android/config/linux_host.h\"\n#endif\n#define __LIBARCHIVE_CONFIG_H_INCLUDED 1\n#if !defined(__linux__)\n#undef HAVE_LINUX_FIEMAP_H\n#undef HAVE_LINUX_FS_H\n#undef HAVE_LINUX_MAGIC_H\n#undef HAVE_LINUX_TYPES_H\n#undef HAVE_SYS_STATFS_H\n#undef HAVE_SYS_VFS_H\n#endif\n#if defined(__APPLE__)\n#undef HAVE_STRUCT_STAT_ST_MTIM_TV_NSEC\n#define HAVE_STRUCT_STAT_ST_MTIMESPEC_TV_NSEC 1\n#undef HAVE_FUTIMESAT\n#undef HAVE_ICONV\n#undef HAVE_ICONV_H\n#endif\n#if defined(_WIN32) && !defined(__CYGWIN__)\n#include <stddef.h>\n#pragma comment(lib, \"advapi32.lib\")\n#pragma comment(lib, \"xmllite.lib\")\n#undef HAVE_UNISTD_H\n#undef HAVE_DECL_SSIZE_MAX\n#define HAVE_DECL_SSIZE_MAX 0\n#define HAVE__GET_TIMEZONE 1\ntypedef ptrdiff_t ssize_t;\ntypedef int pid_t;\ntypedef unsigned short mode_t;\n#ifndef PROV_RSA_AES\n#define PROV_RSA_AES 24\n#endif\n#ifndef CALG_SHA_256\n#define CALG_SHA_256 0x0000800c\n#endif\n#ifndef CALG_SHA_384\n#define CALG_SHA_384 0x0000800d\n#endif\n#ifndef CALG_SHA_512\n#define CALG_SHA_512 0x0000800e\n#endif\n#endif\n#undef HAVE_BZLIB_H\n#define HAVE_BZLIB_H 1\n#undef HAVE_LIBBZ2\n#define HAVE_LIBBZ2 1\n#undef HAVE_LIBLZ4\n#define HAVE_LIBLZ4 1\n#undef HAVE_LIBLZMA\n#define HAVE_LIBLZMA 1\n#undef HAVE_LIBZ\n#define HAVE_LIBZ 1\n#undef HAVE_LIBZSTD\n#define HAVE_LIBZSTD 1\n#undef HAVE_LZ4_H\n#define HAVE_LZ4_H 1\n#undef HAVE_LZ4HC_H\n#define HAVE_LZ4HC_H 1\n#undef HAVE_LZMA_H\n#define HAVE_LZMA_H 1\n#undef HAVE_LZMA_STREAM_ENCODER_MT\n#undef HAVE_ZLIB_H\n#define HAVE_ZLIB_H 1\n#undef HAVE_ZSTD_H\n#define HAVE_ZSTD_H 1\n#undef HAVE_ZSTD_compressStream\n#define HAVE_ZSTD_compressStream 1\n#undef HAVE_ZSTD_minCLevel\n#define HAVE_ZSTD_minCLevel 1\n#undef HAVE_LOCALCHARSET_H\n#define HAVE_LOCALCHARSET_H 1\n#undef HAVE_LOCALE_CHARSET\n#define HAVE_LOCALE_CHARSET 1\n#undef HAVE_CLOSEFROM\n#define HAVE_CLOSEFROM 0\n#undef HAVE_CLOSE_RANGE\n#define HAVE_CLOSE_RANGE 0\n#ifndef HAVE_DECL_INT32_MAX\n#define HAVE_DECL_INT32_MAX 1\n#endif\n#ifndef HAVE_DECL_INT32_MIN\n#define HAVE_DECL_INT32_MIN 1\n#endif\n#ifndef HAVE_DECL_UINTMAX_MAX\n#define HAVE_DECL_UINTMAX_MAX 1\n#endif\n#ifndef HAVE_DECL_INTMAX_MAX\n#define HAVE_DECL_INTMAX_MAX 1\n#endif\n#ifndef HAVE_DECL_INTMAX_MIN\n#define HAVE_DECL_INTMAX_MIN 1\n#endif\n",
44+
},
45+
sources = {
46+
"*/libarchive/archive_acl.c",
47+
"*/libarchive/archive_blake2s_ref.c",
48+
"*/libarchive/archive_blake2sp_ref.c",
49+
"*/libarchive/archive_check_magic.c",
50+
"*/libarchive/archive_cmdline.c",
51+
"*/libarchive/archive_cryptor.c",
52+
"*/libarchive/archive_digest.c",
53+
"*/libarchive/archive_entry.c",
54+
"*/libarchive/archive_entry_copy_stat.c",
55+
"*/libarchive/archive_entry_link_resolver.c",
56+
"*/libarchive/archive_entry_sparse.c",
57+
"*/libarchive/archive_entry_stat.c",
58+
"*/libarchive/archive_entry_strmode.c",
59+
"*/libarchive/archive_entry_xattr.c",
60+
"*/libarchive/archive_hmac.c",
61+
"*/libarchive/archive_match.c",
62+
"*/libarchive/archive_options.c",
63+
"*/libarchive/archive_pack_dev.c",
64+
"*/libarchive/archive_parse_date.c",
65+
"*/libarchive/archive_pathmatch.c",
66+
"*/libarchive/archive_ppmd8.c",
67+
"*/libarchive/archive_ppmd7.c",
68+
"*/libarchive/archive_random.c",
69+
"*/libarchive/archive_rb.c",
70+
"*/libarchive/archive_read.c",
71+
"*/libarchive/archive_read_add_passphrase.c",
72+
"*/libarchive/archive_read_append_filter.c",
73+
"*/libarchive/archive_read_data_into_fd.c",
74+
"*/libarchive/archive_read_disk_entry_from_file.c",
75+
"*/libarchive/archive_read_disk_posix.c",
76+
"*/libarchive/archive_read_disk_windows.c",
77+
"*/libarchive/archive_read_disk_set_standard_lookup.c",
78+
"*/libarchive/archive_read_extract.c",
79+
"*/libarchive/archive_read_extract2.c",
80+
"*/libarchive/archive_read_open_fd.c",
81+
"*/libarchive/archive_read_open_file.c",
82+
"*/libarchive/archive_read_open_filename.c",
83+
"*/libarchive/archive_read_open_memory.c",
84+
"*/libarchive/archive_read_set_format.c",
85+
"*/libarchive/archive_read_set_options.c",
86+
"*/libarchive/archive_read_support_filter_all.c",
87+
"*/libarchive/archive_read_support_filter_by_code.c",
88+
"*/libarchive/archive_read_support_filter_bzip2.c",
89+
"*/libarchive/archive_read_support_filter_compress.c",
90+
"*/libarchive/archive_read_support_filter_gzip.c",
91+
"*/libarchive/archive_read_support_filter_grzip.c",
92+
"*/libarchive/archive_read_support_filter_lrzip.c",
93+
"*/libarchive/archive_read_support_filter_lz4.c",
94+
"*/libarchive/archive_read_support_filter_lzop.c",
95+
"*/libarchive/archive_read_support_filter_none.c",
96+
"*/libarchive/archive_read_support_filter_program.c",
97+
"*/libarchive/archive_read_support_filter_rpm.c",
98+
"*/libarchive/archive_read_support_filter_uu.c",
99+
"*/libarchive/archive_read_support_filter_xz.c",
100+
"*/libarchive/archive_read_support_filter_zstd.c",
101+
"*/libarchive/archive_read_support_format_7zip.c",
102+
"*/libarchive/archive_read_support_format_all.c",
103+
"*/libarchive/archive_read_support_format_ar.c",
104+
"*/libarchive/archive_read_support_format_by_code.c",
105+
"*/libarchive/archive_read_support_format_cab.c",
106+
"*/libarchive/archive_read_support_format_cpio.c",
107+
"*/libarchive/archive_read_support_format_empty.c",
108+
"*/libarchive/archive_read_support_format_iso9660.c",
109+
"*/libarchive/archive_read_support_format_lha.c",
110+
"*/libarchive/archive_read_support_format_mtree.c",
111+
"*/libarchive/archive_read_support_format_rar.c",
112+
"*/libarchive/archive_read_support_format_rar5.c",
113+
"*/libarchive/archive_read_support_format_raw.c",
114+
"*/libarchive/archive_read_support_format_tar.c",
115+
"*/libarchive/archive_read_support_format_warc.c",
116+
"*/libarchive/archive_read_support_format_xar.c",
117+
"*/libarchive/archive_read_support_format_zip.c",
118+
"*/libarchive/archive_string.c",
119+
"*/libarchive/archive_string_sprintf.c",
120+
"*/libarchive/archive_time.c",
121+
"*/libarchive/archive_util.c",
122+
"*/libarchive/archive_version_details.c",
123+
"*/libarchive/archive_virtual.c",
124+
"*/libarchive/archive_windows.c",
125+
"*/libarchive/archive_write.c",
126+
"*/libarchive/archive_write_disk_posix.c",
127+
"*/libarchive/archive_write_disk_windows.c",
128+
"*/libarchive/archive_write_disk_set_standard_lookup.c",
129+
"*/libarchive/archive_write_open_fd.c",
130+
"*/libarchive/archive_write_open_file.c",
131+
"*/libarchive/archive_write_open_filename.c",
132+
"*/libarchive/archive_write_open_memory.c",
133+
"*/libarchive/archive_write_add_filter.c",
134+
"*/libarchive/archive_write_add_filter_b64encode.c",
135+
"*/libarchive/archive_write_add_filter_by_name.c",
136+
"*/libarchive/archive_write_add_filter_bzip2.c",
137+
"*/libarchive/archive_write_add_filter_compress.c",
138+
"*/libarchive/archive_write_add_filter_grzip.c",
139+
"*/libarchive/archive_write_add_filter_gzip.c",
140+
"*/libarchive/archive_write_add_filter_lrzip.c",
141+
"*/libarchive/archive_write_add_filter_lz4.c",
142+
"*/libarchive/archive_write_add_filter_lzop.c",
143+
"*/libarchive/archive_write_add_filter_none.c",
144+
"*/libarchive/archive_write_add_filter_program.c",
145+
"*/libarchive/archive_write_add_filter_uuencode.c",
146+
"*/libarchive/archive_write_add_filter_xz.c",
147+
"*/libarchive/archive_write_add_filter_zstd.c",
148+
"*/libarchive/archive_write_set_format.c",
149+
"*/libarchive/archive_write_set_format_7zip.c",
150+
"*/libarchive/archive_write_set_format_ar.c",
151+
"*/libarchive/archive_write_set_format_by_name.c",
152+
"*/libarchive/archive_write_set_format_cpio.c",
153+
"*/libarchive/archive_write_set_format_cpio_binary.c",
154+
"*/libarchive/archive_write_set_format_cpio_newc.c",
155+
"*/libarchive/archive_write_set_format_cpio_odc.c",
156+
"*/libarchive/archive_write_set_format_filter_by_ext.c",
157+
"*/libarchive/archive_write_set_format_gnutar.c",
158+
"*/libarchive/archive_write_set_format_iso9660.c",
159+
"*/libarchive/archive_write_set_format_mtree.c",
160+
"*/libarchive/archive_write_set_format_pax.c",
161+
"*/libarchive/archive_write_set_format_raw.c",
162+
"*/libarchive/archive_write_set_format_shar.c",
163+
"*/libarchive/archive_write_set_format_ustar.c",
164+
"*/libarchive/archive_write_set_format_v7tar.c",
165+
"*/libarchive/archive_write_set_format_warc.c",
166+
"*/libarchive/archive_write_set_format_xar.c",
167+
"*/libarchive/archive_write_set_format_zip.c",
168+
"*/libarchive/archive_write_set_options.c",
169+
"*/libarchive/archive_write_set_passphrase.c",
170+
"*/libarchive/filter_fork_posix.c",
171+
"*/libarchive/filter_fork_windows.c",
172+
"*/libarchive/xxhash.c",
173+
},
174+
targets = { ["libarchive"] = { kind = "lib" } },
175+
deps = {
176+
["compat.zlib"] = "v1.3.2",
177+
["compat.bzip2"] = "1.0.8",
178+
["compat.lz4"] = "v1.10.0",
179+
["compat.zstd"] = "v1.5.7",
180+
["compat.xz"] = "5.8.3",
181+
},
182+
},
183+
}

pkgs/c/compat.lua.lua

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ package = {
4646
language = "c++23", -- top-level [package].standard knob; mcpp drives a c++23 toolchain even for pure-C deps.
4747
import_std = false, -- pure C — no `import std;`.
4848
c_standard = "c99", -- Lua's reference build is c99-clean; matches upstream src/Makefile.
49-
include_dirs = { "*/src" }, -- public headers (lua.h, lualib.h, lauxlib.h, luaconf.h) live next to .c files.
49+
include_dirs = { "*/src", "mcpp_generated/include" }, -- public headers plus package-owned config.
50+
cflags = { "-include mcpp_lua_platform_config.h" },
51+
generated_files = {
52+
["mcpp_generated/include/mcpp_lua_platform_config.h"] = "#ifndef MCPP_LUA_PLATFORM_CONFIG_H\n#define MCPP_LUA_PLATFORM_CONFIG_H\n#if !defined(_WIN32) && !defined(LUA_USE_LINUX) && !defined(LUA_USE_MACOSX)\n#if defined(__APPLE__)\n#define LUA_USE_MACOSX\n#else\n#define LUA_USE_LINUX\n#endif\n#endif\n#endif\n",
53+
},
5054
sources = {
5155
"*/src/lapi.c",
5256
"*/src/lauxlib.c",

pkgs/c/compat.lz4.lua

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
package = {
2+
spec = "1",
3+
namespace = "compat",
4+
name = "compat.lz4",
5+
description = "LZ4 extremely fast compression",
6+
licenses = {"BSD-2-Clause"},
7+
repo = "https://github.com/lz4/lz4",
8+
type = "package",
9+
10+
xpm = {
11+
linux = {
12+
["v1.10.0"] = {
13+
url = "https://github.com/lz4/lz4/archive/refs/tags/v1.10.0.tar.gz",
14+
sha256 = "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b",
15+
},
16+
},
17+
macosx = {
18+
["v1.10.0"] = {
19+
url = "https://github.com/lz4/lz4/archive/refs/tags/v1.10.0.tar.gz",
20+
sha256 = "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b",
21+
},
22+
},
23+
windows = {
24+
["v1.10.0"] = {
25+
url = "https://github.com/lz4/lz4/archive/refs/tags/v1.10.0.tar.gz",
26+
sha256 = "537512904744b35e232912055ccf8ec66d768639ff3abe5788d90d792ec5f48b",
27+
},
28+
},
29+
},
30+
31+
mcpp = {
32+
language = "c++23",
33+
import_std = false,
34+
c_standard = "c11",
35+
include_dirs = {"*/lib"},
36+
cflags = { "-D_GNU_SOURCE" },
37+
sources = {"*/lib/*.c"},
38+
targets = { ["lz4"] = { kind = "lib" } },
39+
deps = {},
40+
},
41+
}

0 commit comments

Comments
 (0)