summaryrefslogtreecommitdiff
path: root/platform/javascript
diff options
context:
space:
mode:
Diffstat (limited to 'platform/javascript')
-rw-r--r--platform/javascript/SCsub41
-rw-r--r--platform/javascript/audio_server_javascript.cpp3
-rw-r--r--platform/javascript/audio_server_javascript.h3
-rw-r--r--platform/javascript/detect.py52
-rw-r--r--platform/javascript/export/export.cpp12
-rw-r--r--platform/javascript/javascript_main.cpp7
-rw-r--r--platform/javascript/os_javascript.cpp4
7 files changed, 70 insertions, 52 deletions
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index a20c0f7a70..bd7b0c304d 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/.javascript_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/audio_server_javascript.cpp b/platform/javascript/audio_server_javascript.cpp
index d5940fb102..bb238ede0c 100644
--- a/platform/javascript/audio_server_javascript.cpp
+++ b/platform/javascript/audio_server_javascript.cpp
@@ -27,7 +27,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
#include "audio_server_javascript.h"
-
+#if 0
#include "emscripten.h"
AudioMixer *AudioServerJavascript::get_mixer() {
@@ -847,3 +847,4 @@ AudioServerJavascript::AudioServerJavascript() {
stream_volume_scale=1.0;
}
+#endif
diff --git a/platform/javascript/audio_server_javascript.h b/platform/javascript/audio_server_javascript.h
index f8c8774e4c..2f48e7e79e 100644
--- a/platform/javascript/audio_server_javascript.h
+++ b/platform/javascript/audio_server_javascript.h
@@ -28,7 +28,7 @@
/*************************************************************************/
#ifndef AUDIO_SERVER_JAVASCRIPT_H
#define AUDIO_SERVER_JAVASCRIPT_H
-
+#if 0
#include "servers/audio_server.h"
class AudioServerJavascript : public AudioServer {
@@ -223,3 +223,4 @@ public:
};
#endif // AUDIO_SERVER_JAVASCRIPT_H
+#endif
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index a701823b2e..799b550899 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -12,8 +12,6 @@ def get_name():
def can_build():
-
- import os
return os.environ.has_key("EMSCRIPTEN_ROOT")
@@ -35,31 +33,41 @@ def get_flags():
]
+def create(env):
+ # remove Windows' .exe suffix
+ return env.Clone(PROGSUFFIX='')
+
+
+def escape_sources_backslashes(target, source, env, for_signature):
+ return [path.replace('\\','\\\\') for path in env.GetBuildPath(source)]
+
+def escape_target_backslashes(target, source, env, for_signature):
+ return env.GetBuildPath(target[0]).replace('\\','\\\\')
+
+
def configure(env):
env['ENV'] = os.environ
- env.use_windows_spawn_fix('javascript')
env.Append(CPPPATH=['#platform/javascript'])
- 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.PrependENVPath('PATH', os.environ['EMSCRIPTEN_ROOT'])
+ env['CC'] = 'emcc'
+ env['CXX'] = 'em++'
+ env['LINK'] = 'emcc'
+ env['RANLIB'] = 'emranlib'
+ # Emscripten's ar has issues with duplicate file names, so use cc
+ env['AR'] = 'emcc'
+ env['ARFLAGS'] = '-o'
+ if (os.name == 'nt'):
+ # use TempFileMunge on Windows since some commands get too long for
+ # cmd.exe even with spawn_fix
+ # need to escape backslashes for this
+ env['ESCAPED_SOURCES'] = escape_sources_backslashes
+ env['ESCAPED_TARGET'] = escape_target_backslashes
+ env['ARCOM'] = '${TEMPFILE("%s")}' % env['ARCOM'].replace('$SOURCES', '$ESCAPED_SOURCES').replace('$TARGET', '$ESCAPED_TARGET')
-# 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["LINKFLAGS"]= string.split(" -g --sysroot="+ld_sysroot+" -Wl,--no-undefined -Wl,-z,noexecstack ")
if (env["target"] == "release"):
env.Append(CCFLAGS=['-O2'])
@@ -78,7 +86,6 @@ def configure(env):
env.Append(CPPFLAGS=["-fno-exceptions", '-DNO_SAFE_CAST', '-fno-rtti'])
env.Append(CPPFLAGS=['-DJAVASCRIPT_ENABLED', '-DUNIX_ENABLED', '-DPTHREAD_NO_RENAME', '-DNO_FCNTL', '-DMPC_FIXED_POINT', '-DTYPED_METHOD_BIND', '-DNO_THREADS'])
env.Append(CPPFLAGS=['-DGLES3_ENABLED'])
- env.Append(CPPFLAGS=['-DGLES_NO_CLIENT_ARRAYS'])
if env['wasm'] == 'yes':
env.Append(LINKFLAGS=['-s', 'BINARYEN=1'])
@@ -88,7 +95,7 @@ def configure(env):
# what is set during compilation, check TOTAL_MEMORY in Emscripten's
# src/settings.js for the default.
env.Append(LINKFLAGS=['-s', 'ALLOW_MEMORY_GROWTH=1'])
- env["PROGSUFFIX"] += ".webassembly"
+ env.extra_suffix = '.webassembly' + env.extra_suffix
else:
env.Append(CPPFLAGS=['-s', 'ASM_JS=1'])
env.Append(LINKFLAGS=['-s', 'ASM_JS=1'])
@@ -101,7 +108,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
diff --git a/platform/javascript/export/export.cpp b/platform/javascript/export/export.cpp
index e487383ef4..2657eaddb5 100644
--- a/platform/javascript/export/export.cpp
+++ b/platform/javascript/export/export.cpp
@@ -29,11 +29,11 @@
#include "version.h"
#include "export.h"
#include "tools/editor/editor_settings.h"
-#include "tools/editor/editor_import_export.h"
+#include "tools/editor/editor_export.h"
#include "tools/editor/editor_node.h"
#include "io/zip_io.h"
#include "io/marshalls.h"
-#include "globals.h"
+#include "global_config.h"
#include "os/file_access.h"
#include "os/os.h"
#include "platform/javascript/logo.h"
@@ -417,14 +417,14 @@ EditorExportPlatformJavaScript::~EditorExportPlatformJavaScript() {
}
-
+#endif
void register_javascript_exporter() {
- Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) );
- EditorImportExport::get_singleton()->add_export_platform(exporter);
+ //Ref<EditorExportPlatformJavaScript> exporter = Ref<EditorExportPlatformJavaScript>( memnew(EditorExportPlatformJavaScript) );
+ //EditorImportExport::get_singleton()->add_export_platform(exporter);
}
-#endif
+
diff --git a/platform/javascript/javascript_main.cpp b/platform/javascript/javascript_main.cpp
index 94320d53c1..076f93f0df 100644
--- a/platform/javascript/javascript_main.cpp
+++ b/platform/javascript/javascript_main.cpp
@@ -151,16 +151,15 @@ int main(int argc, char *argv[]) {
/* Initialize the window */
- printf("let it go!\n");
+ printf("let it go dude!\n");
glutInit(&argc, argv);
os = new OS_JavaScript(_gfx_init,NULL,NULL);
#if 0
char *args[]={"-test","gui","-v",NULL};
Error err = Main::setup("apk",3,args);
#else
- //char *args[]={"-v",NULL};//
- //Error err = Main::setup("",1,args);
- Error err = Main::setup("",0,NULL);
+ char *args[]={"-main_pack","data.pck",NULL}; //pass location of main pack manually, because it wont get an executable name
+ Error err = Main::setup("",2,args);
#endif
ResourceLoader::set_abort_on_missing_resources(false); //ease up compatibility
diff --git a/platform/javascript/os_javascript.cpp b/platform/javascript/os_javascript.cpp
index b8c3dea3b4..201008b1db 100644
--- a/platform/javascript/os_javascript.cpp
+++ b/platform/javascript/os_javascript.cpp
@@ -34,7 +34,7 @@
#include "drivers/unix/dir_access_unix.h"
#include "servers/visual/visual_server_raster.h"
#include "main/main.h"
-#include "core/globals.h"
+#include "core/global_config.h"
#include "dom_keys.h"
#include <stdlib.h>
@@ -282,6 +282,8 @@ void OS_JavaScript::initialize(const VideoMode& p_desired,int p_video_driver,int
javascript_eval = memnew(JavaScript);
GlobalConfig::get_singleton()->add_singleton(GlobalConfig::Singleton("JavaScript", javascript_eval));
#endif
+
+ visual_server->init();
}
void OS_JavaScript::set_main_loop( MainLoop * p_main_loop ) {