@@ -16,33 +16,54 @@ CARGO_LAMBDA_VERSION="${1:-${CARGO_LAMBDA_VERSION:-v0.17.1}}"
1616# Install rustup if not present
1717if ! command -v rustup & > /dev/null; then
1818 curl --proto ' =https' --tlsv1.2 --retry 10 --retry-connrefused -fsSL https://sh.rustup.rs | sh -s -- --default-toolchain none -y
19- source " $HOME /.cargo/env"
19+ # source cargo env (file doesn't exist on Windows where Rust is pre-installed)
20+ if [ -f " $HOME /.cargo/env" ]; then
21+ source " $HOME /.cargo/env"
22+ fi
2023 if [ -n " ${GITHUB_PATH:- } " ]; then
2124 echo " ${CARGO_HOME:- $HOME / .cargo} /bin" >> " $GITHUB_PATH "
2225 fi
2326fi
2427
2528rustup toolchain install stable --profile minimal --no-self-update
2629rustup default stable
27- rustup target add x86_64-unknown-linux-gnu --toolchain stable
28- rustup target add aarch64-unknown-linux-gnu --toolchain stable
30+
31+ if [[ " ${RUNNER_OS:- } " == " Windows" ]]; then
32+ # On Windows, add Windows-native targets
33+ rustup target add x86_64-pc-windows-msvc --toolchain stable || true
34+ else
35+ rustup target add x86_64-unknown-linux-gnu --toolchain stable
36+ rustup target add aarch64-unknown-linux-gnu --toolchain stable
37+ fi
2938
3039# Install cargo-lambda and ziglang
3140if [ " $USE_UV " = true ]; then
3241 PYTHON311=" $( uv python find 3.11) "
3342 PYTHON311_BIN=" $( dirname " $PYTHON311 " ) "
34- uv pip install --break-system-packages --python " $PYTHON311 " " cargo-lambda==$CARGO_LAMBDA_VERSION "
43+ uv pip install --break-system-packages --python " $PYTHON311 " " cargo-lambda==$CARGO_LAMBDA_VERSION " ziglang
44+ PYTHON_CMD=" $PYTHON311 "
3545 if [ -n " ${GITHUB_PATH:- } " ]; then
3646 echo " $PYTHON311_BIN " >> " $GITHUB_PATH "
3747 fi
3848else
39- python3.11 -m pip install " cargo-lambda==$CARGO_LAMBDA_VERSION "
40- PYTHON311 =" python3.11"
49+ python3.11 -m pip install " cargo-lambda==$CARGO_LAMBDA_VERSION " ziglang
50+ PYTHON_CMD =" python3.11"
4151fi
4252
4353# Create a zig wrapper so SAM CLI's cargo-lambda can find it
44- printf ' #!/bin/bash\nexec %s -m ziglang "$@"\n' " $PYTHON311 " | sudo tee /usr/local/bin/zig > /dev/null
45- sudo chmod +x /usr/local/bin/zig
54+ if [[ " ${RUNNER_OS:- } " == " Windows" ]]; then
55+ # Install zig via chocolatey (most reliable on Windows)
56+ choco install zig --no-progress -y 2> /dev/null || true
57+ # Fallback: create wrappers using the Python that has ziglang installed
58+ if ! command -v zig & > /dev/null; then
59+ ZIG_PYTHON=" $PYTHON_CMD "
60+ printf ' #!/bin/bash\nexec "%s" -m ziglang "$@"\n' " $ZIG_PYTHON " > /c/Windows/zig
61+ printf ' @echo off\r\n"%s" -m ziglang %%*\r\n' " $ZIG_PYTHON " > /c/Windows/zig.cmd
62+ fi
63+ else
64+ printf ' #!/bin/bash\nexec %s -m ziglang "$@"\n' " $PYTHON_CMD " | sudo tee /usr/local/bin/zig > /dev/null
65+ sudo chmod +x /usr/local/bin/zig
66+ fi
4667
4768rustc -V
4869cargo -V
0 commit comments