Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.en.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ The video background below is a test frame. The HUD is drawn by the client. [Key

Follow the [step-by-step user guide (Chinese)](docs/getting-started/user-guide.md) to download the repository, install dependencies, build on Windows or Ubuntu, preview offline, run a simulated match, and connect to official match services.

On Windows, open Command Prompt by typing `cmd` in File Explorer’s address bar at the source root. Follow the [Windows steps](docs/getting-started/user-guide.md#windows-x64从-cmd-开始) for one-time setup. After the first successful build, use the same batch file to launch the client.
On Windows, open Command Prompt by typing `cmd` in File Explorer’s address bar at the source root. Follow the [Windows steps](docs/getting-started/user-guide.md#windows-x64从-cmd-开始) for one-time setup. After the first successful build, double-click `start-windows.bat` in the repository root to launch the client.

GitHub distributes source code, assets, the simulator, and build tools. The prebuilt executable and double-click launchers are distributed separately as part of the team's runtime kit. See the [runtime kit notes](scripts/portable/README.md) if you already have that package.

Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@

**从 GitHub 下载后,请按[客户端使用指南](docs/getting-started/user-guide.md)操作。** 指南覆盖依赖安装、Windows 和 Ubuntu 编译、离线预览、模拟比赛及官方赛事接入。

Windows 读者可以在源码文件夹的地址栏输入 `cmd`,然后按[Windows 步骤](docs/getting-started/user-guide.md#windows-x64从-cmd-开始)粘贴命令。首次编译完成后,可双击同一脚本启动。
Windows 源码编译按[四条 CMD 命令](docs/getting-started/user-guide.md#windows-x64从-cmd-开始)操作。首次编译成功后,双击根目录的 `start-windows.bat` 启动。

GitHub 提供源码、资源、模拟器和构建工具。战队交付包里的预编译程序和双击启动入口随完整运行包提供。已经拿到完整运行包的队员可以查阅[运行包说明](scripts/portable/README.md)。

Expand Down
29 changes: 14 additions & 15 deletions docs/getting-started/user-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,28 +11,27 @@ git clone https://github.com/SPR-Algorithm/SPR_Client_27.git
cd SPR_Client_27
```

仓库包含源码、地图等资源、模拟器及部分启动和打包工具。源码包没有编译好的 Windows 客户端、战队交付目录里的双击启动脚本、官方赛事引擎或 USB 驱动。手上已经有战队完整运行包的队员可以按[运行包说明](../../scripts/portable/README.md)直接运行。
仓库包含源码、地图等资源、模拟器及部分启动和打包工具。源码包里的 Windows 脚本用于编译和启动自定义客户端。预编译客户端、官方赛事引擎和 USB 驱动需要另行取得。手上已经有战队完整运行包的队员可以按[运行包说明](../../scripts/portable/README.md)直接运行。

## 2. 安装依赖并编译

### Windows x64,从 CMD 开始

如果你已经拿到了战队完整运行包,按[运行包说明](../../scripts/portable/README.md)双击启动。以下步骤用于从 GitHub 下载的源码,第一次做完后,日常可以直接双击源码里的启动脚本。
1. **装 MSYS2** — 从 [MSYS2 官网](https://www.msys2.org/)下载 Windows x64 安装器。保留默认路径 `C:\msys64`。
2. **打开 CMD** — 打开能看到 `CMakeLists.txt` 的源码文件夹,在资源管理器地址栏输入 `cmd`,回车。

1. **下载源码。** 在 GitHub 点 **Code → Download ZIP**,解压。打开能看到 `CMakeLists.txt` 那一级文件夹。
2. **安装 MSYS2。** 从 [MSYS2 官网](https://www.msys2.org/)下载安装器,安装路径保持默认的 `C:\msys64`。安装器结束时如果另开了终端,可以关掉。后面的命令都在普通 CMD 执行。
3. **在源码目录打开 CMD。** 在资源管理器点地址栏,输入 `cmd` 并回车。输入 `dir CMakeLists.txt`,能列出这个文件就说明目录正确。如果你已经打开了 CMD,也可以用 `cd /d "C:\dev\SPR_Client_27"`,把引号内的路径换成自己实际的解压目录。
4. **依次粘贴以下命令,每条跑完再执行下一条。** 第一条更新 MSYS2,第二条安装编译依赖,第三条编译并打开客户端。
下面每次**只复制左边的命令**,上一条成功后再跑下一条。

```cmd
scripts\portable\windows\start-from-source.bat update
scripts\portable\windows\start-from-source.bat setup
scripts\portable\windows\start-from-source.bat build
```

如果更新提示关闭 MSYS2 进程,按提示结束该次更新,再在 CMD 里重新运行 `update`,直到更新结束后再执行 `setup`。软件包装好后,下次只想打开界面时,双击 [start-from-source.bat](../../scripts/portable/windows/start-from-source.bat) 即可。源码更新后用 `build` 重新编译。脚本生成的程序在 `build/windows/RoboMasterClient2025.exe`。

MSYS2 装在其他位置时,在当前 CMD 先执行 `set "MSYS2_ROOT=D:\msys64"`,把路径换成实际目录,然后在同一窗口执行上述命令。MSYS2 软件包版本随更新变化。项目此前验证的 Windows 编译环境为 MinGW x64 与 Qt 6.8.3。
| CMD 命令 | 这步干什么 |
| --- | --- |
| `start-windows.bat check` | 检查 MSYS2。看到 `MSYS2 found` 再继续。 |
| `start-windows.bat update` | 更新 MSYS2。遇到 `[Y/n]` 输入 `Y` 回车。 |
| `start-windows.bat setup` | 下载编译器、Qt 等依赖。遇到 `[Y/n]` 输入 `Y` 回车。看到 `Build dependencies ready` 再继续。 |
| `start-windows.bat build` | 编译并打开客户端。看到客户端界面就完成了。 |

- **提示 `MSYS2 not found`** — 先安装 MSYS2。装在其他盘时,先执行 `set "MSYS2_ROOT=D:\msys64"`(换成实际路径),再跑 `check`。
- **更新提示要关闭所有 MSYS2 进程** — 输入 `Y` 回车,它会结束这轮更新。回到 CMD 再跑一次 `update`。CMD 如果也关了,就从文件夹地址栏重新打开。更新结束后再跑 `setup`。
- **以后怎么打开** — 默认安装路径直接双击源码根目录的 [start-windows.bat](../../start-windows.bat)。用自定义安装路径时,从设好 `MSYS2_ROOT` 的 CMD 执行 `start-windows.bat`。改了源码就再跑 `build`。

### Ubuntu 24.04 图形桌面

Expand Down
36 changes: 26 additions & 10 deletions scripts/portable/windows/start-from-source.bat
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,37 @@ if not defined MSYS2_ROOT set "MSYS2_ROOT=C:\msys64"
set "BASH=%MSYS2_ROOT%\usr\bin\bash.exe"
set "TOOLCHAIN=%MSYS2_ROOT%\mingw64"
if not exist "%BASH%" goto missing_msys2
if not exist "%MSYS2_ROOT%\usr\bin\pacman.exe" goto missing_msys2
set "MSYSTEM=MINGW64"
set "CHERE_INVOKING=1"

if /i "%~1"=="check" goto check
if /i "%~1"=="update" goto update
if /i "%~1"=="setup" goto setup
if /i "%~1"=="build" goto build
if not "%~1"=="" goto usage
if not exist "%~dp0..\..\..\build\windows\RoboMasterClient2025.exe" goto build
goto launch

:check
echo MSYS2 found at "%MSYS2_ROOT%".
exit /b 0

:update
"%BASH%" --login -c "pacman -Syu"
echo Updating MSYS2. If it asks to close MSYS2 processes, rerun update after it exits.
"%BASH%" --login -c "pacman -Syu && echo MSYS2 update command finished."
exit /b %errorlevel%

:setup
"%BASH%" --login -c "pacman -S --needed mingw-w64-x86_64-{gcc,cmake,ninja,pkgconf,qt6-base,qt6-declarative,qt6-multimedia,qt6-serialport,qt6-svg,abseil-cpp,protobuf,paho.mqtt.c,ffmpeg}"
exit /b %errorlevel%
echo Installing the compiler, Qt and other build dependencies.
set "PACKAGES=mingw-w64-x86_64-{gcc,cmake,ninja,pkgconf,qt6-base,qt6-declarative,qt6-multimedia,qt6-serialport,qt6-svg,abseil-cpp,protobuf,paho.mqtt.c,ffmpeg}"
"%BASH%" --login -c "pacman -S --needed %PACKAGES% && pacman -Q %PACKAGES% > /dev/null"
if errorlevel 1 exit /b 1
echo Build dependencies ready.
exit /b 0

:build
echo Building the SPR client.
if not exist "%TOOLCHAIN%\bin\cmake.exe" goto missing_deps
set "PATH=%TOOLCHAIN%\bin;%PATH%"
pushd "%~dp0..\..\.." || goto failed
Expand All @@ -36,31 +48,35 @@ if errorlevel 1 goto failed_in_dir
popd

:launch
echo Opening the SPR client.
set "PATH=%TOOLCHAIN%\bin;%PATH%"
pushd "%~dp0..\..\..\build\windows" || goto failed
start "" "RoboMasterClient2025.exe"
if not exist "RoboMasterClient2025.exe" goto failed_in_dir
start "" ".\RoboMasterClient2025.exe"
if errorlevel 1 goto failed_in_dir
popd
exit /b 0

:missing_msys2
echo MSYS2 was not found at "%MSYS2_ROOT%".
echo Install MSYS2 from https://www.msys2.org/ or set MSYS2_ROOT to its install directory.
echo MSYS2 not found at "%MSYS2_ROOT%".
echo This command ran before MSYS2 was installed or the script was given the wrong path.
echo Install MSYS2 from https://www.msys2.org/ then run: start-windows.bat check
echo For a custom installation directory, set MSYS2_ROOT in CMD and rerun check.
goto show_guide

:missing_deps
echo Build dependencies are missing. Run this script with update, then setup, from CMD.
echo Build dependencies are missing. Run start-windows.bat setup in CMD, then repeat build.
goto show_guide

:usage
echo Usage: start-from-source.bat [update^|setup^|build]
echo Usage: start-windows.bat [check^|update^|setup^|build]
exit /b 2

:failed_in_dir
popd
:failed
echo SPR client build or launch failed. See the error above.
:show_guide
echo Guide: docs\getting-started\user-guide.md
pause
echo Guide: "%~dp0..\..\..\docs\getting-started\user-guide.md"
if "%~1"=="" pause
exit /b 1
3 changes: 3 additions & 0 deletions start-windows.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
@echo off
call "%~dp0scripts\portable\windows\start-from-source.bat" %*
exit /b %errorlevel%
1 change: 1 addition & 0 deletions tools/release/public_paths.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
"resources.qrc",
"run_docker.sh",
"run_test.sh",
"start-windows.bat",
"videoplayer.sh"
]
}