This repository has been archived by the owner on Aug 26, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 124
/
makefile
241 lines (207 loc) · 5.08 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
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
#
# LibreSignage make entry point.
#
PHPUNIT_API_HOST ?= http://localhost:80
PHPUNIT_CONFIG := tests/phpunit.xml
PHPUNIT_FLAGS := -c "$(PHPUNIT_CONFIG)" --testdox --color=auto
# Define required dependency versions.
NPM_REQ_VER := 6.4.0
COMPOSER_REQ_VER := 1.8.0
MAKE_REQ_VER := 4.0
PANDOC_REQ_VER := 2.0
DOXYGEN_REQ_VER := 1.8.0
RSVG_REQ_VER := 2.40.0
# Caller supplied settings.
CONF ?= ""
TARGET ?=
PASS ?=
.PHONY: \
configure-build \
configure-system \
configure \
clean \
realclean \
LOC \
test-api \
doxygen-docs \
build \
php-dev-autoload \
php-prod-autoload \
install
.ONESHELL:
all: initchk php-prod-autoload
+make -f makefile.build
+make -f makefile.post
# Perform some initialization checks.
initchk:
@:
set +e
tmp=0
./build/scripts/check_shell.sh
tmp=$$(expr $$tmp + $$?)
./build/scripts/dep_checks/npm_version.sh $(NPM_REQ_VER)
tmp=$$(expr $$tmp + $$?)
./build/scripts/dep_checks/composer_version.sh $(COMPOSER_REQ_VER)
tmp=$$(expr $$tmp + $$?)
./build/scripts/dep_checks/make_version.sh $(MAKE_REQ_VER)
tmp=$$(expr $$tmp + $$?)
./build/scripts/dep_checks/pandoc_version.sh $(PANDOC_REQ_VER)
tmp=$$(expr $$tmp + $$?)
./build/scripts/dep_checks/rsvg_version.sh $(RSVG_REQ_VER)
tmp=$$(expr $$tmp + $$?)
$(call initchk_warn,$$tmp)
# Install deps from Composer.
vendor:
@:
set -e
composer install
# Install deps from NPM.
node_modules:
@:
set -e
npm install
# Dump production autoload files.
php-prod-autoload: vendor
@:
echo "[Info] Dump production autoload."
composer dump-autoload --no-ansi --no-dev --optimize
# Dump development autoload files.
php-dev-autoload: vendor
@:
echo "[Info] Dump development autoload."
composer dump-autoload --no-ansi
# Install deps and configure.
configure: vendor node_modules configure-build configure-system
# Create build configuration.
configure-build:
@:
set -e
if [ -z "$(TARGET)" ]; then
printf "[Error] Please specify a build target using 'TARGET=[target]'.\n" > /dev/stderr
exit 1
fi
./build/scripts/configure_build.sh --target="$(TARGET)" --pass $(PASS)
# Create system configuration.
configure-system:
@:
set -e
./build/scripts/configure_system.sh --config="$(CONF)" --pass $(PASS)
# Install LibreSignage.
install:
@:
set -e
./build/scripts/install.sh --config="$(CONF)" --pass $(PASS)
# Clean the source tree.
clean:
@:
set -e
$(call status,rm,dist,none)
rm -rf dist
$(call status,rm,dep,none)
rm -rf dep
$(call status,rm,*.log,none)
rm -f *.log
for f in '__pycache__' '.sass-cache' '.mypy_cache'; do
TMP="`find . -type d -name $$f -printf '%p '`"
if [ ! -z "$$TMP" ]; then
$(call status,rm,$$TMP,none)
rm -rf $$TMP
fi
done
# Realclean the source tree.
realclean: clean
@:
set -e
$(call status,rm,build/*.conf,none);
rm -f build/*.conf
$(call status,rm,build/link,none);
rm -rf build/link
$(call status,rm,node_modules,none);
rm -rf node_modules
$(call status,rm,package-lock.json,none);
rm -f package-lock.json
$(call status,rm,vendor,none)
rm -rf vendor
$(call status,rm,composer.lock,none)
rm -f composer.lock
$(call status,rm,server,none)
rm -rf server
$(call status,rm,.phpunit.result.cache,none)
rm -f .phpunit.result.cache
# Remove temporary nano files.
TMP="`find . \
\( -type d -path './node_modules/*' -prune \) \
-o \( \
-type f -name '*.swp' -printf '%p ' \
-o -type f -name '*.save' -printf '%p ' \
\)`"
if [ ! -z "$$TMP" ]; then
$(call status,rm,$$TMP,none)
rm -f $$TMP
fi
# Remove temporary emacs files.
TMP="`find . \
\( -type d -path './node_modules/*' -prune \) \
-o \( \
-type f -name '\#*\#*' -printf '%p ' \
-o -type f -name '*~' -printf '%p ' \
\)`"
if [ ! -z "$$TMP" ]; then
$(call status,rm,$$TMP,none)
rm -f $$TMP
fi
# Count the lines of code in LibreSignage.
LOC:
@:
set -e
printf 'Lines Of Code: \n'
wc -l `find . \
\( \
-path "./dist/*" \
-o -path "./node_modules/*" \
-o -path "./vendor/*" \
-o -path "./doxygen_docs/*" \
-o -path "./jsdoc_docs/*" \
\) -prune \
-o -name ".#*" -printf '' \
-o -name 'package-lock.json' -printf '' \
-o -name 'composer.lock.json' -printf '' \
-o -name "Dockerfile" -print \
-o -name "makefile" -print \
-o -name "makefile.common" -print \
-o -name "makefile.build" -print \
-o -name "makefile.post" -print \
-o -name "*.py" -print \
-o -name "*.php" -print \
-o -name "*.js" -print \
-o -name "*.html" -print \
-o -name "*.css" -print \
-o -name "*.scss" -print \
-o -name "*.sh" -print \
-o -name "*.json" -print`
# Run API integration tests.
test-api: php-dev-autoload
@:
set -e
printf '[Info] Running API integration tests...\n'
if [ ! -d 'dist/' ]; then
echo "[Error] 'dist'/ doesn't exist. Did you compile first?"
exit 1
fi
sh tests/setup.sh "API"
export PHPUNIT_API_HOST="$(PHPUNIT_API_HOST)"
vendor/bin/phpunit $(PHPUNIT_FLAGS) $(PASS) --testsuite "API"
sh tests/cleanup.sh "API"
# Generate doxygen docs.
doxygen-docs:
@:
set -e
./build/scripts/dep_checks/doxygen_version.sh $(DOXYGEN_REQ_VER)
$(call initchk_warn,$$?)
doxygen Doxyfile
# Generate JSDoc docs.
jsdoc-docs:
@:
set -e
npx jsdoc -c jsdoc.json
include makefile.common