Files

54 lines
1.0 KiB
Makefile

GO ?= go
CMD_DIR := ./cmd/server
ifeq ($(OS),Windows_NT)
EXE := .exe
else
EXE :=
endif
BINARY := lsp-gateway$(EXE)
CONFIG_FILE ?= ./config.json
.PHONY: help tidy fmt vet test build run run-config clean
help:
@echo "Targets:"
@echo " make build Build binary ($(BINARY))"
@echo " make run Run service with current env"
@echo " make run-config Run service with CONFIG_FILE=$(CONFIG_FILE)"
@echo " make test Run all tests"
@echo " make fmt Format Go code"
@echo " make vet Run go vet"
@echo " make tidy Sync go.mod/go.sum"
@echo " make clean Remove built binary"
tidy:
$(GO) mod tidy
fmt:
$(GO) fmt ./...
vet:
$(GO) vet ./...
test:
$(GO) test ./...
build:
$(GO) build -o $(BINARY) $(CMD_DIR)
run:
$(GO) run $(CMD_DIR)
run-config:
CONFIG_FILE=$(CONFIG_FILE) $(GO) run $(CMD_DIR)
clean:
-$(GO) clean
ifeq ($(OS),Windows_NT)
-powershell -NoProfile -Command "if (Test-Path '$(BINARY)') { Remove-Item -Force '$(BINARY)' }"
else
-rm -f $(BINARY)
endif