Fix Makefile for Windows builds (#566)

Fixes #564 (/gitea/tea/issues/564) by applying minor changes to the Makefile.
- Defines a `BINEXT` variable which holds a file name extension (.exe for Windows, empty otherwise)
- Replaces uses of `$(EXECUTABLE)` with `tea$(EXECUTABLE)`
- appends `$(BINEXT)` to the custom vet tool flag

Besides that I made two minor changes
- Add `[.exe]` to the ignore rule for gitea-vet, so it also ignores the binary when built on Windows hosts
- Removed `$(DIST)/binaries` from release-dirs as this is not being called anywhere else

I've tested almost all `make` tasks to work on Windows. The only one I haven't run is the docker build.

WIP tag is because I still have to test it on Linux, will do so in a bit. I also asked for some discussion on the original issue, which I'd like to do before blindly asking to merge in changes

Reviewed-on: https://gitea.com/gitea/tea/pulls/566
Co-authored-by: Martin Veldwijk <riven@tae.moe>
Co-committed-by: Martin Veldwijk <riven@tae.moe>
This commit is contained in:
Martin Veldwijk 2023-07-28 14:03:26 +00:00 committed by John Olheiser
parent 5582f92df4
commit 77837e909e
2 changed files with 5 additions and 3 deletions

2
.gitignore vendored
View File

@ -1,5 +1,5 @@
tea tea
/gitea-vet /gitea-vet[.exe]
.idea/ .idea/
.history/ .history/

View File

@ -36,8 +36,10 @@ SOURCES ?= $(shell find . -name "*.go" -type f)
# OS specific vars. # OS specific vars.
ifeq ($(OS), Windows_NT) ifeq ($(OS), Windows_NT)
EXECUTABLE := tea.exe EXECUTABLE := tea.exe
VET_TOOL := gitea-vet.exe
else else
EXECUTABLE := tea EXECUTABLE := tea
VET_TOOL := gitea-vet
ifneq ($(shell uname -s), OpenBSD) ifneq ($(shell uname -s), OpenBSD)
override BUILDMODE := -buildmode=pie override BUILDMODE := -buildmode=pie
endif endif
@ -61,7 +63,7 @@ vet:
$(GO) vet $(PACKAGES) $(GO) vet $(PACKAGES)
# Custom vet # Custom vet
$(GO) build code.gitea.io/gitea-vet $(GO) build code.gitea.io/gitea-vet
$(GO) vet -vettool=gitea-vet $(PACKAGES) $(GO) vet -vettool=$(VET_TOOL) $(PACKAGES)
.PHONY: lint .PHONY: lint
lint: install-lint-tools lint: install-lint-tools
@ -120,7 +122,7 @@ release: release-dirs install-release-tools release-os release-compress release-
.PHONY: release-dirs .PHONY: release-dirs
release-dirs: release-dirs:
mkdir -p $(DIST)/binaries $(DIST)/release mkdir -p $(DIST)/release
.PHONY: release-os .PHONY: release-os
release-os: release-os: