-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
73 lines (58 loc) · 1.6 KB
/
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
GO_VERSION := $(shell go version 2>/dev/null)
HZ_VERSION := $(shell hz -v 2>/dev/null)
AIR_VERSION := $(shell air -v 2>/dev/null)
ENT_VERSION := $(shell go run -mod=mod entgo.io/ent/cmd/ent -h 2>/dev/null)
ENT_ROOT := ./ent
SHELL = /usr/bin/bash
.SHELLFLAGS = -ec
.ONESHELL:
.SILENT:
UTILS :=
UTILS += go
UTILS += protoc
include CheckUtils.mk
all: require prepare init dev
require:
# @echo "Checking the programs required for the build are installed..."
# @go version >/dev/null 2>&1 || (echo "ERROR: go is required."; exit 1)
# @protoc --version >/dev/null 2>&1 || (echo "ERROR: protoc is required. REF: https://github.com/protocolbuffers/protobuf/releases"; exit 1)
prepare:
@echo "Preparing..."
# hz -- code generation tool for HTTP framework in Go
ifdef HZ_VERSION
@echo "Found hz version $(HZ_VERSION)"
else
@echo Not found
go install github.com/cloudwego/hertz/cmd/hz@latest
endif
# air -- hot reload
ifdef AIR_VERSION
@echo "Found air version $(AIR_VERSION)"
else
@echo Not found
go install github.com/cosmtrek/air@latest
endif
# ent -- ORM code generation tool for Go
ifdef ENT_VERSION
@echo "Found air version $(ENT_VERSION)"
else
@echo Not found
go get -d entgo.io/ent/cmd/ent
endif
init:
@echo "Initializing..."
ifeq (,$(wildcard ./.hz))
hz new -mod take-a-rest
endif
dev:
air --build.cmd "go build -o bin/take-a-rest main.go router.go router_gen.go" --build.bin "./bin/take-a-rest"
api-gen:
hz update -I idl -idl $(idl)
model-gen:
go generate $(ENT_ROOT)
model-new:
go run -mod=mod entgo.io/ent/cmd/ent new $(name)
generate:
go generate ./...
build:
go build