Improved build scripts

This commit is contained in:
2019-09-06 13:35:52 +09:00
parent 7286dfb8a2
commit 985423e981
10 changed files with 103 additions and 43 deletions

View File

@ -4,7 +4,6 @@
GOTEST=@./utils/test/go-test-color.sh
PACK=$(shell command -v pack 2> /dev/null)
RUN=$(shell command -v run 2> /dev/null)
SERVICEFILE=/etc/systemd/system/animenotifier.service
# Determine the name of the platform
OSNAME=
@ -21,45 +20,30 @@ else
endif
endif
# Build targets
# builds the server executable
server:
@go build -v
deps:
go mod download
jobs:
@./jobs/build.sh
bots:
@./bots/build.sh
patches:
@./patches/build.sh
test:
$(GOTEST) github.com/animenotifier/notify.moe -v -cover
bench:
$(GOTEST) -bench .
pack:
go install github.com/aerogo/pack/...
run:
go install github.com/aerogo/run/...
# installs development tools
tools:
ifeq ($(OSNAME),OSX)
brew install coreutils
endif
@make pack
@make run
service:
sudo cp systemd.service $(SERVICEFILE)
sudo sed -i "s|MAKEFILE_USER|$(USER)|g" $(SERVICEFILE)
sudo sed -i "s|MAKEFILE_PWD|$(PWD)|g" $(SERVICEFILE)
sudo sed -i "s|MAKEFILE_EXEC|$(PWD)/notify.moe|g" $(SERVICEFILE)
sudo systemctl daemon-reload
@echo -e "\nYou can now start the service using:\n\nsudo systemctl start animenotifier.service"
go install github.com/aerogo/pack/...
go install github.com/aerogo/run/...
# 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
@ -70,6 +54,29 @@ 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
# 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 ports clean versions
.PHONY: tools assets server bots jobs patches services ports clean