This repository was archived by the owner on Feb 11, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmakefile
More file actions
63 lines (53 loc) · 1.51 KB
/
makefile
File metadata and controls
63 lines (53 loc) · 1.51 KB
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
APP_VERSION := "1.0.0"
COMMIT_ID := $(shell git log --format=%H -n 1)
PROJECT := $(shell pwd)
BUILD_DIR := $(PROJECT)/build
LIB_DIR := $(BUILD_DIR)/lib
SERVER_DIR := ./server
# packages to cover
PKGS := ./sources/reddit \
./sources/stackexchange
LIBS := reddit \
stackexchange
.PHONY: all
all: clean assets server libs run
@echo "Build done"
.PHONY: run
run:
$(BUILD_DIR)/server
.PHONY: server
server:
@echo "Building server..."; \
go build -o $(BUILD_DIR)/server -ldflags "-X main.version=$(APP_VERSION) -X main.commit=$(COMMIT_ID)" ./server
.PHONY: libs
libs:
@$(foreach lib, $(LIBS), echo "Building '$(lib)' library"; \
go build -buildmode=plugin -o $(LIB_DIR)/$(lib).so ./sources/$(lib);)
.PHONY: clean
clean:
@if [ -d "$(BUILD_DIR)" ]; then \
rm -rf "$(BUILD_DIR)"; \
echo "Removed $(BUILD_DIR)"; \
fi;
.PHONY: assets
assets:
@echo "Copying assets..."; \
if [ ! -d "$(BUILD_DIR)" ]; then \
mkdir "$(BUILD_DIR)"; \
fi; \
cp $(SERVER_DIR)/config.json $(BUILD_DIR)/config.json; \
cp -rf $(SERVER_DIR)/public $(BUILD_DIR)/public;
.PHONY: watch
watch:
@if ! command -v "inotifywait" > /dev/null; then \
echo "Please install 'inotifywait' tool:"; \
echo "sudo apt install inotify-tools libnotify-bin"; \
exit 1; \
fi; \
echo "Tracking changes in '$(PROJECT)/server'..."; \
inotifywait -mrq -e create -e modify $(PROJECT)/server | \
while read file; do (echo "Changed: $$file"; make all&) done
.PHONY: cover
cover:
@$(foreach pkg,$(PKGS), go test -coverprofile=/tmp/cover.out $(pkg);\
rm /tmp/cover.out;)