Skip to content

Commit c291a04

Browse files
authored
Add verification step for metadata tags in settings.js. NFC (#25677)
At this point we could also consider removing these tags but I think it makes reading the settings.js directly more useful to keep them for now. This new code just checks that the tags are always in sync with the lists and maps in `settings.py`.
1 parent d4b9f91 commit c291a04

File tree

3 files changed

+71
-24
lines changed

3 files changed

+71
-24
lines changed

site/source/docs/tools_reference/settings_reference.rst

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1056,7 +1056,7 @@ This option is mutually exclusive with EXCEPTION_CATCHING_ALLOWED.
10561056
This option only applies to Emscripten (JavaScript-based) exception handling
10571057
and does not control the native Wasm exception handling.
10581058

1059-
[compile+link] - affects user code at compile and system libraries at link
1059+
.. note:: Applicable during both linking and compilation
10601060

10611061
Default value: 1
10621062

@@ -1073,7 +1073,7 @@ This option is mutually exclusive with DISABLE_EXCEPTION_CATCHING.
10731073
This option only applies to Emscripten (JavaScript-based) exception handling
10741074
and does not control the native Wasm exception handling.
10751075

1076-
[compile+link] - affects user code at compile and system libraries at link
1076+
.. note:: Applicable during both linking and compilation
10771077

10781078
Default value: []
10791079

@@ -1092,12 +1092,12 @@ time, then you will get errors on undefined symbols, as the exception
10921092
throwing code is not linked in. If so you should either unset the option (if
10931093
you do want exceptions) or fix the compilation of the source files so that
10941094
indeed no exceptions are used).
1095-
TODO(sbc): Move to settings_internal (current blocked due to use in test
1096-
code).
10971095

10981096
This option only applies to Emscripten (JavaScript-based) exception handling
10991097
and does not control the native Wasm exception handling.
11001098

1099+
.. note:: Applicable during both linking and compilation
1100+
11011101
Default value: false
11021102

11031103
.. _export_exception_handling_helpers:
@@ -1628,6 +1628,8 @@ Automatically set for SIDE_MODULE or MAIN_MODULE.
16281628

16291629
.. note:: Applicable during both linking and compilation
16301630

1631+
.. note:: This setting is deprecated
1632+
16311633
Default value: false
16321634

16331635
.. _main_module:
@@ -1687,6 +1689,8 @@ PROXY_TO_WORKER
16871689
If set to 1, we build the project into a js file that will run in a worker,
16881690
and generate an html file that proxies input and output to/from it.
16891691

1692+
.. note:: This setting is deprecated
1693+
16901694
Default value: false
16911695

16921696
.. _proxy_to_worker_filename:
@@ -1698,6 +1702,8 @@ If set, the script file name the main thread loads. Useful if your project
16981702
doesn't run the main emscripten- generated script immediately but does some
16991703
setup before
17001704

1705+
.. note:: This setting is deprecated
1706+
17011707
Default value: ''
17021708

17031709
.. _proxy_to_pthread:
@@ -1739,6 +1745,10 @@ to set this explicitly. Note that MAIN_MODULE and SIDE_MODULE mode 2 do
17391745
*not* set this, so that we still do normal DCE on them, and in that case
17401746
you must keep relevant things alive yourself using exporting.
17411747

1748+
.. note:: Applicable during both linking and compilation
1749+
1750+
.. note:: This setting is deprecated
1751+
17421752
Default value: false
17431753

17441754
.. _strict:
@@ -2442,6 +2452,8 @@ SDL2_IMAGE_FORMATS
24422452
Formats to support in SDL2_image. Valid values: bmp, gif, lbm, pcx, png, pnm,
24432453
tga, xcf, xpm, xv
24442454

2455+
.. note:: Applicable during both linking and compilation
2456+
24452457
Default value: []
24462458

24472459
.. _sdl2_mixer_formats:
@@ -2451,6 +2463,8 @@ SDL2_MIXER_FORMATS
24512463

24522464
Formats to support in SDL2_mixer. Valid values: ogg, mp3, mod, mid
24532465

2466+
.. note:: Applicable during both linking and compilation
2467+
24542468
Default value: ["ogg"]
24552469

24562470
.. _use_sqlite3:
@@ -2471,7 +2485,8 @@ SHARED_MEMORY
24712485
=============
24722486

24732487
If 1, target compiling a shared Wasm Memory.
2474-
[compile+link] - affects user code at compile and system libraries at link.
2488+
2489+
.. note:: Applicable during both linking and compilation
24752490

24762491
Default value: false
24772492

@@ -2483,7 +2498,8 @@ WASM_WORKERS
24832498
Enables support for Wasm Workers. Wasm Workers enable applications
24842499
to create threads using a lightweight web-specific API that builds on top
24852500
of Wasm SharedArrayBuffer + Atomics API.
2486-
[compile+link] - affects user code at compile and system libraries at link.
2501+
2502+
.. note:: Applicable during both linking and compilation
24872503

24882504
Default value: 0
24892505

@@ -3004,9 +3020,10 @@ little bit of code size and performance when catching exceptions.
30043020
- 1: Default setjmp/longjmp/handling, depending on the mode of exceptions.
30053021
'wasm' if '-fwasm-exceptions' is used, 'emscripten' otherwise.
30063022

3007-
[compile+link] - at compile time this enables the transformations needed for
3008-
longjmp support at codegen time, while at link it allows linking in the
3009-
library support.
3023+
At compile time this enables the transformations needed for longjmp support
3024+
at codegen time, while at link it allows linking in the library support.
3025+
3026+
.. note:: Applicable during both linking and compilation
30103027

30113028
Default value: true
30123029

@@ -3200,6 +3217,8 @@ fed into wasm-split (the binaryen tool).
32003217
As well as this the generated JS code will contains help functions
32013218
to loading split modules.
32023219

3220+
.. note:: This is an experimental setting
3221+
32033222
Default value: false
32043223

32053224
.. _autoload_dylibs:
@@ -3306,6 +3325,8 @@ This is only currently implemented in the pre-release/nightly version of node,
33063325
and not yet supported by browsers.
33073326
Requires EXPORT_ES6
33083327

3328+
.. note:: This is an experimental setting
3329+
33093330
Default value: false
33103331

33113332
.. _wasm_esm_integration:
@@ -3316,6 +3337,8 @@ WASM_ESM_INTEGRATION
33163337
Experimental support for wasm ESM integration.
33173338
Requires EXPORT_ES6 and MODULARIZE=instance
33183339

3340+
.. note:: This is an experimental setting
3341+
33193342
Default value: false
33203343

33213344
.. _js_base64_api:
@@ -3354,6 +3377,8 @@ Experimental support for WebAssembly js-types proposal.
33543377
It's currently only available under a flag in certain browsers,
33553378
so we disable it by default to save on code size.
33563379

3380+
.. note:: This is an experimental setting
3381+
33573382
Default value: false
33583383

33593384
.. _cross_origin:

src/settings.js

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -709,7 +709,7 @@ var LZ4 = false;
709709
// This option only applies to Emscripten (JavaScript-based) exception handling
710710
// and does not control the native Wasm exception handling.
711711
//
712-
// [compile+link] - affects user code at compile and system libraries at link
712+
// [compile+link]
713713
var DISABLE_EXCEPTION_CATCHING = 1;
714714

715715
// Enables catching exception but only in the listed functions. This
@@ -720,7 +720,7 @@ var DISABLE_EXCEPTION_CATCHING = 1;
720720
// This option only applies to Emscripten (JavaScript-based) exception handling
721721
// and does not control the native Wasm exception handling.
722722
//
723-
// [compile+link] - affects user code at compile and system libraries at link
723+
// [compile+link]
724724
var EXCEPTION_CATCHING_ALLOWED = [];
725725

726726
// Internal: Tracks whether Emscripten should link in exception throwing (C++
@@ -733,13 +733,11 @@ var EXCEPTION_CATCHING_ALLOWED = [];
733733
// throwing code is not linked in. If so you should either unset the option (if
734734
// you do want exceptions) or fix the compilation of the source files so that
735735
// indeed no exceptions are used).
736-
// TODO(sbc): Move to settings_internal (current blocked due to use in test
737-
// code).
738736
//
739737
// This option only applies to Emscripten (JavaScript-based) exception handling
740738
// and does not control the native Wasm exception handling.
741739
//
742-
// [link]
740+
// [compile+link]
743741
var DISABLE_EXCEPTION_THROWING = false;
744742

745743
// Make the exception message printing function, 'getExceptionMessage' available
@@ -1118,6 +1116,7 @@ var INCLUDE_FULL_LIBRARY = false;
11181116
// globals and function pointers are all offset (by gb and fp, respectively)
11191117
// Automatically set for SIDE_MODULE or MAIN_MODULE.
11201118
// [compile+link]
1119+
// [deprecated]
11211120
var RELOCATABLE = false;
11221121

11231122
// A main module is a file compiled in a way that allows us to link it to
@@ -1148,12 +1147,14 @@ var BUILD_AS_WORKER = false;
11481147
// If set to 1, we build the project into a js file that will run in a worker,
11491148
// and generate an html file that proxies input and output to/from it.
11501149
// [link]
1150+
// [deprecated]
11511151
var PROXY_TO_WORKER = false;
11521152

11531153
// If set, the script file name the main thread loads. Useful if your project
11541154
// doesn't run the main emscripten- generated script immediately but does some
11551155
// setup before
11561156
// [link]
1157+
// [deprecated]
11571158
var PROXY_TO_WORKER_FILENAME = '';
11581159

11591160
// If set to 1, compiles in a small stub main() in between the real main() which
@@ -1184,7 +1185,8 @@ var PROXY_TO_PTHREAD = false;
11841185
// to set this explicitly. Note that MAIN_MODULE and SIDE_MODULE mode 2 do
11851186
// *not* set this, so that we still do normal DCE on them, and in that case
11861187
// you must keep relevant things alive yourself using exporting.
1187-
// [link]
1188+
// [compile+link]
1189+
// [deprecated]
11881190
var LINKABLE = false;
11891191

11901192
// Emscripten 'strict' build mode: Drop supporting any deprecated build options.
@@ -1607,11 +1609,11 @@ var USE_MODPLUG = false;
16071609

16081610
// Formats to support in SDL2_image. Valid values: bmp, gif, lbm, pcx, png, pnm,
16091611
// tga, xcf, xpm, xv
1610-
// [link]
1612+
// [compile+link]
16111613
var SDL2_IMAGE_FORMATS = [];
16121614

16131615
// Formats to support in SDL2_mixer. Valid values: ogg, mp3, mod, mid
1614-
// [link]
1616+
// [compile+link]
16151617
var SDL2_MIXER_FORMATS = ["ogg"];
16161618

16171619
// 1 = use sqlite3 from emscripten-ports
@@ -1620,13 +1622,13 @@ var SDL2_MIXER_FORMATS = ["ogg"];
16201622
var USE_SQLITE3 = false;
16211623

16221624
// If 1, target compiling a shared Wasm Memory.
1623-
// [compile+link] - affects user code at compile and system libraries at link.
1625+
// [compile+link]
16241626
var SHARED_MEMORY = false;
16251627

16261628
// Enables support for Wasm Workers. Wasm Workers enable applications
16271629
// to create threads using a lightweight web-specific API that builds on top
16281630
// of Wasm SharedArrayBuffer + Atomics API.
1629-
// [compile+link] - affects user code at compile and system libraries at link.
1631+
// [compile+link]
16301632
var WASM_WORKERS = 0;
16311633

16321634
// If true, enables targeting Wasm Web Audio AudioWorklets. Check out the
@@ -1978,9 +1980,9 @@ var MINIMAL_RUNTIME_STREAMING_WASM_INSTANTIATION = false;
19781980
// - 1: Default setjmp/longjmp/handling, depending on the mode of exceptions.
19791981
// 'wasm' if '-fwasm-exceptions' is used, 'emscripten' otherwise.
19801982
//
1981-
// [compile+link] - at compile time this enables the transformations needed for
1982-
// longjmp support at codegen time, while at link it allows linking in the
1983-
// library support.
1983+
// At compile time this enables the transformations needed for longjmp support
1984+
// at codegen time, while at link it allows linking in the library support.
1985+
// [compile+link]
19841986
var SUPPORT_LONGJMP = true;
19851987

19861988
// If set to 1, disables old deprecated HTML5 API event target lookup behavior.
@@ -2107,6 +2109,7 @@ var IMPORTED_MEMORY = false;
21072109
// As well as this the generated JS code will contains help functions
21082110
// to loading split modules.
21092111
// [link]
2112+
// [experimental]
21102113
var SPLIT_MODULE = false;
21112114

21122115
// For MAIN_MODULE builds, automatically load any dynamic library dependencies
@@ -2169,11 +2172,13 @@ var SIGNATURE_CONVERSIONS = [];
21692172
// and not yet supported by browsers.
21702173
// Requires EXPORT_ES6
21712174
// [link]
2175+
// [experimental]
21722176
var SOURCE_PHASE_IMPORTS = false;
21732177

21742178
// Experimental support for wasm ESM integration.
21752179
// Requires EXPORT_ES6 and MODULARIZE=instance
21762180
// [link]
2181+
// [experimental]
21772182
var WASM_ESM_INTEGRATION = false;
21782183

21792184
// Enable use of the JS arraybuffer-base64 API:
@@ -2194,6 +2199,7 @@ var GROWABLE_ARRAYBUFFERS = false;
21942199
// Experimental support for WebAssembly js-types proposal.
21952200
// It's currently only available under a flag in certain browsers,
21962201
// so we disable it by default to save on code size.
2202+
// [experimental]
21972203
var WASM_JS_TYPES = false;
21982204

21992205
// If the emscripten-generated program is hosted on separate origin then

tools/maint/update_settings_docs.py

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,13 @@
2525

2626
sys.path.insert(0, root_dir)
2727

28-
from tools.settings import DEPRECATED_SETTINGS, LEGACY_SETTINGS
29-
from tools.utils import path_from_root, read_file, safe_ensure_dirs
28+
from tools.settings import (
29+
COMPILE_TIME_SETTINGS,
30+
DEPRECATED_SETTINGS,
31+
EXPERIMENTAL_SETTINGS,
32+
LEGACY_SETTINGS,
33+
)
34+
from tools.utils import exit_with_error, path_from_root, read_file, safe_ensure_dirs
3035

3136
header = '''\
3237
.. _settings-reference:
@@ -82,6 +87,16 @@
8287
output_file = path_from_root('site/source/docs/tools_reference/settings_reference.rst')
8388

8489

90+
def check_tags(setting_name, tags):
91+
if setting_name in COMPILE_TIME_SETTINGS and 'compile' not in tags and 'compile+link' not in tags:
92+
print(tags)
93+
exit_with_error(f'setting {setting_name} in COMPILE_TIME_SETTINGS but missing [compile] tag')
94+
if setting_name in DEPRECATED_SETTINGS and 'deprecated' not in tags:
95+
exit_with_error(f'setting {setting_name} in DEPRECATED_SETTINGS but missing [deprecated] tag')
96+
if setting_name in EXPERIMENTAL_SETTINGS and 'experimental' not in tags:
97+
exit_with_error(f'setting {setting_name} in EXPERIMENTAL_SETTINGS but missing [experimental] tag')
98+
99+
85100
def write_setting(f, setting_name, setting_default, comment, tags):
86101
# Convert markdown backticks to rst double backticks
87102
f.write('\n.. _' + setting_name.lower() + ':\n')
@@ -127,6 +142,7 @@ def write_file(f):
127142
# Split it and strip the final ';'.
128143
_, setting_name, _, setting_default = line.strip(';').split(None, 3)
129144
comment = '\n'.join(current_comment).strip()
145+
check_tags(setting_name, current_tags)
130146
write_setting(f, setting_name, setting_default, comment, current_tags)
131147
current_comment = []
132148
current_tags = []

0 commit comments

Comments
 (0)