-
Notifications
You must be signed in to change notification settings - Fork 178
/
Copy pathMakefile
60 lines (47 loc) · 2.91 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
CURRENT_DIR := $(shell pwd)
WORK_DIR_BACKEND := $(CURRENT_DIR)/backend
DIST_DIR_BACKEND := $(WORK_DIR_BACKEND)/dist
WORK_DIR_FRONTEND := $(CURRENT_DIR)/front
VERSION ?= local
COMMIT_ID ?= local
BINARY_NAME := moments
LINUX_AMD64_BINARY_NAME := $(BINARY_NAME)-linux-amd64-$(VERSION)
LINUX_ARM64_BINARY_NAME := $(BINARY_NAME)-linux-arm64-$(VERSION)
DARWIN_AMD64_BINARY_NAME := $(BINARY_NAME)-darwin-amd64-$(VERSION)
DARWIN_ARM64_BINARY_NAME := $(BINARY_NAME)-darwin-arm64-$(VERSION)
WINDOWS_AMD64_BINARY_NAME := $(BINARY_NAME)-windows-amd64-$(VERSION).exe
WINDOWS_ARM64_BINARY_NAME := $(BINARY_NAME)-windows-arm64-$(VERSION).exe
BUILD_CMD_DEV := go build -ldflags="-X main.version=$(VERSION) -X main.commitId=$(COMMIT_ID)"
BUILD_CMD_PROD := go build -tags prod -ldflags="-s -w -X main.version=$(VERSION) -X main.commitId=$(COMMIT_ID)"
.PHONY: frontend-install frontend-dev backend-dev clean build frontend backend zip checksums
frontend-install:
cd $(WORK_DIR_FRONTEND) && pnpm i
frontend-dev:
cd $(WORK_DIR_FRONTEND) && pnpm run dev
backend-dev:
cd $(WORK_DIR_BACKEND) && $(BUILD_CMD_DEV) -o $(DIST_DIR_BACKEND)/$(LINUX_AMD64_BINARY_NAME)
$(DIST_DIR_BACKEND)/$(LINUX_AMD64_BINARY_NAME)
build: clean frontend backend
clean:
cd $(WORK_DIR_BACKEND) && go clean
cd $(WORK_DIR_BACKEND) && rm -rf ./public ./dist
cd $(WORK_DIR_FRONTEND) && rm -rf ./.output ./dist
frontend:
cd $(WORK_DIR_FRONTEND) && pnpm i && pnpm generate
cp -r $(WORK_DIR_FRONTEND)/.output/public $(WORK_DIR_BACKEND)
backend:
cd $(WORK_DIR_BACKEND) && GOOS=linux GOARCH=amd64 $(BUILD_CMD_PROD) -o $(DIST_DIR_BACKEND)/$(LINUX_AMD64_BINARY_NAME)
cd $(WORK_DIR_BACKEND) && GOOS=linux GOARCH=arm64 $(BUILD_CMD_PROD) -o $(DIST_DIR_BACKEND)/$(LINUX_ARM64_BINARY_NAME)
cd $(WORK_DIR_BACKEND) && GOOS=darwin GOARCH=amd64 $(BUILD_CMD_PROD) -o $(DIST_DIR_BACKEND)/$(DARWIN_AMD64_BINARY_NAME)
cd $(WORK_DIR_BACKEND) && GOOS=darwin GOARCH=arm64 $(BUILD_CMD_PROD) -o $(DIST_DIR_BACKEND)/$(DARWIN_ARM64_BINARY_NAME)
cd $(WORK_DIR_BACKEND) && GOOS=windows GOARCH=amd64 $(BUILD_CMD_PROD) -o $(DIST_DIR_BACKEND)/$(WINDOWS_AMD64_BINARY_NAME)
cd $(WORK_DIR_BACKEND) && GOOS=windows GOARCH=arm64 $(BUILD_CMD_PROD) -o $(DIST_DIR_BACKEND)/$(WINDOWS_ARM64_BINARY_NAME)
zip:
cd $(DIST_DIR_BACKEND) && find . -type f -name "$(BINARY_NAME)-*" | xargs -I {} zip {}.zip {}
checksums:
cd $(DIST_DIR_BACKEND) && md5sum $(LINUX_AMD64_BINARY_NAME) > $(LINUX_AMD64_BINARY_NAME)-checksum.txt
cd $(DIST_DIR_BACKEND) && md5sum $(LINUX_ARM64_BINARY_NAME) > $(LINUX_ARM64_BINARY_NAME)-checksum.txt
cd $(DIST_DIR_BACKEND) && md5sum $(DARWIN_AMD64_BINARY_NAME) > $(DARWIN_AMD64_BINARY_NAME)-checksum.txt
cd $(DIST_DIR_BACKEND) && md5sum $(DARWIN_ARM64_BINARY_NAME) > $(DARWIN_ARM64_BINARY_NAME)-checksum.txt
cd $(DIST_DIR_BACKEND) && md5sum $(WINDOWS_AMD64_BINARY_NAME) > $(WINDOWS_AMD64_BINARY_NAME)-checksum.txt
cd $(DIST_DIR_BACKEND) && md5sum $(WINDOWS_ARM64_BINARY_NAME) > $(WINDOWS_ARM64_BINARY_NAME)-checksum.txt