]> prime8.dev >> repos - ttyd.git/commitdiff
scripts: use cross compiler from musl.cc
authorShuanglei Tao <tsl0922@gmail.com>
Sun, 26 Jul 2020 12:57:55 +0000 (20:57 +0800)
committerShuanglei Tao <tsl0922@gmail.com>
Sun, 26 Jul 2020 13:05:51 +0000 (21:05 +0800)
.github/workflows/backend.yml
.github/workflows/frontend.yml
.github/workflows/release.yml
scripts/cross-build.sh

index 4d07a5ee4d24bd8e183d613ca393715580d2189f..706f824d16a590f7fe37702b07bfa7cb5153a4ee 100644 (file)
@@ -34,7 +34,7 @@ jobs:
           cd libwebsockets-${LWS_VERSION}
           cmake -DLWS_WITH_LIBUV=ON -DLWS_UNIX_SOCK=ON -DLWS_IPV6=ON -DLWS_WITHOUT_TESTAPPS=ON -DCMAKE_BUILD_TYPE=RELEASE .
           make && sudo make install && sudo ldconfig
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v2
       - name: Build ttyd
         run: |
           cmake -DCMAKE_BUILD_TYPE=RELEASE .
@@ -44,13 +44,17 @@ jobs:
     runs-on: ubuntu-16.04
     strategy:
       matrix:
-        arch: [i386, x86_64, arm, armhf, aarch64, mips, mipsel]
+        arch: [i686, x86_64, arm, armhf, aarch64, mips, mipsel, mips64, mips64el]
     steps:
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v2
+      - name: Install packages
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y autoconf automake build-essential cmake curl file libtool
       - name: Cross build (${{ matrix.arch }})
         env:
           ARCH: ${{ matrix.arch }}
-        run: docker run --rm -v $(pwd):/ttyd -w /ttyd tsl0922/musl-cross ./scripts/cross-build.sh $ARCH
+        run: ./scripts/cross-build.sh $ARCH
       - uses: actions/upload-artifact@v1
         with:
           name: ttyd.${{ matrix.arch }}
index f4acdfd4f429606e29083ed3cefc1a47a3238228..6777acd8c4aa2b44543cda64006d3d45c04b5f49 100644 (file)
@@ -14,7 +14,7 @@ jobs:
   build:
     runs-on: ubuntu-16.04
     steps:
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v2
       - uses: actions/setup-node@v1
         with:
           node-version: '12.x'
index 72f8d0befd99dd53add9529ea27a46f564751b78..2d8f817c5e7617adb1fd5a9206d96c0b3ba31874 100644 (file)
@@ -9,12 +9,16 @@ jobs:
   build:
     runs-on: ubuntu-16.04
     steps:
-      - uses: actions/checkout@v1
+      - uses: actions/checkout@v2
+      - name: Install packages
+        run: |
+          sudo apt-get update
+          sudo apt-get install -y autoconf automake build-essential cmake curl file libtool
       - name: Build Release
         run: |
           mkdir -p bin
-          for arch in i386 x86_64 arm armhf aarch64 mips mipsel; do
-            docker run --rm -v $(pwd):/ttyd -w /ttyd tsl0922/musl-cross ./scripts/cross-build.sh $arch
+          for arch in i686 x86_64 arm armhf aarch64 mips mipsel mips64 mips64el; do
+            ./scripts/cross-build.sh $arch
             cp build/ttyd bin/ttyd_linux.$arch
             sha256sum bin/ttyd_linux.$arch >> bin/SHA256SUMS
           done
index 7c631699104c0b1b30e4c089f2e4660307f197de..3be72019d827ccbb9e84985f8747b5b8031a0a92 100755 (executable)
@@ -1,9 +1,5 @@
 #!/bin/bash
-#
-# This script should be run inside the tsl0922/musl-cross docker image
-# Example:
-#         docker run --rm -v $(pwd):/ttyd -w /ttyd tsl0922/musl-cross ./scripts/cross-build.sh mips
-#
+
 set -eo pipefail
 
 CROSS_ROOT="${CROSS_ROOT:-/opt/cross}"
@@ -14,7 +10,7 @@ ZLIB_VERSION="${ZLIB_VERSION:-1.2.11}"
 JSON_C_VERSION="${JSON_C_VERSION:-0.14}"
 OPENSSL_VERSION="${OPENSSL_VERSION:-1.0.2u}"
 LIBUV_VERSION="${LIBUV_VERSION:-1.38.0}"
-LIBWEBSOCKETS_VERSION="${LIBWEBSOCKETS_VERSION:-4.0.19}"
+LIBWEBSOCKETS_VERSION="${LIBWEBSOCKETS_VERSION:-4.0.20}"
 
 build_zlib() {
     echo "=== Building zlib-${ZLIB_VERSION} (${TARGET})..."
@@ -51,7 +47,7 @@ build_openssl() {
 }
 
 build_libuv() {
-  echo "=== Building libuv-${LIBUV_VERSION} (${TARGET})..."
+    echo "=== Building libuv-${LIBUV_VERSION} (${TARGET})..."
     curl -sLo- "https://dist.libuv.org/dist/v${LIBUV_VERSION}/libuv-v${LIBUV_VERSION}.tar.gz" | tar xz -C "${BUILD_DIR}"
     pushd "${BUILD_DIR}/libuv-v${LIBUV_VERSION}"
         ./autogen.sh
@@ -71,17 +67,19 @@ set(CMAKE_FIND_ROOT_PATH "${STAGE_DIR}")
 set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
 set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
 set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
+
+set(OPENSSL_USE_STATIC_LIBS TRUE)
 EOF
 }
 
 build_libwebsockets() {
     echo "=== Building libwebsockets-${LIBWEBSOCKETS_VERSION} (${TARGET})..."
-    curl -sLo- "https://github.com/warmcat/libwebsockets/archive/v${LIBWEBSOCKETS_VERSION}.tar.gz" | tar xz -C "${BUILD_DIR}"
+    curl -sLo- "https://github.com/warmcat/libwebsockets/archive/v${LIBWEBSOCKETS_VERSION}.tar.gz" | tar xz -C ${BUILD_DIR}
     pushd "${BUILD_DIR}/libwebsockets-${LIBWEBSOCKETS_VERSION}"
         sed -i 's/ websockets_shared//g' cmake/LibwebsocketsConfig.cmake.in
+        sed -i '/PC_OPENSSL/d' CMakeLists.txt
         mkdir build && cd build
         cmake -DCMAKE_TOOLCHAIN_FILE="${BUILD_DIR}/cross-${TARGET}.cmake" \
-            -DCMAKE_BUILD_TYPE=RELEASE \
             -DCMAKE_INSTALL_PREFIX="${STAGE_DIR}" \
             -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
             -DCMAKE_EXE_LINKER_FLAGS="-static" \
@@ -93,20 +91,19 @@ build_libwebsockets() {
             -DLWS_IPV6=ON \
             ..
         make -j"$(nproc)" install
-        sed -i 's/ssl;crypto;//g' "${STAGE_DIR}/lib/cmake/libwebsockets/LibwebsocketsTargets-release.cmake"
     popd
 }
 
 build_ttyd() {
     echo "=== Building ttyd (${TARGET})..."
     rm -rf build && mkdir -p build && cd build
-  cmake -DCMAKE_TOOLCHAIN_FILE="${BUILD_DIR}/cross-${TARGET}.cmake" \
-      -DCMAKE_INSTALL_PREFIX="${STAGE_DIR}" \
-      -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
-      -DCMAKE_EXE_LINKER_FLAGS="-static -no-pie -s" \
-      -DCMAKE_BUILD_TYPE=RELEASE \
-      ..
-  make install
+    cmake -DCMAKE_TOOLCHAIN_FILE="${BUILD_DIR}/cross-${TARGET}.cmake" \
+        -DCMAKE_INSTALL_PREFIX="${STAGE_DIR}" \
+        -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
+        -DCMAKE_EXE_LINKER_FLAGS="-static -no-pie -s" \
+        -DCMAKE_BUILD_TYPE=RELEASE \
+        ..
+    make install
 }
 
 build() {
@@ -115,6 +112,11 @@ build() {
     STAGE_DIR="${STAGE_ROOT}/${TARGET}"
     BUILD_DIR="${BUILD_ROOT}/${TARGET}"
 
+    echo "=== Installing toolchain ${ALIAS} (${TARGET})..."
+
+    mkdir -p "${CROSS_ROOT}" && export PATH="${PATH}:/opt/cross/bin"
+    curl -sLo- "http://musl.cc/${TARGET}-cross.tgz" | tar xz -C ${CROSS_ROOT} --strip-components 1
+
     echo "=== Building target ${ALIAS} (${TARGET})..."
 
     rm -rf "${STAGE_DIR}" "${BUILD_DIR}"
@@ -132,15 +134,15 @@ build() {
 }
 
 case $1 in
-  i386|x86_64|aarch64|mips|mipsel)
-    build "$1-linux-musl" "$1"
-    ;;
-  arm)
-    build arm-linux-musleabi "$1"
-    ;;
-  armhf)
-    build arm-linux-musleabihf "$1"
-    ;;
-  *)
-    echo "usage: $0 i386|x86_64|arm|armhf|aarch64|mips|mipsel" && exit 1
+    i686|x86_64|aarch64|mips|mipsel|mips64|mips64el)
+        build "$1-linux-musl" "$1"
+        ;;
+    arm)
+        build arm-linux-musleabi "$1"
+        ;;
+    armhf)
+        build arm-linux-musleabihf "$1"
+        ;;
+    *)
+        echo "usage: $0 i686|x86_64|arm|armhf|aarch64|mips|mipsel|mips64|mips64el" && exit 1
 esac