-
Notifications
You must be signed in to change notification settings - Fork 4
/
Makefile
134 lines (124 loc) · 5.04 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
EMSCRIPTEN_ENV := $(shell command -v emmake 2> /dev/null)
CXX := $(shell command -v ccache 2> /dev/null > /dev/null && echo ccache em++ || echo em++)
all: dev
clean:
rm -f endless-sky.js
#rm -f endless-sky.worker.js
rm -f endless-sky.data
rm -f endless-sky.wasm
rm -f dataversion.js
rm -rf output
rm -f endless-sky.wasm.map
rm -f lib/emcc/libendless-sky.a
rm -f favicon.ico
rm -f Ubuntu-Regular.ttf
rm -f title.png
rm -rf build/emcc
distclean: clean
rm -rf lib/emcc
rm -rf libjpeg-turbo-2.1.0
2.1.0.tar.gz:
wget -nv https://github.com/libjpeg-turbo/libjpeg-turbo/archive/refs/tags/2.1.0.tar.gz
libjpeg-turbo-2.1.0: 2.1.0.tar.gz
tar xzf 2.1.0.tar.gz
# | means libjpeg-turbo-2.1.0 is a "order-only prerequisite" so creating the file doesn't invalidate the dir
libjpeg-turbo-2.1.0/libturbojpeg.a: | libjpeg-turbo-2.1.0
ifndef EMSCRIPTEN_ENV
$(error "emmake is not available, activate the emscripten env first")
endif
cd libjpeg-turbo-2.1.0; emcmake cmake -G"Unix Makefiles" -DWITH_SIMD=0 -DCMAKE_BUILD_TYPE=Release -Wno-dev
cd libjpeg-turbo-2.1.0; emmake $(MAKE)
dev: endless-sky.js dataversion.js Ubuntu-Regular.ttf title.png
emrun --serve_after_close --serve_after_exit --browser chrome --private_browsing endless-sky.html
title.png:
cp images/_menu/title.png title.png
Ubuntu-Regular.ttf:
curl -Ls 'https://github.com/google/fonts/blob/main/ufl/ubuntu/Ubuntu-Regular.ttf?raw=true' > Ubuntu-Regular.ttf
favicon.ico:
wget -nv https://endless-sky.github.io/favicon.ico
# not using -flto because of a change introduced in emscripten in 2.0.27 that I don't understand
COMMON_FLAGS = -O3\
-s USE_SDL=2\
-s USE_LIBPNG=1\
-s DISABLE_EXCEPTION_CATCHING=0
CFLAGS = $(COMMON_FLAGS)\
-Duuid_generate_random=uuid_generate\
-std=c++11\
-Wall\
-Werror\
-Wold-style-cast\
-DES_GLES\
-DES_NO_THREADS\
-gsource-map\
-I libjpeg-turbo-2.1.0\
# -fno-rtti\ # some dynamic_casts in the code make this no longer possible
# Note that that libmad is not linked! It's mocked out until it works with Emscripten
LINK_FLAGS = $(COMMON_FLAGS)\
-s LLD_REPORT_UNDEFINED\
-L libjpeg-turbo-2.1.0\
-l jpeg\
-lidbfs.js\
--source-map-base http://localhost:6931/\
-s USE_WEBGL2=1\
-s ASSERTIONS=2\
-s DEMANGLE_SUPPORT=1\
-s GL_ASSERTIONS=1\
-s ASYNCIFY\
-s MIN_WEBGL_VERSION=2\
-s MAX_WEBGL_VERSION=2\
-s WASM_MEM_MAX=2147483648\
-s INITIAL_MEMORY=1347289088\
-s ALLOW_MEMORY_GROWTH=1\
--preload-file data\
--preload-file images\
--preload-file sounds\
--preload-file credits.txt\
--preload-file keys.txt\
-s EXPORTED_RUNTIME_METHODS=['callMain']\
--emrun
CPPS := $(shell ls source/*.cpp) $(shell ls source/text/*.cpp) $(shell ls source/ship/*.cpp)
CPPS_EXCEPT_MAIN := $(shell ls source/*.cpp | grep -v main.cpp) $(shell ls source/text/*.cpp) $(shell ls source/ship/*.cpp)
TEMP := $(subst source/,build/emcc/,$(CPPS))
OBJS := $(subst .cpp,.o,$(TEMP))
TEMP := $(subst source/,build/emcc/,$(CPPS_EXCEPT_MAIN))
OBJS_EXCEPT_MAIN := $(subst .cpp,.o,$(TEMP))
HEADERS := $(shell ls source/*.h*) $(shell ls source/text/*.h*) $(shell ls source/ship/*.h*) $(shell ls source/comparators/*.h*)
build/emcc/%.o: source/%.cpp $(HEADERS) libjpeg-turbo-2.1.0/libturbojpeg.a
@mkdir -p build/emcc
@mkdir -p build/emcc/text
@mkdir -p build/emcc/ship
@mkdir -p build/emcc/comparators
$(CXX) $(CFLAGS) -c $< -o $@
lib/emcc/libendless-sky.a: $(OBJS_EXCEPT_MAIN)
@mkdir -p lib/emcc
emar rcs lib/emcc/libendless-sky.a $(OBJS_EXCEPT_MAIN)
endless-sky.js: libjpeg-turbo-2.1.0/libturbojpeg.a lib/emcc/libendless-sky.a build/emcc/main.o
ifndef EMSCRIPTEN_ENV
$(error "em++ is not available, activate the emscripten env first")
endif
em++ -o endless-sky.js $(LINK_FLAGS) build/emcc/main.o lib/emcc/libendless-sky.a
dataversion.js: endless-sky.js
./hash-data.py endless-sky.data dataversion.js
output/index.html: endless-sky.js endless-sky.html favicon.ico Ubuntu-Regular.ttf dataversion.js js/cached-resource.js js/plugins.js js/save-games.js
rm -rf output
mkdir -p output
cp endless-sky.html to-be-modified-endless-sky.html
cp endless-sky.js to-be-modified-endless-sky.js
./copy-to-hashed-location.py endless-sky.wasm endless-sky.data endless-sky.js output/
mkdir output/js
./copy-to-hashed-location.py js/* output/
./copy-to-hashed-location.py dataversion.js output/
./copy-to-hashed-location.py loading.mp3 output/
./copy-to-hashed-location.py Ubuntu-Regular.ttf output/
cp favicon.ico output/
mv to-be-modified-endless-sky.js output/endless-sky-*.js
mv to-be-modified-endless-sky.html output/index.html
test: output/index.html
cd output; emrun --serve_after_close --serve_after_exit --browser chrome --private_browsing index.html
deploy: output/index.html
aws s3 sync --size-only --exclude index.html output s3://play-endless-sky.com/live --cache-control 'public, max-age=604800, immutable'
aws s3 sync --exclude '*' --include index.html output s3://play-endless-sky.com/live --cache-control 'max-age=0'
# play-endless-sky.com
aws cloudfront create-invalidation --distribution-id E2TZUW922XPLEF --paths / /index.html
# play-endless-web.com
aws cloudfront create-invalidation --distribution-id E3D0Y4DMGSVPWC --paths / /index.html