Skip to content

Commit 7baa690

Browse files
Allow comments in response files. (#21330)
It can be useful to have comments in a response file for exported symbols to explain what some stuff might be in there for.
1 parent 145b146 commit 7baa690

File tree

5 files changed

+12
-1
lines changed

5 files changed

+12
-1
lines changed

ChangeLog.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ See docs/process.md for more on how version tagging works.
4444
#21276)
4545
- Added concept of external ports which live outside emscripten and are
4646
loaded on demand using the syntax `--use-port=/path/to/my_port.py` (#21316)
47+
- Allow comments in response files. Any line starting with `#` is now ignored.
48+
This is useful when listing exported symbols. (#21330)
4749

4850

4951
3.1.53 - 01/29/24

docs/emcc.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,9 @@ Options that are modified or new in *emcc* are listed below:
147147

148148
* The specified file path must be absolute, not relative.
149149

150+
* The file may contain comments where the first character of the
151+
line is "'#'".
152+
150153
Note:
151154

152155
Options can be specified as a single argument with or without a

emcc.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1450,7 +1450,7 @@ def parse_symbol_list_file(contents):
14501450
kind of quoting or escaping.
14511451
"""
14521452
values = contents.splitlines()
1453-
return [v.strip() for v in values]
1453+
return [v.strip() for v in values if not v.startswith('#')]
14541454

14551455

14561456
def parse_value(text, expected_type):

site/source/docs/tools_reference/emcc.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ Options that are modified or new in *emcc* are listed below:
134134

135135
- In this case the file should contain a list of symbols, one per line. For legacy use cases JSON-formatted files are also supported: e.g. ``["_func1", "func2"]``.
136136
- The specified file path must be absolute, not relative.
137+
- The file may contain comments where the first character of the line is ``'#'``.
138+
137139

138140
.. note:: Options can be specified as a single argument with or without a space
139141
between the ``-s`` and option name. e.g. ``-sFOO`` or ``-s FOO``.

test/test_other.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7714,6 +7714,10 @@ def test_dash_s_response_file_list(self):
77147714
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.txt'])
77157715
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.json'])
77167716

7717+
def test_dash_s_response_file_list_with_comments(self):
7718+
create_file('response_file.txt', '_main\n#_nope_ish_nope\n_malloc\n')
7719+
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.txt'])
7720+
77177721
def test_dash_s_response_file_misssing(self):
77187722
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@foo'])
77197723
self.assertContained('error: foo: file not found parsing argument: EXPORTED_FUNCTIONS=@foo', err)

0 commit comments

Comments
 (0)