Fix: build only flag

This commit is contained in:
zijiren233 2024-01-10 16:03:41 +08:00
parent 18ff4282dc
commit 49ccec8ae8
2 changed files with 35 additions and 8 deletions

View File

@ -2,9 +2,9 @@ name: build
on: on:
push: push:
branches: ["main"] branches: ["master"]
pull_request: pull_request:
branches: ["main"] branches: ["master"]
concurrency: concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@ -23,4 +23,4 @@ jobs:
- name: Build - name: Build
run: | run: |
bash scripts/build.sh bash scripts/build.sh -h

View File

@ -18,6 +18,29 @@ function Init() {
fi fi
} }
function Help() {
echo "-h: help"
echo "-t: test build only"
}
function ParseArgs() {
while getopts "ht" arg; do
case $arg in
h)
Help
exit 0
;;
t)
TEST_BUILD_ONLY="1"
;;
?)
echo "unkonw argument"
exit 1
;;
esac
done
}
function Build() { function Build() {
TARGET="$1" TARGET="$1"
make TARGET=${TARGET} GCC_VER="11.4.0" \ make TARGET=${TARGET} GCC_VER="11.4.0" \
@ -35,13 +58,16 @@ function Build() {
echo "build ${TARGET} error" echo "build ${TARGET} error"
exit 1 exit 1
fi fi
if [ ! "$TEST_BUILD_ONLY" ]; then
rm -rf output/${TARGET} rm -rf output/${TARGET}
tar -zcvf ${DIST}/${TARGET}.tgz output/* tar -zcvf ${DIST}/${TARGET}.tgz output/*
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "package ${TARGET} error" echo "package ${TARGET} error"
exit 1 exit 1
fi fi
fi
rm -rf output/* rm -rf output/*
rm -rf build/*
} }
ALL_TARGETS='aarch64-linux-musl ALL_TARGETS='aarch64-linux-musl
@ -98,4 +124,5 @@ function BuildAll() {
ChToScriptFileDir ChToScriptFileDir
Init Init
ParseArgs "$@"
BuildAll BuildAll