88 lines
1.9 KiB
Makefile
Raw Normal View History

2017-06-16 15:05:37 +02:00
# Makefile for Anime Notifier
2019-08-27 17:45:18 +09:00
# Constants
2018-03-21 20:22:57 +01:00
GOTEST=@./utils/test/go-test-color.sh
GOBINARIES=`go env GOPATH`/bin
PACK=$(GOBINARIES)/pack
2018-02-19 06:13:33 +01:00
# Determine the name of the platform
2017-11-08 12:11:20 +01:00
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
2017-06-16 15:05:37 +02:00
2019-09-06 13:35:52 +09:00
# builds the server executable
2017-06-16 15:05:37 +02:00
server:
2019-09-06 08:35:35 +09:00
@go build -v
2019-09-06 13:35:52 +09:00
# installs development tools
2017-07-06 01:51:42 +02:00
tools:
2017-11-08 14:54:43 +01:00
ifeq ($(OSNAME),OSX)
brew install coreutils
endif
2019-09-06 13:35:52 +09:00
go install github.com/aerogo/pack/...
go install github.com/aerogo/run/...
2019-10-26 16:10:24 +09:00
go install github.com/itchyny/gojq/...
2019-09-06 13:35:52 +09:00
# compiles assets for the server
2017-06-16 15:29:09 +02:00
assets:
2019-08-27 17:45:18 +09:00
@tsc
@$(PACK)
2019-09-06 13:35:52 +09:00
# cleans all binaries and generated files
2017-06-16 15:38:10 +02:00
clean:
2017-06-16 15:42:22 +02:00
find . -type f | xargs file | grep "ELF.*executable" | awk -F: '{print $1}' | xargs rm
2019-04-14 19:04:08 +09:00
find . -type f | grep /scripts/ | grep .js | xargs rm
2019-04-21 13:38:56 +09:00
rm -rf ./components
2019-09-06 13:35:52 +09:00
# forwards local ports 80 and 443 to 4000 and 4001
2017-06-16 15:21:01 +02:00
ports:
2017-11-08 12:11:20 +01:00
ifeq ($(OSNAME),LINUX)
2019-08-27 17:45:18 +09:00
@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
2017-11-08 12:11:20 +01:00
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
2019-09-06 13:35:52 +09:00
2019-09-09 08:27:13 +09:00
# downloads the database
db:
@./db/build.sh
2019-09-06 13:35:52 +09:00
# 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 .
2018-04-07 14:17:33 +02:00
all: tools assets server bots jobs patches
2017-06-16 15:05:37 +02:00
2019-09-09 08:27:13 +09:00
.PHONY: tools assets server bots jobs patches services db ports clean