Skip to content

Commit

Permalink
启用 UPX 压缩
Browse files Browse the repository at this point in the history
  • Loading branch information
lanthora committed Jun 11, 2024
1 parent 84ff9c6 commit e77eae1
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/standalone.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install UPX
uses: crazy-max/ghaction-upx@v3
with:
install-only: true
- name: Cross compile
run: |
./scripts/build-standalone.sh
Expand All @@ -24,6 +28,7 @@ jobs:
CANDY_OS: ${{ matrix.os }}
CANDY_ARCH: ${{ matrix.arch }}
CANDY_STRIP: "1"
CANDY_UPX: "1"
- name: upload
uses: actions/upload-artifact@v4
with:
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@ cmake --install build

```bash
export CANDY_WORKSPACE=/tmp/candy
export CANDY_STRIP=1
export CANDY_ARCH=x86_64
export CANDY_OS=linux
```
Expand Down
16 changes: 10 additions & 6 deletions scripts/build-standalone.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ if [[ -z $TARGET || -z $TARGET_OPENSSL ]];then
echo "CANDY_ARCH: $CANDY_ARCH"
echo "CANDY_OS: $CANDY_OS"
if [[ "$CANDY_OS" == "linux" ]]; then
if [[ "$CANDY_ARCH" == "aarch64" ]]; then TARGET="aarch64-linux-musl";TARGET_OPENSSL="linux-aarch64"
elif [[ "$CANDY_ARCH" == "arm" ]]; then TARGET="arm-linux-musleabi";TARGET_OPENSSL="linux-armv4"
elif [[ "$CANDY_ARCH" == "mips" ]]; then TARGET="mips-linux-musl";TARGET_OPENSSL="linux-mips32"
elif [[ "$CANDY_ARCH" == "mipsel" ]]; then TARGET="mipsel-linux-musl";TARGET_OPENSSL="linux-mips32"
elif [[ "$CANDY_ARCH" == "x86_64" ]]; then TARGET="x86_64-linux-musl";TARGET_OPENSSL="linux-x86_64"
if [[ "$CANDY_ARCH" == "aarch64" ]]; then TARGET="aarch64-linux-musl";TARGET_OPENSSL="linux-aarch64";UPX=1
elif [[ "$CANDY_ARCH" == "arm" ]]; then TARGET="arm-linux-musleabi";TARGET_OPENSSL="linux-armv4";UPX=0
elif [[ "$CANDY_ARCH" == "mips" ]]; then TARGET="mips-linux-musl";TARGET_OPENSSL="linux-mips32";UPX=0
elif [[ "$CANDY_ARCH" == "mipsel" ]]; then TARGET="mipsel-linux-musl";TARGET_OPENSSL="linux-mips32";UPX=0
elif [[ "$CANDY_ARCH" == "x86_64" ]]; then TARGET="x86_64-linux-musl";TARGET_OPENSSL="linux-x86_64";UPX=1
else echo "Unknown CANDY_ARCH: $CANDY_ARCH";exit 1;fi
elif [[ "$CANDY_OS" == "macos" ]]; then
echo "macos is not supported yet";exit 1
Expand Down Expand Up @@ -58,6 +58,10 @@ SOURCE_DIR="$(dirname $(readlink -f "$0"))/../"
cmake -G "$GENERATOR" -B "$BUILD_DIR" -DCMAKE_BUILD_TYPE=Release -DCANDY_STATIC=1 -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=$OUTPUT_DIR -DTARGET_OPENSSL=$TARGET_OPENSSL $SOURCE_DIR
cmake --build $BUILD_DIR --parallel $(nproc)

if [ $CANDY_STRIP ];then
if [[ $CANDY_STRIP && $CANDY_STRIP -eq 1 ]];then
$STRIP $OUTPUT_DIR/candy
fi

if [[ $CANDY_UPX && $CANDY_UPX -eq 1 && $UPX -eq 1 ]];then
upx $OUTPUT_DIR/candy
fi

0 comments on commit e77eae1

Please sign in to comment.