]> prime8.dev >> repos - ttyd.git/commitdiff
workflow: switch to mingw build for win10
authorShuanglei Tao <tsl0922@gmail.com>
Sat, 6 Mar 2021 10:27:01 +0000 (18:27 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sat, 6 Mar 2021 11:19:57 +0000 (19:19 +0800)
.github/workflows/backend.yml
scripts/mingw-build.sh [new file with mode: 0644]
scripts/msys2-build.sh [deleted file]

index 9c3a6bdbb0bba453f86e85925108d3fff06499f3..19c668610020da5c6e18fd080d25ec5f28f13981 100644 (file)
@@ -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
diff --git a/scripts/mingw-build.sh b/scripts/mingw-build.sh
new file mode 100644 (file)
index 0000000..1a4f4ea
--- /dev/null
@@ -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
diff --git a/scripts/msys2-build.sh b/scripts/msys2-build.sh
deleted file mode 100644 (file)
index 683fdfe..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-#!/bin/bash
-
-set -eo pipefail
-
-TMPDIR="${TMPDIR:-/tmp}"
-JSON_C_VERSION="${JSON_C_VERSION:-0.15}"
-LIBWEBSOCKETS_VERSION="${LIBWEBSOCKETS_VERSION:-3.2.2}"
-
-build_json-c() {
-  curl -sLo- "https://s3.amazonaws.com/json-c_releases/releases/json-c-${JSON_C_VERSION}.tar.gz" | tar xz -f - -C "${TMPDIR}" || true
-  pushd "${TMPDIR}/json-c-${JSON_C_VERSION}"
-      rm -rf build && mkdir -p build && cd build
-      cmake -DCMAKE_BUILD_TYPE=RELEASE -DBUILD_SHARED_LIBS=OFF ..
-      make -j"$(nproc)" install
-  popd
-}
-
-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/LibwebsocketsConfig.cmake.in
-      rm -rf build && mkdir -p build && cd build
-      cmake -DCMAKE_BUILD_TYPE=RELEASE \
-          -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
-          -DCMAKE_EXE_LINKER_FLAGS="-static" \
-          -DLWS_WITH_SSL=OFF \
-          -DLWS_WITH_BUNDLED_ZLIB=OFF \
-          -DLWS_WITHOUT_TESTAPPS=ON \
-          -DLWS_WITH_LIBUV=ON \
-          -DLWS_STATIC_PIC=ON \
-          -DLWS_WITH_SHARED=OFF \
-          -DLWS_UNIX_SOCK=ON \
-          -DLWS_IPV6=ON \
-          -DLWS_WITH_HTTP2=OFF \
-          -DLWS_WITHOUT_CLIENT=ON \
-          -DLWS_WITH_LEJP=OFF \
-          -DLWS_WITH_LEJP_CONF=OFF \
-          -DLWS_WITH_LWSAC=OFF \
-          -DLWS_WITH_CUSTOM_HEADERS=OFF \
-          -DLWS_WITH_SEQUENCER=OFF \
-          ..
-      make -j"$(nproc)" install
-  popd
-}
-
-build_json-c
-build_libwebsockets
-
-rm -rf build && mkdir -p build && cd build
-cmake -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