Skip to content

Commit

Permalink
workflow: switch to mingw build for win10
Browse files Browse the repository at this point in the history
  • Loading branch information
tsl0922 committed Mar 6, 2021
1 parent 02bbbec commit 79af0b8
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 65 deletions.
23 changes: 13 additions & 10 deletions .github/workflows/backend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,23 +59,26 @@ jobs:
with:
name: ttyd.${{ matrix.target }}
path: build/ttyd
msys2:
win10:
runs-on: windows-latest
steps:
- uses: actions/checkout@v2
- uses: msys2/setup-msys2@v2
with:
msystem: MSYS
install: gcc cmake make libuv-devel zlib-devel openssl-devel
msystem: MINGW64
install: >-
make
mingw64/mingw-w64-x86_64-gcc
mingw64/mingw-w64-x86_64-cmake
mingw64/mingw-w64-x86_64-zlib
mingw64/mingw-w64-x86_64-libuv
mingw64/mingw-w64-x86_64-mbedtls
mingw64/mingw-w64-x86_64-json-c
update: true
- name: Build ttyd
shell: msys2 {0}
run: |
./scripts/msys2-build.sh
cp /usr/bin/msys-2.0.dll build
run: ./scripts/mingw-build.sh
- uses: actions/upload-artifact@v2
with:
name: ttyd.msys2
path: |
build/ttyd.exe
build/msys-2.0.dll
name: ttyd.win10
path: build/ttyd.exe
40 changes: 40 additions & 0 deletions scripts/mingw-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
#!/bin/bash

set -eo pipefail

TMPDIR="${TMPDIR:-/tmp}"
JSON_C_VERSION="${JSON_C_VERSION:-0.15}"
LIBWEBSOCKETS_VERSION="${LIBWEBSOCKETS_VERSION:-4.1.6}"

build_libwebsockets() {
curl -sLo- "https://github.com/warmcat/libwebsockets/archive/v${LIBWEBSOCKETS_VERSION}.tar.gz" | tar xz -f - -C "${TMPDIR}"
pushd "${TMPDIR}/libwebsockets-${LIBWEBSOCKETS_VERSION}"
sed -i 's/ websockets_shared//g' cmake/libwebsockets-config.cmake.in
sed -i '/PC_OPENSSL/d' lib/tls/CMakeLists.txt
rm -rf build && mkdir -p build && cd build
MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
cmake -G"MSYS Makefiles" \
-DCMAKE_INSTALL_PREFIX=${MINGW_PREFIX} \
-DCMAKE_BUILD_TYPE=RELEASE \
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
-DCMAKE_EXE_LINKER_FLAGS="-static" \
-DLWS_WITH_MBEDTLS=ON \
-DLWS_WITH_DIR=OFF \
-DLWS_WITHOUT_DAEMONIZE=ON \
-DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITH_LIBUV=ON \
..
make -j"$(nproc)" install
popd
}

build_libwebsockets

rm -rf build && mkdir -p build && cd build
cmake -G"MSYS Makefiles" \
-DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
-DCMAKE_C_FLAGS="-Os -ffunction-sections -fdata-sections -fno-unwind-tables -fno-asynchronous-unwind-tables -flto" \
-DCMAKE_EXE_LINKER_FLAGS="-static -no-pie -Wl,-s -Wl,-Bsymbolic -Wl,--gc-sections" \
-DCMAKE_BUILD_TYPE=RELEASE \
..
make install
55 changes: 0 additions & 55 deletions scripts/msys2-build.sh

This file was deleted.

0 comments on commit 79af0b8

Please sign in to comment.