Better wasm support again (#1779)
* wasm: add shell file for loading wasm module * wasm: disable pcre2 jit * wasm: add more configuration options * cross/wasm: more build options (cherry picked from commit 6575c297b50417eff0b82fd80340a192ba016b99)
This commit is contained in:
@@ -41,5 +41,9 @@ sips -s dpiWidth 144 -s dpiHeight 144 macos/background@2x.png
|
||||
|
||||
`sips` and `tiffutil` are available by default on macOS.
|
||||
|
||||
### Other Files
|
||||
|
||||
- `shell.html`: A shell file for use with WASM builds.
|
||||
|
||||
|
||||
[1]: https://mesonbuild.com/Cross-compilation.html
|
||||
|
||||
@@ -1,26 +1,62 @@
|
||||
# cross file for WASM.
|
||||
# use this file by running meson setup --cross-file resources/cross/wasm.txt <builddir>
|
||||
# Cross file for WASM.
|
||||
# Use this file by running meson setup --cross-file resources/cross/wasm.txt <builddir>
|
||||
# You can import other cross files after this one to override the options.
|
||||
|
||||
[constants]
|
||||
|
||||
# a list of functions that can run without being asyncified; proceed with caution
|
||||
# A list of functions that can run without being asyncified; proceed with caution
|
||||
asyncify_ignores = '["SDL_BlitScaled","SDL_UpperBlitScaled","SDL_MapRGB*","SDL_FillRect","SDL_FreeSurface","SDL_CreateRGBSurface","SDL_GetWindowSurface","SDL_PollEvent","SDL_CreateSystemCursor","SDL_SetWindowTitle","SDL_SetCursor","SDL_GetWindowSize","SDL_GetWindowPosition","lua_push*","lua_rawget*","luaL_check*","pcre2*","FT_*","Bezier_*","g_*","FT_*","ft_*","TT_*","tt_*","__*","*printf","gray_*","fopen","fclose","fread","fflush","qsort","sift"]'
|
||||
|
||||
# enable advising for optimizing the list above; disable this to prevent flooding logs
|
||||
# Enable advising for optimizing the list above; disable this to prevent flooding logs
|
||||
asyncify_advise = '0'
|
||||
|
||||
# initial heap size in bytes; make sure it is not too low (around 64mb - 250mb)
|
||||
# Stack size for asyncify; increase this if you have problems with asyncify-induced crashes
|
||||
asyncify_stack_size = '6144'
|
||||
|
||||
# Initial heap size in bytes; make sure it is not too low (around 64mb - 250mb)
|
||||
initial_heap = '104857600'
|
||||
|
||||
# Emscripten is not always added to PATH.
|
||||
# Replace this variable with the path to Emscripten;
|
||||
# or supply a second machine file that defines this variable.
|
||||
toolchain = ''
|
||||
|
||||
# The memory allocator to use. You shouldn't need to change this,
|
||||
# but other allocator might offer more performance at the cost of binary size.
|
||||
malloc_impl = 'emmalloc'
|
||||
|
||||
# Functions exported by the main module.
|
||||
# This is needed if you plan to load shared libraries which need symbols from the main binary.
|
||||
# e.g. stdout, stderr, fopen, etc. Use another cross file to override this value.
|
||||
exported_functions = '_main'
|
||||
|
||||
# Exported Filesystem modules.
|
||||
# For example, you can put '-lidbfs.js' to export IDBFS for later use.
|
||||
exported_filesystems = []
|
||||
|
||||
# Exported JS values in Module.
|
||||
# This is needed to preserve symbols after tree shaking.
|
||||
exported_js_values = '[]'
|
||||
|
||||
# Extra link options passed to the linker.
|
||||
extra_link_options = []
|
||||
|
||||
# In order to run Lite XL, you will also need to bundle the /data directory.
|
||||
# The following option is added to the linking process to bundle the /data directory.
|
||||
# If you want to do this manually or the automatic bundling process does not work,
|
||||
# comment out the following line.
|
||||
bundle_paths = ['--preload-file', '../data@/usr/share/lite-xl/']
|
||||
|
||||
|
||||
[binaries]
|
||||
c = 'emcc'
|
||||
cpp = 'em++'
|
||||
ar = 'emar'
|
||||
strip = 'emstrip'
|
||||
cmake = ['emmake', 'cmake']
|
||||
pkg-config = ['emconfigure', 'pkg-config']
|
||||
sdl2-config = ['emconfigure', 'sdl2-config']
|
||||
c = toolchain / 'emcc'
|
||||
cpp = toolchain / 'em++'
|
||||
ar = toolchain / 'emar'
|
||||
strip = toolchain / 'emstrip'
|
||||
cmake = [toolchain / 'emmake', 'cmake']
|
||||
pkg-config = [toolchain / 'emconfigure', 'pkg-config']
|
||||
sdl2-config = [toolchain / 'emconfigure', 'sdl2-config']
|
||||
file_packager = ['python3', toolchain / 'tools/file_packager.py']
|
||||
|
||||
|
||||
[properties]
|
||||
@@ -28,16 +64,23 @@ needs_exe_wrapper = true
|
||||
|
||||
|
||||
[built-in options]
|
||||
c_args = []
|
||||
c_args = ['-fPIC']
|
||||
c_link_args = []
|
||||
cpp_args = []
|
||||
cpp_args = ['-fPIC']
|
||||
cpp_link_args = []
|
||||
|
||||
|
||||
[project options]
|
||||
buildtype = 'release'
|
||||
c_link_args = ['-s', 'ALLOW_MEMORY_GROWTH=1', '-s', 'INITIAL_MEMORY=' + initial_heap, '-s', 'ASYNCIFY=1', '-s', 'ASYNCIFY_ADVISE=' + asyncify_advise, '-s', 'ASYNCIFY_STACK_SIZE=6144', '-s', 'ASYNCIFY_REMOVE=' + asyncify_ignores, '-s', 'FORCE_FILESYSTEM=1']
|
||||
portable = true
|
||||
arch_tuple = 'wasm32-unknown'
|
||||
wrap_mode = 'nofallback'
|
||||
force_fallback_for = 'lua,pcre2,freetype2'
|
||||
c_link_args = ['-sALLOW_MEMORY_GROWTH=1', '-sINITIAL_MEMORY=' + initial_heap, '-sASYNCIFY', '-sASYNCIFY_ADVISE=' + asyncify_advise, '-sASYNCIFY_STACK_SIZE=' + asyncify_stack_size, '-sASYNCIFY_REMOVE=' + asyncify_ignores, '-sFORCE_FILESYSTEM=1', '-sEXIT_RUNTIME=1', '-sMALLOC=' + malloc_impl, '-sMAIN_MODULE=1', '-sEXPORTED_FUNCTIONS=' + exported_functions, '-sEXPORTED_RUNTIME_METHODS=' + exported_js_values] + extra_link_options + bundle_paths + exported_filesystems
|
||||
|
||||
[pcre2:project options]
|
||||
jit = 'disabled'
|
||||
jit_sealloc = 'disabled'
|
||||
|
||||
[host_machine]
|
||||
system = 'emscripten'
|
||||
|
||||
@@ -0,0 +1,87 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8" />
|
||||
<meta http-equiv="x-ua-compatible" content="ie=edge" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<title>Lite XL</title>
|
||||
|
||||
<style>
|
||||
/* make everything fullscreen */
|
||||
html,
|
||||
body,
|
||||
canvas {
|
||||
width: 100%;
|
||||
height: 100%;
|
||||
display: block;
|
||||
margin: 0;
|
||||
font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Open Sans', 'Helvetica Neue', sans-serif;
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.modal {
|
||||
position: fixed;
|
||||
top: 50%;
|
||||
left: 50%;
|
||||
transform: translate(-50%, -50%);
|
||||
}
|
||||
|
||||
#close {
|
||||
display: none;
|
||||
}
|
||||
</style>
|
||||
<script type="application/javascript">
|
||||
var Module = {
|
||||
arguments: ['/home/web_user/welcome.md'],
|
||||
preRun: [function () {
|
||||
ENV.LITE_PREFIX = '/usr';
|
||||
FS.chdir('/home/web_user');
|
||||
FS.writeFile('/home/web_user/welcome.md',
|
||||
'# Welcome to Lite XL!\n\n' +
|
||||
'This is an instance of Lite XL running on your browser using **JavaScript** and **WASM**.\n\n' +
|
||||
'There isn\'t a lot of things you can do here; you can **create, edit and save files**,\n' +
|
||||
'but they _will not be persisted_ across different tabs / sessions.\n\n' +
|
||||
'Not all plugins work, and **some keyboard shortcuts might not work** if your browser\n' +
|
||||
'overrides them. Nevertheless, this is pretty cool.\n');
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
}],
|
||||
onExit: function () {
|
||||
document.getElementById('loading').style.display = 'none';
|
||||
document.getElementById('canvas').style.display = 'none';
|
||||
document.getElementById('close').style.display = 'block';
|
||||
}
|
||||
};
|
||||
|
||||
window.onload = function () {
|
||||
// disable canvas right click
|
||||
var canvas = document.getElementById('canvas');
|
||||
var status = document.getElementById('status');
|
||||
canvas.oncontextmenu = function (e) { e.preventDefault(); };
|
||||
Module.canvas = canvas;
|
||||
Module.setStatus = function (s) {
|
||||
status.textContent = s;
|
||||
};
|
||||
};
|
||||
</script>
|
||||
<script type="application/javascript" src="./lite-xl.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<canvas id="canvas"></canvas>
|
||||
<div class="modal" id="loading">
|
||||
<h2>Loading...</h2>
|
||||
<p>Status: <span id="status">Unknown</span></p>
|
||||
<p>If this page freezes, please check the console for any errors.</p>
|
||||
</div>
|
||||
<div class="modal" id="close">
|
||||
<h2>Oops, Lite XL is closed!</h2>
|
||||
<p>If you didn't do this intentionally, please check the console for any errors.</p>
|
||||
<p>You can refresh the page to load Lite XL again.</p>
|
||||
</div>
|
||||
<noscript>
|
||||
<p>You need to enable JavaScript and WASM for this page to work.</p>
|
||||
</noscript>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user