Skip to content

Commit d1d9f3b

Browse files
committed
Move html templates to html/ directory
I'm looking into adding some more template samples, such as one that includes xterm.js. Keeping all the html in separate directory seems tidier.
1 parent da8b92b commit d1d9f3b

File tree

11 files changed

+27
-18
lines changed

11 files changed

+27
-18
lines changed

docs/emcc.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -396,7 +396,7 @@ Options that are modified or new in *emcc* are listed below:
396396

397397
Note:
398398

399-
* See src/shell.html and src/shell_minimal.html for examples.
399+
* See html/shell.html and html/shell_minimal.html for examples.
400400

401401
* This argument is ignored if a target other than HTML is
402402
specified using the "-o" option.

html/README.md

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
HTML Template Files
2+
===================
3+
4+
The files in this directory are html templates used by emscripten when
5+
generating html output. These are only used when the output of the compiler
6+
has the `.html` suffix (or when `-oformat=html` is specified).
7+
8+
By default the `shell.html` file in this directory is used but an alternative
9+
can be specified using the `--shell-file` flag.
File renamed without changes.

src/shell.html renamed to html/shell.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<span id='controls'>
1616
<span><input type="checkbox" id="resize">Resize canvas</span>
1717
<span><input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer &nbsp;&nbsp;&nbsp;</span>
18-
<span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
18+
<span><input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
1919
document.getElementById('resize').checked)">
2020
</span>
2121
</span>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@
5151
<figure style="overflow:visible;" id="spinner"><div class="spinner"></div><center style="margin-top:0.5em"><strong>emscripten</strong></center></figure>
5252
<div class="emscripten" id="status">Downloading...</div>
5353
<div class="emscripten">
54-
<progress value="0" max="100" id="progress" hidden=1></progress>
54+
<progress value="0" max="100" id="progress" hidden=1></progress>
5555
</div>
5656
<div class="emscripten_border">
5757
<canvas class="emscripten" id="canvas" oncontextmenu="event.preventDefault()" tabindex=-1></canvas>
@@ -61,10 +61,10 @@
6161
<input type="checkbox" id="resize">Resize canvas
6262
<input type="checkbox" id="pointerLock" checked>Lock/hide mouse pointer
6363
&nbsp;&nbsp;&nbsp;
64-
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
64+
<input type="button" value="Fullscreen" onclick="Module.requestFullscreen(document.getElementById('pointerLock').checked,
6565
document.getElementById('resize').checked)">
6666
</div>
67-
67+
6868
<hr/>
6969
<textarea class="emscripten" id="output" rows="8"></textarea>
7070
<hr>

site/source/docs/compiling/Deploying-Pages.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ Emscripten build output consists of two essential parts: 1) the low level compil
1313

1414
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.
1515

16-
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.
16+
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.
1717

1818
The following sections offer tips for improving the site experience.
1919

site/source/docs/tools_reference/emcc.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -383,7 +383,7 @@ Options that are modified or new in *emcc* are listed below:
383383

384384
.. note::
385385

386-
- 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.
386+
- 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.
387387
- This argument is ignored if a target other than HTML is specified using the ``-o`` option.
388388

389389
.. _emcc-source-map-base:

test/test_browser.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -734,7 +734,7 @@ def test_custom_file_package_url(self):
734734
# change the file package base dir to look in a "cdn". note that normally
735735
# you would add this in your own custom html file etc., and not by
736736
# modifying the existing shell in this manner
737-
default_shell = read_file(path_from_root('src/shell.html'))
737+
default_shell = read_file(path_from_root('html/shell.html'))
738738
create_file('shell.html', default_shell.replace('var Module = {', '''
739739
var Module = {
740740
locateFile: function(path, prefix) {
@@ -836,7 +836,7 @@ def setup(assetLocalization):
836836
self.run_browser('test.html', '/report_result?1')
837837

838838
# TODO: CORS, test using a full url for locateFile
839-
# 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;}, '))
839+
# 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;}, '))
840840
# test()
841841

842842
@also_with_wasmfs
@@ -3643,7 +3643,7 @@ def test_memory_growth_during_startup(self):
36433643
# pthreads tests
36443644

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

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

4956-
# Tests that the different code paths in src/shell_minimal_runtime.html all work ok.
4956+
# Tests that the different code paths in html/shell_minimal_runtime.html all work ok.
49574957
@parameterized({
49584958
'': ([],),
49594959
'modularize': (['-sMODULARIZE'],),

tools/link.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858

5959
logger = logging.getLogger('link')
6060

61-
DEFAULT_SHELL_HTML = utils.path_from_root('src/shell.html')
61+
DEFAULT_SHELL_HTML = utils.path_from_root('html/shell.html')
6262

6363
DEFAULT_ASYNCIFY_IMPORTS = ['__asyncjs__*']
6464

@@ -1139,7 +1139,7 @@ def limit_incoming_module_api():
11391139
if not options.shell_path:
11401140
# Minimal runtime uses a different default shell file
11411141
if settings.MINIMAL_RUNTIME:
1142-
options.shell_path = options.shell_path = utils.path_from_root('src/shell_minimal_runtime.html')
1142+
options.shell_path = options.shell_path = utils.path_from_root('html/shell_minimal_runtime.html')
11431143
else:
11441144
options.shell_path = DEFAULT_SHELL_HTML
11451145

@@ -1627,7 +1627,7 @@ def limit_incoming_module_api():
16271627

16281628
if settings.MODULARIZE and not (settings.EXPORT_ES6 and not settings.SINGLE_FILE) and \
16291629
settings.EXPORT_NAME == 'Module' and options.oformat == OFormat.HTML and \
1630-
(options.shell_path == DEFAULT_SHELL_HTML or options.shell_path == utils.path_from_root('src/shell_minimal.html')):
1630+
(options.shell_path == DEFAULT_SHELL_HTML or options.shell_path == utils.path_from_root('html/shell_minimal.html')):
16311631
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)')
16321632

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

25402540
shell = do_replace(shell, '{{{ SCRIPT }}}', script.replacement())
2541-
shell = shell.replace('{{{ SHELL_CSS }}}', utils.read_file(utils.path_from_root('src/shell.css')))
2541+
shell = shell.replace('{{{ SHELL_CSS }}}', utils.read_file(utils.path_from_root('html/shell.css')))
25422542
logo_filename = utils.path_from_root('media/powered_by_logo_shell.png')
25432543
logo_b64 = base64_encode(logo_filename)
25442544
shell = shell.replace('{{{ SHELL_LOGO }}}', f'<img id="emscripten_logo" src="data:image/png;base64,{logo_b64}">')

0 commit comments

Comments
 (0)