mirror of
https://github.com/siyuan-note/siyuan.git
synced 2026-01-17 06:05:29 +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/darwin-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,26 +52,37 @@ rm -rf app/kernel-darwin-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=darwin
|
||||
export GOARCH=amd64
|
||||
go build --tags fts5 -v -o "../app/kernel-darwin/SiYuan-Kernel" -ldflags "-s -w" .
|
||||
if [[ "$TARGET" == 'amd64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Kernel amd64'
|
||||
export GOOS=darwin
|
||||
export GOARCH=amd64
|
||||
go build --tags fts5 -v -o "../app/kernel-darwin/SiYuan-Kernel" -ldflags "-s -w" .
|
||||
fi
|
||||
|
||||
echo 'Building Kernel arm64'
|
||||
export GOOS=darwin
|
||||
export GOARCH=arm64
|
||||
go build --tags fts5 -v -o "../app/kernel-darwin-arm64/SiYuan-Kernel" -ldflags "-s -w" .
|
||||
cd ..
|
||||
if [[ "$TARGET" == 'arm64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Kernel arm64'
|
||||
export GOOS=darwin
|
||||
export GOARCH=arm64
|
||||
go build --tags fts5 -v -o "../app/kernel-darwin-arm64/SiYuan-Kernel" -ldflags "-s -w" .
|
||||
fi
|
||||
cd .. || exit
|
||||
|
||||
echo 'Building Electron App amd64'
|
||||
cd app
|
||||
pnpm run dist-darwin
|
||||
echo 'Building Electron App arm64'
|
||||
pnpm run dist-darwin-arm64
|
||||
cd ..
|
||||
cd app || exit
|
||||
|
||||
if [[ "$TARGET" == 'amd64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Electron App amd64'
|
||||
pnpm run dist-darwin
|
||||
fi
|
||||
|
||||
if [[ "$TARGET" == 'arm64' || "$TARGET" == 'all' ]]; then
|
||||
echo 'Building Electron App arm64'
|
||||
pnpm run dist-darwin-arm64
|
||||
fi
|
||||
|
||||
cd .. || exit
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
@ -1,8 +1,60 @@
|
|||
@echo off
|
||||
echo 'use ".\scripts\win-build.bat" instead of "win-build.bat"'
|
||||
|
||||
echo 'Building UI'
|
||||
echo TIP: This script must be run from the project root directory
|
||||
echo Usage: .\scripts\win-build.bat [--target=^<target^>]
|
||||
echo Options:
|
||||
echo --target=^<target^> Build target: amd64, arm64, appx-amd64, appx-arm64, or all (default: all)
|
||||
echo.
|
||||
|
||||
set "TARGET=all"
|
||||
|
||||
:parse_args
|
||||
if "%1"=="" goto :end_parse_args
|
||||
if "%1"=="--target" (
|
||||
if "%2"=="" (
|
||||
echo Error: --target option requires an equal sign and value
|
||||
echo Usage: --target=^<target^>
|
||||
echo Example: --target=amd64
|
||||
exit /b 1
|
||||
) else (
|
||||
if not "%2"=="amd64" if not "%2"=="arm64" if not "%2"=="appx-amd64" if not "%2"=="appx-arm64" if not "%2"=="all" (
|
||||
echo Error: Invalid target '%2'
|
||||
echo Valid targets are: amd64, arm64, appx-amd64, appx-arm64, all
|
||||
exit /b 1
|
||||
)
|
||||
set "TARGET=%2"
|
||||
shift
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
) else (
|
||||
@REM Skip unknown options
|
||||
shift
|
||||
goto :parse_args
|
||||
)
|
||||
:end_parse_args
|
||||
|
||||
if "%TARGET%"=="amd64" (
|
||||
set BUILD_AMD64=1
|
||||
) else if "%TARGET%"=="arm64" (
|
||||
set BUILD_ARM64=1
|
||||
) else if "%TARGET%"=="appx-amd64" (
|
||||
set BUILD_APPX_AMD64=1
|
||||
) else if "%TARGET%"=="appx-arm64" (
|
||||
set BUILD_APPX_ARM64=1
|
||||
) else (
|
||||
REM all: build everything
|
||||
set BUILD_AMD64=1
|
||||
set BUILD_ARM64=1
|
||||
set BUILD_APPX_AMD64=1
|
||||
set BUILD_APPX_ARM64=1
|
||||
)
|
||||
|
||||
echo Building UI
|
||||
cd app
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
call pnpm install
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
|
|
@ -12,69 +64,102 @@ if errorlevel 1 (
|
|||
exit /b %errorlevel%
|
||||
)
|
||||
cd ..
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo 'Cleaning Builds'
|
||||
echo Cleaning Builds
|
||||
rmdir /S /Q app\build 1>nul
|
||||
rmdir /S /Q app\kernel 1>nul
|
||||
rmdir /S /Q app\kernel-arm64 1>nul
|
||||
|
||||
echo 'Building Kernel'
|
||||
echo Building Kernel
|
||||
@REM the C compiler "gcc" is necessary https://sourceforge.net/projects/mingw-w64/files/mingw-w64/
|
||||
go version
|
||||
set GO111MODULE=on
|
||||
set GOPROXY=https://mirrors.aliyun.com/goproxy/
|
||||
set CGO_ENABLED=1
|
||||
set GOOS=windows
|
||||
|
||||
cd kernel
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
@REM you can use `go mod tidy` to update kernel dependency before build
|
||||
@REM you can use `go generate` instead (need add something in main.go)
|
||||
goversioninfo -platform-specific=true -icon=resource/icon.ico -manifest=resource/goversioninfo.exe.manifest
|
||||
|
||||
echo 'Building Kernel amd64'
|
||||
set GOOS=windows
|
||||
set GOARCH=amd64
|
||||
go build --tags fts5 -v -o "../app/kernel/SiYuan-Kernel.exe" -ldflags "-s -w -H=windowsgui" .
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
if defined BUILD_AMD64 (
|
||||
echo Building Kernel amd64
|
||||
set GOARCH=amd64
|
||||
go build --tags fts5 -v -o "../app/kernel/SiYuan-Kernel.exe" -ldflags "-s -w -H=windowsgui" .
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
)
|
||||
|
||||
echo 'Building Kernel arm64'
|
||||
set GOARCH=arm64
|
||||
@REM if you want to build arm64, you need to install aarch64-w64-mingw32-gcc
|
||||
set CC="D:/Program Files/llvm-mingw-20240518-ucrt-x86_64/bin/aarch64-w64-mingw32-gcc.exe"
|
||||
go build --tags fts5 -v -o "../app/kernel-arm64/SiYuan-Kernel.exe" -ldflags "-s -w -H=windowsgui" .
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
if defined BUILD_ARM64 (
|
||||
echo Building Kernel arm64
|
||||
set GOARCH=arm64
|
||||
@REM if you want to build arm64, you need to install aarch64-w64-mingw32-gcc
|
||||
set CC="D:/Program Files/llvm-mingw-20240518-ucrt-x86_64/bin/aarch64-w64-mingw32-gcc.exe"
|
||||
go build --tags fts5 -v -o "../app/kernel-arm64/SiYuan-Kernel.exe" -ldflags "-s -w -H=windowsgui" .
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
)
|
||||
cd ..
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo 'Building Electron App amd64'
|
||||
cd app
|
||||
|
||||
copy "elevator\elevator-amd64.exe" "kernel\elevator.exe"
|
||||
copy "elevator\elevator-arm64.exe" "kernel-arm64\elevator.exe"
|
||||
|
||||
call pnpm run dist
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
echo 'Building Electron App arm64'
|
||||
call pnpm run dist-arm64
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
|
||||
if defined BUILD_AMD64 (
|
||||
echo Building Electron App amd64
|
||||
copy "elevator\elevator-amd64.exe" "kernel\elevator.exe"
|
||||
call pnpm run dist
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
)
|
||||
|
||||
if defined BUILD_ARM64 (
|
||||
echo Building Electron App arm64
|
||||
copy "elevator\elevator-arm64.exe" "kernel-arm64\elevator.exe"
|
||||
call pnpm run dist-arm64
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
)
|
||||
cd ..
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
|
||||
echo 'Building Appx'
|
||||
echo 'Building Appx should be disabled if you do not need it. Not configured correctly will lead to build failures'
|
||||
cd . > app\build\win-unpacked\resources\ms-store
|
||||
call electron-windows-store --input-directory app\build\win-unpacked --output-directory app\build\ --package-version 1.0.0.0 --package-name SiYuan --manifest app\appx\AppxManifest.xml --assets app\appx\assets\ --make-pri true
|
||||
if defined BUILD_APPX_AMD64 (
|
||||
echo Building Appx amd64
|
||||
echo Building Appx amd64 should be disabled if you do not need it. Not configured correctly will lead to build failures
|
||||
cd . > app\build\win-unpacked\resources\ms-store
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
call electron-windows-store --input-directory app\build\win-unpacked --output-directory app\build\ --package-version 1.0.0.0 --package-name SiYuan --manifest app\appx\AppxManifest.xml --assets app\appx\assets\ --make-pri true
|
||||
|
||||
rmdir /S /Q app\build\pre-appx 1>nul
|
||||
rmdir /S /Q app\build\pre-appx 1>nul
|
||||
)
|
||||
|
||||
echo 'Building Appx arm64'
|
||||
echo 'Building Appx arm64 should be disabled if you do not need it. Not configured correctly will lead to build failures'
|
||||
cd . > app\build\win-arm64-unpacked\resources\ms-store
|
||||
call electron-windows-store --input-directory app\build\win-arm64-unpacked --output-directory app\build\ --package-version 1.0.0.0 --package-name SiYuan-arm64 --manifest app\appx\AppxManifest-arm64.xml --assets app\appx\assets\ --make-pri true
|
||||
if defined BUILD_APPX_ARM64 (
|
||||
echo Building Appx arm64
|
||||
echo Building Appx arm64 should be disabled if you do not need it. Not configured correctly will lead to build failures
|
||||
cd . > app\build\win-arm64-unpacked\resources\ms-store
|
||||
if errorlevel 1 (
|
||||
exit /b %errorlevel%
|
||||
)
|
||||
call electron-windows-store --input-directory app\build\win-arm64-unpacked --output-directory app\build\ --package-version 1.0.0.0 --package-name SiYuan-arm64 --manifest app\appx\AppxManifest-arm64.xml --assets app\appx\assets\ --make-pri true
|
||||
|
||||
rmdir /S /Q app\build\pre-appx 1>nul
|
||||
rmdir /S /Q app\build\pre-appx 1>nul
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue