Compare commits
8
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
98bfe76808 | ||
|
|
40e72957e3 | ||
|
|
fdbf3160e8 | ||
|
|
2cc862a8da | ||
|
|
2c0c566c81 | ||
|
|
926a568dc0 | ||
|
|
cd44c7ecff | ||
|
|
aeab68d421 |
No files matched your search
@@ -0,0 +1,179 @@
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Net.Http;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace GC;
|
||||
|
||||
/// <summary>
|
||||
/// 新界面启动壳。
|
||||
///
|
||||
/// 发布包同时带 <c>GC.UI.Server</c>(本地 HTTP 后端 + 模型窗口宿主)和
|
||||
/// <c>GC-UI</c>(Flutter 前端)时,启动器只做三件事:
|
||||
/// 1. 拉起后端并等 <c>/api/health</c> 就绪;
|
||||
/// 2. 拉起 Flutter 窗口;
|
||||
/// 3. 界面退出后关掉后端。
|
||||
///
|
||||
/// 两个产物缺任意一个就返回 <c>false</c>,由调用方回退到内置 Avalonia 界面——
|
||||
/// 这样 `dotnet run`、只编了启动器的开发场景、以及交叉编译缺前端产物的包都能正常打开。
|
||||
/// </summary>
|
||||
internal static class FlutterShell
|
||||
{
|
||||
/// <summary>与 GC-UI/frontend 的默认 baseUrl 保持一致,前端不需要额外配置。</summary>
|
||||
private const int Port = 17890;
|
||||
|
||||
private static readonly HttpClient Http = new() { Timeout = TimeSpan.FromSeconds(1.5) };
|
||||
private static Process? _backend;
|
||||
|
||||
public static bool TryRun(string[] args)
|
||||
{
|
||||
var dir = AppContext.BaseDirectory;
|
||||
var backendPath = FindBackend(dir);
|
||||
var uiPath = FindUi(dir);
|
||||
if (backendPath == null || uiPath == null) return false;
|
||||
|
||||
// 用户可能重复启动:已有后端在跑就直接复用,退出时也不要关掉别人的进程。
|
||||
var reused = IsHealthy();
|
||||
if (!reused)
|
||||
{
|
||||
_backend = Start(backendPath, $"--port {Port}", dir);
|
||||
if (_backend == null) return false;
|
||||
|
||||
if (!WaitHealthy(TimeSpan.FromSeconds(25)))
|
||||
{
|
||||
Stop(_backend);
|
||||
_backend = null;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
AppDomain.CurrentDomain.ProcessExit += (_, _) => Stop(_backend);
|
||||
|
||||
var ui = Start(uiPath, null, dir);
|
||||
if (ui == null)
|
||||
{
|
||||
Stop(_backend);
|
||||
_backend = null;
|
||||
return false;
|
||||
}
|
||||
|
||||
ui.WaitForExit();
|
||||
Stop(_backend);
|
||||
_backend = null;
|
||||
return true;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 产物定位
|
||||
|
||||
private static string? FindBackend(string dir)
|
||||
{
|
||||
foreach (var name in OperatingSystem.IsWindows()
|
||||
? new[] { "GC.UI.Server.exe", "GC.UI.Server" }
|
||||
: new[] { "GC.UI.Server", "GC.UI.Server.exe" })
|
||||
{
|
||||
var path = Path.Combine(dir, name);
|
||||
if (File.Exists(path)) return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Flutter 桌面产物。
|
||||
/// macOS 是 <c>GC-UI.app/Contents/MacOS/GC-UI</c>;Windows 是 <c>GC-UI.exe</c>;
|
||||
/// Linux 是 <c>GC-UI</c>。
|
||||
/// </summary>
|
||||
private static string? FindUi(string dir)
|
||||
{
|
||||
if (OperatingSystem.IsMacOS())
|
||||
{
|
||||
var exe = Path.Combine(dir, "GC-UI.app", "Contents", "MacOS", "GC-UI");
|
||||
if (File.Exists(exe)) return exe;
|
||||
}
|
||||
|
||||
foreach (var name in OperatingSystem.IsWindows() ? new[] { "GC-UI.exe" } : new[] { "GC-UI" })
|
||||
{
|
||||
var path = Path.Combine(dir, name);
|
||||
if (File.Exists(path)) return path;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 进程管理
|
||||
|
||||
private static Process? Start(string fileName, string? arguments, string workingDirectory)
|
||||
{
|
||||
try
|
||||
{
|
||||
var info = new ProcessStartInfo(fileName)
|
||||
{
|
||||
WorkingDirectory = workingDirectory,
|
||||
UseShellExecute = false,
|
||||
CreateNoWindow = true,
|
||||
};
|
||||
if (!string.IsNullOrEmpty(arguments)) info.Arguments = arguments;
|
||||
|
||||
// macOS .app 内的二进制也需要可执行位;发布包由 zip 解开时可能丢失。
|
||||
if (!OperatingSystem.IsWindows())
|
||||
{
|
||||
try { File.SetUnixFileMode(fileName, UnixFileMode.UserRead | UnixFileMode.UserWrite | UnixFileMode.UserExecute); }
|
||||
catch { /* 权限不足时交给系统判断 */ }
|
||||
}
|
||||
|
||||
return Process.Start(info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"[shell] 启动失败 {fileName}: {ex.Message}");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private static void Stop(Process? process)
|
||||
{
|
||||
if (process == null) return;
|
||||
try
|
||||
{
|
||||
if (!process.HasExited) process.Kill(entireProcessTree: true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.Error.WriteLine($"[shell] 关闭后端失败: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
process.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
// ---------------------------------------------------------------- 健康检查
|
||||
|
||||
private static bool IsHealthy()
|
||||
{
|
||||
try
|
||||
{
|
||||
using var response = Http.GetAsync($"http://127.0.0.1:{Port}/api/health")
|
||||
.GetAwaiter().GetResult();
|
||||
return response.IsSuccessStatusCode;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private static bool WaitHealthy(TimeSpan timeout)
|
||||
{
|
||||
var deadline = DateTime.UtcNow + timeout;
|
||||
while (DateTime.UtcNow < deadline)
|
||||
{
|
||||
// 后端进程已经退出就没必要再等:端口被占、依赖缺失都会走这里。
|
||||
if (_backend is { HasExited: true }) return false;
|
||||
|
||||
if (IsHealthy()) return true;
|
||||
Thread.Sleep(250);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,9 @@ internal static class Program
|
||||
// 上次下载的启动器新版,到这次启动才应用
|
||||
if (DownloadModuleHost.Factory.TryApplyPending(paths)) return;
|
||||
|
||||
// 发布包带 Flutter 前端时,界面交给它;没带则回退到内置 Avalonia 界面。
|
||||
if (FlutterShell.TryRun(args)) return;
|
||||
|
||||
BuildAvaloniaApp().StartWithClassicDesktopLifetime(args);
|
||||
}
|
||||
|
||||
|
||||
+48
-2
@@ -64,9 +64,55 @@ Windows 还需要 **VS Build Tools 的「使用 C++ 的桌面开发」工作负
|
||||
## 本地构建(不经 CI)
|
||||
|
||||
```bash
|
||||
# macOS
|
||||
# Linux / macOS:三平台一次出齐。Windows 前端用 mingw-w64 + wine 交叉编译,
|
||||
# 不需要 Windows 机器。
|
||||
./build.sh build
|
||||
|
||||
# 只编 macOS 前端
|
||||
./GC-UI/build-ui.sh macos
|
||||
|
||||
# Windows
|
||||
# Windows 主机原生构建
|
||||
GC-UI\build-ui.cmd
|
||||
```
|
||||
|
||||
### Windows 前端交叉编译
|
||||
|
||||
Flutter 官方不支持在非 Windows 主机上 `flutter build windows`,但 Windows 嵌入层
|
||||
(`windows/runner/*.cpp` + `cpp_client_wrapper`)是纯 Win32 + 标准 C++,只通过 C ABI
|
||||
调用 `flutter_windows.dll`,所以 mingw-w64 就能编译。整条链路上唯一必须执行的
|
||||
Windows 二进制是 AOT 快照生成器 `gen_snapshot.exe`,交给 wine 跑即可。
|
||||
|
||||
```bash
|
||||
# 依赖
|
||||
sudo apt install mingw-w64 cmake ninja-build wine # Linux
|
||||
brew install mingw-w64 cmake ninja # macOS
|
||||
brew install --cask wine-stable # macOS 的 wine
|
||||
|
||||
# 单独构建(默认输出到 GC-UI/frontend/build/windows/x64/runner/Release)
|
||||
./buildsh/cross/build-ui-win-cross.sh [输出目录]
|
||||
```
|
||||
|
||||
产物与官方 toolchain 完全一致,可直接拷到 Windows 运行:
|
||||
|
||||
```
|
||||
GC-UI.exe flutter_windows.dll data/{icudtl.dat, app.so, flutter_assets/}
|
||||
```
|
||||
|
||||
实现分三层:
|
||||
|
||||
| 文件 | 职责 |
|
||||
|---|---|
|
||||
| `buildsh/cross/toolchain-mingw.cmake` | CMake 交叉工具链(posix 线程模型,静态链接 libstdc++,产物只依赖系统 DLL) |
|
||||
| `buildsh/cross/CMakeLists.txt` | 只编 C++ 外壳;绕开 `tool_backend.bat` 与 MSVC 专用参数 |
|
||||
| `buildsh/cross/build-ui-win-cross.sh` | 拉引擎产物、装 `gen_snapshot` 的 wine 包装、生成 AOT 快照、组装 |
|
||||
|
||||
两个容易踩的坑,脚本里已处理:
|
||||
|
||||
- `flutter_tools` 会 exec 路径为 `.../windows-x64-release/gen_snapshot`(**没有 `.exe`**)
|
||||
的文件,所以脚本在原 `.exe` 旁边放一个同名 shell 脚本转调 wine。
|
||||
- `Runner.rc` 在 windres 下有两处不兼容:图标用反斜杠相对路径、`VERSION_AS_STRING`
|
||||
依赖命令行传 `-D` 的转义字符串。脚本生成一份路径与宏都已规整的 rc 副本再编译。
|
||||
|
||||
`.gitea/workflows` 里的 `windows` 任务仍然跑在 `windows-latest` 上;若手头只有 macOS/Linux
|
||||
构建机,可以把该任务的 `runs-on` 换成对应标签,直接复用这套交叉编译脚本,
|
||||
不再需要 VS Build Tools。
|
||||
@@ -140,7 +140,7 @@ class _Sidebar extends StatelessWidget {
|
||||
borderRadius: BorderRadius.circular(8),
|
||||
),
|
||||
alignment: Alignment.center,
|
||||
child: const Text(
|
||||
child: Text(
|
||||
'◎',
|
||||
style: TextStyle(fontSize: 14, color: GcColors.accent),
|
||||
),
|
||||
|
||||
@@ -5,10 +5,10 @@
|
||||
// 'flutter create' template.
|
||||
|
||||
// The application's name. By default this is also the title of the Flutter window.
|
||||
PRODUCT_NAME = gc_ui
|
||||
PRODUCT_NAME = GC-UI
|
||||
|
||||
// The application's bundle identifier
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.morris.gc.gcUi
|
||||
|
||||
// The copyright displayed in application information
|
||||
PRODUCT_COPYRIGHT = Copyright © 2026 com.morris.gc. All rights reserved.
|
||||
PRODUCT_COPYRIGHT = Copyright © 2026 Morris. All rights reserved.
|
||||
@@ -4,7 +4,7 @@ project(gc_ui LANGUAGES CXX)
|
||||
|
||||
# The name of the executable created for the application. Change this to change
|
||||
# the on-disk name of your application.
|
||||
set(BINARY_NAME "gc_ui")
|
||||
set(BINARY_NAME "GC-UI")
|
||||
|
||||
# Explicitly opt in to modern CMake behaviors to avoid warnings with recent
|
||||
# versions of CMake.
|
||||
|
||||
@@ -89,13 +89,13 @@ BEGIN
|
||||
BEGIN
|
||||
BLOCK "040904e4"
|
||||
BEGIN
|
||||
VALUE "CompanyName", "com.morris.gc" "\0"
|
||||
VALUE "FileDescription", "gc_ui" "\0"
|
||||
VALUE "CompanyName", "Morris" "\0"
|
||||
VALUE "FileDescription", "GC UI" "\0"
|
||||
VALUE "FileVersion", VERSION_AS_STRING "\0"
|
||||
VALUE "InternalName", "gc_ui" "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2026 com.morris.gc. All rights reserved." "\0"
|
||||
VALUE "OriginalFilename", "gc_ui.exe" "\0"
|
||||
VALUE "ProductName", "gc_ui" "\0"
|
||||
VALUE "InternalName", "GC-UI" "\0"
|
||||
VALUE "LegalCopyright", "Copyright (C) 2026 Morris. All rights reserved." "\0"
|
||||
VALUE "OriginalFilename", "GC-UI.exe" "\0"
|
||||
VALUE "ProductName", "Morris GC" "\0"
|
||||
VALUE "ProductVersion", VERSION_AS_STRING "\0"
|
||||
END
|
||||
END
|
||||
|
||||
@@ -27,7 +27,7 @@ int APIENTRY wWinMain(_In_ HINSTANCE instance, _In_opt_ HINSTANCE prev,
|
||||
FlutterWindow window(project);
|
||||
Win32Window::Point origin(10, 10);
|
||||
Win32Window::Size size(1280, 720);
|
||||
if (!window.Create(L"gc_ui", origin, size)) {
|
||||
if (!window.Create(L"Morris GC", origin, size)) {
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
window.SetQuitOnClose(true);
|
||||
|
||||
@@ -39,12 +39,33 @@ bs_build() {
|
||||
|
||||
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
|
||||
fi
|
||||
|
||||
progress_step "编译 Win-x64"
|
||||
_run_publish winx64 70 publish_rid "win-x64" "dist/win-amd64" true || return 1
|
||||
publish_backend "win-x64" "dist/win-amd64" || return 1
|
||||
|
||||
progress_step "编译 Win-arm64"
|
||||
_run_publish winarm 70 publish_rid "win-arm64" "dist/win-arm64" true || return 1
|
||||
publish_backend "win-arm64" "dist/win-arm64" || return 1
|
||||
|
||||
# Windows 前端:Windows 主机走官方 toolchain;Linux/macOS 主机用 mingw-w64 +
|
||||
# wine 交叉编译(buildsh/cross)。只产出 x64 一份,两个包共用,
|
||||
# ARM64 上由系统模拟 x64 进程运行前端。
|
||||
case "$(uname -s)" in
|
||||
MINGW*|MSYS*|CYGWIN*) build_flutter_ui windows "dist/win-flutter" || return 1 ;;
|
||||
*) build_flutter_ui_cross "dist/win-flutter" ;;
|
||||
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
|
||||
|
||||
progress_step "运行骨架"; progress_tick 100
|
||||
package_mac_app
|
||||
|
||||
@@ -0,0 +1,108 @@
|
||||
cmake_minimum_required(VERSION 3.14)
|
||||
|
||||
# 交叉编译 Flutter Windows 桌面外壳。
|
||||
#
|
||||
# 只编译 C++ 层:runner(Win32 窗口)+ cpp_client_wrapper(Dart 互操作)。
|
||||
# Dart 侧的 flutter_assets 由 flutter assemble 单独产出,最后与
|
||||
# flutter_windows.dll 一起摆进同一个目录就是完整的可运行包。
|
||||
#
|
||||
# 与 windows/CMakeLists.txt 的区别:不调用 tool_backend.bat(它在非 Windows
|
||||
# 上不可执行),也不依赖 Visual Studio 生成器。
|
||||
|
||||
project(gc_ui_cross LANGUAGES CXX RC)
|
||||
|
||||
get_filename_component(APP_DIR "${CMAKE_CURRENT_LIST_DIR}/../../GC-UI/frontend" ABSOLUTE)
|
||||
|
||||
set(WIN_DIR "${APP_DIR}/windows")
|
||||
set(RUN_DIR "${WIN_DIR}/runner")
|
||||
set(EPHEMERAL "${WIN_DIR}/flutter/ephemeral")
|
||||
set(WRAPPER "${EPHEMERAL}/cpp_client_wrapper")
|
||||
set(DLL_LIB "${EPHEMERAL}/flutter_windows.dll.lib")
|
||||
|
||||
foreach(required
|
||||
"${EPHEMERAL}/flutter_windows.dll"
|
||||
"${DLL_LIB}"
|
||||
"${WRAPPER}/core_implementations.cc")
|
||||
if(NOT EXISTS "${required}")
|
||||
message(FATAL_ERROR
|
||||
"缺少 Flutter Windows 引擎产物:${required}\n"
|
||||
"先运行 buildsh/cross/build-ui-win-cross.sh 里的 fetch_engine 步骤。")
|
||||
endif()
|
||||
endforeach()
|
||||
|
||||
set(FLUTTER_VERSION "1.0.0" CACHE STRING "写入 exe 版本资源")
|
||||
|
||||
# windres 在非 Windows 主机上不按 rc 文件所在目录解析图标路径,
|
||||
# 这里把 resources\\app_icon.ico 换成绝对路径再交给 windres。
|
||||
# 注意只替换这一处:rc 里其它 "\0" 是字符串转义,不能动。
|
||||
file(READ "${RUN_DIR}/Runner.rc" _rc_text)
|
||||
string(REPLACE "resources\\\\app_icon.ico" "${RUN_DIR}/resources/app_icon.ico" _rc_text "${_rc_text}")
|
||||
# windres 收到 -DFLUTTER_VERSION=\"1.0.0\" 时会把反斜杠留在宏值里,展开成非法 token。
|
||||
# 直接把宏定义成字面量,绕开命令行转义。
|
||||
string(REPLACE "#define VERSION_AS_STRING FLUTTER_VERSION"
|
||||
"#define VERSION_AS_STRING \"${FLUTTER_VERSION}\""
|
||||
_rc_text "${_rc_text}")
|
||||
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/Runner.cross.rc" "${_rc_text}")
|
||||
|
||||
add_executable(${BINARY_NAME} WIN32
|
||||
"${RUN_DIR}/main.cpp"
|
||||
"${RUN_DIR}/flutter_window.cpp"
|
||||
"${RUN_DIR}/utils.cpp"
|
||||
"${RUN_DIR}/win32_window.cpp"
|
||||
"${WIN_DIR}/flutter/generated_plugin_registrant.cc"
|
||||
"${WRAPPER}/core_implementations.cc"
|
||||
"${WRAPPER}/standard_codec.cc"
|
||||
"${WRAPPER}/plugin_registrar.cc"
|
||||
"${WRAPPER}/flutter_engine.cc"
|
||||
"${WRAPPER}/flutter_view_controller.cc"
|
||||
"${CMAKE_CURRENT_BINARY_DIR}/Runner.cross.rc"
|
||||
)
|
||||
|
||||
target_include_directories(${BINARY_NAME} PRIVATE
|
||||
"${RUN_DIR}"
|
||||
"${WIN_DIR}"
|
||||
"${EPHEMERAL}"
|
||||
"${EPHEMERAL}/include"
|
||||
"${WRAPPER}/include"
|
||||
)
|
||||
|
||||
target_compile_features(${BINARY_NAME} PRIVATE cxx_std_17)
|
||||
|
||||
# Flutter 的 C++ wrapper 需要 RTTI 与异常;线程安全相关的锁依赖 posix 线程模型。
|
||||
target_compile_options(${BINARY_NAME} PRIVATE
|
||||
-fexceptions
|
||||
-frtti
|
||||
-Wall
|
||||
-Wno-unused-parameter
|
||||
-Wno-missing-field-initializers
|
||||
)
|
||||
|
||||
# Runner.rc 里的 #include "resource.h" / runner.exe.manifest 都是相对路径,
|
||||
# windres 不按源文件目录解析,必须显式给 -I。
|
||||
set_source_files_properties("${RUN_DIR}/Runner.rc" PROPERTIES
|
||||
COMPILE_FLAGS "-I\"${RUN_DIR}\"")
|
||||
|
||||
target_compile_definitions(${BINARY_NAME} PRIVATE
|
||||
"FLUTTER_VERSION=\"${FLUTTER_VERSION}\""
|
||||
"FLUTTER_VERSION_MAJOR=${FLUTTER_VERSION_MAJOR}"
|
||||
"FLUTTER_VERSION_MINOR=${FLUTTER_VERSION_MINOR}"
|
||||
"FLUTTER_VERSION_PATCH=${FLUTTER_VERSION_PATCH}"
|
||||
"FLUTTER_VERSION_BUILD=${FLUTTER_VERSION_BUILD}"
|
||||
"NOMINMAX"
|
||||
)
|
||||
|
||||
target_link_libraries(${BINARY_NAME} PRIVATE
|
||||
"${DLL_LIB}"
|
||||
dwmapi
|
||||
ole32
|
||||
uuid
|
||||
)
|
||||
|
||||
# runner 的入口是 wWinMain(宽字符版);MSVC 自动处理,mingw 需要 -municode
|
||||
# 才会链接 wWinMainCRTStartup,否则报 undefined reference to `WinMain'。
|
||||
target_link_options(${BINARY_NAME} PRIVATE -municode)
|
||||
|
||||
set_target_properties(${BINARY_NAME} PROPERTIES
|
||||
OUTPUT_NAME "GC-UI"
|
||||
SUFFIX ".exe"
|
||||
)
|
||||
Executable
+221
@@ -0,0 +1,221 @@
|
||||
#!/usr/bin/env bash
|
||||
#
|
||||
# 在 Linux / macOS 上交叉编译 Flutter Windows 桌面界面(GC-UI)。
|
||||
#
|
||||
# ./buildsh/cross/build-ui-win-cross.sh [输出目录]
|
||||
#
|
||||
# 产物目录是可直接拷到 Windows 上运行的一整套:
|
||||
# GC-UI.exe flutter_windows.dll data/{icudtl.dat,app.so,flutter_assets/}
|
||||
#
|
||||
# 原理:
|
||||
# Flutter 的 Windows 外壳(runner + cpp_client_wrapper)是纯 Win32 + 标准 C++,
|
||||
# 只通过 C ABI 调 flutter_windows.dll,所以 mingw-w64 就能编译。
|
||||
# 唯一的 Windows 专属步骤是 AOT 快照生成(gen_snapshot.exe 是 PE 文件),
|
||||
# 用 wine 执行即可,全流程不需要 Windows 机器或 MSVC。
|
||||
#
|
||||
# 依赖:
|
||||
# Linux sudo apt install mingw-w64 cmake ninja-build wine unzip curl
|
||||
# macOS brew install mingw-w64 cmake ninja && brew install --cask wine-stable
|
||||
#
|
||||
# 环境变量:
|
||||
# FLUTTER_BIN flutter 可执行文件(默认 PATH 中的 flutter,要求 3.24+)
|
||||
# WIN_ENGINE_MIRROR 引擎产物来源(默认官方 GCS,国内可换 storage.flutter-io.cn)
|
||||
#
|
||||
set -euo pipefail
|
||||
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/../.." && pwd)
|
||||
UI_DIR="$ROOT_DIR/GC-UI/frontend"
|
||||
OUT_DIR="${1:-$UI_DIR/build/windows/x64/runner/Release}"
|
||||
BUILD_DIR="$UI_DIR/build/windows/x64/cross"
|
||||
|
||||
say() { printf '\033[36m==>\033[0m %s\n' "$*"; }
|
||||
warn() { printf '\033[33m!!\033[0m %s\n' "$*"; }
|
||||
die() { printf '\033[31mxx\033[0m %s\n' "$*" >&2; exit 1; }
|
||||
|
||||
need() { command -v "$1" >/dev/null 2>&1 || die "缺少 $1($2)"; }
|
||||
|
||||
# ---------------------------------------------------------------- 工具链
|
||||
|
||||
MINGW_CXX=""
|
||||
check_toolchain() {
|
||||
need cmake "Linux: apt install cmake;macOS: brew install cmake"
|
||||
need ninja "Linux: apt install ninja-build;macOS: brew install ninja"
|
||||
need unzip "Linux: apt install unzip"
|
||||
need curl "Linux: apt install curl"
|
||||
|
||||
for c in x86_64-w64-mingw32-g++-posix x86_64-w64-mingw32-g++; do
|
||||
if command -v "$c" >/dev/null 2>&1; then MINGW_CXX="$c"; break; fi
|
||||
done
|
||||
[ -n "$MINGW_CXX" ] || die "缺少 mingw-w64 C++ 编译器
|
||||
Linux: sudo apt install g++-mingw-w64-x86-64-posix
|
||||
macOS: brew install mingw-w64"
|
||||
|
||||
command -v x86_64-w64-mingw32-windres >/dev/null 2>&1 || die "缺少 mingw-w64 资源编译器"
|
||||
|
||||
# gen_snapshot.exe 靠 wine 执行;没有 wine 就只能出 debug 版(JIT)
|
||||
if command -v wine >/dev/null 2>&1 || command -v wine64 >/dev/null 2>&1; then
|
||||
WINE_BIN=$(command -v wine 2>/dev/null || command -v wine64)
|
||||
else
|
||||
die "缺少 wine(AOT 快照需要执行 Windows 版 gen_snapshot.exe)
|
||||
Linux: sudo apt install wine
|
||||
macOS: brew install --cask wine-stable"
|
||||
fi
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- Flutter
|
||||
|
||||
resolve_flutter() {
|
||||
FLUTTER_BIN="${FLUTTER_BIN:-flutter}"
|
||||
command -v "$FLUTTER_BIN" >/dev/null 2>&1 || die "未找到 flutter,可设置 FLUTTER_BIN=/path/to/flutter"
|
||||
|
||||
local bin_path root target
|
||||
bin_path=$(command -v "$FLUTTER_BIN")
|
||||
while [ -L "$bin_path" ]; do
|
||||
target=$(readlink "$bin_path")
|
||||
case "$target" in
|
||||
/*) bin_path="$target" ;;
|
||||
*) bin_path="$(cd "$(dirname "$bin_path")" && pwd)/$target" ;;
|
||||
esac
|
||||
done
|
||||
root=$(cd "$(dirname "$bin_path")/.." && pwd)
|
||||
|
||||
[ -f "$root/bin/internal/engine.version" ] || die "$root 不像 Flutter SDK 根目录"
|
||||
FLUTTER_ROOT="$root"
|
||||
ENGINE_DIR="$root/bin/cache/artifacts/engine"
|
||||
ENGINE_HASH=$(tr -d '[:space:]' < "$root/bin/internal/engine.version")
|
||||
|
||||
# pubspec 要求 Dart 3.5+(Flutter 3.24+),版本不对直接提醒
|
||||
local dart_ver
|
||||
dart_ver=$("$root/bin/cache/dart-sdk/bin/dart" --version 2>/dev/null | grep -oE '[0-9]+\.[0-9]+\.[0-9]+' | head -1) || dart_ver=""
|
||||
say "Flutter SDK: $root(engine ${ENGINE_HASH:0:10}${dart_ver:+, dart $dart_ver})"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- 引擎产物
|
||||
|
||||
ENGINE_DIR="" # 由 resolve_flutter 填充
|
||||
|
||||
fetch_engine() {
|
||||
local base="$MIRROR/flutter/$ENGINE_HASH"
|
||||
local cache="${TMPDIR:-/tmp}/gc-win-engine"
|
||||
mkdir -p "$cache"
|
||||
|
||||
# 每个条目:远端相对路径 | 落地目录 | 落地后的标志文件
|
||||
local -a items=(
|
||||
"windows-x64-release/windows-x64-flutter.zip|$ENGINE_DIR/windows-x64-release|flutter_windows.dll.lib"
|
||||
"windows-x64/artifacts.zip|$ENGINE_DIR/windows-x64|frontend_server_aot.dart.snapshot"
|
||||
"windows-x64/flutter-cpp-client-wrapper.zip|$ENGINE_DIR/windows-x64/cpp_client_wrapper|core_implementations.cc"
|
||||
)
|
||||
|
||||
local item remote dest marker zip
|
||||
for item in "${items[@]}"; do
|
||||
IFS='|' read -r remote dest marker <<<"$item"
|
||||
[ -f "$dest/$marker" ] && continue
|
||||
|
||||
zip="$cache/$(echo "$remote" | tr '/' '_')"
|
||||
if [ ! -s "$zip" ]; then
|
||||
say "下载 $(basename "$remote")"
|
||||
curl -fL --retry 3 --retry-delay 2 -o "$zip.part" "$base/$remote" \
|
||||
|| die "下载失败:$base/$remote
|
||||
可设置 WIN_ENGINE_MIRROR=https://storage.flutter-io.cn/flutter_infra_release 走国内镜像"
|
||||
mv "$zip.part" "$zip"
|
||||
fi
|
||||
mkdir -p "$dest"
|
||||
unzip -oq "$zip" -d "$dest"
|
||||
done
|
||||
|
||||
install_gen_snapshot_shim
|
||||
}
|
||||
|
||||
# flutter_tools 会直接 exec $ENGINE_DIR/*/gen_snapshot(无 .exe 后缀)。
|
||||
# 这里放一个调用 wine 的同名脚本,并给原本的 exe 加上 .win 后缀避免混淆。
|
||||
install_gen_snapshot_shim() {
|
||||
local dirs=("$ENGINE_DIR/windows-x64-release" "$ENGINE_DIR/windows-x64")
|
||||
local dir shim
|
||||
for dir in "${dirs[@]}"; do
|
||||
[ -f "$dir/gen_snapshot.exe" ] || continue
|
||||
[ -f "$dir/gen_snapshot.exe.win" ] || mv "$dir/gen_snapshot.exe" "$dir/gen_snapshot.exe.win"
|
||||
|
||||
shim="$dir/gen_snapshot"
|
||||
cat > "$shim" <<EOF
|
||||
#!/bin/sh
|
||||
# 由 buildsh/cross/build-ui-win-cross.sh 生成:用 wine 执行 Windows 版 gen_snapshot。
|
||||
export WINEPREFIX="\${WINEPREFIX:-\$HOME/.wine64}"
|
||||
export WINEDEBUG=-all
|
||||
exec "$WINE_BIN" "$dir/gen_snapshot.exe.win" "\$@"
|
||||
EOF
|
||||
chmod +x "$shim"
|
||||
done
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- 构建
|
||||
|
||||
build_assets_and_aot() {
|
||||
say "生成 Dart 资源与 AOT 快照"
|
||||
( cd "$UI_DIR" && "$FLUTTER_BIN" --no-version-check --suppress-analytics pub get >/dev/null )
|
||||
|
||||
local dart="$FLUTTER_ROOT/bin/cache/dart-sdk/bin/dart"
|
||||
local tool="$FLUTTER_ROOT/packages/flutter_tools/bin/tool_backend.dart"
|
||||
|
||||
# tool_backend 是官方 CMake 调用的同一入口:解包引擎产物到 ephemeral、
|
||||
# 生成 flutter_assets、aot_elf_release。它末尾的收尾步骤在非 Windows host
|
||||
# 上可能非零退出,所以只校验产物是否齐备。
|
||||
( cd "$UI_DIR" && \
|
||||
FLUTTER_ROOT="$FLUTTER_ROOT" \
|
||||
PROJECT_DIR="$UI_DIR" \
|
||||
FLUTTER_STORAGE_BASE_URL="${FLUTTER_STORAGE_BASE_URL:-$MIRROR}" \
|
||||
"$dart" "$tool" windows-x64 release ) || true
|
||||
|
||||
[ -f "$UI_DIR/build/windows/app.so" ] || die "AOT 快照未生成(wine 执行 gen_snapshot 失败?)"
|
||||
[ -d "$UI_DIR/build/flutter_assets" ] || die "flutter_assets 未生成"
|
||||
say "AOT 快照 $(du -h "$UI_DIR/build/windows/app.so" | cut -f1),资源 $(du -sh "$UI_DIR/build/flutter_assets" | cut -f1)"
|
||||
}
|
||||
|
||||
build_cpp() {
|
||||
local ver major minor patch build_no
|
||||
read -r major minor patch build_no <<<"$(sed -n 's/^version:[[:space:]]*//p' "$UI_DIR/pubspec.yaml" \
|
||||
| head -1 | awk -F'[.+]' '{print $1+0, $2+0, $3+0, ($4==""?0:$4+0)}')"
|
||||
ver="${major}.${minor}.${patch}"
|
||||
|
||||
say "编译 C++ 外壳($(basename "$MINGW_CXX"))"
|
||||
cmake -S "$ROOT_DIR/buildsh/cross" -B "$BUILD_DIR" -G Ninja \
|
||||
-DCMAKE_TOOLCHAIN_FILE="$ROOT_DIR/buildsh/cross/toolchain-mingw.cmake" \
|
||||
-DCMAKE_BUILD_TYPE=Release \
|
||||
-DBINARY_NAME=GC-UI \
|
||||
-DFLUTTER_VERSION="$ver" \
|
||||
-DFLUTTER_VERSION_MAJOR="$major" \
|
||||
-DFLUTTER_VERSION_MINOR="$minor" \
|
||||
-DFLUTTER_VERSION_PATCH="$patch" \
|
||||
-DFLUTTER_VERSION_BUILD="$build_no" >/dev/null
|
||||
|
||||
cmake --build "$BUILD_DIR" -- -j "$(getconf _NPROCESSORS_ONLN 2>/dev/null || echo 4)" \
|
||||
|| die "C++ 编译失败"
|
||||
|
||||
[ -f "$BUILD_DIR/GC-UI.exe" ] || die "未产出 GC-UI.exe"
|
||||
}
|
||||
|
||||
stage() {
|
||||
local eph="$UI_DIR/windows/flutter/ephemeral"
|
||||
say "组装到 $OUT_DIR"
|
||||
rm -rf "$OUT_DIR"
|
||||
mkdir -p "$OUT_DIR/data"
|
||||
|
||||
cp "$BUILD_DIR/GC-UI.exe" "$OUT_DIR/"
|
||||
cp "$eph/flutter_windows.dll" "$OUT_DIR/"
|
||||
cp "$eph/icudtl.dat" "$OUT_DIR/data/"
|
||||
cp "$UI_DIR/build/windows/app.so" "$OUT_DIR/data/"
|
||||
cp -R "$UI_DIR/build/flutter_assets/." "$OUT_DIR/data/flutter_assets/"
|
||||
|
||||
say "完成:$(du -sh "$OUT_DIR" | cut -f1)"
|
||||
find "$OUT_DIR" -maxdepth 2 -mindepth 1 | sed "s|$OUT_DIR| .|"
|
||||
}
|
||||
|
||||
# ---------------------------------------------------------------- main
|
||||
|
||||
MIRROR="${WIN_ENGINE_MIRROR:-https://storage.googleapis.com/flutter_infra_release}"
|
||||
|
||||
check_toolchain
|
||||
resolve_flutter
|
||||
fetch_engine
|
||||
build_assets_and_aot
|
||||
build_cpp
|
||||
stage
|
||||
@@ -0,0 +1,36 @@
|
||||
# 在 Linux / macOS 上交叉编译 Flutter Windows 桌面应用的 CMake 工具链。
|
||||
#
|
||||
# 原理:Flutter 的 Windows 嵌入层(windows/runner/*.cpp + cpp_client_wrapper)
|
||||
# 是纯 Win32 + 标准 C++,只通过 C ABI 调用 flutter_windows.dll。因此用
|
||||
# mingw-w64(GCC,posix 线程模型)即可产出与官方 toolchain 等价的 PE 产物,
|
||||
# 不需要 Windows 机器,也不需要 MSVC。
|
||||
#
|
||||
# 用法:
|
||||
# cmake -B build -G Ninja -DCMAKE_TOOLCHAIN_FILE=.../toolchain-mingw.cmake ...
|
||||
|
||||
set(CMAKE_SYSTEM_NAME Windows)
|
||||
set(CMAKE_SYSTEM_VERSION 10.0)
|
||||
set(CMAKE_SYSTEM_PROCESSOR x86_64)
|
||||
|
||||
set(MINGW_PREFIX "x86_64-w64-mingw32" CACHE STRING "目标三元组前缀")
|
||||
|
||||
# 必须用 posix 线程模型:Flutter 的 C++ wrapper 依赖 std::mutex / std::thread,
|
||||
# win32 线程模型下的 libstdc++ 不提供这些类型。
|
||||
find_program(MINGW_C NAMES ${MINGW_PREFIX}-gcc-posix ${MINGW_PREFIX}-gcc REQUIRED)
|
||||
find_program(MINGW_CXX NAMES ${MINGW_PREFIX}-g++-posix ${MINGW_PREFIX}-g++ REQUIRED)
|
||||
find_program(MINGW_RC NAMES ${MINGW_PREFIX}-windres REQUIRED)
|
||||
|
||||
set(CMAKE_C_COMPILER "${MINGW_C}")
|
||||
set(CMAKE_CXX_COMPILER "${MINGW_CXX}")
|
||||
set(CMAKE_RC_COMPILER "${MINGW_RC}")
|
||||
|
||||
set(CMAKE_FIND_ROOT_PATH "/usr/${MINGW_PREFIX}")
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)
|
||||
set(CMAKE_FIND_ROOT_PATH_MODE_PACKAGE ONLY)
|
||||
|
||||
# 静态链接 libgcc / libstdc++ / winpthread,产物只依赖 flutter_windows.dll
|
||||
# 和系统 DLL,拷到干净机器上也能跑。
|
||||
set(CMAKE_CXX_FLAGS_INIT "-DUNICODE -D_UNICODE -DNOMINMAX -D_HAS_EXCEPTIONS=1")
|
||||
set(CMAKE_EXE_LINKER_FLAGS_INIT "-static -static-libgcc -static-libstdc++")
|
||||
@@ -174,32 +174,112 @@ pack_models() {
|
||||
# macOS: .app 必须打成 zip 才能作为单文件分发;文件名用 .app.zip,
|
||||
# 这样 macOS 双击会用归档工具解压出可运行的 .app。
|
||||
# 若直接命名 .app,系统会把 zip 当成应用包解析 => 报「已损坏/打不开」。
|
||||
# 发布本地 UI 后端(GC.UI.Server)。启动器会拉起它并等待 /api/health,
|
||||
# 模型窗口也由它承载,所以必须和启动器放在同一目录。
|
||||
publish_backend() {
|
||||
RID="$1"; OUT="$2"
|
||||
echo "==> 编译 UI 后端 (${RID}) -> ${OUT}"
|
||||
dotnet publish "$ROOT_DIR/GC-UI/backend/GC.UI.Server/GC.UI.Server.csproj" \
|
||||
-c Release \
|
||||
-r "$RID" \
|
||||
--self-contained true \
|
||||
-p:Version="$VERSION" \
|
||||
-p:DebugType=none \
|
||||
-p:PublishSingleFile=false \
|
||||
-p:PublishTrimmed=false \
|
||||
-o "$ROOT_DIR/$OUT" || return 1
|
||||
}
|
||||
|
||||
# 当前主机原生构建 Flutter 前端(Windows 主机编 Windows,macOS 主机编 macOS)。
|
||||
# macOS 版 Flutter 桌面只能在 macOS 上编;Windows 版则由 build_flutter_ui_cross
|
||||
# 在 Linux/macOS 上交叉编译。
|
||||
build_flutter_ui() {
|
||||
PLAT="$1"; DEST="$2"
|
||||
UI_SRC="$ROOT_DIR/GC-UI/frontend"
|
||||
[ -d "$UI_SRC" ] || return 0
|
||||
|
||||
FLUTTER_BIN="${FLUTTER_BIN:-flutter}"
|
||||
if ! command -v "$FLUTTER_BIN" >/dev/null 2>&1; then
|
||||
echo "!! 未找到 flutter(可用 FLUTTER_BIN=<路径> 指定),本次包内不含 Flutter 界面"
|
||||
return 0
|
||||
fi
|
||||
|
||||
echo "==> 构建 Flutter 前端 (${PLAT})"
|
||||
( cd "$UI_SRC" && "$FLUTTER_BIN" pub get && "$FLUTTER_BIN" build "$PLAT" --release ) || return 1
|
||||
|
||||
mkdir -p "$ROOT_DIR/$DEST"
|
||||
case "$PLAT" in
|
||||
windows)
|
||||
# Release/ 里含 GC-UI.exe、flutter_windows.dll 和 data/
|
||||
cp -R "$UI_SRC/build/windows/x64/runner/Release/." "$ROOT_DIR/$DEST/"
|
||||
;;
|
||||
macos)
|
||||
rm -rf "$ROOT_DIR/$DEST/GC-UI.app"
|
||||
cp -R "$UI_SRC/build/macos/Build/Products/Release/GC-UI.app" "$ROOT_DIR/$DEST/"
|
||||
;;
|
||||
esac
|
||||
echo " -> $DEST(Flutter ${PLAT})"
|
||||
}
|
||||
|
||||
# 在 Linux / macOS 上交叉编译 Windows 前端:mingw-w64 编 C++ 外壳,
|
||||
# wine 跑 Windows 版 gen_snapshot 生成 AOT 快照,无需 Windows 机器。
|
||||
# 产物布局与官方 toolchain 完全一致(GC-UI.exe + flutter_windows.dll + data/)。
|
||||
build_flutter_ui_cross() {
|
||||
DEST="$1"
|
||||
UI_SRC="$ROOT_DIR/GC-UI/frontend"
|
||||
[ -d "$UI_SRC" ] || return 0
|
||||
|
||||
FLUTTER_BIN="${FLUTTER_BIN:-flutter}"
|
||||
if ! command -v "$FLUTTER_BIN" >/dev/null 2>&1; then
|
||||
echo "!! 未找到 flutter(可用 FLUTTER_BIN=<路径> 指定),本次包内不含 Flutter 界面"
|
||||
return 0
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT_DIR/build/logs"
|
||||
echo "==> 交叉编译 Windows 前端(mingw-w64 + wine)"
|
||||
if ! FLUTTER_BIN="$FLUTTER_BIN" bash "$ROOT_DIR/buildsh/cross/build-ui-win-cross.sh" \
|
||||
"$UI_SRC/build/windows/x64/runner/Release" \
|
||||
>"$ROOT_DIR/build/logs/flutter-win-cross.log" 2>&1; then
|
||||
echo "!! 交叉编译失败,本次包内不含 Flutter 界面(日志:build/logs/flutter-win-cross.log)"
|
||||
return 0
|
||||
fi
|
||||
|
||||
mkdir -p "$ROOT_DIR/$DEST"
|
||||
cp -R "$UI_SRC/build/windows/x64/runner/Release/." "$ROOT_DIR/$DEST/"
|
||||
echo " -> $DEST(Flutter windows,交叉编译)"
|
||||
}
|
||||
|
||||
pack_launcher() {
|
||||
echo "==> 生成启动器产物(GC-<版本>-<系统>-<架构>)"
|
||||
|
||||
# --- Windows:exe 单文件(连同 GC-SAVEDOG.exe 一起打进 zip)---
|
||||
# --- Windows:启动器 + 守护进程 + UI 后端 + Flutter 前端,整目录打包 ---
|
||||
for pair in "win-x64:win-amd64" "win-arm64:win-arm64"; do
|
||||
RID="${pair%%:*}"; LABEL="${pair##*:}"
|
||||
SRC="$ROOT_DIR/dist/$LABEL"
|
||||
[ -d "$SRC" ] || SRC="$ROOT_DIR/dist/$RID" # 兼容旧布局
|
||||
[ -d "$SRC" ] || continue
|
||||
# 注意排除守护进程:GC-SAVEDOG.exe 在字典序里排在 GC.exe 前面
|
||||
EXE=$(ls "$SRC"/*.exe 2>/dev/null | grep -v 'GC-SAVEDOG' | head -1)
|
||||
|
||||
# 启动器固定是 GC.exe;后端与前端是可选的随包产物,不能当成启动器。
|
||||
EXE="$SRC/GC.exe"
|
||||
[ -f "$EXE" ] || EXE=$(ls "$SRC"/*.exe 2>/dev/null | grep -v 'GC-SAVEDOG\|GC.UI.Server\|GC-UI' | head -1)
|
||||
[ -n "$EXE" ] || continue
|
||||
|
||||
TMP="$ROOT_DIR/dist/.winpkg-$LABEL"
|
||||
rm -rf "$TMP"; mkdir -p "$TMP"
|
||||
cp "$EXE" "$TMP/GC-${VERSION}-${LABEL}.exe"
|
||||
cp -R "$SRC"/. "$TMP"/
|
||||
rm -f "$TMP"/*.zip
|
||||
mv "$TMP/$(basename "$EXE")" "$TMP/GC-${VERSION}-${LABEL}.exe"
|
||||
chmod +x "$TMP/GC-${VERSION}-${LABEL}.exe" 2>/dev/null || true
|
||||
if [ -f "$SRC/GC-SAVEDOG.exe" ]; then
|
||||
cp "$SRC/GC-SAVEDOG.exe" "$TMP/GC-SAVEDOG.exe"
|
||||
else
|
||||
if [ ! -f "$TMP/GC-SAVEDOG.exe" ]; then
|
||||
echo " !! 缺少 GC-SAVEDOG.exe,该平台将退回旧脚本更新"
|
||||
fi
|
||||
if [ ! -f "$TMP/GC-UI.exe" ]; then
|
||||
echo " !! 包内没有 Flutter 前端,启动器将使用内置 Avalonia 界面"
|
||||
fi
|
||||
|
||||
ZIP="$ROOT_DIR/dist/$LABEL/GC-${VERSION}-${LABEL}.zip"
|
||||
rm -f "$ZIP"
|
||||
( cd "$TMP" && zip -q "$ZIP" ./* )
|
||||
( cd "$TMP" && zip -qr "$ZIP" . )
|
||||
rm -rf "$TMP"
|
||||
echo " -> dist/$LABEL/GC-${VERSION}-${LABEL}.zip"
|
||||
done
|
||||
|
||||
@@ -11,7 +11,7 @@ using GC.Services;
|
||||
// 仓库根 version.json 与 model/version.json(内容相同,便于两种源地址读取)。
|
||||
|
||||
// 仓库地址(编译产物的 Release 也发在这里):与启动器默认 updateRepository 保持一致。
|
||||
const string Repository = "https://gitcode.com/Morris_1/GC";
|
||||
const string Repository = "https://git.xhmcl.com/Morris/GC";
|
||||
|
||||
// 位置参数:<仓库根> <启动器版本>;开关:--launcher-only
|
||||
// --launcher-only 只刷新 launcher.packages(构建脚本在打完 zip 之后再调一次),
|
||||
@@ -150,7 +150,7 @@ var packages = new Dictionary<string, Dictionary<string, object>>();
|
||||
// 2) 仓库里的编译产物 dist/<系统>-<架构>/GC-<版本>-<系统>-<架构>.zip ——
|
||||
// 不发 Release、只提交产物也能更新(用户明确要求支持这种布局)。
|
||||
// 两种都写:url 只是「去哪儿找」,真正的完整性凭据是下面的 sha256(受签名保护)。
|
||||
var releaseBase = $"{Repository}/releases/download/v{launcherVersion}";
|
||||
var releaseBase = $"{Repository}/releases/download/{launcherVersion}";
|
||||
foreach (var rid in new[] { "win-x64", "win-arm64", "osx-arm64", "osx-x64", "linux-x64" })
|
||||
{
|
||||
var label = LauncherArtifacts.LabelOf(rid);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
],
|
||||
"assembly": "ContourMapModel.dll",
|
||||
"type": "GC.ContourMap.ContourMapFactory",
|
||||
"version": "1.0",
|
||||
"version": "1.1",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -25,6 +25,6 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "43dcb6dc63",
|
||||
"updatedAt": "2026-11-17T22:53:52Z"
|
||||
"build": "773ab2161d",
|
||||
"updatedAt": "2026-11-18T04:35:15Z"
|
||||
}
|
||||
@@ -17,7 +17,7 @@
|
||||
"atlas"
|
||||
],
|
||||
"dataDir": "earth-geography.model",
|
||||
"version": "1.8",
|
||||
"version": "1.9",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -25,6 +25,6 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "16eaf4110f",
|
||||
"updatedAt": "2026-11-17T22:53:52Z"
|
||||
"build": "cc68b8863b",
|
||||
"updatedAt": "2026-11-18T04:35:15Z"
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"type": "GC.EarthModels.RevolutionModelFactory",
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.6",
|
||||
"version": "1.7",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -31,6 +31,6 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "bd57e6ed67",
|
||||
"updatedAt": "2026-11-17T22:53:52Z"
|
||||
"build": "53b7a0fbc3",
|
||||
"updatedAt": "2026-11-18T04:35:15Z"
|
||||
}
|
||||
@@ -23,7 +23,7 @@
|
||||
"type": "GC.EarthModels.RotationModelFactory",
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.6",
|
||||
"version": "1.7",
|
||||
"chrome": {
|
||||
"titleBar": "#0C1828",
|
||||
"titleBorder": "#1B2740",
|
||||
@@ -31,6 +31,6 @@
|
||||
"button": "#9FB4D4",
|
||||
"frame": "#0A1524"
|
||||
},
|
||||
"build": "a79f660ec2",
|
||||
"updatedAt": "2026-11-17T22:53:52Z"
|
||||
"build": "ecd52665f9",
|
||||
"updatedAt": "2026-11-18T04:35:15Z"
|
||||
}
|
||||
@@ -24,7 +24,7 @@
|
||||
"type": "GC.ScaleCalculator.ScaleCalculatorFactory",
|
||||
"preview": "preview.png",
|
||||
"apiVersion": 1,
|
||||
"version": "1.5",
|
||||
"version": "1.6",
|
||||
"chrome": {
|
||||
"titleBar": "#FFFFFF",
|
||||
"titleBorder": "#E3E8F3",
|
||||
@@ -32,6 +32,6 @@
|
||||
"button": "#5B6A86",
|
||||
"frame": "#F4F6FB"
|
||||
},
|
||||
"build": "ec6119e3f4",
|
||||
"updatedAt": "2026-11-17T22:53:52Z"
|
||||
"build": "105653737d",
|
||||
"updatedAt": "2026-11-18T04:35:15Z"
|
||||
}
|
||||
+39
-39
@@ -1,93 +1,93 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"generated": "2026-11-17T22:53:52Z",
|
||||
"repository": "https://gitcode.com/Morris_1/GC",
|
||||
"generated": "2026-11-18T05:48:18Z",
|
||||
"repository": "https://git.xhmcl.com/Morris/GC",
|
||||
"branch": "main",
|
||||
"modelDir": "model",
|
||||
"launcher": {
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"revision": "",
|
||||
"packages": {
|
||||
"win-x64": {
|
||||
"path": "dist/win-amd64/GC-1.0.7-win-amd64.zip",
|
||||
"path": "dist/win-amd64/GC-1.0.8-win-amd64.zip",
|
||||
"dir": "dist/win-amd64",
|
||||
"name": "GC-1.0.7-win-amd64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-amd64.zip",
|
||||
"sha256": "f90ff51ac6b041ae238cbeb4672622b0d029142a9d8b0705f08e654336512308",
|
||||
"size": 46363183
|
||||
"name": "GC-1.0.8-win-amd64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-win-amd64.zip",
|
||||
"sha256": "eb61c4aa619cb2245c5b79b733bf22a81ed63e304b794c3f0fb5a553e0e7f752",
|
||||
"size": 114371163
|
||||
},
|
||||
"win-arm64": {
|
||||
"path": "dist/win-arm64/GC-1.0.7-win-arm64.zip",
|
||||
"path": "dist/win-arm64/GC-1.0.8-win-arm64.zip",
|
||||
"dir": "dist/win-arm64",
|
||||
"name": "GC-1.0.7-win-arm64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-arm64.zip",
|
||||
"sha256": "0b2bab2c3ac7e6223d8dd0b0faf9a0994319fa5ad13826addf7b402619b812e0",
|
||||
"size": 44390354
|
||||
"name": "GC-1.0.8-win-arm64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-win-arm64.zip",
|
||||
"sha256": "557a64b5028947435959329d2b23bcb24051cb62f7300e1d7c0e07599e467355",
|
||||
"size": 110424955
|
||||
},
|
||||
"osx-arm64": {
|
||||
"path": "dist/mac-arm64/GC-1.0.7-mac-arm64.zip",
|
||||
"path": "dist/mac-arm64/GC-1.0.8-mac-arm64.zip",
|
||||
"dir": "dist/mac-arm64",
|
||||
"name": "GC-1.0.7-mac-arm64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-mac-arm64.zip",
|
||||
"sha256": "e5fd355bace68dc0794eb3e049cbef63c952a60a765ab3806adaf1199e1b09ab",
|
||||
"size": 9178314
|
||||
"name": "GC-1.0.8-mac-arm64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-mac-arm64.zip",
|
||||
"sha256": "c01ae349fbd897a4bb21119360b8afb952900e4791738efc33b74c974bac1c14",
|
||||
"size": 60065452
|
||||
},
|
||||
"osx-x64": {
|
||||
"path": "dist/mac-x64/GC-1.0.7-mac-x64.zip",
|
||||
"path": "dist/mac-x64/GC-1.0.8-mac-x64.zip",
|
||||
"dir": "dist/mac-x64",
|
||||
"name": "GC-1.0.7-mac-x64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-mac-x64.zip"
|
||||
"name": "GC-1.0.8-mac-x64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-mac-x64.zip"
|
||||
},
|
||||
"linux-x64": {
|
||||
"path": "dist/linux-amd64/GC-1.0.7-linux-amd64.zip",
|
||||
"path": "dist/linux-amd64/GC-1.0.8-linux-amd64.zip",
|
||||
"dir": "dist/linux-amd64",
|
||||
"name": "GC-1.0.7-linux-amd64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-linux-amd64.zip"
|
||||
"name": "GC-1.0.8-linux-amd64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-linux-amd64.zip"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models": [
|
||||
{
|
||||
"id": "contour-map",
|
||||
"version": "1.0",
|
||||
"build": "43dcb6dc63",
|
||||
"manifestSha256": "f7896a85d5f9e9f10e021c07931dee51f0ef86151a6a89e2ed39e37cb7f996a6",
|
||||
"version": "1.1",
|
||||
"build": "773ab2161d",
|
||||
"manifestSha256": "1542e3132541e34f9a371ec11d56beb4479b7824433d97083e78c4349af48cff",
|
||||
"filesSha256": "a6bdf9b4273aabee50c3c94ceab4d0abee15f0df1af90c58bdbb796e0d2d5699",
|
||||
"files": 5,
|
||||
"dir": "model/contour-map"
|
||||
},
|
||||
{
|
||||
"id": "earth-geography",
|
||||
"version": "1.8",
|
||||
"build": "16eaf4110f",
|
||||
"manifestSha256": "0b8dd41e8535284576873956ed1db8755097649fe801d887b65ca5ac369f267c",
|
||||
"version": "1.9",
|
||||
"build": "cc68b8863b",
|
||||
"manifestSha256": "62e5c3b2ec28c89ade9131f44854ff45b24873193036ce2e13b18d9b68a320cd",
|
||||
"filesSha256": "c018ba481831e23d3183a38ac47251f19754c7464baa5d85b47cea7a49fcfa95",
|
||||
"files": 11,
|
||||
"dir": "model/earth-geography"
|
||||
},
|
||||
{
|
||||
"id": "earth-revolution",
|
||||
"version": "1.6",
|
||||
"build": "bd57e6ed67",
|
||||
"manifestSha256": "2d05234ea0d4de5ac55b7a076085ccfbb94ed107cce2b2d40e56d45bc3b37f3e",
|
||||
"version": "1.7",
|
||||
"build": "53b7a0fbc3",
|
||||
"manifestSha256": "12a628168785740f67d7bafcce8467875f741b31a1b852643f28ed879972210f",
|
||||
"filesSha256": "4cd45b0324a77574a0da3a939c2a6faebc785c5a24cb50136d62a78a6ea2e9b1",
|
||||
"files": 7,
|
||||
"dir": "model/earth-revolution"
|
||||
},
|
||||
{
|
||||
"id": "earth-rotation",
|
||||
"version": "1.6",
|
||||
"build": "a79f660ec2",
|
||||
"manifestSha256": "cb4ec5f310e7f05235042180dfdb1d8904c37b2d67b06a174f55589eed1652b9",
|
||||
"version": "1.7",
|
||||
"build": "ecd52665f9",
|
||||
"manifestSha256": "3a492fe3220a3093569164735420d21470e971ca1c73f1ada73c5d91cdd651da",
|
||||
"filesSha256": "594b005a6a9f36cd0b5d4e4a7a0b1ab42d53c8032832545b71c3915493d56c8e",
|
||||
"files": 7,
|
||||
"dir": "model/earth-rotation"
|
||||
},
|
||||
{
|
||||
"id": "scale-calculator",
|
||||
"version": "1.5",
|
||||
"build": "ec6119e3f4",
|
||||
"manifestSha256": "54cf496553d11b704abfa06588ffccfed3f881a3b919d0e2304c18e157fd1f0a",
|
||||
"version": "1.6",
|
||||
"build": "105653737d",
|
||||
"manifestSha256": "c1d65815cfea866e4461b877d53f7af4a920dcb559e2b2453a6bcaa3e1650c66",
|
||||
"filesSha256": "732dd26406e0f1e836970499d7ea644def332ce909d7f8aa0a403bbe7337e604",
|
||||
"files": 6,
|
||||
"dir": "model/scale-calculator"
|
||||
|
||||
+39
-39
@@ -1,93 +1,93 @@
|
||||
{
|
||||
"schema": 1,
|
||||
"generated": "2026-11-17T22:53:52Z",
|
||||
"repository": "https://gitcode.com/Morris_1/GC",
|
||||
"generated": "2026-11-18T05:48:18Z",
|
||||
"repository": "https://git.xhmcl.com/Morris/GC",
|
||||
"branch": "main",
|
||||
"modelDir": "model",
|
||||
"launcher": {
|
||||
"version": "1.0.7",
|
||||
"version": "1.0.8",
|
||||
"revision": "",
|
||||
"packages": {
|
||||
"win-x64": {
|
||||
"path": "dist/win-amd64/GC-1.0.7-win-amd64.zip",
|
||||
"path": "dist/win-amd64/GC-1.0.8-win-amd64.zip",
|
||||
"dir": "dist/win-amd64",
|
||||
"name": "GC-1.0.7-win-amd64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-amd64.zip",
|
||||
"sha256": "f90ff51ac6b041ae238cbeb4672622b0d029142a9d8b0705f08e654336512308",
|
||||
"size": 46363183
|
||||
"name": "GC-1.0.8-win-amd64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-win-amd64.zip",
|
||||
"sha256": "eb61c4aa619cb2245c5b79b733bf22a81ed63e304b794c3f0fb5a553e0e7f752",
|
||||
"size": 114371163
|
||||
},
|
||||
"win-arm64": {
|
||||
"path": "dist/win-arm64/GC-1.0.7-win-arm64.zip",
|
||||
"path": "dist/win-arm64/GC-1.0.8-win-arm64.zip",
|
||||
"dir": "dist/win-arm64",
|
||||
"name": "GC-1.0.7-win-arm64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-win-arm64.zip",
|
||||
"sha256": "0b2bab2c3ac7e6223d8dd0b0faf9a0994319fa5ad13826addf7b402619b812e0",
|
||||
"size": 44390354
|
||||
"name": "GC-1.0.8-win-arm64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-win-arm64.zip",
|
||||
"sha256": "557a64b5028947435959329d2b23bcb24051cb62f7300e1d7c0e07599e467355",
|
||||
"size": 110424955
|
||||
},
|
||||
"osx-arm64": {
|
||||
"path": "dist/mac-arm64/GC-1.0.7-mac-arm64.zip",
|
||||
"path": "dist/mac-arm64/GC-1.0.8-mac-arm64.zip",
|
||||
"dir": "dist/mac-arm64",
|
||||
"name": "GC-1.0.7-mac-arm64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-mac-arm64.zip",
|
||||
"sha256": "e5fd355bace68dc0794eb3e049cbef63c952a60a765ab3806adaf1199e1b09ab",
|
||||
"size": 9178314
|
||||
"name": "GC-1.0.8-mac-arm64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-mac-arm64.zip",
|
||||
"sha256": "c01ae349fbd897a4bb21119360b8afb952900e4791738efc33b74c974bac1c14",
|
||||
"size": 60065452
|
||||
},
|
||||
"osx-x64": {
|
||||
"path": "dist/mac-x64/GC-1.0.7-mac-x64.zip",
|
||||
"path": "dist/mac-x64/GC-1.0.8-mac-x64.zip",
|
||||
"dir": "dist/mac-x64",
|
||||
"name": "GC-1.0.7-mac-x64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-mac-x64.zip"
|
||||
"name": "GC-1.0.8-mac-x64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-mac-x64.zip"
|
||||
},
|
||||
"linux-x64": {
|
||||
"path": "dist/linux-amd64/GC-1.0.7-linux-amd64.zip",
|
||||
"path": "dist/linux-amd64/GC-1.0.8-linux-amd64.zip",
|
||||
"dir": "dist/linux-amd64",
|
||||
"name": "GC-1.0.7-linux-amd64.zip",
|
||||
"url": "https://gitcode.com/Morris_1/GC/releases/download/v1.0.7/GC-1.0.7-linux-amd64.zip"
|
||||
"name": "GC-1.0.8-linux-amd64.zip",
|
||||
"url": "https://git.xhmcl.com/Morris/GC/releases/download/1.0.8/GC-1.0.8-linux-amd64.zip"
|
||||
}
|
||||
}
|
||||
},
|
||||
"models": [
|
||||
{
|
||||
"id": "contour-map",
|
||||
"version": "1.0",
|
||||
"build": "43dcb6dc63",
|
||||
"manifestSha256": "f7896a85d5f9e9f10e021c07931dee51f0ef86151a6a89e2ed39e37cb7f996a6",
|
||||
"version": "1.1",
|
||||
"build": "773ab2161d",
|
||||
"manifestSha256": "1542e3132541e34f9a371ec11d56beb4479b7824433d97083e78c4349af48cff",
|
||||
"filesSha256": "a6bdf9b4273aabee50c3c94ceab4d0abee15f0df1af90c58bdbb796e0d2d5699",
|
||||
"files": 5,
|
||||
"dir": "model/contour-map"
|
||||
},
|
||||
{
|
||||
"id": "earth-geography",
|
||||
"version": "1.8",
|
||||
"build": "16eaf4110f",
|
||||
"manifestSha256": "0b8dd41e8535284576873956ed1db8755097649fe801d887b65ca5ac369f267c",
|
||||
"version": "1.9",
|
||||
"build": "cc68b8863b",
|
||||
"manifestSha256": "62e5c3b2ec28c89ade9131f44854ff45b24873193036ce2e13b18d9b68a320cd",
|
||||
"filesSha256": "c018ba481831e23d3183a38ac47251f19754c7464baa5d85b47cea7a49fcfa95",
|
||||
"files": 11,
|
||||
"dir": "model/earth-geography"
|
||||
},
|
||||
{
|
||||
"id": "earth-revolution",
|
||||
"version": "1.6",
|
||||
"build": "bd57e6ed67",
|
||||
"manifestSha256": "2d05234ea0d4de5ac55b7a076085ccfbb94ed107cce2b2d40e56d45bc3b37f3e",
|
||||
"version": "1.7",
|
||||
"build": "53b7a0fbc3",
|
||||
"manifestSha256": "12a628168785740f67d7bafcce8467875f741b31a1b852643f28ed879972210f",
|
||||
"filesSha256": "4cd45b0324a77574a0da3a939c2a6faebc785c5a24cb50136d62a78a6ea2e9b1",
|
||||
"files": 7,
|
||||
"dir": "model/earth-revolution"
|
||||
},
|
||||
{
|
||||
"id": "earth-rotation",
|
||||
"version": "1.6",
|
||||
"build": "a79f660ec2",
|
||||
"manifestSha256": "cb4ec5f310e7f05235042180dfdb1d8904c37b2d67b06a174f55589eed1652b9",
|
||||
"version": "1.7",
|
||||
"build": "ecd52665f9",
|
||||
"manifestSha256": "3a492fe3220a3093569164735420d21470e971ca1c73f1ada73c5d91cdd651da",
|
||||
"filesSha256": "594b005a6a9f36cd0b5d4e4a7a0b1ab42d53c8032832545b71c3915493d56c8e",
|
||||
"files": 7,
|
||||
"dir": "model/earth-rotation"
|
||||
},
|
||||
{
|
||||
"id": "scale-calculator",
|
||||
"version": "1.5",
|
||||
"build": "ec6119e3f4",
|
||||
"manifestSha256": "54cf496553d11b704abfa06588ffccfed3f881a3b919d0e2304c18e157fd1f0a",
|
||||
"version": "1.6",
|
||||
"build": "105653737d",
|
||||
"manifestSha256": "c1d65815cfea866e4461b877d53f7af4a920dcb559e2b2453a6bcaa3e1650c66",
|
||||
"filesSha256": "732dd26406e0f1e836970499d7ea644def332ce909d7f8aa0a403bbe7337e604",
|
||||
"files": 6,
|
||||
"dir": "model/scale-calculator"
|
||||
|
||||
Reference in new issue
Block a user