Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
godot
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
community
godot
Commits
d2eef397
Commit
d2eef397
authored
May 08, 2020
by
Fabio Alessandrelli
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix Closure compiler build, python style.
Move copyToFS into utils.js library included with '--pre-js'.
parent
7411e7fd
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
79 additions
and
50 deletions
+79
-50
webrtc_data_channel_js.cpp
modules/webrtc/webrtc_data_channel_js.cpp
+3
-3
emws_client.cpp
modules/websocket/emws_client.cpp
+3
-3
SCsub
platform/javascript/SCsub
+12
-15
detect.py
platform/javascript/detect.py
+4
-2
display_server_javascript.cpp
platform/javascript/display_server_javascript.cpp
+5
-5
engine.js
platform/javascript/engine/engine.js
+3
-3
utils.js
platform/javascript/engine/utils.js
+0
-18
http_request.js
platform/javascript/native/http_request.js
+0
-0
id_handler.js
platform/javascript/native/id_handler.js
+0
-0
utils.js
platform/javascript/native/utils.js
+48
-0
os_javascript.cpp
platform/javascript/os_javascript.cpp
+1
-1
No files found.
modules/webrtc/webrtc_data_channel_js.cpp
View file @
d2eef397
...
...
@@ -312,14 +312,14 @@ WebRTCDataChannelJS::WebRTCDataChannelJS(int js_id) {
return
;
}
var
len
=
buffer
.
length
*
buffer
.
BYTES_PER_ELEMENT
;
var
out
=
Module
.
_malloc
(
len
);
Module
.
HEAPU8
.
set
(
buffer
,
out
);
var
out
=
_malloc
(
len
);
HEAPU8
.
set
(
buffer
,
out
);
ccall
(
"_emrtc_on_ch_message"
,
"void"
,
[
"number"
,
"number"
,
"number"
,
"number"
],
[
c_ptr
,
out
,
len
,
is_string
]
);
Module
.
_free
(
out
);
_free
(
out
);
}
},
this
,
js_id
);
...
...
modules/websocket/emws_client.cpp
View file @
d2eef397
...
...
@@ -142,14 +142,14 @@ Error EMWSClient::connect_to_host(String p_host, String p_path, uint16_t p_port,
}
var
len
=
buffer
.
length
*
buffer
.
BYTES_PER_ELEMENT
;
var
out
=
Module
.
_malloc
(
len
);
Module
.
HEAPU8
.
set
(
buffer
,
out
);
var
out
=
_malloc
(
len
);
HEAPU8
.
set
(
buffer
,
out
);
ccall
(
"_esws_on_message"
,
"void"
,
[
"number"
,
"number"
,
"number"
,
"number"
],
[
c_ptr
,
out
,
len
,
is_string
]
);
Module
.
_free
(
out
);
_free
(
out
);
});
socket
.
addEventListener
(
"error"
,
function
(
event
)
{
...
...
platform/javascript/SCsub
View file @
d2eef397
...
...
@@ -18,18 +18,19 @@ if env["threads_enabled"]:
build
=
env
.
add_program
(
build_targets
,
javascript_files
)
js_libraries
=
[
"http_request.js"
,
"
native/
http_request.js"
,
]
for
lib
in
js_libraries
:
env
.
Append
(
LINKFLAGS
=
[
"--js-library"
,
env
.
File
(
lib
)
.
path
])
env
.
Depends
(
build
,
js_libraries
)
js_modules
=
[
"id_handler.js"
,
js_pre
=
[
"native/id_handler.js"
,
"native/utils.js"
,
]
for
module
in
js_modules
:
env
.
Append
(
LINKFLAGS
=
[
"--pre-js"
,
env
.
File
(
module
)
.
path
])
env
.
Depends
(
build
,
js_
modules
)
for
js
in
js_pre
:
env
.
Append
(
LINKFLAGS
=
[
"--pre-js"
,
env
.
File
(
js
)
.
path
])
env
.
Depends
(
build
,
js_
pre
)
engine
=
[
"engine/preloader.js"
,
...
...
@@ -49,16 +50,12 @@ js_wrapped = env.Textfile("#bin/godot", [env.File(f) for f in wrap_list], TEXTFI
zip_dir
=
env
.
Dir
(
"#bin/.javascript_zip"
)
binary_name
=
"godot.tools"
if
env
[
"tools"
]
else
"godot"
out_files
=
[
zip_dir
.
File
(
binary_name
+
".js"
),
zip_dir
.
File
(
binary_name
+
".wasm"
),
zip_dir
.
File
(
binary_name
+
".html"
)
zip_dir
.
File
(
binary_name
+
".js"
),
zip_dir
.
File
(
binary_name
+
".wasm"
),
zip_dir
.
File
(
binary_name
+
".html"
),
]
html_file
=
"#misc/dist/html/full-size.html"
in_files
=
[
js_wrapped
,
build
[
1
],
html_file
]
in_files
=
[
js_wrapped
,
build
[
1
],
html_file
]
if
env
[
"threads_enabled"
]:
in_files
.
append
(
build
[
2
])
out_files
.
append
(
zip_dir
.
File
(
binary_name
+
".worker.js"
))
...
...
@@ -69,5 +66,5 @@ env.Zip(
zip_files
,
ZIPROOT
=
zip_dir
,
ZIPSUFFIX
=
"${PROGSUFFIX}${ZIPSUFFIX}"
,
ZIPCOMSTR
=
"Archving $SOURCES as $TARGET"
ZIPCOMSTR
=
"Archving $SOURCES as $TARGET"
,
)
platform/javascript/detect.py
View file @
d2eef397
...
...
@@ -2,6 +2,7 @@ import os
from
emscripten_helpers
import
parse_config
,
run_closure_compiler
,
create_engine_file
def
is_active
():
return
True
...
...
@@ -16,6 +17,7 @@ def can_build():
def
get_opts
():
from
SCons.Variables
import
BoolVariable
return
[
# eval() can be a security concern, so it can be disabled.
BoolVariable
(
"javascript_eval"
,
"Enable JavaScript eval interface"
,
True
),
...
...
@@ -55,7 +57,7 @@ def configure(env):
env
.
Append
(
CPPDEFINES
=
[
"DEBUG_ENABLED"
])
# Retain function names for backtraces at the cost of file size.
env
.
Append
(
LINKFLAGS
=
[
"--profiling-funcs"
])
else
:
# "debug"
else
:
# "debug"
env
.
Append
(
CPPDEFINES
=
[
"DEBUG_ENABLED"
])
env
.
Append
(
CCFLAGS
=
[
"-O1"
,
"-g"
])
env
.
Append
(
LINKFLAGS
=
[
"-O1"
,
"-g"
])
...
...
@@ -164,6 +166,6 @@ def configure(env):
env
.
Append
(
LINKFLAGS
=
[
"-s"
,
"OFFSCREEN_FRAMEBUFFER=1"
])
# callMain for manual start, FS for preloading, PATH and ERRNO_CODES for BrowserFS.
env
.
Append
(
LINKFLAGS
=
[
"-s"
,
"EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'FS', 'PATH'
, 'ERRNO_CODES'
]"
])
env
.
Append
(
LINKFLAGS
=
[
"-s"
,
"EXTRA_EXPORTED_RUNTIME_METHODS=['callMain', 'FS', 'PATH']"
])
# Add code that allow exiting runtime.
env
.
Append
(
LINKFLAGS
=
[
"-s"
,
"EXIT_RUNTIME=1"
])
platform/javascript/display_server_javascript.cpp
View file @
d2eef397
...
...
@@ -820,16 +820,16 @@ DisplayServerJavaScript::DisplayServerJavaScript(const String &p_rendering_drive
EM_ASM
({
const
canvas
=
Module
[
'
canvas
'
];
var
enc
=
new
TextEncoder
(
"utf-8"
);
buffer
=
new
Uint8Array
(
enc
.
encode
(
canvas
.
id
));
var
len
=
buffer
.
length
*
buffer
.
BYTES_PER_ELEMENT
;
var
out
=
Module
.
_malloc
(
len
);
Module
.
HEAPU8
.
set
(
buffer
,
out
);
var
buffer
=
new
Uint8Array
(
enc
.
encode
(
canvas
.
id
));
var
len
=
buffer
.
byteLength
;
var
out
=
_malloc
(
len
);
HEAPU8
.
set
(
buffer
,
out
);
ccall
(
"_set_canvas_id"
,
"void"
,
[
"number"
,
"number"
],
[
out
,
len
]
);
Module
.
_free
(
out
);
_free
(
out
);
});
/* clang-format on */
...
...
platform/javascript/engine/engine.js
View file @
d2eef397
...
...
@@ -82,7 +82,7 @@ Function('return this')()['Engine'] = (function() {
var
me
=
this
;
return
me
.
init
().
then
(
function
()
{
if
(
!
me
.
rtenv
)
{
reject
(
new
Error
(
'The engine must be initialized before it can be started'
));
re
turn
Promise
.
re
ject
(
new
Error
(
'The engine must be initialized before it can be started'
));
}
if
(
!
(
me
.
canvas
instanceof
HTMLCanvasElement
))
{
...
...
@@ -124,7 +124,7 @@ Function('return this')()['Engine'] = (function() {
}
return
new
Promise
(
function
(
resolve
,
reject
)
{
preloader
.
preloadedFiles
.
forEach
(
function
(
file
)
{
Utils
.
copyToFS
(
me
.
rtenv
[
'FS'
],
file
.
path
,
file
.
buffer
);
me
.
rtenv
[
'copyToFS'
](
file
.
path
,
file
.
buffer
);
});
preloader
.
preloadedFiles
.
length
=
0
;
// Clear memory
me
.
rtenv
[
'callMain'
](
args
);
...
...
@@ -217,7 +217,7 @@ Function('return this')()['Engine'] = (function() {
if
(
this
.
rtenv
==
null
)
{
throw
new
Error
(
"Engine must be inited before copying files"
);
}
Utils
.
copyToFS
(
this
.
rtenv
[
'FS'
],
path
,
buffer
);
this
.
rtenv
[
'copyToFS'
](
path
,
buffer
);
}
// Closure compiler exported engine methods.
...
...
platform/javascript/engine/utils.js
View file @
d2eef397
...
...
@@ -27,24 +27,6 @@ var Utils = {
return
instantiateWasm
;
},
copyToFS
:
function
(
fs
,
path
,
buffer
)
{
var
p
=
path
.
lastIndexOf
(
"/"
);
var
dir
=
"/"
;
if
(
p
>
0
)
{
dir
=
path
.
slice
(
0
,
path
.
lastIndexOf
(
"/"
));
}
try
{
fs
.
stat
(
dir
);
}
catch
(
e
)
{
if
(
e
.
errno
!==
44
)
{
// 'ENOENT', see https://github.com/emscripten-core/emscripten/blob/master/system/lib/libc/musl/arch/emscripten/bits/errno.h
throw
e
;
}
fs
[
'mkdirTree'
](
dir
);
}
// With memory growth, canOwn should be false.
fs
[
'writeFile'
](
path
,
new
Uint8Array
(
buffer
),
{
'flags'
:
'wx+'
});
},
findCanvas
:
function
()
{
var
nodes
=
document
.
getElementsByTagName
(
'canvas'
);
if
(
nodes
.
length
&&
nodes
[
0
]
instanceof
HTMLCanvasElement
)
{
...
...
platform/javascript/http_request.js
→
platform/javascript/
native/
http_request.js
View file @
d2eef397
File moved
platform/javascript/id_handler.js
→
platform/javascript/
native/
id_handler.js
View file @
d2eef397
File moved
platform/javascript/native/utils.js
0 → 100644
View file @
d2eef397
/*************************************************************************/
/* utils.js */
/*************************************************************************/
/* This file is part of: */
/* GODOT ENGINE */
/* https://godotengine.org */
/*************************************************************************/
/* Copyright (c) 2007-2020 Juan Linietsky, Ariel Manzur. */
/* Copyright (c) 2014-2020 Godot Engine contributors (cf. AUTHORS.md). */
/* */
/* Permission is hereby granted, free of charge, to any person obtaining */
/* a copy of this software and associated documentation files (the */
/* "Software"), to deal in the Software without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of the Software, and to */
/* permit persons to whom the Software is furnished to do so, subject to */
/* the following conditions: */
/* */
/* The above copyright notice and this permission notice shall be */
/* included in all copies or substantial portions of the Software. */
/* */
/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */
/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */
/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/
/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */
/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */
/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
Module
[
'copyToFS'
]
=
function
(
path
,
buffer
)
{
var
p
=
path
.
lastIndexOf
(
"/"
);
var
dir
=
"/"
;
if
(
p
>
0
)
{
dir
=
path
.
slice
(
0
,
path
.
lastIndexOf
(
"/"
));
}
try
{
FS
.
stat
(
dir
);
}
catch
(
e
)
{
if
(
e
.
errno
!==
ERRNO_CODES
.
ENOENT
)
{
// 'ENOENT', see https://github.com/emscripten-core/emscripten/blob/master/system/lib/libc/musl/arch/emscripten/bits/errno.h
throw
e
;
}
FS
.
mkdirTree
(
dir
);
}
// With memory growth, canOwn should be false.
FS
.
writeFile
(
path
,
new
Uint8Array
(
buffer
),
{
'flags'
:
'wx+'
});
}
platform/javascript/os_javascript.cpp
View file @
d2eef397
...
...
@@ -71,7 +71,7 @@ void OS_JavaScript::initialize() {
char
locale_ptr
[
16
];
/* clang-format off */
EM_ASM
({
stringToUTF8
(
Module
.
locale
,
$
0
,
16
);
stringToUTF8
(
Module
[
'
locale
'
]
,
$
0
,
16
);
},
locale_ptr
);
/* clang-format on */
setenv
(
"LANG"
,
locale_ptr
,
true
);
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment