Skip to content

Commit d140623

Browse files
committed
fix(index): refresh missing default mcpplibs index
1 parent 40c51b9 commit d140623

6 files changed

Lines changed: 96 additions & 21 deletions

File tree

.agents/docs/2026-05-30-bmi-cache-custom-index-fix.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,3 +81,29 @@ There is also a cache-key correctness gap: all dependency cache entries currentl
8181
- Local verification: `mcpp build` succeeded, then `MCPP=target/x86_64-linux-gnu/4d24c8b57fdbbbb4/bin/mcpp bash tests/e2e/49_bmi_cache_nested_custom_index.sh` returned `OK`.
8282
- `mcpp test -- --gtest_filter=BmiCache.*` initially exposed an unrelated local environment issue: `~/.mcpp/registry/data/xpkgs/xim-x-binutils/2.42` only had `.xpkg.lua` and no `bin/as`. Re-running with a temporary `MCPP_HOME` pointed at the complete installed mcpp registry passed: 15 test binaries ok, 0 failed.
8383
- Remote custom-index first-use sync keeps the mcpp-level `Fetching custom index repos (first use)` status, but calls `update_index(..., quiet=true)` so `mcpp build` does not expose xlings update output. A non-zero update exits with a concise mcpp-level error.
84+
85+
## Final Outcome
86+
87+
- Landed with PR #88: https://github.com/mcpp-community/mcpp/pull/88
88+
- Released in `mcpp 0.0.35`: https://github.com/mcpp-community/mcpp/releases/tag/v0.0.35
89+
- The mcpp status line remains visible, but internal `xlings update` output is quiet.
90+
- The xlings migration PR #314 completed without `warning: bmi cache populate failed` in the Linux `E2E-00: mcpp builds xlings from source` log.
91+
92+
## Follow-up: Default Index Freshness
93+
94+
The final local xlings verification exposed a separate default-index freshness bug:
95+
when `~/.mcpp/registry/data` contained other xlings-managed index clones but no
96+
`mcpplibs` clone, `mcpp` treated the registry as fresh and skipped the default
97+
index update. `mcpp build` then failed before dependency resolution with:
98+
99+
```text
100+
error: dependency 'compat.libarchive': index entry not found in local clone
101+
```
102+
103+
Fix for `0.0.36`:
104+
105+
- `is_index_fresh()` now requires `registry/data/mcpplibs/pkgs` specifically.
106+
- Regression coverage verifies that an unrelated `xim-pkgindex/pkgs` tree no
107+
longer satisfies default `mcpplibs` freshness.
108+
- A fresh/mixed user cache will trigger the normal default-index update path
109+
before searching or building `compat.*` dependencies.

.agents/docs/2026-05-30-package-owned-build-flags-plan.md

Lines changed: 17 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# mcpp 0.0.35: Package-Owned Build Metadata Plan
22

3-
> 状态: in progress
3+
> 状态: complete
44
> 分支: `codex/package-owned-build-flags`
55
> 目标: 让依赖包在官方 mcpp-index 中携带自己的 C/C++ 编译 flags、include 优先级和配置头,从而让 xlings 不再把第三方 C 库的 configure 结果写在项目根 `mcpp.toml`
66
@@ -73,5 +73,19 @@ cd /home/speak/workspace/github/openxlings/xlings
7373
- `mcpp build --target x86_64-linux-musl` -> `target/x86_64-linux-musl/7e48a312cd4dbb49/bin/xlings` static ELF.
7474
- [x] PR draft 创建: https://github.com/mcpp-community/mcpp/pull/88
7575
- [x] 版本 bump 到 `0.0.35`,并补充 `CHANGELOG.md` 发布说明。
76-
- [ ] CI 每 120s 检查一次直到完成。
77-
- [ ] CI 通过后发布 `0.0.35`
76+
- [x] CI 每 120s 检查一次直到完成。
77+
- [x] CI 通过后发布 `0.0.35`
78+
79+
## Final Outcome
80+
81+
- PR: https://github.com/mcpp-community/mcpp/pull/88
82+
- Merge commit: `40c51b93c0ce7f821533dc05ac0e2cbf535737bf`
83+
- Release: https://github.com/mcpp-community/mcpp/releases/tag/v0.0.35
84+
- CI evidence:
85+
- Linux `build + test`: success.
86+
- macOS ARM64 `xlings LLVM end-to-end`: success.
87+
- Windows x64 `build + test`: success.
88+
- Downstream evidence:
89+
- openxlings/xlings PR #314 used `mcpp 0.0.35` with official `compat.libarchive`.
90+
- Linux E2E `mcpp builds xlings from source` passed.
91+
- xlings `v0.4.46` release was published after the migration.

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.36] — 2026-05-31
7+
8+
### 修复
9+
10+
- 修复默认 `mcpplibs` 索引缺失时被其他 xlings 索引误判为 fresh 的问题。
11+
`mcpp build/search` 现在会要求默认索引自身存在并处于 TTL 内,避免
12+
`compat.*` 依赖在混合缓存状态下找不到。
13+
614
## [0.0.35] — 2026-05-30
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.35"
3+
version = "0.0.36"
44
description = "Modern C++ build & package management tool"
55
license = "Apache-2.0"
66
authors = ["mcpp-community"]

src/xlings.cppm

Lines changed: 7 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,8 @@ void ensure_ninja(const Env& env, bool quiet,
232232

233233
// ─── Index freshness ────────────────────────────────────────────────
234234

235-
// Check whether local index data exists and is fresh (within ttlSeconds).
235+
// Check whether the default mcpplibs index data exists and is fresh
236+
// (within ttlSeconds).
236237
// Returns true if index is present and fresh, false otherwise.
237238
bool is_index_fresh(const Env& env, std::int64_t ttlSeconds);
238239

@@ -930,23 +931,12 @@ void ensure_ninja(const Env& env, bool quiet,
930931
// ─── Index freshness ────────────────────────────────────────────────
931932

932933
bool is_index_fresh(const Env& env, std::int64_t ttlSeconds) {
933-
auto data = paths::index_data(env);
934-
if (!std::filesystem::exists(data)) return false;
935-
936-
// Look for any directory under data/ that has a pkgs/ subdirectory —
937-
// that's a cloned index repo.
938934
std::error_code ec;
939-
bool hasIndex = false;
940-
std::filesystem::file_time_type newest{};
941-
for (auto& entry : std::filesystem::directory_iterator(data, ec)) {
942-
if (!entry.is_directory()) continue;
943-
auto pkgsDir = entry.path() / "pkgs";
944-
if (!std::filesystem::exists(pkgsDir)) continue;
945-
hasIndex = true;
946-
auto t = std::filesystem::last_write_time(pkgsDir, ec);
947-
if (!ec && t > newest) newest = t;
948-
}
949-
if (!hasIndex) return false;
935+
auto pkgsDir = paths::index_data(env) / "mcpplibs" / "pkgs";
936+
if (!std::filesystem::exists(pkgsDir)) return false;
937+
938+
auto newest = std::filesystem::last_write_time(pkgsDir, ec);
939+
if (ec) return false;
950940

951941
// Check TTL
952942
auto now = std::filesystem::file_time_type::clock::now();

tests/unit/test_xlings.cpp

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#include <gtest/gtest.h>
2+
3+
import std;
4+
import mcpp.xlings;
5+
6+
namespace {
7+
8+
std::filesystem::path make_tempdir(std::string_view name) {
9+
auto base = std::filesystem::temp_directory_path()
10+
/ std::format("{}-{}", name, std::chrono::steady_clock::now().time_since_epoch().count());
11+
std::filesystem::create_directories(base);
12+
return base;
13+
}
14+
15+
} // namespace
16+
17+
TEST(XlingsIndexFreshness, RequiresDefaultMcpplibsIndex) {
18+
auto home = make_tempdir("mcpp-xlings-index-freshness");
19+
std::filesystem::create_directories(home / "data" / "xim-pkgindex" / "pkgs");
20+
21+
mcpp::xlings::Env env{.home = home};
22+
23+
EXPECT_FALSE(mcpp::xlings::is_index_fresh(env, 3600));
24+
25+
std::filesystem::remove_all(home);
26+
}
27+
28+
TEST(XlingsIndexFreshness, AcceptsFreshDefaultMcpplibsIndex) {
29+
auto home = make_tempdir("mcpp-xlings-index-freshness");
30+
std::filesystem::create_directories(home / "data" / "mcpplibs" / "pkgs");
31+
32+
mcpp::xlings::Env env{.home = home};
33+
34+
EXPECT_TRUE(mcpp::xlings::is_index_fresh(env, 3600));
35+
36+
std::filesystem::remove_all(home);
37+
}

0 commit comments

Comments
 (0)