Skip to content

Commit 32962c3

Browse files
committed
fix: mcpp auto-resolves xpkg from global xlings, remove all CI workarounds
When xlings installs a toolchain, the payload may land in xlings' global data dir instead of mcpp's sandbox. package_fetcher now checks ~/.xlings/data/xpkgs/ as fallback and copies automatically. Removed from CI/release: - xlings install llvm (mcpp handles it) - Pre-seed cp -r of LLVM xpkgs (mcpp handles it) mcpp now works like a real user: just `xlings install mcpp` then `mcpp build`.
1 parent 2f7642c commit 32962c3

3 files changed

Lines changed: 24 additions & 23 deletions

File tree

.github/workflows/ci-windows.yml

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,7 @@ jobs:
5656
export PATH="$USERPROFILE/.xlings/subos/default/bin:$PATH"
5757
echo "$USERPROFILE/.xlings/subos/default/bin" >> "$GITHUB_PATH"
5858
xlings.exe --version
59-
xlings.exe install llvm -y || xlings.exe install llvm@20.1.7 -y
60-
xlings.exe install mcpp -y || xlings.exe install mcpp@0.0.17 -y
59+
xlings.exe install mcpp -y
6160
echo "=== Searching for mcpp binary ==="
6261
find "$USERPROFILE/.xlings" -name "mcpp.exe" -o -name "mcpp" 2>/dev/null | head -10
6362
MCPP=$(find "$USERPROFILE/.xlings" -name "mcpp.exe" -path "*/bin/*" 2>/dev/null | head -1)
@@ -76,16 +75,6 @@ jobs:
7675
run: |
7776
export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
7877
79-
# Pre-seed mcpp sandbox with xlings LLVM (avoids redundant download)
80-
MCPP_XPKGS="$USERPROFILE/.mcpp/registry/data/xpkgs"
81-
XLINGS_XPKGS="$USERPROFILE/.xlings/data/xpkgs"
82-
if [ -d "$XLINGS_XPKGS/xim-x-llvm" ]; then
83-
mkdir -p "$MCPP_XPKGS"
84-
rm -rf "$MCPP_XPKGS/xim-x-llvm"
85-
cp -r "$XLINGS_XPKGS/xim-x-llvm" "$MCPP_XPKGS/xim-x-llvm"
86-
echo "Pre-seeded LLVM from global xlings"
87-
fi
88-
8978
"$MCPP" build
9079
9180
MCPP_SELF=$(find target -name "mcpp.exe" -path "*/bin/*" | head -1)

.github/workflows/release.yml

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,7 @@ jobs:
462462
export PATH="$USERPROFILE/.xlings/subos/default/bin:$PATH"
463463
echo "$USERPROFILE/.xlings/subos/default/bin" >> "$GITHUB_PATH"
464464
xlings.exe --version
465-
xlings.exe install llvm -y || xlings.exe install llvm@20.1.7 -y
466-
xlings.exe install mcpp -y || xlings.exe install mcpp@0.0.17 -y
465+
xlings.exe install mcpp -y
467466
MCPP=$(find "$USERPROFILE/.xlings" -name "mcpp.exe" -path "*/bin/*" 2>/dev/null | head -1)
468467
if [ -z "$MCPP" ]; then
469468
MCPP=$(find "$USERPROFILE/.xlings" -name "mcpp" -path "*/bin/*" 2>/dev/null | head -1)
@@ -481,15 +480,6 @@ jobs:
481480
run: |
482481
export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
483482
484-
# Pre-seed mcpp sandbox with xlings LLVM (avoids redundant download)
485-
MCPP_XPKGS="$USERPROFILE/.mcpp/registry/data/xpkgs"
486-
if [ -d "$XLINGS_XPKGS/xim-x-llvm" ]; then
487-
mkdir -p "$MCPP_XPKGS"
488-
rm -rf "$MCPP_XPKGS/xim-x-llvm"
489-
cp -r "$XLINGS_XPKGS/xim-x-llvm" "$MCPP_XPKGS/xim-x-llvm"
490-
echo "Pre-seeded LLVM from global xlings"
491-
fi
492-
493483
"$MCPP" build
494484
495485
MCPP_BIN=$(find target -name "mcpp.exe" -path "*/bin/*" | head -1)

src/pm/package_fetcher.cppm

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,28 @@ Fetcher::resolve_xpkg_path(std::string_view target,
605605
};
606606

607607
auto resolve = [&]() -> std::expected<XpkgPayload, CallError> {
608+
// xlings may install the package into its global home rather than
609+
// the mcpp sandbox. If the expected path is missing, copy from the
610+
// global xlings data directory.
611+
if (!std::filesystem::exists(verdir)) {
612+
auto xhome = std::getenv("HOME");
613+
#if defined(_WIN32)
614+
if (!xhome) xhome = std::getenv("USERPROFILE");
615+
#endif
616+
if (xhome) {
617+
auto globalDir = std::filesystem::path(xhome)
618+
/ ".xlings" / "data" / "xpkgs"
619+
/ verdir.parent_path().filename()
620+
/ verdir.filename();
621+
std::error_code ec;
622+
if (std::filesystem::exists(globalDir, ec)) {
623+
std::filesystem::create_directories(verdir.parent_path(), ec);
624+
std::filesystem::copy(globalDir, verdir,
625+
std::filesystem::copy_options::recursive
626+
| std::filesystem::copy_options::overwrite_existing, ec);
627+
}
628+
}
629+
}
608630
if (!std::filesystem::exists(verdir)) {
609631
return std::unexpected(CallError{
610632
std::format("xpkg payload missing: {}", verdir.string())});

0 commit comments

Comments
 (0)