-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (55 loc) · 1.72 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
GO := go
YARN := yarn
BINARY_NAME := sniper-go
SRC_DIR := server
BUILD_DIR := bin
PROD_PATH := /usr/local/share/$(BINARY_NAME)
.PHONY: help build setup dependencies install service clean docs
.DEFAULT_GOAL := help
define PRINT_HELP_PYSCRIPT
import re, sys
BOLD = '\033[1m'
BLUE = '\033[94m'
END = '\033[0m'
print("Usage: make <target>\n")
print(BOLD + "%-20s%s" % ("target", "description") + END)
for line in sys.stdin:
match = re.match(r'^([a-zA-Z_-]+):.*?## (.*)$$', line)
if match:
target, help = match.groups()
print( BLUE + "%-20s" % (target) + END + "%s" % (help))
endef
export PRINT_HELP_PYSCRIPT
help: ## Show this help
@python3 -c "$$PRINT_HELP_PYSCRIPT" < $(MAKEFILE_LIST)
clean: ## Remove build artifacts
rm -rf dist
rm -rf $(BUILD_DIR)
rm -rf site
build: ## Build the binary file
@echo "Building the backend..."
$(GO) build -o $(BUILD_DIR)/$(BINARY_NAME) ./$(SRC_DIR)
$(YARN) --cwd ./client build:dev
setup: ## Setup the project
@echo "Setting up the project..."
cd $(SRC_DIR) && $(GO) get .
@echo "Building the frontend..."
$(YARN) --cwd ./client install
dependencies: ## Install the dependencies
@echo "Installing the dependencies..."
bash ./scripts/install_dependencies.sh
install: dependencies setup build ## Install the project
@echo "Installing the project..."
mkdir -p $(PROD_PATH)
cp README.md $(PROD_PATH)
cp -r ./dist $(PROD_PATH)
cp -r ./scripts $(PROD_PATH)
cp -r ./templates $(PROD_PATH)
cp ./$(BUILD_DIR)/$(BINARY_NAME) /usr/local/bin/$(BINARY_NAME)
@echo "Done!"
service: install ## Create the systemd service
@echo "Creating systemd service..."
bash ./scripts/install_service.sh
docs: ## Generate the documentation
@echo "Generating the documentation..."
python3 -m mkdocs build --clean