forked from maribethb/blockly-games
-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathMakefile
More file actions
191 lines (155 loc) · 6.54 KB
/
Makefile
File metadata and controls
191 lines (155 loc) · 6.54 KB
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
##############################
# Definitions
##############################
SHELL = /bin/bash
REQUIRED_BINS = unzip wget java python
##############################
# Rules
##############################
all: deps games
index: common
python build/compress.py index
puzzle: common
python build/compress.py puzzle
maze: common
python build/compress.py maze
bird: common
python build/compress.py bird
turtle: common
python build/compress.py turtle
movie: common
python build/compress.py movie
music: common
python build/compress.py music
pond-tutor: common
python build/compress.py pond/tutor
pond-duck: common
python build/compress.py pond/duck
gallery: common
python build/compress.py gallery
games: index puzzle maze bird turtle movie music pond-tutor pond-duck gallery
common:
@echo "Converting messages.js to JSON for Translatewiki."
python build/messages_to_json.py
@echo "Converting JSON from Translatewiki to message files."
python build/json_to_js.py
@echo
deps:
$(foreach bin,$(REQUIRED_BINS),\
$(if $(shell command -v $(bin) 2> /dev/null),$(info Found `$(bin)`),$(error Please install `$(bin)`)))
mkdir -p build/third-party-downloads
wget -N https://unpkg.com/google-closure-compiler-java/compiler.jar;
mv -f compiler.jar build/third-party-downloads/closure-compiler.jar;
mkdir -p server/html/third-party
wget -N https://unpkg.com/@babel/standalone@7.14.8/babel.min.js
mv babel.min.js server/html/third-party/
wget https://github.com/ajaxorg/ace-builds/archive/refs/heads/master.zip
unzip -u master.zip
rm master.zip
rm -rf server/html/third-party/ace/
mv ace-builds-master/src-noconflict/ server/html/third-party/ace/
rm -r ace-builds-master/
wget https://github.com/NeilFraser/blockly-for-BG/archive/refs/heads/master.zip
unzip -u master.zip
rm master.zip
rm -rf server/html/third-party/blockly/
mv blockly-for-BG-master/ server/html/third-party/blockly/
wget https://github.com/CreateJS/SoundJS/archive/refs/heads/master.zip
unzip -u master.zip
rm master.zip
rm -rf server/html/third-party/SoundJS/
mv SoundJS-master/lib/ server/html/third-party/SoundJS/
rm -r SoundJS-master/
cp third-party/base.js server/html/third-party/
cp -R third-party/soundfonts server/html/third-party/
wget https://github.com/NeilFraser/JS-Interpreter/archive/refs/heads/master.zip
unzip -u master.zip
rm master.zip
rm -rf server/html/third-party/JS-Interpreter/
mv JS-Interpreter-master/ server/html/third-party/JS-Interpreter/
@# Compile JS-Interpreter using SIMPLE_OPTIMIZATIONS because the Music game needs to mess with the stack.
java -jar build/third-party-downloads/closure-compiler.jar\
--language_out ECMASCRIPT5\
--language_in ECMASCRIPT5\
--js server/html/third-party/JS-Interpreter/acorn.js\
--js server/html/third-party/JS-Interpreter/interpreter.js\
--js_output_file server/html/third-party/JS-Interpreter/compressed.js
stage:
rm -rf ../html_staging
rm -rf ../scripts_staging
rm -rf ../admin_staging
cp -R server/html ../html_staging
cp -R server/scripts ../scripts_staging
cp -R server/admin ../admin_staging
chmod +x ../scripts_staging/errorReporter.py
chmod +x ../scripts_staging/gallery_submit.py
chmod +x ../scripts_staging/gallery_view.py
chmod +x ../scripts_staging/storage.py
chmod +x ../admin_staging/expiry.py
chmod +x ../admin_staging/gallery_delete.py
chmod +x ../admin_staging/gallery_publish.py
chmod +x ../admin_staging/gallery_view.py
# Precompress JavaScript files.
gzip -9 ../html_staging/common/*.js
gzip -9 ../html_staging/third-party/ace/*.js
gzip -9 ../html_staging/third-party/*.js
gzip -9 ../html_staging/third-party/JS-Interpreter/*.js
#gzip -9 ../html/generated/*.js -- Currently no such files.
gzip -9 ../html_staging/*/generated/*.js
gzip -9 ../html_staging/*/*/generated/*.js
gzip -9 ../html_staging/generated/msg/*.js
gzip -9 ../html_staging/*/generated/msg/*.js
gzip -9 ../html_staging/*/*/generated/msg/*.js
# Build ready to test at http://staging.blockly.games/
deploy:
@[ -d ../html_staging ] || ( echo "Error: Directory '../html_staging' not found." >&2; exit 1 )
@[ -d ../scripts_staging ] || ( echo "Error: Directory '../scripts_staging' not found." >&2; exit 1 )
@[ -d ../admin_staging ] || ( echo "Error: Directory '../admin_staging' not found." >&2; exit 1 )
rm -rf ../html
mv ../html_staging ../html
rm -rf ../scripts
mv ../scripts_staging ../scripts
rm -rf ../admin
mv ../admin_staging ../admin
# Build deployed to https://blockly.games
offline: clean-offline
mkdir offline
cp -R server/html offline/blockly-games
rm -f offline/blockly-games/{admin.html,apple-touch-icon.png,favicon.ico,robots.txt}
rm -rf offline/blockly-games/gallery*
rm -rf offline/blockly-games/generated/
rm -rf offline/blockly-games/{./,*,*/*}/src
rm -f offline/blockly-games/{./,*,*/*}/generated/uncompressed.js
rm -f offline/blockly-games/index/title.png
rm -f offline/blockly-games/index/title-beta.png
rm -f offline/blockly-games/pond/crobots.txt
rm -rf offline/blockly-games/pond/battle
rm -f offline/blockly-games/common/stripes.svg
rm -f offline/blockly-games/third-party/base.js
rm -f offline/blockly-games/third-party/soundfonts/README.txt
mv offline/blockly-games/third-party/ace/{ace.js,mode-javascript.js,theme-chrome.js,worker-javascript.js} offline/
rm -rf offline/blockly-games/third-party/ace/*
mv offline/{ace.js,mode-javascript.js,theme-chrome.js,worker-javascript.js} offline/blockly-games/third-party/ace/
mv offline/blockly-games/third-party/SoundJS/soundjs.min.js offline/
rm -rf offline/blockly-games/third-party/SoundJS/*
mv offline/soundjs.min.js offline/blockly-games/third-party/SoundJS/
mv offline/blockly-games/third-party/blockly/media/ offline/
rm -rf offline/blockly-games/third-party/blockly/*
mv offline/media/ offline/blockly-games/third-party/blockly/
mv offline/blockly-games/third-party/JS-Interpreter/compressed.js offline/
rm -rf offline/blockly-games/third-party/JS-Interpreter/{*,.gitignore}
mv offline/compressed.js offline/blockly-games/third-party/JS-Interpreter/
echo '<html><head><meta http-equiv=refresh content="0; url=blockly-games/index.html"/></head></html>' > offline/blockly-games.html
find offline -name '.DS_Store' -delete
cd offline; \
zip -r9 blockly-games.zip blockly-games/ blockly-games.html
clean: clean-games clean-offline clean-deps
clean-games:
rm -rf server/html/{.,index,puzzle,maze,bird,turtle,movie,music,pond,pond/tutor,pond/duck,gallery}/generated
clean-offline:
rm -rf offline/
clean-deps:
rm -rf server/html/third-party
rm -rf build/third-party-downloads
# Prevent non-traditional rules from exiting with no changes.
.PHONY: deps