-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
51 lines (38 loc) · 1.49 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
SHELL:=/usr/bin/env bash
.DEFAULT_GOAL:=all
MAKEFLAGS += --no-print-directory
PRIMARY_MODULE_DIR := $(shell cd backend && go list -f "{{ .Dir }}" -m "github.com/lyft/clutch/backend")
TOOLS_MODULE_DIR := $(shell cd backend && go list -f "{{ .Dir }}" -m "github.com/lyft/clutch/tools")
MY_ROOT_DIR:=$(shell dirname $(realpath $(firstword $(MAKEFILE_LIST))))
YARN:=./build/bin/yarn.sh
.PHONY: all # Generate API, Frontend, and backend assets.
all: api frontend backend-tidy backend-with-assets
.PHONY: api
api: yarn-ensure
$(SHELL) $(TOOLS_MODULE_DIR)/compile-protos.sh $(MY_ROOT_DIR)
.PHONY: backend
backend:
cd backend && go build -o ../build/clutch main.go
.PHONY: backend-dev
backend-dev:
REPO_ROOT=$(MY_ROOT_DIR) $(SHELL) $(TOOLS_MODULE_DIR)/air.sh
.PHONY: backend-test
backend-test:
cd backend && go test -race -covermode=atomic ./...
backend-tidy:
cd backend && go mod tidy
.PHONY: backend-with-assets
backend-with-assets: frontend
cd backend && go run $(PRIMARY_MODULE_DIR)/cmd/assets/generate.go ../frontend/build && go build -tags withAssets -o ../build/clutch -ldflags="-X main.version=$(VERSION)"
.PHONY: frontend
frontend: yarn-install
$(YARN) --cwd frontend build
.PHONY: yarn-install
yarn-install: yarn-ensure
$(YARN) --cwd frontend install
.PHONY: yarn-ensure
yarn-ensure:
@$(SHELL) $(TOOLS_MODULE_DIR)/install-yarn.sh
.PHONY: frontend-dev # Start the frontend in development mode.
frontend-dev: yarn-ensure
$(YARN) --cwd frontend install --frozen-lockfile && $(YARN) --cwd frontend start