mirror of
https://github.com/PurpleI2P/i2pd.git
synced 2026-10-20 18:54:01 +00:00
287 lines
11 KiB
YAML
287 lines
11 KiB
YAML
name: Build on Windows
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- '*'
|
|
paths:
|
|
- .github/workflows/build-windows.yml
|
|
- build/CMakeLists.txt
|
|
- build/cmake_modules/**
|
|
- daemon/**
|
|
- i18n/**
|
|
- libi2pd/**
|
|
- libi2pd_client/**
|
|
- Win32/**
|
|
- Makefile
|
|
- Makefile.mingw
|
|
pull_request:
|
|
branches:
|
|
- '*'
|
|
workflow_call:
|
|
|
|
defaults:
|
|
run:
|
|
shell: msys2 {0}
|
|
|
|
jobs:
|
|
build:
|
|
name: ${{ matrix.arch }}
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include: [
|
|
{ msystem: UCRT64, arch: ucrt-x86_64, arch_short: x64-ucrt, compiler: gcc, os: windows-latest },
|
|
{ msystem: CLANG64, arch: clang-x86_64, arch_short: x64-clang, compiler: clang, os: windows-latest },
|
|
{ msystem: MINGW64, arch: x86_64, arch_short: x64, compiler: gcc, os: windows-latest },
|
|
{ msystem: MINGW32, arch: i686, arch_short: x86, compiler: gcc, os: windows-latest },
|
|
{ msystem: CLANGARM64, arch: clang-aarch64, arch_short: arm64, compiler: clang, os: windows-11-arm }
|
|
]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup MSYS2
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: ${{ matrix.msystem }}
|
|
install: >-
|
|
base-devel git mingw-w64-${{ matrix.arch }}-${{ matrix.compiler }} mingw-w64-${{ matrix.arch }}-openssl
|
|
${{ matrix.msystem == 'MINGW32' && 'mingw-w64-i686-cmake mingw-w64-i686-ninja' || format('mingw-w64-{0}-boost mingw-w64-{0}-miniupnpc', matrix.arch) }}
|
|
update: true
|
|
|
|
# MSYS2 no longer ships Boost and miniupnpc for i686
|
|
- name: Build Boost and miniupnpc
|
|
if: ${{ matrix.msystem == 'MINGW32' }}
|
|
env:
|
|
BOOST_VERSION: 1.92.0
|
|
BOOST_SHA256: ea7b982002cc9dfbe59b0b217b206f470dc75f3de0bb2973d844118934d82411
|
|
MINIUPNPC_VERSION: 2.3.3
|
|
MINIUPNPC_SHA256: d52a0afa614ad6c088cc9ddff1ae7d29c8c595ac5fdd321170a05f41e634bd1a
|
|
run: |
|
|
set -e
|
|
curl -fsSL -o boost.tar.xz https://github.com/boostorg/boost/releases/download/boost-$BOOST_VERSION/boost-$BOOST_VERSION-b2-nodocs.tar.xz
|
|
echo "$BOOST_SHA256 boost.tar.xz" | sha256sum -c -
|
|
tar xJf boost.tar.xz
|
|
cd boost-$BOOST_VERSION
|
|
./bootstrap.sh --with-toolset=gcc
|
|
./b2 -j4 toolset=gcc target-os=windows threadapi=win32 address-model=32 architecture=x86 \
|
|
link=static threading=multi variant=release --layout=system \
|
|
--with-filesystem --with-program_options --with-json --with-url stage
|
|
cp -r boost $MINGW_PREFIX/include/
|
|
# Makefile.mingw links the MSYS2 library names with the -mt suffix
|
|
for lib in filesystem program_options json url; do cp stage/lib/libboost_$lib.a $MINGW_PREFIX/lib/libboost_$lib-mt.a; done
|
|
cd ..
|
|
curl -fsSL -o miniupnpc.tar.gz https://github.com/miniupnp/miniupnp/releases/download/miniupnpc_${MINIUPNPC_VERSION//./_}/miniupnpc-$MINIUPNPC_VERSION.tar.gz
|
|
echo "$MINIUPNPC_SHA256 miniupnpc.tar.gz" | sha256sum -c -
|
|
tar xzf miniupnpc.tar.gz
|
|
cmake -S miniupnpc-$MINIUPNPC_VERSION -B miniupnpc-build -G Ninja -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX \
|
|
-DUPNPC_BUILD_SHARED=OFF -DUPNPC_BUILD_TESTS=OFF -DUPNPC_BUILD_SAMPLE=OFF
|
|
cmake --build miniupnpc-build
|
|
cmake --install miniupnpc-build
|
|
|
|
- name: Install additional clang packages
|
|
if: ${{ matrix.compiler == 'clang' }}
|
|
run: pacman --noconfirm -S mingw-w64-${{ matrix.arch }}-gcc-compat
|
|
|
|
- name: Build application
|
|
run: |
|
|
mkdir -p obj/Win32 obj/libi2pd obj/libi2pd_client obj/daemon
|
|
make USE_UPNP=yes DEBUG=no USE_GIT_VERSION=yes -j3
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: i2pd-${{ matrix.arch_short }}.exe
|
|
path: i2pd.exe
|
|
|
|
build-cmake:
|
|
name: CMake ${{ matrix.arch }}
|
|
runs-on: ${{ matrix.os }}
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
include: [
|
|
{ msystem: UCRT64, arch: ucrt-x86_64, arch_short: x64-ucrt, compiler: gcc, os: windows-latest },
|
|
{ msystem: CLANG64, arch: clang-x86_64, arch_short: x64-clang, compiler: clang, os: windows-latest },
|
|
{ msystem: MINGW64, arch: x86_64, arch_short: x64, compiler: gcc, os: windows-latest },
|
|
{ msystem: CLANGARM64, arch: clang-aarch64, arch_short: arm64, compiler: clang, os: windows-11-arm }
|
|
]
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup MSYS2
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: ${{ matrix.msystem }}
|
|
install: base-devel git mingw-w64-${{ matrix.arch }}-cmake mingw-w64-${{ matrix.arch }}-ninja mingw-w64-${{ matrix.arch }}-${{ matrix.compiler }} mingw-w64-${{ matrix.arch }}-boost mingw-w64-${{ matrix.arch }}-openssl mingw-w64-${{ matrix.arch }}-miniupnpc
|
|
update: true
|
|
|
|
- name: Build application
|
|
run: |
|
|
cd build
|
|
cmake -DWITH_GIT_VERSION=ON -DWITH_STATIC=ON -DWITH_UPNP=ON -DCMAKE_BUILD_TYPE=Release .
|
|
cmake --build . -- -j3
|
|
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: i2pd-cmake-${{ matrix.arch_short }}.exe
|
|
path: build/i2pd.exe
|
|
|
|
build-xp:
|
|
name: XP
|
|
runs-on: windows-latest
|
|
|
|
strategy:
|
|
fail-fast: false
|
|
|
|
steps:
|
|
- name: Checkout
|
|
uses: actions/checkout@v4
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Setup MSYS2
|
|
uses: msys2/setup-msys2@v2
|
|
with:
|
|
msystem: MINGW32
|
|
install: base-devel git mingw-w64-i686-gcc mingw-w64-i686-openssl mingw-w64-i686-cmake mingw-w64-i686-ninja
|
|
cache: true
|
|
update: true
|
|
|
|
- name: Clone MinGW packages repository
|
|
run: git clone https://github.com/msys2/MINGW-packages
|
|
|
|
# headers
|
|
- name: Get headers package version
|
|
id: version-headers
|
|
run: |
|
|
echo "version=$(pacman -Si mingw-w64-i686-headers | grep -Po '^Version\s*: \K.+')" >> $GITHUB_OUTPUT
|
|
- name: Cache headers package
|
|
uses: actions/cache@v4
|
|
id: cache-headers
|
|
with:
|
|
path: MINGW-packages/mingw-w64-headers/*.zst
|
|
key: winxp-headers-${{ steps.version-headers.outputs.version }}
|
|
- name: Build WinXP-capable headers package
|
|
if: steps.cache-headers.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd MINGW-packages/mingw-w64-headers
|
|
sed -i 's/0x601/0x501/' PKGBUILD
|
|
MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm --nocheck
|
|
- name: Install headers package
|
|
run: pacman --noconfirm -U MINGW-packages/mingw-w64-headers/mingw-w64-i686-*-any.pkg.tar.zst
|
|
|
|
# CRT
|
|
- name: Get crt package version
|
|
id: version-crt
|
|
run: |
|
|
echo "version=$(pacman -Si mingw-w64-i686-crt | grep -Po '^Version\s*: \K.+')" >> $GITHUB_OUTPUT
|
|
- name: Cache crt package
|
|
uses: actions/cache@v4
|
|
id: cache-crt
|
|
with:
|
|
path: MINGW-packages/mingw-w64-crt/*.zst
|
|
key: winxp-crt-${{ steps.version-crt.outputs.version }}
|
|
- name: Build WinXP-capable crt package
|
|
if: steps.cache-crt.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd MINGW-packages/mingw-w64-crt
|
|
MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm --nocheck
|
|
- name: Install crt package
|
|
run: pacman --noconfirm -U MINGW-packages/mingw-w64-crt/mingw-w64-i686-*-any.pkg.tar.zst
|
|
|
|
# winpthreads
|
|
- name: Get winpthreads package version
|
|
id: version-winpthreads
|
|
run: |
|
|
echo "version=$(pacman -Si mingw-w64-i686-winpthreads | grep -Po '^Version\s*: \K.+')" >> $GITHUB_OUTPUT
|
|
- name: Cache winpthreads package
|
|
uses: actions/cache@v4
|
|
id: cache-winpthreads
|
|
with:
|
|
path: MINGW-packages/mingw-w64-winpthreads/*.zst
|
|
key: winxp-winpthreads-${{ steps.version-winpthreads.outputs.version }}
|
|
- name: Build WinXP-capable winpthreads package
|
|
if: steps.cache-winpthreads.outputs.cache-hit != 'true'
|
|
run: |
|
|
cd MINGW-packages/mingw-w64-winpthreads
|
|
MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm --nocheck
|
|
- name: Install winpthreads package
|
|
run: pacman --noconfirm -U MINGW-packages/mingw-w64-winpthreads/mingw-w64-i686-*-any.pkg.tar.zst
|
|
|
|
# OpenSSL
|
|
- name: Get openssl package version
|
|
id: version-openssl
|
|
run: |
|
|
echo "version=$(pacman -Si mingw-w64-i686-openssl | grep -Po '^Version\s*: \K.+')" >> $GITHUB_OUTPUT
|
|
- name: Cache openssl package
|
|
uses: actions/cache@v4
|
|
id: cache-openssl
|
|
with:
|
|
path: MINGW-packages/mingw-w64-openssl/*.zst
|
|
key: winxp-openssl-${{ steps.version-openssl.outputs.version }}-no-uplink
|
|
- name: Build WinXP-capable openssl package
|
|
if: steps.cache-openssl.outputs.cache-hit != 'true'
|
|
run: |
|
|
set -e
|
|
cd MINGW-packages/mingw-w64-openssl
|
|
# ms/uplink.c imports msvcrt.dll!wcscpy_s, which Windows XP does not have
|
|
sed -i 's/^ shared \\$/ shared no-uplink \\/' PKGBUILD
|
|
grep -q '^ shared no-uplink \\$' PKGBUILD
|
|
curl https://openssl-library.org/source/pubkeys.asc | gpg --import
|
|
MINGW_ARCH=mingw32 makepkg-mingw -sCLf --noconfirm --nocheck
|
|
- name: Install openssl package
|
|
run: pacman --noconfirm -U MINGW-packages/mingw-w64-openssl/mingw-w64-i686-*-any.pkg.tar.zst
|
|
|
|
# Boost
|
|
- name: Build Boost and miniupnpc
|
|
env:
|
|
BOOST_VERSION: 1.85.0
|
|
BOOST_SHA256: be0d91732d5b0cc6fbb275c7939974457e79b54d6f07ce2e3dfdd68bef883b0b
|
|
MINIUPNPC_VERSION: 2.3.3
|
|
MINIUPNPC_SHA256: d52a0afa614ad6c088cc9ddff1ae7d29c8c595ac5fdd321170a05f41e634bd1a
|
|
run: |
|
|
set -e
|
|
curl -fsSL -o boost.tar.gz https://archives.boost.io/release/$BOOST_VERSION/source/boost_${BOOST_VERSION//./_}.tar.gz
|
|
echo "$BOOST_SHA256 boost.tar.gz" | sha256sum -c -
|
|
tar xzf boost.tar.gz
|
|
cd boost_${BOOST_VERSION//./_}
|
|
./bootstrap.sh --with-toolset=gcc
|
|
./b2 -j4 toolset=gcc target-os=windows threadapi=win32 address-model=32 architecture=x86 \
|
|
link=static threading=multi variant=release --layout=system \
|
|
--with-filesystem --with-program_options --with-json --with-url stage
|
|
cp -r boost $MINGW_PREFIX/include/
|
|
for lib in filesystem program_options json url; do cp stage/lib/libboost_$lib.a $MINGW_PREFIX/lib/libboost_$lib-mt.a; done
|
|
cd ..
|
|
curl -fsSL -o miniupnpc.tar.gz https://github.com/miniupnp/miniupnp/releases/download/miniupnpc_${MINIUPNPC_VERSION//./_}/miniupnpc-$MINIUPNPC_VERSION.tar.gz
|
|
echo "$MINIUPNPC_SHA256 miniupnpc.tar.gz" | sha256sum -c -
|
|
tar xzf miniupnpc.tar.gz
|
|
cmake -S miniupnpc-$MINIUPNPC_VERSION -B miniupnpc-build -G Ninja -DCMAKE_INSTALL_PREFIX=$MINGW_PREFIX \
|
|
-DUPNPC_BUILD_SHARED=OFF -DUPNPC_BUILD_TESTS=OFF -DUPNPC_BUILD_SAMPLE=OFF
|
|
cmake --build miniupnpc-build
|
|
cmake --install miniupnpc-build
|
|
|
|
# Building i2pd
|
|
- name: Build application
|
|
run: |
|
|
mkdir -p obj/Win32 obj/libi2pd obj/libi2pd_client obj/daemon
|
|
make USE_UPNP=yes DEBUG=no USE_GIT_VERSION=yes USE_WINXP_FLAGS=yes -j3
|
|
if objdump -p i2pd.exe | grep -w wcscpy_s; then exit 1; fi
|
|
- name: Upload artifacts
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: i2pd-xp.exe
|
|
path: i2pd.exe
|