Skip to content

Commit afa2418

Browse files
authored
Improve Makefile (#223)
1 parent f1b7a8c commit afa2418

File tree

1 file changed

+26
-11
lines changed

1 file changed

+26
-11
lines changed

Makefile

Lines changed: 26 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,51 @@
11
GO_SOURCES=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
22
FRONTEND_BUILD_DIR = pkg/web/build
33

4-
# Builds frontend and backend Go code.
5-
build:
4+
.PHONY: build
5+
build: build-web build-go # Builds frontend and backend
6+
7+
.PHONY: build-web
8+
build-web: # Build frontend assets
69
rm -rf $(FRONTEND_BUILD_DIR)
710
export PUBLIC_BACKEND_ENDPOINT="" && \
811
export PUBLIC_BACKEND_WS_ENDPOINT="" && \
912
cd pkg/web && npm install && npm run build
10-
make build-go
1113

12-
# Does not (re)build frontend files, only Go code.
13-
build-go:
14+
.PHONY: build-go
15+
build-go: # Build Go binary (doesn't rebuild frontend)
1416
mkdir -p $(FRONTEND_BUILD_DIR)
1517
test -e $(FRONTEND_BUILD_DIR)/index.html || \
1618
cp pkg/web/dev.html $(FRONTEND_BUILD_DIR)/index.html
1719
go build -o bin/quickpizza ./cmd
1820

1921
.PHONY: proto
20-
proto:
22+
proto: # Generate protobuf files
2123
protoc --go_out=. --go-grpc_out=. proto/quickpizza.proto
2224

23-
format:
25+
.PHONY: format
26+
format: format-go format-web
27+
28+
.PHONY: format-go
29+
format-go: # Format Go code with goimports
2430
@goimports -w -l $(GO_SOURCES)
2531

26-
format-web:
32+
.PHONY: format-web
33+
format-web: # Format frontend code
2734
cd pkg/web/ && npm run format
2835

29-
format-check:
36+
.PHONY: format-check
37+
format-check: # Check Go code formatting
3038
@out=$$(goimports -l $(GO_SOURCES)) && echo "$$out" && test -z "$$out"
3139

32-
docker-build:
40+
.PHONY: docker-build
41+
docker-build: # Build Docker image
3342
docker build . -t grafana/quickpizza-local:latest
3443

35-
docker-run:
44+
.PHONY: docker-run
45+
docker-run: # Run Docker container
3646
docker run --rm -it -p 3333:3333 -p 3334:3334 -p 3335:3335 -v $$(pwd):/db -e QUICKPIZZA_DB=file:/db/quickpizza.db grafana/quickpizza-local:latest
47+
48+
.PHONY: help
49+
help: # Show help for each of the Makefile recipes.
50+
@grep -E '^[a-zA-Z0-9 -]+:.*#' Makefile | sort | while read -r l; do printf "\033[1;32m$$(echo $$l | cut -f 1 -d':')\033[00m:$$(echo $$l | cut -f 2- -d'#')\n"; done
51+

0 commit comments

Comments
 (0)