From 77837e909ef4822b06c475160f9e8dcc693d3393 Mon Sep 17 00:00:00 2001 From: Martin Veldwijk Date: Fri, 28 Jul 2023 14:03:26 +0000 Subject: [PATCH] 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 Co-committed-by: Martin Veldwijk --- .gitignore | 2 +- Makefile | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.gitignore b/.gitignore index 10fad8b..9ebe256 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,5 @@ tea -/gitea-vet +/gitea-vet[.exe] .idea/ .history/ diff --git a/Makefile b/Makefile index 58ce385..381ca47 100644 --- a/Makefile +++ b/Makefile @@ -36,8 +36,10 @@ SOURCES ?= $(shell find . -name "*.go" -type f) # OS specific vars. ifeq ($(OS), Windows_NT) EXECUTABLE := tea.exe + VET_TOOL := gitea-vet.exe else EXECUTABLE := tea + VET_TOOL := gitea-vet ifneq ($(shell uname -s), OpenBSD) override BUILDMODE := -buildmode=pie endif @@ -61,7 +63,7 @@ vet: $(GO) vet $(PACKAGES) # Custom vet $(GO) build code.gitea.io/gitea-vet - $(GO) vet -vettool=gitea-vet $(PACKAGES) + $(GO) vet -vettool=$(VET_TOOL) $(PACKAGES) .PHONY: lint lint: install-lint-tools @@ -120,7 +122,7 @@ release: release-dirs install-release-tools release-os release-compress release- .PHONY: release-dirs release-dirs: - mkdir -p $(DIST)/binaries $(DIST)/release + mkdir -p $(DIST)/release .PHONY: release-os release-os: