mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-21 07:46:09 +01:00
👷 Add --target parameter for selective architecture builds (#16823)
* 🔨 Add --arch parameter for selective architecture builds * 🔨 Add --variant parameter for selective architecture builds * 🔨 Add --variant parameter for selective architecture builds * 🔨 Add --variant parameter for selective architecture builds * 🔨 Add --variant parameter for selective architecture builds * 🔨 Add --variant parameter for selective architecture builds * 🔨 Add --variant parameter for selective architecture builds * 🔨 Add --target parameter for selective architecture builds * 🔨 Add --target parameter for selective architecture builds
This commit is contained in:
parent
28ee9bb08d
commit
174d3aff6a
3 changed files with 261 additions and 74 deletions
|
|
@ -1,9 +1,49 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo 'TIP: This script must be run from the project root directory'
|
||||
echo 'Usage: ./scripts/linux-build.sh [--target=<target>]'
|
||||
echo 'Options:'
|
||||
echo ' --target=<target> Build target: amd64, arm64, or all (default: all)'
|
||||
echo
|
||||
|
||||
TARGET='all'
|
||||
|
||||
validate_target() {
|
||||
if [[ -z "$1" ]]; then
|
||||
echo 'Error: --target option requires a value'
|
||||
echo 'Usage: --target=<target>'
|
||||
echo 'Examples: --target=amd64'
|
||||
exit 1
|
||||
elif [[ "$1" != 'amd64' && "$1" != 'arm64' && "$1" != 'all' ]]; then
|
||||
echo "Error: Invalid target '$1'"
|
||||
echo 'Valid targets are: amd64, arm64, all'
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case $1 in
|
||||
--target=*)
|
||||
TARGET="${1#*=}"
|
||||
validate_target "$TARGET"
|
||||
shift
|
||||
;;
|
||||
--target)
|
||||
TARGET="$2"
|
||||
validate_target "$TARGET"
|
||||
[ -n "$2" ] && shift 2 || shift
|
||||
;;
|
||||
*)
|
||||
# Skip unknown options
|
||||
shift
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
echo 'Building UI'
|
||||
cd app
|
||||
cd app || exit
|
||||
pnpm install && pnpm run build
|
||||
cd ..
|
||||
cd .. || exit
|
||||
|
||||
echo 'Cleaning Builds'
|
||||
rm -rf app/build
|
||||
|
|
@ -12,27 +52,38 @@ rm -rf app/kernel-linux-arm64
|
|||
|
||||
echo 'Building Kernel'
|
||||
|
||||
cd kernel
|
||||
cd kernel || exit
|
||||
go version
|
||||
export GO111MODULE=on
|
||||
export GOPROXY=https://mirrors.aliyun.com/goproxy/
|
||||
export CGO_ENABLED=1
|
||||
|
||||
echo 'Building Kernel amd64'
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export CC=~/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc
|
||||
go build -buildmode=pie --tags fts5 -v -o "../app/kernel-linux/SiYuan-Kernel" -ldflags "-s -w -extldflags -static-pie" .
|
||||
if [[ "$TARGET" == 'amd64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Kernel amd64'
|
||||
export GOOS=linux
|
||||
export GOARCH=amd64
|
||||
export CC=~/x86_64-linux-musl-cross/bin/x86_64-linux-musl-gcc
|
||||
go build -buildmode=pie --tags fts5 -v -o "../app/kernel-linux/SiYuan-Kernel" -ldflags "-s -w -extldflags -static-pie" .
|
||||
fi
|
||||
|
||||
echo 'Building Kernel arm64'
|
||||
export GOARCH=arm64
|
||||
export CC=~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
|
||||
go build -buildmode=pie --tags fts5 -v -o "../app/kernel-linux-arm64/SiYuan-Kernel" -ldflags "-s -w -extldflags -static-pie" .
|
||||
cd ..
|
||||
if [[ "$TARGET" == 'arm64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Kernel arm64'
|
||||
export GOARCH=arm64
|
||||
export CC=~/aarch64-linux-musl-cross/bin/aarch64-linux-musl-gcc
|
||||
go build -buildmode=pie --tags fts5 -v -o "../app/kernel-linux-arm64/SiYuan-Kernel" -ldflags "-s -w -extldflags -static-pie" .
|
||||
fi
|
||||
cd .. || exit
|
||||
|
||||
echo 'Building Electron App amd64'
|
||||
cd app
|
||||
pnpm run dist-linux
|
||||
echo 'Building Electron App arm64'
|
||||
pnpm run dist-linux-arm64
|
||||
cd ..
|
||||
cd app || exit
|
||||
|
||||
if [[ "$TARGET" == 'amd64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Electron App amd64'
|
||||
pnpm run dist-linux
|
||||
fi
|
||||
|
||||
if [[ "$TARGET" == 'arm64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Electron App arm64'
|
||||
pnpm run dist-linux-arm64
|
||||
fi
|
||||
|
||||
cd .. || exit
|
||||
Loading…
Add table
Add a link
Reference in a new issue