mirror of
https://github.com/xiaozhou233/JuiceAgent.git
synced 2026-12-05 21:15:56 +08:00
- ci: build with -static-libgcc -static-libstdc++ (matching w64devkit, the local toolchain) so the DLLs do not depend on a libstdc++-6.dll that could be shadowed by an incompatible one on the runner - ci: bundle only the non-system DLLs actually imported, taken from the compiler that built them, and print the import list for diagnosis
84 lines
2.9 KiB
YAML
84 lines
2.9 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [ main ]
|
|
pull_request:
|
|
workflow_dispatch:
|
|
|
|
jobs:
|
|
build-and-test:
|
|
name: Build & integration tests (Windows, MinGW)
|
|
runs-on: windows-latest
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Set up JDK
|
|
uses: actions/setup-java@v4
|
|
with:
|
|
distribution: temurin
|
|
java-version: '25'
|
|
|
|
- name: Set up MinGW-w64 toolchain
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: MINGW64
|
|
update: false
|
|
install: >-
|
|
mingw-w64-x86_64-gcc
|
|
mingw-w64-x86_64-binutils
|
|
mingw-w64-x86_64-cmake
|
|
mingw-w64-x86_64-ninja
|
|
|
|
- name: Configure
|
|
shell: msys2 {0}
|
|
run: |
|
|
# Link the C/C++ runtime statically, like w64devkit (the toolchain the
|
|
# project is built with locally). Without this the DLLs depend on
|
|
# libstdc++-6/libgcc_s_seh-1, which can be shadowed by a different
|
|
# version elsewhere on the machine and fail to load.
|
|
cmake -S . -B build -G Ninja -DCMAKE_BUILD_TYPE=Release \
|
|
-DCMAKE_EXE_LINKER_FLAGS="-static-libgcc -static-libstdc++" \
|
|
-DCMAKE_SHARED_LINKER_FLAGS="-static-libgcc -static-libstdc++"
|
|
|
|
- name: Build
|
|
shell: msys2 {0}
|
|
run: |
|
|
cmake --build build
|
|
|
|
echo "compiler: $(command -v g++)"
|
|
echo "target: $(gcc -dumpmachine)"
|
|
|
|
echo "--- imports (non-system DLLs) ---"
|
|
objdump -p build/bin/libagent.dll build/bin/libloader.dll build/bin/libinject.dll \
|
|
| grep 'DLL Name:' | sed 's/.*DLL Name:[[:space:]]*//' | sort -u
|
|
|
|
# Bundle whatever non-system DLLs are still imported, taken from the
|
|
# toolchain that built them, so the tests can load libagent.dll
|
|
# without depending on PATH.
|
|
GCC_BIN="$(dirname "$(command -v gcc)")"
|
|
deps="$(objdump -p build/bin/libagent.dll build/bin/libloader.dll build/bin/libinject.dll \
|
|
| grep 'DLL Name:' | sed 's/.*DLL Name:[[:space:]]*//' | sort -u \
|
|
| grep -viE '^(kernel32|user32|advapi32|ws2_32|shell32|ole32|gdi32|msvcrt|ucrtbase|ntdll|comdlg32|comctl32|psapi|version|iphlpapi|bcrypt|secur32|crypt32|winmm|imm32|netapi32|userenv|rpcrt4|setupapi|mswsock|dnsapi|normaliz)[.]dll$' \
|
|
| grep -viE '^api-ms-win-')"
|
|
for dll in $deps; do
|
|
if [ -f "$GCC_BIN/$dll" ]; then
|
|
cp -f "$GCC_BIN/$dll" build/bin/
|
|
echo "bundled $dll"
|
|
else
|
|
echo "MISSING $dll (not found in $GCC_BIN)"
|
|
fi
|
|
done
|
|
|
|
echo "--- build/bin ---"
|
|
ls -1 build/bin
|
|
|
|
- name: Run integration tests
|
|
shell: pwsh
|
|
run: |
|
|
# Fallback for any remaining runtime DLLs.
|
|
$env:PATH = "C:\msys64\mingw64\bin;$env:PATH"
|
|
./tests/run-tests.ps1
|