-
Notifications
You must be signed in to change notification settings - Fork 710
/
Makefile
137 lines (121 loc) · 3.98 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
# Partially based off of:
# http://nefariousdesigns.co.uk/website-builds-using-make.html
# if a mod is specified but doesn't exist, raise an error
err:=$(shell if [ ! -z '$(mod)' ] && [ ! -d 'mods/$(mod)' ]; then echo 'Mod [$(mod)] not found!'; fi)
ifneq '$(err)' ''
$(error $(err))
endif
mod-dir=$(shell if [ -z '$(mod)' ]; then echo 'default'; else echo $(mod); fi)
err:=$(shell if [ ! -f 'mods/$(mod-dir)/intro.js' ]; then echo 'File mods/$(mod-dir)/intro.js not found!'; fi)
ifneq '$(err)' ''
$(error $(err))
endif
js-target = scripts/build/untrusted.js
js-target-min = scripts/build/untrusted.min.js
js-modules = scripts/util.js \
mods/$(mod-dir)/intro.js\
scripts/_head.js \
scripts/game.js \
scripts/codeEditor.js \
scripts/display.js \
scripts/dynamicObject.js \
scripts/inventory.js \
scripts/map.js \
scripts/objects.js \
scripts/player.js \
scripts/reference.js \
scripts/sound.js \
scripts/validate.js \
scripts/ui.js \
levels/levels.js \
scripts/_launcher_release.js \
scripts/_tail.js
js-modules-debug = scripts/util.js \
mods/$(mod-dir)/intro.js\
scripts/_head.js \
scripts/game.js \
scripts/codeEditor.js \
scripts/display.js \
scripts/dynamicObject.js \
scripts/inventory.js \
scripts/map.js \
scripts/objects.js \
scripts/player.js \
scripts/reference.js \
scripts/sound.js \
scripts/validate.js \
scripts/ui.js \
levels/levels.js \
scripts/_launcher_debug.js \
scripts/_tail.js
yui-jar = tools/yuicompressor-2.4.8pre.jar
# `make` or `make debug` merges scripts (using debug launcher)
debug:
@echo "Building level file…\t\t\t\c"
@./compile_levels.sh $(mod-dir)
@echo "[ Done ]"
@echo "Merging JS files…\t\t\t\c"
@cat $(js-modules-debug) > $(js-target)
@./parse_target.sh $(js-target) $(mod-dir)
@echo "[ Done ]"
# `make release` merges and compresses scripts (using release launcher)
release:
@rm -f $(js-target-min)
@echo "Building level file…\t\t\t\c"
@./compile_levels.sh $(mod-dir)
@echo "[ Done ]"
@echo "Merging JS files…\t\t\t\c"
@cat $(js-modules) > $(js-target)
@./parse_target.sh $(js-target) $(mod-dir)
@echo "[ Done ]"
@echo "Compressing merged JS…\t\t\t\c"
@java -jar $(yui-jar) -o $(js-target-min) $(js-target)
@echo "[ Done ]"
# `make clean` removes built scripts
clean:
@rm -f $(js-target) $(js-target-min)
# to use `make deploy` to deploy Untrusted to your own server, create
# a deploy.sh script (ncftpput is helpful for uploading via FTP).
deploy: release
@echo "Deploying to server…\t\t\t\c"
@rm -rf _site
@mkdir _site
@cp -R levels scripts styles images sound index.html _site
@./deploy.sh /untrusted _site
@rm -rf _site
@echo "[ Done ]"
# `make deploy-full` also deploys music and libs
deploy-full: release
@echo "Deploying to server…\t\t\t\c"
@rm -rf _site
@mkdir _site
@cp -R levels scripts styles images sound music lib index.html _site
@./deploy.sh /untrusted _site
@rm -rf _site
@echo "[ Done ]"
# `make deploy-debug` deploys the debug version to /debug
deploy-debug: debug
@echo "Deploying to server…\t\t\t\c"
@rm -rf _site
@mkdir _site
@cp -R levels scripts styles images sound index.html _site
@./deploy.sh /untrusted/debug _site
@rm -rf _site
@echo "[ Done ]"
# `make deploy-debug` deploys the debug version to /debug
deploy-debug-full: debug
@echo "Deploying to server…\t\t\t\c"
@rm -rf _site
@mkdir _site
@cp -R levels scripts styles images sound music lib index.html _site
@./deploy.sh /untrusted/debug _site
@rm -rf _site
@echo "[ Done ]"
deploy-github:
@git checkout gh-pages && git merge master --no-commit && make release && git commit -am "build" && git push origin gh-pages; git checkout master && make
# run-local will start a mini python webserver and host a local
# instance of the game will run on an available port
# the option -c-1 disables caching
runlocal: debug
@echo "Running local instance"
./node_modules/http-server/bin/http-server -c-1