File tree Expand file tree Collapse file tree 2 files changed +31
-2
lines changed
Expand file tree Collapse file tree 2 files changed +31
-2
lines changed Original file line number Diff line number Diff line change 2121 type : string
2222
2323env :
24- VCPKG_ROOT : ${{ github.workspace }}/vcpkg
24+ # VCPKG_ROOT is NOT set here globally to allow container ENV to take precedence on Linux.
25+ # We will set it dynamically in the "Setup Vcpkg" step if it's missing.
2526 VCPKG_DEFAULT_BINARY_CACHE : ${{ github.workspace }}/vcpkg_cache
2627
2728jobs :
7879 - name : Setup Vcpkg
7980 shell : bash
8081 run : |
82+ # 1. Check if VCPKG_ROOT is already set (e.g. by Docker container)
83+ if [ -n "$VCPKG_ROOT" ]; then
84+ echo "VCPKG_ROOT is already set to: $VCPKG_ROOT"
85+ if [ -d "$VCPKG_ROOT" ]; then
86+ echo "Vcpkg directory exists. Using: $VCPKG_ROOT"
87+ # No action needed, env var is already present in this shell.
88+ # To be safe for subsequent steps, we re-export it to GITHUB_ENV if it wasn't there (it is via Docker ENV, but good practice)
89+ echo "VCPKG_ROOT=$VCPKG_ROOT" >> $GITHUB_ENV
90+ exit 0
91+ else
92+ echo "Warning: VCPKG_ROOT is set but directory missing. Falling back to install."
93+ fi
94+ fi
95+
96+ # 2. Check for VCPKG_INSTALLATION_ROOT (GitHub Actions default sometimes)
8197 if [ -n "$VCPKG_INSTALLATION_ROOT" ] && [ -d "$VCPKG_INSTALLATION_ROOT" ]; then
98+ echo "Found VCPKG_INSTALLATION_ROOT: $VCPKG_INSTALLATION_ROOT"
8299 echo "VCPKG_ROOT=$VCPKG_INSTALLATION_ROOT" >> $GITHUB_ENV
83100 else
101+ # 3. Fallback: Clone and Bootstrap locally
102+ echo "Vcpkg not found. Installing to workspace."
84103 git clone https://github.com/microsoft/vcpkg.git "$GITHUB_WORKSPACE/vcpkg"
85104 if [[ "$RUNNER_OS" == "Windows" ]]; then
86105 "$GITHUB_WORKSPACE/vcpkg/bootstrap-vcpkg.bat"
Original file line number Diff line number Diff line change @@ -23,5 +23,15 @@ RUN pacman -Sy --noconfirm archlinux-keyring cachyos-keyring && \
2323 # Remove EXTERNALLY-MANAGED to allow pip usage if needed (optional but helpful)
2424 rm -f /usr/lib/python3.*/EXTERNALLY-MANAGED
2525
26- # Force vcpkg to use system binaries
26+ # Install Vcpkg
27+ RUN git clone https://github.com/microsoft/vcpkg.git /opt/vcpkg && \
28+ /opt/vcpkg/bootstrap-vcpkg.sh && \
29+ # Clean up to reduce image size
30+ rm -rf /opt/vcpkg/downloads/* && \
31+ rm -rf /opt/vcpkg/buildtrees/* && \
32+ rm -rf /opt/vcpkg/packages/*
33+
34+ # Environment variables
35+ ENV VCPKG_ROOT=/opt/vcpkg
36+ ENV PATH=$VCPKG_ROOT:$PATH
2737ENV VCPKG_FORCE_SYSTEM_BINARIES=1
You can’t perform that action at this time.
0 commit comments