-
Notifications
You must be signed in to change notification settings - Fork 17
/
build.py
60 lines (51 loc) · 2.1 KB
/
build.py
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
import sys
import os
import shutil
import subprocess
import platform
import dukpy
import jsmin
def compile(build_dir,target_dir, option, license_js, effekseer_core_js, effekseer_src_js, effekseer_js, effekseer_min_js):
if not os.path.exists(build_dir):
os.mkdir(build_dir)
os.chdir(build_dir)
if platform.system() == "Windows":
subprocess.check_call(["cmd", "/c", "emcmake", "cmake",
"-G", "MinGW Makefiles", option, target_dir])
subprocess.check_call(["mingw32-make"])
else:
subprocess.check_call(["command", "emcmake", "cmake", option, target_dir])
subprocess.check_call(["make"])
outfile_js = open(effekseer_js, "w")
outfile_min_js = open(effekseer_min_js, "w")
with open(license_js) as infile:
data = infile.read()
outfile_js.write(data)
outfile_min_js.write(data)
with open(effekseer_core_js) as infile:
data = infile.read()
outfile_js.write(data)
outfile_min_js.write(data)
with open(effekseer_src_js) as infile:
data = infile.read()
data_es5 = dukpy.babel_compile(data)["code"]
outfile_js.write(data_es5)
outfile_min_js.write(jsmin.jsmin(data_es5))
os.chdir('../')
compile('build_asmjs',
'../src/',
'-DAS_WASM=OFF',
license_js = os.path.join("..", "src", "js", "license.js"),
effekseer_core_js = os.path.join(".", "effekseer.core.js"),
effekseer_src_js = os.path.join("..", "src", "js", "effekseer.src.js"),
effekseer_js = os.path.join("..", "Release", "effekseer_asmjs.js"),
effekseer_min_js = os.path.join("..", "Release", "effekseer_asmjs.min.js"))
compile('build_wasm',
'../src/',
'-DAS_WASM=ON',
license_js = os.path.join("..", "src", "js", "license.js"),
effekseer_core_js = os.path.join(".", "effekseer.core.js"),
effekseer_src_js = os.path.join("..", "src", "js", "effekseer.src.js"),
effekseer_js = os.path.join("..", "Release", "effekseer.js"),
effekseer_min_js = os.path.join("..", "Release", "effekseer.min.js"))
shutil.copy('build_wasm/effekseer.core.wasm', 'Release/effekseer.wasm')