Skip to content

Commit fbcf203

Browse files
authored
fix(index): expose xim deps for project indices
1 parent 0d04a33 commit fbcf203

5 files changed

Lines changed: 45 additions & 4 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,14 @@
33
> 本文件追踪 `mcpp-community/mcpp` 公开仓的版本演进。
44
> 格式参考 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)
55
6+
## [0.0.40] — 2026-06-01
7+
8+
### 修复
9+
10+
- 修复 project-local index 包的 xpm hook 工具依赖无法解析官方 `xim`
11+
索引的问题。项目级 xlings 配置现在会在 custom/local index 旁边显式暴露
12+
官方 `xim` 索引,让 `xim:python` 等 hook 工具依赖可用。
13+
614
## [0.0.39] — 2026-06-01
715

816
### 修复

mcpp.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "mcpp"
3-
version = "0.0.39"
3+
version = "0.0.40"
44
description = "Modern C++ build & package management tool"
55
license = "Apache-2.0"
66
authors = ["mcpp-community"]

src/config.cppm

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -674,10 +674,24 @@ bool ensure_project_index_dir(
674674
customRepos.emplace_back(name, spec.url);
675675
}
676676

677+
auto officialIndex = cfg.xlingsHome() / "data" / "xim-pkgindex";
678+
std::error_code ec;
679+
if (!customRepos.empty() && std::filesystem::exists(officialIndex / "pkgs", ec)) {
680+
bool hasXim = false;
681+
for (auto const& [name, _] : customRepos) {
682+
if (name == "xim") {
683+
hasXim = true;
684+
break;
685+
}
686+
}
687+
if (!hasXim) {
688+
customRepos.emplace_back("xim", officialIndex.generic_string());
689+
}
690+
}
691+
677692
if (customRepos.empty()) return false; // nothing to do
678693

679694
auto dotMcpp = projectDir / ".mcpp";
680-
std::error_code ec;
681695
std::filesystem::create_directories(dotMcpp, ec);
682696

683697
// Seed .xlings.json with the custom index entries.
@@ -725,7 +739,6 @@ bool ensure_project_index_dir(
725739
// project data dir. Expose the global official xim index there too, so
726740
// package deps like `xim:python@latest` can resolve without falling back
727741
// to unrelated remote index updates or system tools.
728-
auto officialIndex = cfg.xlingsHome() / "data" / "xim-pkgindex";
729742
if (std::filesystem::exists(officialIndex / "pkgs", ec)) {
730743
auto projectData = dotMcpp / ".xlings" / "data";
731744
auto projectOfficial = projectData / "xim-pkgindex";

src/toolchain/fingerprint.cppm

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import mcpp.toolchain.detect;
1818

1919
export namespace mcpp::toolchain {
2020

21-
inline constexpr std::string_view MCPP_VERSION = "0.0.39";
21+
inline constexpr std::string_view MCPP_VERSION = "0.0.40";
2222

2323
struct FingerprintInputs {
2424
Toolchain toolchain;

tests/e2e/52_local_path_namespaced_index.sh

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,21 @@ FAKE_REGISTRY="$TMP/fake-registry"
8989
FAKE_LOG="$TMP/fake-xlings.log"
9090
FAKE_DIRECT_LOG="$TMP/fake-xlings-direct.log"
9191
mkdir -p "$FAKE_REGISTRY/data"
92+
mkdir -p "$FAKE_REGISTRY/data/xim-pkgindex/pkgs/p"
93+
cat > "$FAKE_REGISTRY/data/xim-pkgindex/pkgs/p/python.lua" <<'EOF'
94+
package = {
95+
spec = "1",
96+
name = "python",
97+
xpm = {
98+
linux = {
99+
["3"] = {
100+
url = "https://example.invalid/python.tar.gz",
101+
sha256 = "0000000000000000000000000000000000000000000000000000000000000000",
102+
},
103+
},
104+
},
105+
}
106+
EOF
92107
if [[ -d "$USER_MCPP/registry/data/xpkgs" ]]; then
93108
ln -s "$USER_MCPP/registry/data/xpkgs" "$FAKE_REGISTRY/data/xpkgs"
94109
fi
@@ -121,6 +136,11 @@ fi
121136
122137
if [[ "${1:-}" == "install" ]]; then
123138
printf '%s\n' "$*" > "${FAKE_XLINGS_DIRECT_LOG:?}"
139+
if ! grep -q '"name": "xim"' "${XLINGS_PROJECT_DIR:?}/.xlings.json"; then
140+
echo "missing official xim index in project .xlings.json" >&2
141+
cat "${XLINGS_PROJECT_DIR:?}/.xlings.json" >&2 2>/dev/null || true
142+
exit 24
143+
fi
124144
if [[ ! -d "${XLINGS_PROJECT_DIR:?}/.xlings/data/compat/pkgs" \
125145
&& ! -d "${XLINGS_PROJECT_DIR:?}/data/compat/pkgs" ]]; then
126146
echo "missing project local path index link" >&2

0 commit comments

Comments
 (0)