35 lines
746 B
Makefile
35 lines
746 B
Makefile
#!/usr/bin/env make -f
|
|
OUTPUT := ./bin/
|
|
VERSION := $(shell git describe --tags 2>/dev/null || echo "git/$(shell git rev-parse --short HEAD 2>/dev/null || echo 'none')")
|
|
CGO_ENABLED := 0
|
|
BUILDINFO_CLASS := devops.lty.name/luo/chatai/internal/config
|
|
LDFLAGS = -s -w
|
|
LDFLAGS += -X "$(BUILDINFO_CLASS).BuildVersion=$(VERSION)"
|
|
LDFLAGS += -X "$(BUILDINFO_CLASS).BuildTime=$(shell date '+%Y-%m-%d %H:%M:%S %Z')"
|
|
LDFLAGS += -X "$(BUILDINFO_CLASS).BuildMode=release"
|
|
|
|
|
|
.PHONY: build_debug
|
|
build_debug: LDFLAGS =
|
|
build_debug: build
|
|
|
|
|
|
.PHONY: build
|
|
build: clean install
|
|
CGO_ENABLED=$(CGO_ENABLED) go build -ldflags '$(LDFLAGS)' -o $(OUTPUT)
|
|
|
|
|
|
.PHONY: run
|
|
run: install
|
|
go run .
|
|
|
|
|
|
.PHONY: install
|
|
install:
|
|
go get
|
|
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
rm -rvf $(OUTPUT)
|