build: 默认编 Flutter 前端,补 Linux 目标并按主机选择产物
此前 build.sh 在非 Windows 宿主上把前端当「可选项」:flutter 缺失只告警、 交叉编译失败只告警、macOS 前端在 Linux 上直接跳过。结果是包照出,用户拿到 的是 Avalonia 回退界面,而构建日志里一行红字很容易被忽略。 改为默认必需: - build_flutter_ui / build_flutter_ui_cross 缺 flutter 或编译失败一律返回非 0, build.sh 立即中断并给出原因(交叉编译失败时带日志尾巴) - 确实要出降级包时显式声明 ./build.sh build --allow-no-ui 目标平台按构建主机决定,每条产物都带 Flutter: macOS 主机 → mac-arm64(Xcode 原生)+ win-amd64/win-arm64(mingw 交叉) Linux 主机 → linux-amd64(原生)+ win-amd64/win-arm64(mingw 交叉) Windows 主机 → win-amd64/win-arm64(原生) Linux 目标此前根本不存在,这次一并补上: - GC-UI/frontend/linux/ 由 flutter create 生成,BINARY_NAME=GC-UI、 APPLICATION_ID=com.xhmcl.GC、窗口标题 "Morris GC" - build_flutter_ui 增加 linux 分支,bundle(GC-UI + lib/ + data/)铺进 dist/linux-amd64/,pack_launcher 增加 Linux 整目录打包 - linux/CMakeLists.txt 强制 CMAKE_INSTALL_PREFIX 指向 build/.../bundle: 某些环境下它会被初始化成 /usr/local,导致 flutter 报「构建成功」但 bundle 是空的、产物装进了系统目录(本机实测踩到) 顺带修正两处: - 生成 settings.json 的默认 updateRepository 还是 gitcode 地址,与只保留 xhmcl 源的现状不符 - 进度条权重改为按实际目标动态计算,新平台不会再把总进度算过 100% 验证(Linux 主机,flutter 3.24.5): - ./build.sh build 出 win-amd64 109 MB、win-arm64 105 MB、linux-amd64 65 MB, 三份均含 Flutter 前端,清单签名 Verified - Linux 包在 Xvfb + llvmpipe 下实跑:后端 /api/health 返回 ok,GC-UI 窗口 正常渲染出模型库首页 - macOS 目标在 Linux 上不再产出 Avalonia 空壳包(要它得回 macOS 编)
This commit is contained in:
1 parent
e327a56421
commit
d7f6d8de9f
11 files changed
+526
-33
No files matched your search
+68
-19
@@ -1,13 +1,41 @@
|
||||
#!/bin/sh
|
||||
# buildsh/build.sh —— 完整发布(原 publish)
|
||||
# 步骤及权重按实测耗时设定,供进度条估算总进度与剩余时间:
|
||||
# 清理(2) 版本(3) Mac(35) WinX64(25) WinArm(25) 骨架(3) 打包(5) 收尾(2) = 100
|
||||
#
|
||||
# 目标平台按构建主机决定,每条产物都带 Flutter 前端:
|
||||
# macOS 主机 : mac-arm64(原生)+ win-amd64 / win-arm64(mingw 交叉)
|
||||
# Linux 主机 : linux-amd64(原生)+ win-amd64 / win-arm64(mingw 交叉)
|
||||
# Windows 主机: win-amd64 / win-arm64(原生)
|
||||
#
|
||||
# 前端是默认必需项:flutter 缺失或编译失败一律中断,不再悄悄产出只带 Avalonia
|
||||
# 回退界面的包。确实要降级时用 ./build.sh build --allow-no-ui。
|
||||
#
|
||||
# 进度权重按实测耗时设定,供进度条估算总进度与剩余时间。
|
||||
|
||||
bs_build() {
|
||||
ROOT_DIR="$1"
|
||||
: "${APP_PROJ:?}" "${SLN:?}" "${VERSION:?}"
|
||||
|
||||
progress_init 100 2 3 35 25 25 3 5 2
|
||||
HOST=$(uname -s)
|
||||
BUILD_MAC=0
|
||||
BUILD_LINUX=0
|
||||
case "$HOST" in
|
||||
Darwin) BUILD_MAC=1 ;;
|
||||
MINGW*|MSYS*|CYGWIN*) : ;; # Windows 主机只能编 Windows
|
||||
*) BUILD_LINUX=1 ;;
|
||||
esac
|
||||
# 显式降级:允许在没有该平台 Flutter 宿主的情况下仍出 Avalonia 版包
|
||||
ALLOW_NO_UI="${GC_ALLOW_NO_UI:-0}"
|
||||
|
||||
# 权重:清理 版本 Mac WinX64 WinArm64 Linux 前端 骨架 打包 收尾
|
||||
WEIGHTS="2 3"
|
||||
[ "$BUILD_MAC" = 1 ] && WEIGHTS="$WEIGHTS 35"
|
||||
WEIGHTS="$WEIGHTS 25 25"
|
||||
[ "$BUILD_LINUX" = 1 ] && WEIGHTS="$WEIGHTS 30"
|
||||
WEIGHTS="$WEIGHTS 25 3 5 2"
|
||||
TOTAL=0
|
||||
for _w in $WEIGHTS; do TOTAL=$((TOTAL + _w)); done
|
||||
|
||||
progress_init "$TOTAL" $WEIGHTS
|
||||
|
||||
progress_step "清理旧产物"; progress_tick 100
|
||||
rm -rf "$ROOT_DIR/dist"; mkdir -p "$ROOT_DIR/dist"
|
||||
@@ -37,12 +65,20 @@ bs_build() {
|
||||
progress_tick 100
|
||||
}
|
||||
|
||||
progress_step "编译 Mac"
|
||||
_run_publish mac 90 publish_rid "osx-arm64" "dist/mac-arm64" false || return 1
|
||||
publish_backend "osx-arm64" "dist/mac-arm64" || return 1
|
||||
# Flutter 的 macOS 产物只能在 macOS 上编;交叉构建时跳过,包内回退内置界面
|
||||
if [ "$(uname -s)" = "Darwin" ]; then
|
||||
build_flutter_ui macos "dist/mac-arm64" || return 1
|
||||
if [ "$BUILD_MAC" = 1 ]; then
|
||||
progress_step "编译 Mac"
|
||||
_run_publish mac 90 publish_rid "osx-arm64" "dist/mac-arm64" false || return 1
|
||||
publish_backend "osx-arm64" "dist/mac-arm64" || return 1
|
||||
# Flutter 的 macOS 产物必须用 Xcode 在本机编,Linux 上无法替代
|
||||
build_flutter_ui macos "dist/mac-arm64" || {
|
||||
echo "!! macOS 前端编译失败。macOS 版 Flutter 只能在 macOS 上编。"
|
||||
return 1
|
||||
}
|
||||
elif [ "$ALLOW_NO_UI" = 1 ]; then
|
||||
progress_step "编译 Mac"
|
||||
_run_publish mac 90 publish_rid "osx-arm64" "dist/mac-arm64" false || return 1
|
||||
publish_backend "osx-arm64" "dist/mac-arm64" || return 1
|
||||
echo "!! --allow-no-ui:macOS 包内不含 Flutter 前端,启动器将回退 Avalonia"
|
||||
fi
|
||||
|
||||
progress_step "编译 Win-x64"
|
||||
@@ -53,25 +89,38 @@ bs_build() {
|
||||
_run_publish winarm 70 publish_rid "win-arm64" "dist/win-arm64" true || return 1
|
||||
publish_backend "win-arm64" "dist/win-arm64" || return 1
|
||||
|
||||
if [ "$BUILD_LINUX" = 1 ]; then
|
||||
progress_step "编译 Linux"
|
||||
_run_publish linux 70 publish_rid "linux-x64" "dist/linux-amd64" false || return 1
|
||||
publish_backend "linux-x64" "dist/linux-amd64" || return 1
|
||||
build_flutter_ui linux "dist/linux-amd64" || return 1
|
||||
fi
|
||||
|
||||
# Windows 前端:Windows 主机走官方 toolchain;Linux/macOS 主机用 mingw-w64 +
|
||||
# wine 交叉编译(buildsh/cross)。只产出 x64 一份,两个包共用,
|
||||
# ARM64 上由系统模拟 x64 进程运行前端。
|
||||
case "$(uname -s)" in
|
||||
progress_step "编译 Win 前端"
|
||||
case "$HOST" in
|
||||
MINGW*|MSYS*|CYGWIN*) build_flutter_ui windows "dist/win-flutter" || return 1 ;;
|
||||
*) build_flutter_ui_cross "dist/win-flutter" ;;
|
||||
*) build_flutter_ui_cross "dist/win-flutter" || return 1 ;;
|
||||
esac
|
||||
if [ -d "$ROOT_DIR/dist/win-flutter" ]; then
|
||||
for label in win-amd64 win-arm64; do
|
||||
cp -R "$ROOT_DIR/dist/win-flutter/." "$ROOT_DIR/dist/$label/"
|
||||
done
|
||||
rm -rf "$ROOT_DIR/dist/win-flutter"
|
||||
fi
|
||||
for label in win-amd64 win-arm64; do
|
||||
cp -R "$ROOT_DIR/dist/win-flutter/." "$ROOT_DIR/dist/$label/"
|
||||
done
|
||||
rm -rf "$ROOT_DIR/dist/win-flutter"
|
||||
|
||||
progress_step "运行骨架"; progress_tick 100
|
||||
package_mac_app
|
||||
if [ -d "$ROOT_DIR/dist/mac-arm64" ]; then
|
||||
package_mac_app
|
||||
fi
|
||||
prepare_runtime_layout "dist/win-amd64"
|
||||
prepare_runtime_layout "dist/win-arm64"
|
||||
prepare_runtime_layout "dist/mac-arm64/GC.app/Contents/MacOS"
|
||||
if [ "$BUILD_LINUX" = 1 ]; then
|
||||
prepare_runtime_layout "dist/linux-amd64"
|
||||
fi
|
||||
if [ -d "$ROOT_DIR/dist/mac-arm64/GC.app/Contents/MacOS" ]; then
|
||||
prepare_runtime_layout "dist/mac-arm64/GC.app/Contents/MacOS"
|
||||
fi
|
||||
|
||||
progress_step "打包 zip"; progress_tick 100
|
||||
pack_launcher
|
||||
|
||||
Reference in new issue
Block a user