-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
122 lines (93 loc) · 3.6 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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
# Copyright 2023 defsub
#
# This file is part of Takeout.
#
# Takeout is free software: you can redistribute it and/or modify it under the
# terms of the GNU Affero General Public License as published by the Free
# Software Foundation, either version 3 of the License, or (at your option)
# any later version.
#
# Takeout is distributed in the hope that it will be useful, but WITHOUT ANY
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for
# more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with Takeout. If not, see <https://www.gnu.org/licenses/>.
GO = go
DOCKER = sudo docker
DOCKER_USER ?= defsub
DOCKER_IMAGE ?= takeout
GIT_VERSION ?= $(shell git log --format="%h" -n 1)
TAKEOUT_VERSION = $(shell sed -n -e 's/\s*Version = "\(.*\)"\s*/\1/p' takeout.go)
COMMON_SOURCES = $(wildcard *.go lib/*/*.go model/*.go spiff/*.go view/*.go)
INTERNAL_SOURCES = $(wildcard internal/*/*.go)
SERVER_SOURCES = ${INTERNAL_SOURCES} ${COMMON_SOURCES}
PLAYOUT_SOURCES = $(wildcard client/*.go player/*.go) ${INTERNAL_SOURCES} ${COMMON_SOURCES}
# server embedded resources
RES_DIR = internal/server/res
RES_STATIC = $(wildcard ${RES_DIR}/static/*.css ${RES_DIR}/static/*.html \
${RES_DIR}/static/*.js ${RES_DIR}/static/*.svg)
RES_ROOT = $(wildcard ${RES_DIR}/template/*.html)
RES_MUSIC = $(wildcard ${RES_DIR}/template/music/*.html)
RES_PODCAST = $(wildcard ${RES_DIR}/template/podcast/*.html)
RES_VIDEO = $(wildcard ${RES_DIR}/template/video/*.html)
RES_TEMPLATE = ${RES_ROOT} ${RES_MUSIC} ${RES_PODCAST} ${RES_VIDEO}
SERVER_RESOURCES = ${RES_STATIC} ${RES_TEMPLATE}
# server
SERVER_CMD_DIR = cmd/takeout
SERVER_CMD_TARGET = ${SERVER_CMD_DIR}/takeout
SERVER_CMD_SRC = $(wildcard ${SERVER_CMD_DIR}/*.go)
# playout
PLAYOUT_CMD_DIR = cmd/playout
PLAYOUT_CMD_TARGET = ${PLAYOUT_CMD_DIR}/playout
PLAYOUT_CMD_SRC = $(wildcard ${PLAYOUT_CMD_DIR}/*.go)
# tmdb
TMDB_CMD_DIR = tools/cmd/tmdb
TMDB_CMD_TARGET = ${TMDB_CMD_DIR}/tmdb
TMDB_CMD_SRC = $(wildcard ${TMDB_CMD_DIR}/*.go)
.PHONY: all install clean
all: server playout
#
server: ${SERVER_CMD_TARGET}
${SERVER_CMD_TARGET}: ${SERVER_CMD_SRC} ${SERVER_SOURCES} ${SERVER_RESOURCES}
@cd ${SERVER_CMD_DIR} && ${GO} build
install-server: server
@cd ${SERVER_CMD_DIR} && ${GO} install
#
playout: ${PLAYOUT_CMD_TARGET}
${PLAYOUT_CMD_TARGET}: ${PLAYOUT_CMD_SRC} ${PLAYOUT_SOURCES}
@cd ${PLAYOUT_CMD_DIR} && ${GO} build
install-playout: playout
@cd ${PLAYOUT_CMD_DIR} && ${GO} install
#
tmdb: ${TMDB_CMD_TARGET}
${TMDB_CMD_TARGET}: ${TMDB_CMD_SRC} ${COMMON_SOURCES}
@cd ${TMDB_CMD_DIR} && ${GO} build
test:
${GO} test ./...
test-coverage:
-${GO} test -coverprofile cover.out ./...
${GO} tool cover -func=cover.out
install: install-server install-playout
clean:
@cd ${SERVER_CMD_DIR} && ${GO} clean
rm -f ${SERVER_CMD_TARGET}
@cd ${PLAYOUT_CMD_DIR} && ${GO} clean
rm -f ${PLAYOUT_CMD_TARGET}
@cd ${TMDB_CMD_DIR} && ${GO} clean
rm -f ${TMDB_CMD_TARGET}
docker docker-build: clean
${DOCKER} build --rm -t ${DOCKER_IMAGE} build
docker-push:
${DOCKER} tag ${DOCKER_IMAGE} ${DOCKER_USER}/${DOCKER_IMAGE}:latest
${DOCKER} tag ${DOCKER_IMAGE} ${DOCKER_USER}/${DOCKER_IMAGE}:${GIT_VERSION}
${DOCKER} push ${DOCKER_USER}/${DOCKER_IMAGE}:latest
${DOCKER} push ${DOCKER_USER}/${DOCKER_IMAGE}:${GIT_VERSION}
# manually update version in takeout.go
# manually git commit -a
# push will add git version tag as needed, push origin, push tag
push:
@git tag --list | grep -q v${TAKEOUT_VERSION} || git tag v${TAKEOUT_VERSION}
@git push origin
@git push origin v${TAKEOUT_VERSION}