Skip to content

Commit f04ba3a

Browse files
committed
debug: revert to simple _putenv_s + add diagnostic output on build failure
1 parent 5e1c9c2 commit f04ba3a

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

.github/workflows/ci-windows.yml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,16 @@ jobs:
7575
run: |
7676
export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
7777
78-
"$MCPP" build
78+
"$MCPP" build || {
79+
echo "=== Debug: mcpp sandbox ==="
80+
find "$USERPROFILE/.mcpp" -name "*.exe" -o -name "xpkgs" -type d 2>/dev/null | head -20
81+
echo "=== Debug: xlings home ==="
82+
find "$USERPROFILE/.xlings" -path "*/xim-x-llvm*" -type d 2>/dev/null | head -10
83+
echo "=== Debug: mcpp registry data ==="
84+
ls -la "$USERPROFILE/.mcpp/registry/data/" 2>/dev/null || echo "no data dir"
85+
ls -la "$USERPROFILE/.mcpp/registry/data/xpkgs/" 2>/dev/null || echo "no xpkgs dir"
86+
exit 1
87+
}
7988
8089
MCPP_SELF=$(find target -name "mcpp.exe" -path "*/bin/*" | head -1)
8190
test -n "$MCPP_SELF" || { echo "FAIL: no mcpp.exe"; exit 1; }

src/xlings.cppm

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -428,18 +428,14 @@ std::filesystem::path sandbox_init_marker(const Env& env) {
428428
std::string build_command_prefix(const Env& env) {
429429
auto xvmBin = paths::sandbox_bin(env).string();
430430
#if defined(_WIN32)
431-
// Windows: set environment variables via _putenv_s (inherited by
432-
// child processes) AND cd to the sandbox home (xlings may use cwd
433-
// to resolve its home). Return a "cd /d <home> && <binary>" prefix.
434431
_putenv_s("XLINGS_HOME", env.home.string().c_str());
435432
_putenv_s("XLINGS_PROJECT_DIR",
436433
env.projectDir.empty() ? "" : env.projectDir.string().c_str());
437434
{
438435
std::string newPath = xvmBin + ";" + (std::getenv("PATH") ? std::getenv("PATH") : "");
439436
_putenv_s("PATH", newPath.c_str());
440437
}
441-
return std::format("cd /d \"{}\" && \"{}\"",
442-
env.home.string(), env.binary.string());
438+
return env.binary.string();
443439
#else
444440
if (env.projectDir.empty()) {
445441
// Global mode: unset XLINGS_PROJECT_DIR (existing behavior).
@@ -663,15 +659,13 @@ int install_with_progress(const Env& env, std::string_view target,
663659
R"({{"targets":["{}"],"yes":true}})", target);
664660

665661
#if defined(_WIN32)
666-
// Ensure xlings sees XLINGS_HOME + runs from the sandbox dir.
667-
// Both _putenv_s (inherited by child) and cd /d (working dir) are
668-
// needed — xlings may resolve its home from either.
669662
_putenv_s("XLINGS_HOME", env.home.string().c_str());
670663
_putenv_s("XLINGS_PROJECT_DIR", "");
671664
std::error_code ec_mkdir;
672665
std::filesystem::create_directories(env.home, ec_mkdir);
673-
auto cmd = std::format("cd /d \"{}\" && \"{}\" interface install_packages --args {} 2>nul",
674-
env.home.string(),
666+
// Use raw command — _putenv_s is inherited by popen child.
667+
// No 2>nul — let xlings output be visible for debugging.
668+
auto cmd = std::format("{} interface install_packages --args {}",
675669
env.binary.string(),
676670
shq(argsJson));
677671
#else
@@ -805,8 +799,7 @@ void ensure_init(const Env& env, bool quiet) {
805799
#if defined(_WIN32)
806800
_putenv_s("XLINGS_HOME", env.home.string().c_str());
807801
_putenv_s("XLINGS_PROJECT_DIR", "");
808-
auto cmd = std::format("cd /d \"{}\" && \"{}\" self init",
809-
env.home.string(), env.binary.string());
802+
auto cmd = env.binary.string() + " self init";
810803
#else
811804
auto cmd = std::format(
812805
"cd {} && env -u XLINGS_PROJECT_DIR XLINGS_HOME={} {} self init >/dev/null 2>&1",

0 commit comments

Comments
 (0)