11name : ci-windows
22
3- # Windows CI for mcpp — validates LLVM/Clang as the Windows toolchain.
4- # Uses xmake to bootstrap mcpp from source (until xlings mcpp ships
5- # Windows-native fixes), then self-hosts, tests, and packages.
3+ # Windows CI for mcpp — same flow as Linux (ci.yml) and macOS (ci-macos.yml):
4+ # xlings install mcpp → self-host build → E2E → smoke → package
65
76on :
87 push :
@@ -25,14 +24,23 @@ jobs:
2524 steps :
2625 - uses : actions/checkout@v4
2726
28- - name : System info
29- shell : bash
30- run : |
31- echo "OS: $(uname -s)"
32- echo "Arch: $(uname -m)"
33- echo "Runner: $RUNNER_OS"
27+ - name : Cache mcpp sandbox
28+ uses : actions/cache@v4
29+ with :
30+ path : ~\.mcpp
31+ key : mcpp-sandbox-${{ runner.os }}-${{ hashFiles('mcpp.toml', '.xlings.json') }}
32+ restore-keys : |
33+ mcpp-sandbox-${{ runner.os }}-
3434
35- - name : Install xlings
35+ - name : Cache xlings
36+ uses : actions/cache@v4
37+ with :
38+ path : ~\.xlings
39+ key : xlings-${{ runner.os }}-v2-${{ hashFiles('.xlings.json') }}
40+ restore-keys : |
41+ xlings-${{ runner.os }}-v2-
42+
43+ - name : Bootstrap mcpp via xlings
3644 shell : bash
3745 env :
3846 XLINGS_NON_INTERACTIVE : ' 1'
@@ -45,92 +53,51 @@ jobs:
4553 cd "${WORK}"
4654 unzip -q "${zipfile}"
4755 "$WORK/xlings-${XLINGS_VERSION}-windows-x86_64/subos/default/bin/xlings.exe" self install
56+ export PATH="$USERPROFILE/.xlings/subos/default/bin:$PATH"
4857 echo "$USERPROFILE/.xlings/subos/default/bin" >> "$GITHUB_PATH"
49- echo "$USERPROFILE/.xlings/bin" >> "$GITHUB_PATH"
50-
51- - name : Install LLVM + xmake via xlings
52- shell : bash
53- run : |
5458 xlings.exe --version
55- xlings.exe install llvm -y || xlings.exe install llvm@20.1.7 -y
56- xlings.exe install xmake -y
57-
58- - name : Bootstrap mcpp with xmake (MSVC)
59- shell : pwsh
60- run : |
61- @"
62- add_rules("mode.release")
63- set_languages("c++23")
64- package("cmdline")
65- set_homepage("https://github.com/mcpplibs/cmdline")
66- add_urls("https://github.com/mcpplibs/cmdline/archive/refs/tags/`$(version).tar.gz")
67- add_versions("0.0.1", "3fb2f5495c1a144485b3cbb2e43e27059151633460f702af0f3851cbff387ef0")
68- on_install(function (package)
69- import("package.tools.xmake").install(package)
70- end)
71- package_end()
72- add_requires("cmdline 0.0.1")
73- target("mcpp")
74- set_kind("binary")
75- add_files("src/main.cpp")
76- add_files("src/**.cppm")
77- add_packages("cmdline")
78- add_includedirs("src/libs/json")
79- set_policy("build.c++.modules", true)
80- "@ | Out-File -Encoding utf8 xmake.lua
81-
82- xmake f -p windows -m release -y
83- xmake build -y mcpp
84-
85- $mcpp = Get-ChildItem -Recurse build -Filter mcpp.exe -ErrorAction SilentlyContinue | Select-Object -First 1
86- if ($mcpp) {
87- Write-Host ":: mcpp.exe built at: $($mcpp.FullName)"
88- & $mcpp.FullName --version
89- "MCPP_BOOTSTRAP=$($mcpp.FullName)" | Out-File -Append $env:GITHUB_ENV
90- } else {
91- exit 1
92- }
93-
94- - name : Self-host — mcpp builds itself
59+ xlings.exe install mcpp -y
60+ MCPP="$USERPROFILE/.xlings/subos/default/bin/mcpp.exe"
61+ test -f "$MCPP" || MCPP="$USERPROFILE/.xlings/subos/default/bin/mcpp"
62+ test -f "$MCPP"
63+ "$MCPP" --version
64+ echo "MCPP=$MCPP" >> "$GITHUB_ENV"
65+ XLINGS_BIN=$(cygpath -w "$USERPROFILE/.xlings/subos/default/bin/xlings.exe")
66+ echo "XLINGS_BIN=$XLINGS_BIN" >> "$GITHUB_ENV"
67+
68+ - name : Build mcpp from source (self-host)
9569 shell : bash
9670 run : |
97- # Save bootstrap binary, clean xmake artifacts
98- mkdir -p /tmp/mcpp-bootstrap
99- cp "$MCPP_BOOTSTRAP" /tmp/mcpp-bootstrap/mcpp.exe
100- MCPP_EXE="/tmp/mcpp-bootstrap/mcpp.exe"
101- rm -rf build xmake.lua .xmake
102-
103- XLINGS_WIN=$(cygpath -w "$USERPROFILE/.xlings/subos/default/bin/xlings.exe")
104- export MCPP_VENDORED_XLINGS="$XLINGS_WIN"
71+ export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
10572
106- # Pre-seed LLVM from global xlings
73+ # Pre-seed mcpp sandbox with xlings LLVM (avoids redundant download)
10774 MCPP_XPKGS="$USERPROFILE/.mcpp/registry/data/xpkgs"
10875 XLINGS_XPKGS="$USERPROFILE/.xlings/data/xpkgs"
10976 if [ -d "$XLINGS_XPKGS/xim-x-llvm" ]; then
11077 mkdir -p "$MCPP_XPKGS"
11178 rm -rf "$MCPP_XPKGS/xim-x-llvm"
11279 cp -r "$XLINGS_XPKGS/xim-x-llvm" "$MCPP_XPKGS/xim-x-llvm"
80+ echo "Pre-seeded LLVM from global xlings"
11381 fi
11482
115- "$MCPP_EXE " build
83+ "$MCPP " build
11684
117- SELF_MCPP =$(find target -name "mcpp.exe" -path "*/bin/*" | head -1)
118- test -n "$SELF_MCPP " || { echo "FAIL: no mcpp.exe"; exit 1; }
119- SELF_MCPP =$(cd "$(dirname "$SELF_MCPP ")" && pwd)/$(basename "$SELF_MCPP ")
120- echo "Self-hosted binary: $SELF_MCPP "
121- "$SELF_MCPP " --version
122- echo "MCPP_SELF=$SELF_MCPP " >> "$GITHUB_ENV"
85+ MCPP_SELF =$(find target -name "mcpp.exe" -path "*/bin/*" | head -1)
86+ test -n "$MCPP_SELF " || { echo "FAIL: no mcpp.exe"; exit 1; }
87+ MCPP_SELF =$(cd "$(dirname "$MCPP_SELF ")" && pwd)/$(basename "$MCPP_SELF ")
88+ echo "Self-hosted binary: $MCPP_SELF "
89+ "$MCPP_SELF " --version
90+ echo "MCPP_SELF=$MCPP_SELF " >> "$GITHUB_ENV"
12391
124- # NOTE: `mcpp test` (unit tests via gtest) requires clang-scan-deps
125- # for module dependency scanning. The xlings LLVM package does not
126- # yet ship clang-scan-deps on Windows. Skip until available.
127- # - name: Unit + integration tests via mcpp test
92+ # NOTE: `mcpp test` requires clang-scan-deps for module dependency
93+ # scanning. The xlings LLVM package does not yet ship it on Windows.
94+ # Enable once available.
12895
12996 - name : E2E suite
13097 shell : bash
13198 run : |
13299 export MCPP="$MCPP_SELF"
133- export MCPP_VENDORED_XLINGS=$(cygpath -w "$USERPROFILE/.xlings/subos/default/bin/xlings.exe")
100+ export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
134101 export MCPP_E2E_TOOLCHAIN_MIRROR=GLOBAL
135102 "$MCPP_SELF" self config --mirror GLOBAL 2>/dev/null || true
136103 "$MCPP_SELF" toolchain default llvm@20.1.7 2>/dev/null || true
@@ -139,7 +106,7 @@ jobs:
139106 - name : Self-host smoke (freshly-built mcpp builds itself again)
140107 shell : bash
141108 run : |
142- export MCPP_VENDORED_XLINGS=$(cygpath -w "$USERPROFILE/.xlings/subos/default/bin/xlings.exe")
109+ export MCPP_VENDORED_XLINGS="$XLINGS_BIN"
143110 "$MCPP_SELF" build
144111 "$MCPP_SELF" --version
145112 echo ":: Self-host smoke PASS"
0 commit comments