Skip to content

Commit 00c2ad3

Browse files
committed
fix: mcpp auto-resolves LLVM from global xlings when sandbox payload missing
When xlings installs a toolchain into the mcpp sandbox, the payload may end up in xlings' own global data dir instead of the sandbox. Add fallback: if the expected xpkg path is missing, check ~/.xlings/data/xpkgs/ and copy from there. Remove CI workarounds: no more explicit `xlings install llvm` or pre-seed cp -r steps. mcpp now handles this like a real user would.
1 parent 2f7642c commit 00c2ad3

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+
if (!std::filesystem::exists(verdir)) {
609+
// xlings may have installed the package into its own global home
610+
// rather than the mcpp sandbox. Try to copy it from the global
611+
// xlings data directory.
612+
auto xlings_home_env = std::getenv("HOME");
613+
#if defined(_WIN32)
614+
if (!xlings_home_env) xlings_home_env = std::getenv("USERPROFILE");
615+
#endif
616+
if (xlings_home_env) {
617+
auto globalXpkgs = std::filesystem::path(xlings_home_env)
618+
/ ".xlings" / "data" / "xpkgs"
619+
/ verdir.parent_path().filename()
620+
/ verdir.filename();
621+
std::error_code ec;
622+
if (std::filesystem::exists(globalXpkgs, ec)) {
623+
std::filesystem::create_directories(verdir.parent_path(), ec);
624+
std::filesystem::copy(globalXpkgs, 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)