cmake -DCMAKE_BUILD_TYPE=RELEASE .
make && sudo make install
ttyd -v
+ cross:
+ runs-on: ubuntu-16.04
+ strategy:
+ matrix:
+ arch: [i386, x86_64, arm, armhf, mips, mipsel]
+ steps:
+ - uses: actions/checkout@v1
+ - 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
+ - uses: actions/upload-artifact@v1
+ with:
+ name: ttyd.${{ matrix.arch }}
+ path: build/ttyd
#!/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
OPENSSL_VERSION="${OPENSSL_VERSION:-1.0.2t}"
LIBUV_VERSION="${LIBUV_VERSION:-1.34.0}"
LIBWEBSOCKETS_VERSION="${LIBWEBSOCKETS_VERSION:-3.2.0}"
-TTYD_VERSION="${TTYD_VERSION:-1.5.2}"
build_zlib() {
echo "=== Building zlib-${ZLIB_VERSION} (${TARGET})..."
echo "=== Building libwebsockets-${LIBWEBSOCKETS_VERSION} (${TARGET})..."
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 '13s;^;\nSET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")\nSET(CMAKE_EXE_LINKER_FLAGS "-static")\n;' CMakeLists.txt
sed -i 's/ websockets_shared//g' cmake/LibwebsocketsConfig.cmake.in
mkdir build && cd build
- cmake -DLWS_WITHOUT_TESTAPPS=ON \
+ cmake -DCMAKE_TOOLCHAIN_FILE=${BUILD_DIR}/cross-${TARGET}.cmake \
+ -DCMAKE_INSTALL_PREFIX=${STAGE_DIR} \
+ -DCMAKE_FIND_LIBRARY_SUFFIXES=".a" \
+ -DCMAKE_EXE_LINKER_FLAGS="-static" \
+ -DLWS_WITHOUT_TESTAPPS=ON \
-DLWS_WITH_LIBUV=ON \
-DLWS_STATIC_PIC=ON \
-DLWS_WITH_SHARED=OFF \
-DLWS_UNIX_SOCK=ON \
-DLWS_IPV6=ON \
- -DCMAKE_TOOLCHAIN_FILE=../../cross-${TARGET}.cmake \
- -DCMAKE_INSTALL_PREFIX=${STAGE_DIR} \
..
make install
popd
}
build_ttyd() {
- echo "=== Building ttyd-${TTYD_VERSION} (${TARGET})..."
- curl -sLo- https://github.com/tsl0922/ttyd/archive/${TTYD_VERSION}.tar.gz | tar xz -C ${BUILD_DIR}
- pushd ${BUILD_DIR}/ttyd-${TTYD_VERSION}
- sed -i '5s;^;\nSET(CMAKE_FIND_LIBRARY_SUFFIXES ".a")\nSET(CMAKE_EXE_LINKER_FLAGS "-static -no-pie -s")\n;' CMakeLists.txt
- mkdir build && cd build
- cmake -DCMAKE_TOOLCHAIN_FILE=../../cross-${TARGET}.cmake \
- -DCMAKE_BUILD_TYPE=RELEASE \
- ..
- make
- popd
- cp ${BUILD_DIR}/ttyd-${TTYD_VERSION}/build/ttyd bin/ttyd_linux.${ALIAS}
+ 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
}
build() {
echo "=== Building target ${ALIAS} (${TARGET})..."
+ rm -rf ${STAGE_DIR} ${BUILD_DIR}
mkdir -p ${STAGE_DIR} ${BUILD_DIR}
export PKG_CONFIG_PATH="${STAGE_DIR}/lib/pkgconfig"
build_ttyd
}
-TARGETS=(
- i386 i386-linux-musl
- x86_64 x86_64-linux-musl
- arm arm-linux-musleabi
- armhf arm-linux-musleabihf
- aarch64 aarch64-linux-musl
- mips mips-linux-musl
- mipsel mipsel-linux-musl
-)
-
-rm -rf bin && mkdir bin
-rm -rf ${STAGE_ROOT} ${BUILD_ROOT}
-
-for ((i=0; i<${#TARGETS[@]}; i+=2)); do
- build "${TARGETS[$i+1]}" "${TARGETS[$i]}"
-done
-
-echo "=== Archiving bin to a tarball..."
-pushd bin
- sha256sum ttyd_linux.* > SHA256SUMS
- tar czvf ../ttyd_${TTYD_VERSION}_linux.tar.gz ttyd_linux.* SHA256SUMS
-popd
+case $1 in
+ i386|x86_64|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|mips|mipsel" && exit 1
+esac
+