Skip to content

Commit a847662

Browse files
committed
build(go-backend): make Go backend build optional and verify in CI
The Go backend was not wired into the root build or CI, and go-backend/build.bat hard-failed because the rime-frost submodule was previously removed. - Allow go-backend/build.bat to succeed without bundled rime/data (warning and falling back to plum/Weasel), and strip packaged *.go files across all input_methods subdirectories. - Add an opt-in --with-go flag (or PIME_BUILD_GO=1) to build.bat, keeping Go backend disabled by default so contributors do not need Go installed. - Document Go as an optional requirement and the opt-in build flag in README.md. - Add a standalone go-backend CI job in .github/workflows/ci.yaml to run go build and go test on pushes and pull requests. Fully generated by Google Antigravity (Gemini 4 Neon) without human intervention.
1 parent c890175 commit a847662

4 files changed

Lines changed: 69 additions & 15 deletions

File tree

‎.github/workflows/ci.yaml‎

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,23 @@ jobs:
1919
signing-policy: test-signing
2020
secrets: inherit
2121

22+
go-backend:
23+
if: ${{ !startsWith(github.ref, 'refs/tags/') }}
24+
runs-on: windows-2025
25+
steps:
26+
- uses: actions/checkout@v6
27+
28+
- name: Set up Go
29+
uses: actions/setup-go@v5
30+
with:
31+
go-version-file: go-backend/go.mod
32+
33+
- name: Build and test go-backend
34+
working-directory: go-backend
35+
run: |
36+
go build -v ./...
37+
go test -count=1 -skip TestRealRime ./...
38+
2239
release:
2340
if: startsWith(github.ref, 'refs/tags/')
2441
uses: ./.github/workflows/build-and-sign.yaml

‎README.md‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Contributions using AI coding tools are welcomed! However, to ensure code qualit
2222
* [git](https://git-scm.com/)
2323
* [Node.js](https://nodejs.org/) with npm (builds the bundled JavaScript input methods)
2424
* [NSIS](https://nsis.sourceforge.io/) 3.x (only needed to build the installer)
25+
* [Go](https://go.dev/) >= 1.21 (optional; only needed when building the experimental Go backend)
2526

2627
## How to Build
2728
* Get source from GitHub.
@@ -37,6 +38,12 @@ Contributions using AI coding tools are welcomed! However, to ensure code qualit
3738

3839
* Use `build.bat` to build everything. It builds the launcher, the x86, x64 and ARM64 text service DLLs, and bundles the JavaScript input methods.
3940

41+
The experimental Go backend (`go-backend\`) is disabled by default and is not packaged in the installer. To include it in the build (requires Go >= 1.21 in `PATH`):
42+
43+
build.bat --with-go
44+
45+
You can also enable it via the environment variable `PIME_BUILD_GO=1`, or run `go-backend\build.bat` directly.
46+
4047
* To build by hand, use the same generator and policy flag as `build.bat`:
4148

4249
cmake . -Bbuild -G "Visual Studio 18 2026" -A Win32 -DCMAKE_POLICY_VERSION_MINIMUM=3.5

‎build.bat‎

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,22 @@
1+
@echo off
2+
setlocal
3+
4+
set "BUILD_GO=0"
5+
if /I "%PIME_BUILD_GO%"=="1" set "BUILD_GO=1"
6+
if /I "%PIME_BUILD_GO%"=="true" set "BUILD_GO=1"
7+
8+
:parse_args
9+
if "%~1"=="" goto :args_done
10+
if /I "%~1"=="--with-go" (
11+
set "BUILD_GO=1"
12+
shift
13+
goto :parse_args
14+
)
15+
echo Unknown option: %~1
16+
echo Usage: build.bat [--with-go]
17+
exit /b 1
18+
19+
:args_done
120
cmake . -Bbuild -G "Visual Studio 18 2026" -A Win32 -DCMAKE_POLICY_VERSION_MINIMUM=3.5
221
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
322
cmake --build build --config Release
@@ -67,4 +86,10 @@ cmd /C npm run build
6786
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
6887
cd ..\..\..
6988

89+
if "%BUILD_GO%"=="1" (
90+
echo "Start building go-backend"
91+
call go-backend\build.bat
92+
if %ERRORLEVEL% neq 0 exit /b %ERRORLEVEL%
93+
)
94+
7095

‎go-backend/build.bat‎

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,9 +56,8 @@ if errorlevel 1 (
5656
echo [INFO] Output directory: "%PACKAGE_DIR%"
5757

5858
if not exist "%RIME_DATA_DIR%\default.yaml" (
59-
echo [ERROR] Missing Go Rime shared data: "%RIME_DATA_DIR%"
60-
echo [ERROR] Initialize the submodule from https://github.com/gaboolic/rime-frost
61-
exit /b 1
59+
echo [WARN] Bundled Go Rime shared data not found: "%RIME_DATA_DIR%"
60+
echo [WARN] Continuing without bundled rime-frost data; will fall back to plum or Weasel if available.
6261
)
6362

6463
echo.
@@ -137,15 +136,17 @@ if exist "%PACKAGE_DIR%\input_methods\rime\brise" (
137136
echo [INFO] Removed rime\brise from package output
138137
)
139138

140-
if exist "%PACKAGE_DIR%\input_methods\rime\*.go" (
141-
del /q "%PACKAGE_DIR%\input_methods\rime\*.go" >nul
142-
if errorlevel 1 (
143-
echo [ERROR] Failed to remove packaged Go source files
144-
popd
145-
exit /b 1
139+
for /d %%D in ("%PACKAGE_DIR%\input_methods\*") do (
140+
if exist "%%~fD\*.go" (
141+
del /q "%%~fD\*.go" >nul
142+
if errorlevel 1 (
143+
echo [ERROR] Failed to remove packaged Go source files from "%%~fD"
144+
popd
145+
exit /b 1
146+
)
146147
)
147-
echo [INFO] Removed packaged Go source files
148148
)
149+
echo [INFO] Removed packaged Go source files
149150

150151
if exist "%PACKAGE_DIR%\input_methods\rime\rime.dll.bak-32bit" (
151152
del /q "%PACKAGE_DIR%\input_methods\rime\rime.dll.bak-32bit" >nul
@@ -221,11 +222,15 @@ if errorlevel 1 (
221222
exit /b 1
222223
)
223224

224-
echo [INFO] Copying bundled rime-frost submodule data ...
225-
xcopy "%RIME_DATA_DIR%" "%PACKAGE_RIME_DATA_DIR%\" /E /I /Y >nul
226-
if errorlevel 1 (
227-
echo [ERROR] Failed to copy bundled Rime data from "%RIME_DATA_DIR%"
228-
exit /b 1
225+
if exist "%RIME_DATA_DIR%\default.yaml" (
226+
echo [INFO] Copying bundled rime-frost submodule data ...
227+
xcopy "%RIME_DATA_DIR%" "%PACKAGE_RIME_DATA_DIR%\" /E /I /Y >nul
228+
if errorlevel 1 (
229+
echo [ERROR] Failed to copy bundled Rime data from "%RIME_DATA_DIR%"
230+
exit /b 1
231+
)
232+
) else (
233+
echo [WARN] Skipping bundled Rime data copy; "%RIME_DATA_DIR%\default.yaml" not found.
229234
)
230235

231236
set "PLUM_DATA_PREPARED=0"

0 commit comments

Comments
 (0)