Skip to content

Commit 2020eb5

Browse files
committed
Build dmr.exe on Windows in build-dmr target
The build-dmr Makefile target always built a binary named "dmr", which is unusable on Windows because the OS requires a .exe suffix to execute it directly. Detect Windows via the built-in $(OS) variable and use a DMR_EXE variable for the output filename, so the target produces dmr.exe on Windows and dmr everywhere else. This avoids shelling out to "go env GOEXE" on every invocation, which adds overhead and can fail if go is not on the PATH. Reuse DMR_EXE in the clean target instead of hardcoding both dmr and dmr.exe so cleanup stays in sync with the build output. Update the README to match.
1 parent d62a635 commit 2020eb5

2 files changed

Lines changed: 9 additions & 3 deletions

File tree

Makefile

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,17 @@ DMR_LDFLAGS := -s -w \
6565
-X main.Version=$(DMR_VERSION) \
6666
-X github.com/docker/model-runner/cmd/cli/desktop.Version=$(DMR_VERSION)
6767

68+
# Add .exe on windows, nothing elsewhere
69+
DMR_EXE := dmr
70+
ifeq ($(OS),Windows_NT)
71+
DMR_EXE := dmr.exe
72+
endif
73+
6874
# build-dmr builds a native dmr binary. dmr has no cgo dependencies, so
6975
# CGO_ENABLED=0 keeps the binary statically linked and trivial to
7076
# cross-compile (see build-dmr-cross).
7177
build-dmr:
72-
CGO_ENABLED=0 go build -ldflags="$(DMR_LDFLAGS)" -o dmr ./cmd/dmr
78+
CGO_ENABLED=0 go build -ldflags="$(DMR_LDFLAGS)" -o $(DMR_EXE) ./cmd/dmr
7379

7480
# build-dmr-cross builds standalone dmr binaries for every platform we
7581
# publish packages for (see packaging/), into dist/dmr/<os>-<arch>/dmr.
@@ -108,7 +114,7 @@ run: build
108114
# Clean build artifacts
109115
clean:
110116
rm -f $(APP_NAME)
111-
rm -f dmr
117+
rm -f $(DMR_EXE)
112118
rm -f model-runner.sock
113119

114120
# Run tests

cmd/dmr/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ dmr rm ai/gemma3 # remove a local model
3737
## Building
3838

3939
```
40-
make build-dmr # native build, output ./dmr
40+
make build-dmr # native build, output ./dmr (or dmr.exe on Windows)
4141
make build-dmr-cross # cross-compile every published target into dist/dmr/<os>-<arch>/
4242
```
4343

0 commit comments

Comments
 (0)