summaryrefslogtreecommitdiff
path: root/platform/javascript
diff options
context:
space:
mode:
authoreska <eska@eska.me>2017-02-20 13:36:54 +0100
committereska <eska@eska.me>2017-02-20 06:59:19 +0100
commit6e2bf31e5a8f3dbe18e31b1aff9c26ee184ad8c8 (patch)
tree9c01f8227b338b7539c50d27e1af1b34573c5852 /platform/javascript
parent335fdea581f677fea55d20f0e23b4c7d7c75664b (diff)
Automatically zip web export templates
Also fix web builds on Windows and clean up
Diffstat (limited to 'platform/javascript')
-rw-r--r--platform/javascript/SCsub41
-rw-r--r--platform/javascript/detect.py25
2 files changed, 33 insertions, 33 deletions
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index a20c0f7a70..7224557b55 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -2,6 +2,9 @@
Import('env')
+env.Tool('textfile')
+env.Tool('zip')
+
javascript_files = [
"os_javascript.cpp",
"audio_driver_javascript.cpp",
@@ -21,18 +24,26 @@ for x in javascript_files:
env.Append(LINKFLAGS=["-s", "EXPORTED_FUNCTIONS=\"['_main','_audio_server_mix_function','_main_after_fs_sync']\""])
env.Append(LINKFLAGS=["--shell-file", '"platform/javascript/godot_shell.html"'])
-build = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")
-Depends(build, "godot_shell.html")
-
-def make_html_shell(target, source, env):
- html_path = target[0].rstr()
- assert html_path[:4] == 'bin/'
- assert html_path[-5:] == '.html'
- basename = html_path[4:-5]
- with open(html_path, 'r+') as html_file:
- fixed_html = html_file.read().replace('.html.mem', '.mem').replace(basename, '$GODOT_BASE')
- html_file.seek(0)
- html_file.truncate()
- html_file.write(fixed_html)
-
-env.AddPostAction(build, Action(make_html_shell, "Creating HTML shell file"))
+html_file = env.Program('#bin/godot', javascript_objects, PROGSUFFIX=env["PROGSUFFIX"] + ".html")[0]
+Depends(html_file, "godot_shell.html")
+basename = "godot" + env["PROGSUFFIX"] # output file name without file extension
+
+# Emscripten hardcodes file names, so replace common base name with
+# placeholder while leaving extension; also change `.html.mem` to just `.mem`
+fixup_html = env.Substfile(html_file, SUBST_DICT=[(basename, '$$GODOT_BASE'), ('.html.mem', '.mem')], SUBSTFILESUFFIX='.fixup.html')
+
+zip_dir = env.Dir('#bin/js_zip')
+zip_files = []
+js_file = env.SideEffect(html_file.File(basename+'.js'), html_file)
+zip_files.append(env.InstallAs(
+ [zip_dir.File('godot.html'), zip_dir.File('godot.js'), zip_dir.File('godotfs.js')],
+ [fixup_html, js_file, '#misc/dist/html_fs/godotfs.js']))
+
+if env['wasm'] == 'yes':
+ wasm_file = env.SideEffect(html_file.File(basename+'.wasm'), html_file)
+ zip_files.append(env.InstallAs(zip_dir.File('godot.wasm'), wasm_file))
+else:
+ asmjs_files = env.SideEffect([html_file.File(basename+'.asm.js'), html_file.File(basename+'.html.mem')], html_file)
+ zip_files.append(env.InstallAs([zip_dir.File('godot.asm.js'), zip_dir.File('godot.mem')], asmjs_files))
+
+Zip('#bin/godot', zip_files, ZIPSUFFIX=env['PROGSUFFIX']+env['ZIPSUFFIX'], ZIPROOT=zip_dir)
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index 648880cb45..7237298169 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -44,22 +44,14 @@ def configure(env):
em_path = os.environ["EMSCRIPTEN_ROOT"]
env['ENV']['PATH'] = em_path + ":" + env['ENV']['PATH']
- env['CC'] = em_path + '/emcc'
- env['CXX'] = em_path + '/emcc'
- #env['AR'] = em_path+"/emar"
- env['AR'] = em_path + "/emcc"
- env['ARFLAGS'] = "-o"
-
-# env['RANLIB'] = em_path+"/emranlib"
- env['RANLIB'] = em_path + "/emcc"
- env['OBJSUFFIX'] = '.bc'
- env['LIBSUFFIX'] = '.bc'
- env['CCCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
- env['CXXCOM'] = "$CC -o $TARGET $CFLAGS $CCFLAGS $_CCCOMCOM $SOURCES"
-
-# env.Append(LIBS=['c','m','stdc++','log','GLESv1_CM','GLESv2'])
+ env['CC'] = em_path + '/emcc'
+ env['CXX'] = em_path + '/em++'
+ env['LINK'] = em_path + '/emcc'
+ env['AR'] = em_path + '/emar'
+ env['RANLIB'] = em_path + '/emranlib'
-# env["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ")
+ env['OBJSUFFIX'] = '.bc'
+ env['LIBSUFFIX'] = '.a'
if (env["target"] == "release"):
env.Append(CCFLAGS=['-O2'])
@@ -101,7 +93,4 @@ def configure(env):
env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
# env.Append(LINKFLAGS=['-g4'])
- # print "CCCOM is:", env.subst('$CCCOM')
- # print "P: ", env['p'], " Platofrm: ", env['platform']
-
import methods