fix(make): append .exe to the dev binary on Windows (#1573)

* fix(make): append .exe to the dev binary on Windows

make build on Windows wrote dist/opencodereview without an extension, which cmd and PowerShell cannot launch. Build, run, and help now use a .exe extension when OS is Windows_NT.

* docs: name the Windows .exe output of make build
This commit is contained in:
Joseph Clauson authored and GitHub committed 2026-09-29 14:35:43 +08:00
1 parent f93ff155dd
commit 998604bcb8
16 files changed
+36 -28

No files matched your search

+4 -3
View File
@@ -7,6 +7,7 @@
BINARY_NAME := opencodereview
GO := go
DIST_DIR := ./dist
EXE := $(if $(filter Windows_NT,$(OS)),.exe,)
# Version info — use git tag if available, fallback to short commit hash
GIT_TAG := $(shell git describe --tags --abbrev=0 2>/dev/null || echo "")
@@ -30,7 +31,7 @@ endef
# ── Development targets ──────────────────────────────────────────────────────
build:
$(GO) build -ldflags "$(LD_FLAGS)" -o $(DIST_DIR)/$(BINARY_NAME) ./cmd/opencodereview
$(GO) build -ldflags "$(LD_FLAGS)" -o $(DIST_DIR)/$(BINARY_NAME)$(EXE) ./cmd/opencodereview
# No node_modules filter is needed for the docs site: pages/go.mod puts it in a
# module of its own, so `go list ./...` skips that subtree entirely -- see that
@@ -59,10 +60,10 @@ clean:
rm -rf $(DIST_DIR) coverage.out
run: build
$(DIST_DIR)/$(BINARY_NAME) --staged
$(DIST_DIR)/$(BINARY_NAME)$(EXE) --staged
help: build
$(DIST_DIR)/$(BINARY_NAME) -h
$(DIST_DIR)/$(BINARY_NAME)$(EXE) -h
fmt:
gofmt -s -w .
+4 -3
View File
@@ -40,7 +40,7 @@ git clone https://github.com/<your-username>/open-code-review.git
cd open-code-review
git remote add upstream https://github.com/alibaba/open-code-review.git
make build # writes dist/opencodereview
make build # writes dist/opencodereview (dist/opencodereview.exe on Windows)
make test # LC_ALL=C go test -v -race -count=1 ./...
```
@@ -50,7 +50,8 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
### Running your local build
```bash
./dist/opencodereview review --preview
./dist/opencodereview review --preview # macOS / Linux
.\dist\opencodereview.exe review --preview # Windows (PowerShell / cmd)
```
For convenience, drop a symlink at `~/bin/ocr-dev` pointing at
@@ -60,7 +61,7 @@ For convenience, drop a symlink at `~/bin/ocr-dev` pointing at
| Target | What it does |
|---|---|
| `make build` | Build for current platform → `dist/opencodereview`. |
| `make build` | Build for current platform → `dist/opencodereview` (`dist/opencodereview.exe` on Windows). |
| `make build-darwin-amd64` | Cross-compile for macOS Intel. |
| `make build-darwin-arm64` | Cross-compile for macOS Apple Silicon. |
| `make build-linux-amd64` | Cross-compile for Linux x86_64. |
+2 -1
View File
@@ -400,7 +400,8 @@ need new providers; an issue for Hg support is open
The static binary published in releases is named after the project
(`opencodereview`); the NPM wrapper installs it as `ocr` for
ergonomics. If you build from source you get `dist/opencodereview` —
ergonomics. If you build from source you get `dist/opencodereview`
(`dist/opencodereview.exe` on Windows) —
copy it to `ocr` on your `$PATH`.
### How do I uninstall?
+1 -1
View File
@@ -172,7 +172,7 @@ without a pre-built binary.
```bash
git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build # writes dist/opencodereview
make build # writes dist/opencodereview (dist/opencodereview.exe on Windows)
sudo cp dist/opencodereview /usr/local/bin/ocr
```
+4 -3
View File
@@ -37,7 +37,7 @@ git clone https://github.com/<your-username>/open-code-review.git
cd open-code-review
git remote add upstream https://github.com/alibaba/open-code-review.git
make build # dist/opencodereview を書き出す
make build # dist/opencodereview を書き出す(Windows では dist/opencodereview.exe)
make test # LC_ALL=C go test -v -race -count=1 ./...
```
@@ -46,7 +46,8 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
### ローカルビルドの実行
```bash
./dist/opencodereview review --preview
./dist/opencodereview review --preview # macOS / Linux
.\dist\opencodereview.exe review --preview # Windows (PowerShell / cmd)
```
便宜のため、`dist/opencodereview` を指すシンボリックリンクを `~/bin/ocr-dev` に置いておくと、
@@ -56,7 +57,7 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
| Target | 作用 |
|---|---|
| `make build` | 現在のプラットフォーム向けにビルド → `dist/opencodereview`。 |
| `make build` | 現在のプラットフォーム向けにビルド → `dist/opencodereview`(Windows では `dist/opencodereview.exe`)。 |
| `make build-darwin-amd64` | macOS Intel 向けのクロスコンパイル。 |
| `make build-darwin-arm64` | macOS Apple Silicon 向けのクロスコンパイル。 |
| `make build-linux-amd64` | Linux x86_64 向けのクロスコンパイル。 |
+1 -1
View File
@@ -355,7 +355,7 @@ provider が必要です。Hg サポートの issue は[こちら](https://githu
### なぜバイナリは `opencodereview` なのに CLI は `ocr` なのか?
release で配布される静的バイナリはプロジェクト名(`opencodereview`)を持ちます。NPM wrapper は
使いやすさのため `ocr` としてインストールされます。ソースからビルドすると `dist/opencodereview` が
使いやすさのため `ocr` としてインストールされます。ソースからビルドすると `dist/opencodereview`(Windows では `dist/opencodereview.exe`)が
得られます——`$PATH` 上の `ocr` としてコピーしてください。
### アンインストールするには?
+1 -1
View File
@@ -156,7 +156,7 @@ OCR 自体を変更する場合、またはプリコンパイル済みバイナ
```bash
git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build # dist/opencodereview を生成
make build # dist/opencodereview を生成(Windows では dist/opencodereview.exe)
sudo cp dist/opencodereview /usr/local/bin/ocr
```
+4 -3
View File
@@ -40,7 +40,7 @@ git clone https://github.com/<your-username>/open-code-review.git
cd open-code-review
git remote add upstream https://github.com/alibaba/open-code-review.git
make build # writes dist/opencodereview
make build # writes dist/opencodereview (dist/opencodereview.exe on Windows)
make test # LC_ALL=C go test -v -race -count=1 ./...
```
@@ -50,7 +50,8 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
### 로컬 빌드 실행하기 {#running-your-local-build}
```bash
./dist/opencodereview review --preview
./dist/opencodereview review --preview # macOS / Linux
.\dist\opencodereview.exe review --preview # Windows (PowerShell / cmd)
```
편하게 쓰려면 `dist/opencodereview`를 가리키는 심볼릭 링크를 `~/bin/ocr-dev`에
@@ -60,7 +61,7 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
| 타깃 | 하는 일 |
|---|---|
| `make build` | 현재 플랫폼용으로 빌드해 `dist/opencodereview`에 씁니다. |
| `make build` | 현재 플랫폼용으로 빌드해 `dist/opencodereview`(Windows에서는 `dist/opencodereview.exe`)에 씁니다. |
| `make build-darwin-amd64` | macOS Intel용 크로스 컴파일. |
| `make build-darwin-arm64` | macOS Apple Silicon용 크로스 컴파일. |
| `make build-linux-amd64` | Linux x86_64용 크로스 컴파일. |
+1 -1
View File
@@ -378,7 +378,7 @@ JSONL과 규칙 파일은 로컬에만 있습니다.
릴리스에 올라가는 정적 바이너리는 프로젝트 이름을 따 `opencodereview`이고, NPM
래퍼는 쓰기 편하도록 `ocr`이라는 이름으로 설치합니다. 소스에서 빌드하면
`dist/opencodereview`가 나옵니다. `$PATH`에 `ocr`로 복사해 두세요.
`dist/opencodereview`(Windows에서는 `dist/opencodereview.exe`)가 나옵니다. `$PATH`에 `ocr`로 복사해 두세요.
### 어떻게 제거하나요? {#how-do-i-uninstall}
+1 -1
View File
@@ -144,7 +144,7 @@ OCR 자체를 수정하거나 사전 빌드 바이너리가 없는 플랫폼에
```bash
git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build # dist/opencodereview 생성
make build # dist/opencodereview 생성 (Windows에서는 dist/opencodereview.exe)
sudo cp dist/opencodereview /usr/local/bin/ocr
```
+4 -3
View File
@@ -41,7 +41,7 @@ git clone https://github.com/<your-username>/open-code-review.git
cd open-code-review
git remote add upstream https://github.com/alibaba/open-code-review.git
make build # writes dist/opencodereview
make build # writes dist/opencodereview (dist/opencodereview.exe on Windows)
make test # LC_ALL=C go test -v -race -count=1 ./...
```
@@ -51,7 +51,8 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
### Запуск локальной сборки
```bash
./dist/opencodereview review --preview
./dist/opencodereview review --preview # macOS / Linux
.\dist\opencodereview.exe review --preview # Windows (PowerShell / cmd)
```
Для удобства создайте в `~/bin/ocr-dev` символическую ссылку на
@@ -61,7 +62,7 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
| Цель | Назначение |
|---|---|
| `make build` | Собирает бинарный файл для текущей платформы → `dist/opencodereview`. |
| `make build` | Собирает бинарный файл для текущей платформы → `dist/opencodereview` (`dist/opencodereview.exe` в Windows). |
| `make build-darwin-amd64` | Кросс-компиляция для macOS Intel. |
| `make build-darwin-arm64` | Кросс-компиляция для macOS Apple Silicon. |
| `make build-linux-amd64` | Кросс-компиляция для Linux x86_64. |
+2 -1
View File
@@ -407,7 +407,8 @@ OCR отправляет ваши **diff** (и необязательные фр
Статический бинарный файл, публикуемый в релизах, назван по имени проекта
(`opencodereview`); обёртка NPM устанавливает его как `ocr` для удобства. При
сборке из исходного кода получается `dist/opencodereview` — скопируйте его как
сборке из исходного кода получается `dist/opencodereview`
(`dist/opencodereview.exe` в Windows) — скопируйте его как
`ocr` в каталог из `$PATH`.
### Как удалить OCR?
+1 -1
View File
@@ -157,7 +157,7 @@ shasum -a 256 -c sha256sum.txt --ignore-missing
```bash
git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build # пишет dist/opencodereview
make build # пишет dist/opencodereview (dist/opencodereview.exe в Windows)
sudo cp dist/opencodereview /usr/local/bin/ocr
```
+4 -3
View File
@@ -37,7 +37,7 @@ git clone https://github.com/<your-username>/open-code-review.git
cd open-code-review
git remote add upstream https://github.com/alibaba/open-code-review.git
make build # writes dist/opencodereview
make build # writes dist/opencodereview (dist/opencodereview.exe on Windows)
make test # LC_ALL=C go test -v -race -count=1 ./...
```
@@ -46,7 +46,8 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
### 运行本地构建
```bash
./dist/opencodereview review --preview
./dist/opencodereview review --preview # macOS / Linux
.\dist\opencodereview.exe review --preview # Windows (PowerShell / cmd)
```
为方便起见,在 `~/bin/ocr-dev` 放一个指向 `dist/opencodereview` 的符号链接,即可在
@@ -56,7 +57,7 @@ make test # LC_ALL=C go test -v -race -count=1 ./...
| Target | 作用 |
|---|---|
| `make build` | 为当前平台构建 → `dist/opencodereview`。 |
| `make build` | 为当前平台构建 → `dist/opencodereview`(Windows 上是 `dist/opencodereview.exe`)。 |
| `make build-darwin-amd64` | 交叉编译 macOS Intel。 |
| `make build-darwin-arm64` | 交叉编译 macOS Apple Silicon。 |
| `make build-linux-amd64` | 交叉编译 Linux x86_64。 |
+1 -1
View File
@@ -325,7 +325,7 @@ issue 已在[此](https://github.com/alibaba/open-code-review/issues)开放。
### 为什么二进制叫 `opencodereview` 而 CLI 是 `ocr`?
release 中发布的静态二进制以项目命名(`opencodereview`);NPM wrapper 为了便于使用而安装为 `ocr`。从源码构建得到 `dist/opencodereview`——复制为 `$PATH` 上的
release 中发布的静态二进制以项目命名(`opencodereview`);NPM wrapper 为了便于使用而安装为 `ocr`。从源码构建得到 `dist/opencodereview`(Windows 上是 `dist/opencodereview.exe`)——复制为 `$PATH` 上的
`ocr`。
### 如何卸载?
+1 -1
View File
@@ -153,7 +153,7 @@ shasum -a 256 -c sha256sum.txt --ignore-missing
```bash
git clone https://github.com/alibaba/open-code-review.git
cd open-code-review
make build # 产出 dist/opencodereview
make build # 产出 dist/opencodereview(Windows 上是 dist/opencodereview.exe)
sudo cp dist/opencodereview /usr/local/bin/ocr
```