Преглед на файлове

Expose Emscripten libs to engine.js discreetly

Leon Krause преди 7 години
родител
ревизия
63c7fc6358
променени са 3 файла, в които са добавени 6 реда и са изтрити 10 реда
  1. 0 7
      platform/javascript/detect.py
  2. 5 2
      platform/javascript/engine.js
  3. 1 1
      platform/javascript/pre.js

+ 0 - 7
platform/javascript/detect.py

@@ -129,13 +129,6 @@ def configure(env):
     # This setting just makes WebGL 2 APIs available, it does NOT disable WebGL 1.
     env.Append(LINKFLAGS=['-s', 'USE_WEBGL2=1'])
 
-    # engine.js uses FS but is not currently evaluated by Emscripten, so export FS.
-    # TODO: Getting rid of this export is desirable.
-    extra_exports = [
-        'FS',
-    ]
-    env.Append(LINKFLAGS=['-s', 'EXTRA_EXPORTED_RUNTIME_METHODS="%s"' % repr(extra_exports)])
-
     env.Append(LINKFLAGS=['-s', 'INVOKE_RUN=0'])
 
     # TODO: Reevaluate usage of this setting now that engine.js manages engine runtime.

+ 5 - 2
platform/javascript/engine.js

@@ -1,3 +1,4 @@
+		exposedLibs['FS'] = FS;
 		return Module;
 	},
 };
@@ -31,6 +32,8 @@
 
 		this.rtenv = null;
 
+		var LIBS = {};
+
 		var initPromise = null;
 		var unloadAfterInit = true;
 
@@ -80,7 +83,7 @@
 			return new Promise(function(resolve, reject) {
 				rtenvProps.onRuntimeInitialized = resolve;
 				rtenvProps.onAbort = reject;
-				rtenvProps.engine.rtenv = Engine.RuntimeEnvironment(rtenvProps);
+				rtenvProps.engine.rtenv = Engine.RuntimeEnvironment(rtenvProps, LIBS);
 			});
 		}
 
@@ -163,7 +166,7 @@
 			this.rtenv.thisProgram = executableName || getBaseName(basePath);
 
 			preloadedFiles.forEach(function(file) {
-				this.rtenv.FS.createDataFile('/', file.name, new Uint8Array(file.buffer), true, true, true);
+				LIBS.FS.createDataFile('/', file.name, new Uint8Array(file.buffer), true, true, true);
 			}, this);
 
 			preloadedFiles = null;

+ 1 - 1
platform/javascript/pre.js

@@ -1,2 +1,2 @@
 var Engine = {
-	RuntimeEnvironment: function(Module) {
+	RuntimeEnvironment: function(Module, exposedLibs) {