From d553554aa3ec6c2c68b8eb129368446c32ee9b7d Mon Sep 17 00:00:00 2001 From: zonyitoo Date: Thu, 2 Sep 2021 03:29:22 +0800 Subject: [PATCH] nightly and release build with local-tun --- .github/workflows/build-nightly-release.yml | 12 ++++++++- .github/workflows/build-release.yml | 12 ++++++++- build/build-release | 27 ++++++++++++------- .../src/local/tun/sys/unix/linux.rs | 1 - 4 files changed, 39 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-nightly-release.yml b/.github/workflows/build-nightly-release.yml index 702a8c3f..40c62788 100644 --- a/.github/workflows/build-nightly-release.yml +++ b/.github/workflows/build-nightly-release.yml @@ -26,8 +26,18 @@ jobs: - name: Build ${{ matrix.target }} timeout-minutes: 120 run: | + compile_target=${{ matrix.target }} + + if [[ "$compile_target" == *"-linux-"* || "$compile_target" == *"-apple-"* ]]; then + compile_features="-f local-redir -f local-tun" + fi + + if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then + compile_compress="-u" + fi + cd build - ./build-release -t ${{ matrix.target }} + ./build-release -t ${{ matrix.target }} $compile_features $compile_compress - name: Upload Artifacts uses: actions/upload-artifact@v2 diff --git a/.github/workflows/build-release.yml b/.github/workflows/build-release.yml index e13a94d4..4873a175 100644 --- a/.github/workflows/build-release.yml +++ b/.github/workflows/build-release.yml @@ -38,8 +38,18 @@ jobs: - name: Build ${{ matrix.target }} timeout-minutes: 120 run: | + compile_target=${{ matrix.target }} + + if [[ "$compile_target" == *"-linux-"* || "$compile_target" == *"-apple-"* ]]; then + compile_features="-f local-redir -f local-tun" + fi + + if [[ "$compile_target" == "mips-"* || "$compile_target" == "mipsel-"* || "$compile_target" == "mips64-"* || "$compile_target" == "mips64el-"* ]]; then + compile_compress="-u" + fi + cd build - ./build-release -t ${{ matrix.target }} + ./build-release -t ${{ matrix.target }} $compile_features $compile_compress - name: Upload Github Assets uses: softprops/action-gh-release@v1 diff --git a/build/build-release b/build/build-release index 4fb16831..618658f2 100755 --- a/build/build-release +++ b/build/build-release @@ -10,8 +10,9 @@ fi targets=() features=() +use_upx=false -while getopts "t:f:" opt; do +while getopts "t:f:u" opt; do case $opt in t) targets+=($OPTARG) @@ -19,8 +20,11 @@ while getopts "t:f:" opt; do f) features+=($OPTARG) ;; + u) + use_upx=true + ;; ?) - echo "Usage: $(basename $0) [-t ] [-f features]" + echo "Usage: $(basename $0) [-t ] [-f features] [-u]" ;; esac done @@ -32,11 +36,18 @@ if [[ "${#targets[@]}" == "0" ]]; then exit 1 fi -[[ -z $upx ]] && upx="echo pending" -if [[ $upx == "echo pending" ]] && hash upx 2>/dev/null; then - upx="upx -9" +if [[ "${use_upx}" = true ]]; then + if [[ ! -z $upx ]] && hash upx 2>/dev/null; then + upx="upx -9" + fi + + if [[ "x$upx" == "x" ]]; then + echo "Couldn't find upx in PATH, consider specifying it with variable \$upx" + exit 1 + fi fi + function build() { cd "$CUR_DIR/.." @@ -45,10 +56,6 @@ function build() { RELEASE_DIR="target/${TARGET}/release" TARGET_FEATURES="${features[@]}" - if [[ "$TARGET" == *"-linux-"* || "$TARGET" == *"-darwin" ]]; then - TARGET_FEATURES+=" local-redir local-tun" - fi - if [[ "${TARGET_FEATURES}" != "" ]]; then echo "* Building ${TARGET} package ${VERSION} with features \"${TARGET_FEATURES}\" ..." @@ -75,7 +82,7 @@ function build() { cd ${RELEASE_DIR} - if [[ "$TARGET" == "mips"* ]]; then + if [[ "${use_upx}" = true ]]; then # Enable upx for MIPS. $upx sslocal ssserver ssurl ssmanager #>/dev/null fi diff --git a/crates/shadowsocks-service/src/local/tun/sys/unix/linux.rs b/crates/shadowsocks-service/src/local/tun/sys/unix/linux.rs index a1402264..15447d3a 100644 --- a/crates/shadowsocks-service/src/local/tun/sys/unix/linux.rs +++ b/crates/shadowsocks-service/src/local/tun/sys/unix/linux.rs @@ -1,6 +1,5 @@ use std::{io, marker::Unpin}; -use bytes::BytesMut; use tokio::io::{AsyncWrite, AsyncWriteExt}; use tun::platform::Device as TunDevice;