-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathMakefile
36 lines (26 loc) · 976 Bytes
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
BINARY := cloudsdale
PACKAGE := github.com/elabosak233/cloudsdale
GOOS := $(shell go env GOOS)
GOARCH := $(shell go env GOARCH)
export TERM := xterm-256color
export CGO_ENABLED := 1
GIT_TAG := $(shell git describe --tags --always)
GIT_COMMIT := $(shell git rev-parse HEAD)
GIT_BRANCH := $(shell git rev-parse --abbrev-ref HEAD)
LDFLAGS := -X $(PACKAGE)/internal/utils.GitTag=$(GIT_TAG) -X $(PACKAGE)/internal/utils.GitCommitID=$(GIT_COMMIT) -X $(PACKAGE)/internal/utils.GitBranch=$(GIT_BRANCH)
.PHONY: all build run clean swag
all: build
clean:
@rm -rf ./build
swag:
@echo Generating swagger docs...
swag init -g ./cmd/cloudsdale/main.go -o ./api
@echo Swagger docs generated.
build: swag
@echo Building $(PACKAGE)...
@go build -ldflags "-linkmode external -w -s $(LDFLAGS)" -o ./build/$(BINARY) $(PACKAGE)/cmd/cloudsdale
@echo Build finished.
run: swag
@echo Running $(PACKAGE)...
go run -ldflags "$(LDFLAGS)" $(PACKAGE)/cmd/cloudsdale
@echo Run finished.