Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:hammer: Install goversioninfo for Windows builds

Daniel0a719d8b6bcc
diff --git a/.github/CONTRIBUTING.md b/.github/CONTRIBUTING.md
index a1fcd8b3ad..adf33d17f1 100644
--- a/.github/CONTRIBUTING.md
+++ b/.github/CONTRIBUTING.md
@@ -41,11 +41,15 @@ Note: In the development environment, the kernel process will not be automatical
1. Install the latest version of [golang](https://go.dev/)
2. Open CGO support, that is, configure the environment variable `CGO_ENABLED=1`
+3. On Windows, add the directory reported by `go env GOBIN` to `PATH`; if it is empty, add the `bin` subdirectory of `go env GOPATH`
### Desktop
* `cd kernel`
-* Windows: `go build -tags "fts5 sqlcipher" -o "../app/kernel/SiYuan-Kernel.exe"`
+* Windows:
+ * `go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest`
+ * `goversioninfo -platform-specific=true -icon=resource/icon.ico -manifest=resource/goversioninfo.exe.manifest`
+ * `go build -tags "fts5 sqlcipher" -o "../app/kernel/SiYuan-Kernel.exe"`
* Linux/macOS: `go build -tags "fts5 sqlcipher" -o "../app/kernel/SiYuan-Kernel"`
* `cd ../app/kernel`
* Windows: `./SiYuan-Kernel.exe serve --mode=dev`
diff --git a/.github/CONTRIBUTING.zh-CN.md b/.github/CONTRIBUTING.zh-CN.md
index 9bd25f32a2..38465996a7 100644
--- a/.github/CONTRIBUTING.zh-CN.md
+++ b/.github/CONTRIBUTING.zh-CN.md
@@ -41,11 +41,15 @@ NPM 镜像:
1. 安装最新版 [golang](https://go.dev/)
2. 打开 CGO 支持,即配置环境变量 `CGO_ENABLED=1`
+3. Windows 下需将 `go env GOBIN` 输出的目录添加到 `PATH`;如果输出为空,则添加 `go env GOPATH` 目录下的 `bin` 子目录
### 桌面端
* `cd kernel`
-* Windows: `go build -tags "fts5 sqlcipher" -o "../app/kernel/SiYuan-Kernel.exe"`
+* Windows:
+ * `go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest`
+ * `goversioninfo -platform-specific=true -icon=resource/icon.ico -manifest=resource/goversioninfo.exe.manifest`
+ * `go build -tags "fts5 sqlcipher" -o "../app/kernel/SiYuan-Kernel.exe"`
* Linux/macOS: `go build -tags "fts5 sqlcipher" -o "../app/kernel/SiYuan-Kernel"`
* `cd ../app/kernel`
* Windows: `./SiYuan-Kernel.exe serve --mode=dev`
diff --git a/scripts/win-build.bat b/scripts/win-build.bat
index 6b9e387845..08c0923b9a 100755
--- a/scripts/win-build.bat
+++ b/scripts/win-build.bat
@@ -101,9 +101,23 @@ set GOPROXY=https://mirrors.aliyun.com/goproxy/,https://goproxy.cn,direct
set CGO_ENABLED=1
set GOOS=windows
+echo Setting up goversioninfo
+go install github.com/josephspurrier/goversioninfo/cmd/goversioninfo@latest
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
+set "GO_BIN="
+for /f "delims=" %%I in ('go env GOBIN') do set "GO_BIN=%%I"
+if not defined GO_BIN (
+ for /f "tokens=1 delims=;" %%I in ('go env GOPATH') do set "GO_BIN=%%I\bin"
+)
+
@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
+"%GO_BIN%\goversioninfo.exe" -platform-specific=true -icon=resource/icon.ico -manifest=resource/goversioninfo.exe.manifest
+if errorlevel 1 (
+ exit /b %errorlevel%
+)
if defined BUILD_AMD64 (
echo.