Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ Options that are modified or new in *emcc* are listed below:

Note:

* See src/shell.html and src/shell_minimal.html for examples.
* See html/shell.html and html/shell_minimal.html for examples.

* This argument is ignored if a target other than HTML is
specified using the "-o" option.
Expand Down
9 changes: 9 additions & 0 deletions html/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
HTML Template Files
===================

The files in this directory are html templates used by emscripten when
generating html output. These are only used when the output of the compiler
has the `.html` suffix (or when `-oformat=html` is specified).

By default the `shell.html` file in this directory is used but an alternative
can be specified using the `--shell-file` flag.
File renamed without changes.
2 changes: 1 addition & 1 deletion src/shell.html → html/shell.html
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<span id='controls'>
<span><input type="checkbox" id="resize">Resize canvas</span>
<span><input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer &nbsp;&nbsp;&nbsp;</span>
<span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
<span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
document.getElementById('resize').checked)">
</span>
</span>
Expand Down
6 changes: 3 additions & 3 deletions src/shell_minimal.html → html/shell_minimal.html
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>emscripten</strong></center></figure>
<div class="emscripten" id="status">Downloading...</div>
<div class="emscripten">
<progress value="0" max="100" id="progress" hidden=1></progress>
<progress value="0" max="100" id="progress" hidden=1></progress>
</div>
<div class="emscripten_border">
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
Expand All @@ -61,10 +61,10 @@
<input type="checkbox" id="resize">Resize canvas
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer
&nbsp;&nbsp;&nbsp;
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
document.getElementById('resize').checked)">
</div>

<hr/>
<textarea class="emscripten" id="output" rows="8"></textarea>
<hr>
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion site/source/docs/compiling/Deploying-Pages.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Emscripten build output consists of two essential parts: 1) the low level compil

Additional build output files can also exist, depending on which features are used. If the Emscripten file packager is used, a binary ``out.data`` package is generated, along with an associated ``out.data.js`` loader file. Also Emscripten pthreads and Fetch APIs have their own associated Web Worker related script ``.js`` output files.

Developers can choose to output either to JavaScript or HTML. If outputting JavaScript (``emcc -o out.js``), the developer is expected to manually create the ``out.html`` main page in which the code is run in browsers. When targeting HTML with ``emcc -o out.html`` (the recommended build mode), Emscripten will generate the HTML shell file automatically. This shell file can be customized by using the ``emcc -o out.html --shell-file path/to/custom_shell.html`` linker directive. Copy the `default minimal HTML shell file <https://github.com/emscripten-core/emscripten/blob/main/src/shell_minimal.html>`_ from Emscripten repository to your project tree to get a good starting template for a customized shell file.
Developers can choose to output either to JavaScript or HTML. If outputting JavaScript (``emcc -o out.js``), the developer is expected to manually create the ``out.html`` main page in which the code is run in browsers. When targeting HTML with ``emcc -o out.html`` (the recommended build mode), Emscripten will generate the HTML shell file automatically. This shell file can be customized by using the ``emcc -o out.html --shell-file path/to/custom_shell.html`` linker directive. Copy the `default minimal HTML shell file <https://github.com/emscripten-core/emscripten/blob/main/html/shell_minimal.html>`_ from Emscripten repository to your project tree to get a good starting template for a customized shell file.

The following sections offer tips for improving the site experience.

Expand Down
2 changes: 1 addition & 1 deletion site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,7 @@ Options that are modified or new in *emcc* are listed below:

.. note::

- See `src/shell.html <https://github.com/emscripten-core/emscripten/blob/main/src/shell.html>`_ and `src/shell_minimal.html <https://github.com/emscripten-core/emscripten/blob/main/src/shell_minimal.html>`_ for examples.
- See `html/shell.html <https://github.com/emscripten-core/emscripten/blob/main/html/shell.html>`_ and `html/shell_minimal.html <https://github.com/emscripten-core/emscripten/blob/main/html/shell_minimal.html>`_ for examples.
- This argument is ignored if a target other than HTML is specified using the ``-o`` option.

.. _emcc-source-map-base:
Expand Down
12 changes: 6 additions & 6 deletions test/test_browser.py
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,7 @@ def test_custom_file_package_url(self):
# change the file package base dir to look in a "cdn". note that normally
# you would add this in your own custom html file etc., and not by
# modifying the existing shell in this manner
default_shell = read_file(path_from_root('src/shell.html'))
default_shell = read_file(path_from_root('html/shell.html'))
create_file('shell.html', default_shell.replace('var Module = {', '''
var Module = {
locateFile: function(path, prefix) {
Expand Down Expand Up @@ -836,7 +836,7 @@ def setup(assetLocalization):
self.run_browser('test.html', '/report_result?1')

# TODO: CORS, test using a full url for locateFile
# create_file('shell.html', read_file(path_from_root('src/shell.html')).replace('var Module = {', 'var Module = { locateFile: function (path) {return "http:/localhost:8888/cdn/" + path;}, '))
# create_file('shell.html', read_file(path_from_root('html/shell.html')).replace('var Module = {', 'var Module = { locateFile: function (path) {return "http:/localhost:8888/cdn/" + path;}, '))
# test()

@also_with_wasmfs
Expand Down Expand Up @@ -3643,7 +3643,7 @@ def test_memory_growth_during_startup(self):
# pthreads tests

def prep_no_SAB(self):
create_file('html.html', read_file(path_from_root('src/shell_minimal.html')).replace('''<body>''', '''<body>
create_file('html.html', read_file(path_from_root('html/shell_minimal.html')).replace('''<body>''', '''<body>
<script>
SharedArrayBuffer = undefined;
Atomics = undefined;
Expand Down Expand Up @@ -4155,7 +4155,7 @@ def test_manual_wasm_instantiate(self):
def test_wasm_locate_file(self):
# Test that it is possible to define "Module.locateFile(foo)" function to locate where worker.js will be loaded from.
ensure_dir('cdn')
shell = read_file(path_from_root('src/shell.html'))
shell = read_file(path_from_root('html/shell.html'))
create_file('shell2.html', shell.replace('var Module = {', 'var Module = { locateFile: (filename) => (filename == "test.wasm") ? "cdn/test.wasm" : filename, '))
self.compile_btest('browser_test_hello_world.c', ['--shell-file', 'shell2.html', '-o', 'test.html'])
shutil.move('test.wasm', Path('cdn/test.wasm'))
Expand Down Expand Up @@ -4804,7 +4804,7 @@ def test_unicode_html_shell(self):
return 0;
}
''')
create_file('shell.html', read_file(path_from_root('src/shell.html')).replace('Emscripten-Generated Code', 'Emscripten-Generated Emoji 😅'))
create_file('shell.html', read_file(path_from_root('html/shell.html')).replace('Emscripten-Generated Code', 'Emscripten-Generated Emoji 😅'))
self.btest_exit('main.c', cflags=['--shell-file', 'shell.html'])

# Tests the functionality of the emscripten_thread_sleep() function.
Expand Down Expand Up @@ -4953,7 +4953,7 @@ def test_no_declare_asm_module_exports_wasm2js(self, args):
def test_no_declare_asm_module_exports(self, args):
self.btest_exit('declare_asm_module_exports.c', cflags=['-sDECLARE_ASM_MODULE_EXPORTS=0', '-sENVIRONMENT=web', '-O3', '--closure=1'] + args)

# Tests that the different code paths in src/shell_minimal_runtime.html all work ok.
# Tests that the different code paths in html/shell_minimal_runtime.html all work ok.
@parameterized({
'': ([],),
'modularize': (['-sMODULARIZE'],),
Expand Down
8 changes: 4 additions & 4 deletions tools/link.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@

logger = logging.getLogger('link')

DEFAULT_SHELL_HTML = utils.path_from_root('src/shell.html')
DEFAULT_SHELL_HTML = utils.path_from_root('html/shell.html')

DEFAULT_ASYNCIFY_IMPORTS = ['__asyncjs__*']

Expand Down Expand Up @@ -1139,7 +1139,7 @@ def limit_incoming_module_api():
if not options.shell_path:
# Minimal runtime uses a different default shell file
if settings.MINIMAL_RUNTIME:
options.shell_path = options.shell_path = utils.path_from_root('src/shell_minimal_runtime.html')
options.shell_path = options.shell_path = utils.path_from_root('html/shell_minimal_runtime.html')
else:
options.shell_path = DEFAULT_SHELL_HTML

Expand Down Expand Up @@ -1627,7 +1627,7 @@ def limit_incoming_module_api():

if settings.MODULARIZE and not (settings.EXPORT_ES6 and not settings.SINGLE_FILE) and \
settings.EXPORT_NAME == 'Module' and options.oformat == OFormat.HTML and \
(options.shell_path == DEFAULT_SHELL_HTML or options.shell_path == utils.path_from_root('src/shell_minimal.html')):
(options.shell_path == DEFAULT_SHELL_HTML or options.shell_path == utils.path_from_root('html/shell_minimal.html')):
exit_with_error(f'Due to collision in variable name "Module", the shell file "{options.shell_path}" is not compatible with build options "-sMODULARIZE -sEXPORT_NAME=Module". Either provide your own shell file, change the name of the export to something else to avoid the name collision. (see https://github.com/emscripten-core/emscripten/issues/7950 for details)')

if settings.WASM_BIGINT:
Expand Down Expand Up @@ -2538,7 +2538,7 @@ def generate_traditional_runtime_html(target, options, js_target, wasm_target):
''' % (script.inline, get_subresource_location_js(wasm_target + '.js'))

shell = do_replace(shell, '{{{ SCRIPT }}}', script.replacement())
shell = shell.replace('{{{ SHELL_CSS }}}', utils.read_file(utils.path_from_root('src/shell.css')))
shell = shell.replace('{{{ SHELL_CSS }}}', utils.read_file(utils.path_from_root('html/shell.css')))
logo_filename = utils.path_from_root('media/powered_by_logo_shell.png')
logo_b64 = base64_encode(logo_filename)
shell = shell.replace('{{{ SHELL_LOGO }}}', f'<img id="emscripten_logo" src="data:image/png;base64,{logo_b64}">')
Expand Down
2 changes: 1 addition & 1 deletion tools/minimal_runtime_shell.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ def generate_minimal_runtime_html(target, options, js_target, target_basename):
shell = building.read_and_preprocess(shell_temp)

if re.search(r'{{{\s*SCRIPT\s*}}}', shell):
utils.exit_with_error('--shell-file "' + options.shell_path + '": MINIMAL_RUNTIME uses a different kind of HTML page shell file than the traditional runtime! Please see $EMSCRIPTEN/src/shell_minimal_runtime.html for a template to use as a basis.')
utils.exit_with_error('--shell-file "' + options.shell_path + '": MINIMAL_RUNTIME uses a different kind of HTML page shell file than the traditional runtime! Please see $EMSCRIPTEN/html/shell_minimal_runtime.html for a template to use as a basis.')

shell = shell.replace('{{{ TARGET_BASENAME }}}', settings.TARGET_BASENAME)
shell = shell.replace('{{{ EXPORT_NAME }}}', settings.EXPORT_NAME)
Expand Down