This repository has been archived by the owner on May 21, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 45
/
Copy pathmakefile
87 lines (70 loc) · 1.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
# Makefile for Anime Notifier
# Constants
GOTEST=@./utils/test/go-test-color.sh
GOBINARIES=`go env GOPATH`/bin
PACK=$(GOBINARIES)/pack
# Determine the name of the platform
OSNAME=
ifeq ($(OS),Windows_NT)
OSNAME = WINDOWS
else
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Linux)
OSNAME = LINUX
endif
ifeq ($(UNAME_S),Darwin)
OSNAME = OSX
endif
endif
# builds the server executable
server:
@go build -v
# installs development tools
tools:
ifeq ($(OSNAME),OSX)
brew install coreutils
endif
go install github.com/aerogo/pack/...
go install github.com/aerogo/run/...
go install github.com/itchyny/gojq/...
# compiles assets for the server
assets:
@tsc
@$(PACK)
# cleans all binaries and generated files
clean:
find . -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs rm
find . -type f | grep /scripts/ | grep .js | xargs rm
rm -rf ./components
# forwards local ports 80 and 443 to 4000 and 4001
ports:
ifeq ($(OSNAME),LINUX)
@sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 4000
@sudo iptables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 4001
@sudo ip6tables -t nat -A OUTPUT -o lo -p tcp --dport 80 -j REDIRECT --to-port 4000
@sudo ip6tables -t nat -A OUTPUT -o lo -p tcp --dport 443 -j REDIRECT --to-port 4001
endif
ifeq ($(OSNAME),OSX)
@echo "rdr pass inet proto tcp from any to any port 443 -> 127.0.0.1 port 4001" | sudo pfctl -ef -
endif
# downloads the database
db:
@./db/build.sh
# installs systemd service files for all required services
services:
@./services/build.sh
# builds all background jobs
jobs:
@./jobs/build.sh
# builds all bots
bots:
@./bots/build.sh
# builds all patches
patches:
@./patches/build.sh
test:
$(GOTEST) github.com/animenotifier/notify.moe -v -cover
bench:
$(GOTEST) -run=^$ -bench .
all: tools assets server bots jobs patches
.PHONY: tools assets server bots jobs patches services db ports clean