Commit graph

117 commits

Author SHA1 Message Date
Fabio Alessandrelli
7431586286 [HTML5] Make threads build the default.
Non-threads build are broken anyway.
2021-07-15 15:33:39 +02:00
Fabio Alessandrelli
897c906ebf [HTML5] Raise default initial memory to 32 MiB.
The memory was resized in any case during start.

Mitigate Chromium issue:
https://bugs.chromium.org/p/v8/issues/detail?id=11863

Also fix a warning about SAFE_HEAP being a linker only flag.
2021-07-13 15:51:00 +02:00
Fabio Alessandrelli
8594613f94 LinuxBSD now compiles without vulkan/x11. 2021-06-01 16:27:54 +02:00
Fabio Alessandrelli
8e2c237008 [HTML5] Fix builds with recent emscripten versions
Library suffix should be `.a`, the `EXTRA_` in
`EXTRA_EXPORTED_RUNTIME_METHODS` is deprecated.
2021-04-30 08:01:26 +02:00
bruvzg
7e557bbec6
[JS, Android] Re-add "no-exceptions" for export templates builds with ICU. 2021-04-20 21:50:48 +03:00
Rafał Mikrut
0b298d201e Allow to not optimize release build 2021-03-14 15:51:05 +01:00
Fabio Alessandrelli
d8bd54fbf2 [HTML5] Add PWA support to the editor page.
This allows to install it as an app, and provide offline support (after
the first run).
Practically, this boils down to adding a JSON file as a manifest, an
offline page to be displayed when the cached files are not avaialble,
and a JS file to cache resources and return them.

The reason for the "first run requirements" is that some browsers, will
emit an "install" by just visiting the page (to see if the JS code is
compatibile), and we do not want to force casual visitors to just
download the 10 MiB+ compressed editor WebAssembly file without pressing
the start button.

Special thanks to Hugo Locurcio (Calinou) for the initial work.
2021-03-08 17:06:24 +01:00
Fabio Alessandrelli
1446cfd13d [HTML5] Fix compilation issues in 4.0
More memory is needed, and a Workaround to avoid undefined symbol due to
dead code elimination.
2021-02-17 13:03:52 +01:00
Quadtree
d2c34e83b5 Add cwrap to EXTRA_EXPORTED_RUNTIME_METHODS 2021-02-16 01:04:44 -08:00
Marcel Admiraal
fad0cec272 Don't handle BaseException in JavaScript build script 2021-01-28 19:23:49 +00:00
Fabio Alessandrelli
4e09453407 [HTML5] Better editor HTML, small refactor.
Side and GDNative libraries are now added by engine.js , the dynlink pre
js had been deleted.
2021-01-25 20:15:57 +01:00
Fabio Alessandrelli
abb8d8e8ca [HTML5] Fix "initial_memory" build option parsing 2021-01-25 17:47:52 +01:00
Fabio Alessandrelli
c327f42b0a [HTML5] Reorganize build script.
Simplify helper functions, fix env/sys_env confusion and depends for
externs and pre-js.
2021-01-10 12:24:40 +01:00
David Snopek
a54a2d65e1 Add support for WebXR 2021-01-04 17:02:37 -06:00
Rémi Verschelde
2760f5d0b4
Merge pull request #44315 from madmiraal/fix-handles-baseexception
Don't handle BaseException in build scripts
2020-12-12 12:23:07 +01:00
Marcel Admiraal
8ef5e3201c Don't handle BaseException in build scripts 2020-12-12 10:05:42 +00:00
Rémi Verschelde
8020515717
HTML5: Code style cleanup for export code 2020-12-10 13:57:46 +01:00
Fabio Alessandrelli
a28d5e2be7 [HTML5] Improve platform buildsystem.
Check emcc version requirements when building GDNative.
Add more build options (sanitizers, initial memory).
2020-12-09 17:54:50 +01:00
Fabio Alessandrelli
ca34b5e57a [HTML5] GDNative support via SIDE_MODULE.
Working with emscripten >= 2.0.10
2020-12-05 00:52:43 +01:00
bruvzg
b9f441e81e
[Complex Text Layouts] Add third-party TextServer dependencies (ICU, HarfBuzz, Graphite). 2020-11-26 13:55:27 +02:00
Rémi Verschelde
2e4bff1cfe
SCons: Remove unnecessary $LINK overrides
As of SCons 4.0.1, the default value for $LINK is $SMARTLINK, which itself
is a function that will use $CXX as linker for C++:

https://github.com/SCons/scons/blob/4.0.1/SCons/Tool/link.py#L327-L328
https://github.com/SCons/scons/blob/4.0.1/SCons/Tool/link.py#L54-L76

So we don't need to manually specify the same value as $CXX for $LINK.
2020-11-19 16:48:03 +01:00
Fabio Alessandrelli
e2083871eb [HTML5] Port JavaScript inline code to libraries.
The API is implemented in javascript, and generates C functions that can
be called from godot.
This allows much cleaner code replacing all `EM_ASM` calls in our C++
code with plain C function calls.
This also gets rid of few hacks and comes with few optimizations (e.g.
custom cursor shapes should be much faster now).
2020-11-10 11:42:51 +01:00
Fabio Alessandrelli
54cda5c3b8 [HTML5] Update syntax for lto. 2020-11-10 11:42:51 +01:00
Fabio Alessandrelli
c3b7c5cc2d Increase HTML5 THREADPOOL size.
This fixes a "random" deadlock when quitting the editor.
I still haven't figure out the root cause, but having a bigger seems to
greatly mitigate the issue.
The new pool size (pre-allocated threads) is now 8.
2020-10-14 11:13:12 +02:00
Fabio Alessandrelli
7998745237 [HTML5] Scons now expects "emcc" to be in PATH.
No longer parse emscripten/emsdk config to detect emcc/node paths.
Use WhereIs to find "emcc" and "node", look for "node_modules" in "emcc"
path.
2020-10-04 14:26:44 +02:00
Fabio Alessandrelli
80b34ccee1 Add extra suffix for HTML5 thread builds. 2020-10-02 13:35:03 +02:00
Fabio Alessandrelli
d2eef39731 Fix Closure compiler build, python style.
Move copyToFS into utils.js library included with '--pre-js'.
2020-05-10 18:22:48 +02:00
Fabio Alessandrelli
7411e7fd37 DisplayServerJavaScript implementation. 2020-05-10 18:22:48 +02:00
Fabio Alessandrelli
ee99cd42d5 [HTML5] Locale, input fix, context, exit.
Add missing semicolumns in engine.js
Add optional extra args to JS Engine.startGame
Remove loader.js, explicit noExitRuntime.
Also add onExit callback (undocumented in emscripten)
2020-05-10 18:19:23 +02:00
Rémi Verschelde
cd4e46ee65 SCons: Format buildsystem files with psf/black
Configured for a max line length of 120 characters.

psf/black is very opinionated and purposely doesn't leave much room for
configuration. The output is mostly OK so that should be fine for us,
but some things worth noting:

- Manually wrapped strings will be reflowed, so by using a line length
  of 120 for the sake of preserving readability for our long command
  calls, it also means that some manually wrapped strings are back on
  the same line and should be manually merged again.

- Code generators using string concatenation extensively look awful,
  since black puts each operand on a single line. We need to refactor
  these generators to use more pythonic string formatting, for which
  many options are available (`%`, `format` or f-strings).

- CI checks and a pre-commit hook will be added to ensure that future
  buildsystem changes are well-formatted.
2020-03-30 09:05:53 +02:00
Fabio Alessandrelli
919bbf8077 [HTML5] Refactor JS, threads support, closures.
- Refactored the Engine code, splitted across files.
- Use MODULARIZE option to build emscripten code into it's own closure.
- Enable lto support (saves ~2MiB in release).
- Enable optional closure compiler pass for JS and generated code.
- Enable optional pthreads support.
- Can now build with tools=yes (not much to see yet).
- Dropped some deprecated code for older toolchains.
2020-03-11 16:09:31 +01:00
Hugo Locurcio
e818b51f32
Only emit the JavaScript support code for Web when building for HTML5
Excluding other unused environments like Node.js makes the support code
about 4 KB smaller.
2020-01-31 12:33:16 +01:00
Rémi Verschelde
6d6280dfa3 Emscripten: Re-add BINARYEN_TRAP_MODE='clamp' for fastcomp
The option is needed when using the 'fastcomp' backend (default before
1.39.0), and must not be defined when using 'upstream' (new default).
So we define it conditionally to support both backends.

Follow-up to #30751.
2019-12-03 13:33:35 +01:00
Rémi Verschelde
02913f53d3 pcre2: Use scons option to disable JIT on some platforms
Third-party platforms (e.g. console ports) need to be able to
disable JIT support in the regex module too, so it can't be
hardcoded in the module SCsub. This is cleaner this way anyway.

Fixes #19316.
2019-11-20 08:54:52 +01:00
Rémi Verschelde
e5dfcb5edd HTML5: Explicitly link idbfs.js for IDBFS support
Upstream Emscripten changed this in 1.39.1+, so IDBFS is no longer
included by default and has to be linked manually.

The explicit linking doesn't seem to be problematic on earlier
versions (tested `1.38.47-upstream`).

Fixes #33724.
2019-11-19 09:45:43 +01:00
Rémi Verschelde
e9e2a4b044 HTML5: Fix support for Emscripten 1.39.1+
A change in upstream Emscripten 1.39.1+ made our buildsystem error
out where it was previously only issuing a warning:
```
[  5%] Linking Static Library ==> main/libmain.javascript.opt.bc
shared:WARNING: Assuming object file output in the absence of `-c`, based on output filename. Please add with `-c` or `-r` to avoid this warning
Ranlib Library         ==> main/libmain.javascript.opt.bc
/opt/emsdk/upstream/bin/llvm-ranlib: error: unable to load 'main/libmain.javascript.opt.bc': file too small to be an archive
```

As advised on emscripten-core/emscripten#9806, we should be using
`emar` here to create the static library and not `emcc`.
This was apparently done to workaround Emscripten issues in the past,
but evidently this is no longer necessary.

The rest of the `env` redefinitions should probably be re-assessed
against the current state of Emscripten.

Fixes #33374.
2019-11-15 09:39:19 +01:00
mellondill
3c176827d6 https://github.com/godotengine/godot/issues/31297 - HTML5: this.rtenv.callMain is not a function when using latest-upstream backend
Added needed changed for normal compiling with emscripten 1.38.41 and later
2019-08-12 21:59:27 +03:00
Rémi Verschelde
63544e6b02 Emscripten: Do not define BINARYEN_TRAP_MODE='clamp'
It is not supported in Emscripten's `latest-upstream` LLVM backend,
and doesn't seem necessary in the `latest` backend either.
It was initially added in #22857 to solve a compilation error with the latter.

Part of #30270.
2019-07-22 13:21:56 +02:00
Fabio Alessandrelli
0c19674621 Better detect Emscripten toolchain.
Emscripten is apparently changing the variables in its config file,
causing potential breakage of our build system.

Binaries of the latest/latest-upstream releases are located in a
subfolder of BINARYEN_ROOT called emscripten.
Binaries of the other releases (e.g. sdk-1.38.31-64bit) are instead
placed under the EMSCRIPTEN_ROOT folder.

This PR checks if BINARYEN_ROOT has a subfolder called emscripten, if
that does not exists, it falls back to checking the EMSCRIPTEN_ROOT.

This way we give precedence to the new releases, given that activating
multiple releases sequentially might result in having mismatching
BINARYEN_ROOT and EMSCRIPTEN_ROOT.
2019-07-09 19:17:27 +02:00
Hugo Locurcio
e08fa103f2
Fix Emscripten root directory detection when building for HTML5
Recent Emscripten SDK versions seem to only include the
`BINARYEN_ROOT` variable in the Emscripten configuration file,
whereas the platform's `detect.py` only looked at `EMSCRIPTEN_ROOT`.
2019-06-19 22:23:58 +02:00
Rémi Verschelde
4b20959d99 SCons: Keep exceptions and rtti on Android, iOS and HTML5 tools build
Those were disable to keep size small, and on Android avoid the dependency on the STL,
but for tools build (editor) this is not really a concern.

Note: as of today it's not possible to build tools=yes for those platforms, but this
change is one of the necessary steps to enable it.

Fixes #25262.
2019-05-20 16:51:20 +02:00
Rémi Verschelde
d52b70fb5e SCons: Always use env.Prepend for CPPPATH
Include paths are processed from left to right, so we use Prepend to
ensure that paths to bundled thirdparty files will have precedence over
system paths (e.g. `/usr/include` should have lowest priority).
2019-04-30 13:12:06 +02:00
Hendrikto
49a81308c0 Remove unused imports 2019-04-06 18:05:05 +02:00
Rémi Verschelde
1807e0f135 SCons: Move platform-specific Opus config to its module 2019-03-02 10:30:25 +01:00
Leon Krause
81554dac61 Fix file preloading warning in HTML5 platform 2019-02-23 20:06:22 +01:00
Rémi Verschelde
5fc86026ca Fix typos with codespell
Using codespell 1.14.0.

Method:
```
$ cat > ../godot-word-whitelist.txt << EOF
ang
doubleclick
lod
nd
numer
que
te
unselect
EOF
$ codespell -w -q 3 -I ../godot-word-whitelist.txt --skip="./thirdparty,*.po"
$ git diff // undo unwanted changes
```
2019-02-13 09:23:29 +01:00
Marcelo Fernandez
3a702b3ed8 Implemented audio input support for JavaScript audio driver 2018-11-26 19:14:52 -03:00
Leon Krause
44e5d446c4 Enable --no-heap-copy flag for HTML5 builds 2018-10-29 21:08:51 +01:00
Leon Krause
b4b816c122 Enable Theora module for HTML5 platform 2018-08-28 01:56:47 +02:00
Leon Krause
975c0516a4 Build HTML5 release_debug with -Os, like release.
The increased build time is negligible in comparison to the decreased
file size.
2018-05-14 15:31:16 +02:00