summaryrefslogtreecommitdiff
path: root/platform
diff options
context:
space:
mode:
authorDavid Snopek <dsnopek@gmail.com>2020-09-26 17:15:21 -0500
committerDavid Snopek <dsnopek@gmail.com>2021-01-04 17:02:37 -0600
commita54a2d65e16cea409c8a876f517451d3168da13b (patch)
treec2cc62d0612cea17620e6c8807e4d89d45ecd44b /platform
parenta511a26ad82bf70ed00ab34a3201ec5c6049387f (diff)
Add support for WebXR
Diffstat (limited to 'platform')
-rw-r--r--platform/javascript/.eslintrc.libs.js3
-rw-r--r--platform/javascript/SCsub10
-rw-r--r--platform/javascript/detect.py4
-rw-r--r--platform/javascript/emscripten_helpers.py12
4 files changed, 28 insertions, 1 deletions
diff --git a/platform/javascript/.eslintrc.libs.js b/platform/javascript/.eslintrc.libs.js
index e5f0c3d147..81b1b8c864 100644
--- a/platform/javascript/.eslintrc.libs.js
+++ b/platform/javascript/.eslintrc.libs.js
@@ -18,5 +18,8 @@ module.exports = {
"GodotRuntime": true,
"GodotFS": true,
"IDHandler": true,
+ "Browser": true,
+ "GL": true,
+ "XRWebGLLayer": true,
},
};
diff --git a/platform/javascript/SCsub b/platform/javascript/SCsub
index 7a8005fe30..1d3f96a6b8 100644
--- a/platform/javascript/SCsub
+++ b/platform/javascript/SCsub
@@ -67,6 +67,16 @@ else:
sys_env.Depends(build[0], sys_env["JS_LIBS"])
+if "JS_PRE" in env:
+ for js in env["JS_PRE"]:
+ env.Append(LINKFLAGS=["--pre-js", env.File(js).path])
+ env.Depends(build, env["JS_PRE"])
+
+if "JS_EXTERNS" in env:
+ for ext in env["JS_EXTERNS"]:
+ env["ENV"]["EMCC_CLOSURE_ARGS"] += " --externs " + ext.path
+ env.Depends(build, env["JS_EXTERNS"])
+
engine = [
"js/engine/preloader.js",
"js/engine/utils.js",
diff --git a/platform/javascript/detect.py b/platform/javascript/detect.py
index d53c774e77..7d501e94b2 100644
--- a/platform/javascript/detect.py
+++ b/platform/javascript/detect.py
@@ -1,7 +1,7 @@
import os
import sys
-from emscripten_helpers import run_closure_compiler, create_engine_file, add_js_libraries
+from emscripten_helpers import run_closure_compiler, create_engine_file, add_js_libraries, add_js_pre, add_js_externs
from methods import get_compiler_version
from SCons.Util import WhereIs
@@ -133,6 +133,8 @@ def configure(env):
# Add helper method for adding libraries.
env.AddMethod(add_js_libraries, "AddJSLibraries")
+ env.AddMethod(add_js_pre, "AddJSPre")
+ env.AddMethod(add_js_externs, "AddJSExterns")
# Add method that joins/compiles our Engine files.
env.AddMethod(create_engine_file, "CreateEngineFile")
diff --git a/platform/javascript/emscripten_helpers.py b/platform/javascript/emscripten_helpers.py
index cc874c432e..278186e4c0 100644
--- a/platform/javascript/emscripten_helpers.py
+++ b/platform/javascript/emscripten_helpers.py
@@ -25,3 +25,15 @@ def add_js_libraries(env, libraries):
if "JS_LIBS" not in env:
env["JS_LIBS"] = []
env.Append(JS_LIBS=env.File(libraries))
+
+
+def add_js_pre(env, js_pre):
+ if "JS_PRE" not in env:
+ env["JS_PRE"] = []
+ env.Append(JS_PRE=env.File(js_pre))
+
+
+def add_js_externs(env, externs):
+ if "JS_EXTERNS" not in env:
+ env["JS_EXTERNS"] = []
+ env.Append(JS_EXTERNS=env.File(externs))