Skip to content

Commit 79af0b8

Browse files
committed
workflow: switch to mingw build for win10
1 parent 02bbbec commit 79af0b8

File tree

3 files changed

+53
-65
lines changed

3 files changed

+53
-65
lines changed

.github/workflows/backend.yml

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -59,23 +59,26 @@ jobs:
5959
with:
6060
name: ttyd.${{ matrix.target }}
6161
path: build/ttyd
62-
msys2:
62+
win10:
6363
runs-on: windows-latest
6464
steps:
6565
- uses: actions/checkout@v2
6666
- uses: msys2/setup-msys2@v2
6767
with:
68-
msystem: MSYS
69-
install: gcc cmake make libuv-devel zlib-devel openssl-devel
68+
msystem: MINGW64
69+
install: >-
70+
make
71+
mingw64/mingw-w64-x86_64-gcc
72+
mingw64/mingw-w64-x86_64-cmake
73+
mingw64/mingw-w64-x86_64-zlib
74+
mingw64/mingw-w64-x86_64-libuv
75+
mingw64/mingw-w64-x86_64-mbedtls
76+
mingw64/mingw-w64-x86_64-json-c
7077
update: true
7178
- name: Build ttyd
7279
shell: msys2 {0}
73-
run: |
74-
./scripts/msys2-build.sh
75-
cp /usr/bin/msys-2.0.dll build
80+
run: ./scripts/mingw-build.sh
7681
- uses: actions/upload-artifact@v2
7782
with:
78-
name: ttyd.msys2
79-
path: |
80-
build/ttyd.exe
81-
build/msys-2.0.dll
83+
name: ttyd.win10
84+
path: build/ttyd.exe

scripts/mingw-build.sh

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
#!/bin/bash
2+
3+
set -eo pipefail
4+
5+
TMPDIR="${TMPDIR:-/tmp}"
6+
JSON_C_VERSION="${JSON_C_VERSION:-0.15}"
7+
LIBWEBSOCKETS_VERSION="${LIBWEBSOCKETS_VERSION:-4.1.6}"
8+
9+
build_libwebsockets() {
10+
curl -sLo- "https://github.com/warmcat/libwebsockets/archive/v${LIBWEBSOCKETS_VERSION}.tar.gz" | tar xz -f - -C "${TMPDIR}"
11+
pushd "${TMPDIR}/libwebsockets-${LIBWEBSOCKETS_VERSION}"
12+
sed -i 's/ websockets_shared//g' cmake/libwebsockets-config.cmake.in
13+
sed -i '/PC_OPENSSL/d' lib/tls/CMakeLists.txt
14+
rm -rf build && mkdir -p build && cd build
15+
MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
16+
cmake -G"MSYS Makefiles" \
17+
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
18+
-DCMAKE_BUILD_TYPE=RELEASE \
19+
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
20+
-DCMAKE_EXE_LINKER_FLAGS="-static" \
21+
-DLWS_WITH_MBEDTLS=ON \
22+
-DLWS_WITH_DIR=OFF \
23+
-DLWS_WITHOUT_DAEMONIZE=ON \
24+
-DLWS_WITHOUT_TESTAPPS=ON \
25+
-DLWS_WITH_LIBUV=ON \
26+
..
27+
make -j"$(nproc)" install
28+
popd
29+
}
30+
31+
build_libwebsockets
32+
33+
rm -rf build && mkdir -p build && cd build
34+
cmake -G"MSYS Makefiles" \
35+
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
36+
-DCMAKE_C_FLAGS="-Os -ffunction-sections -fdata-sections -fno-unwind-tables -fno-asynchronous-unwind-tables -flto" \
37+
-DCMAKE_EXE_LINKER_FLAGS="-static -no-pie -Wl,-s -Wl,-Bsymbolic -Wl,--gc-sections" \
38+
-DCMAKE_BUILD_TYPE=RELEASE \
39+
..
40+
make install

scripts/msys2-build.sh

Lines changed: 0 additions & 55 deletions
This file was deleted.

0 commit comments

Comments
 (0)