Skip to content

Commit e407104

Browse files
committed
fix: wrap scan-deps in cmd /c for shell redirect + 7z for release LLVM
ninja on Windows uses CreateProcess which doesn't interpret `>` as shell redirection. Wrap the clang-scan-deps command in `cmd /c` so stdout redirect to $out works correctly. Also update release.yml to use 7z for LLVM extraction.
1 parent 91a056e commit e407104

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

.github/workflows/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -484,11 +484,16 @@ jobs:
484484
LLVM_VER="20.1.7"
485485
LLVM_DEST="$USERPROFILE/.mcpp/registry/data/xpkgs/xim-x-llvm/$LLVM_VER"
486486
if [ ! -f "$LLVM_DEST/bin/clang++.exe" ]; then
487-
curl -fsSL -o /tmp/llvm.tar.xz \
487+
WORK=$(mktemp -d)
488+
curl -fSL --retry 3 -o "$WORK/llvm.tar.xz" \
488489
"https://github.com/xlings-res/llvm/releases/download/$LLVM_VER/llvm-$LLVM_VER-windows-x86_64.tar.xz"
489490
mkdir -p "$LLVM_DEST"
490-
tar -xf /tmp/llvm.tar.xz -C "$LLVM_DEST" --strip-components=1
491-
rm -f /tmp/llvm.tar.xz
491+
cd "$WORK"
492+
7z x -y llvm.tar.xz && 7z x -y llvm.tar -o"$LLVM_DEST" -aoa
493+
INNER=$(ls -d "$LLVM_DEST"/llvm-* 2>/dev/null | head -1)
494+
[ -d "$INNER/bin" ] && mv "$INNER"/* "$LLVM_DEST"/ && rmdir "$INNER" 2>/dev/null || true
495+
cd -
496+
rm -rf "$WORK"
492497
fi
493498
494499
"$MCPP" build

src/build/ninja_backend.cppm

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,10 @@ std::string emit_ninja_string(const BuildPlan& plan) {
317317
} else {
318318
// Clang path: clang-scan-deps produces P1689 JSON to stdout.
319319
#if defined(_WIN32)
320-
append(" command = $scan_deps -format=p1689 -- "
321-
"$cxx $cxxflags -c $in -o $compile_target > $out\n");
320+
// Wrap in cmd /c for shell redirection (ninja on Windows uses
321+
// CreateProcess which doesn't interpret > as redirect).
322+
append(" command = cmd /c \"$scan_deps -format=p1689 -- "
323+
"$cxx $cxxflags -c $in -o $compile_target > $out\"\n");
322324
#else
323325
append(" command = $toolenv $scan_deps -format=p1689 -- "
324326
"$cxx $cxxflags -c $in -o $compile_target > $out\n");

0 commit comments

Comments
 (0)