Skip to content

Commit 9ee8a21

Browse files
Allow comments in exported symbols response files.
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 0671dfc commit 9ee8a21

File tree

4 files changed

+10
-1
lines changed

4 files changed

+10
-1
lines changed

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
@@ -7685,6 +7685,10 @@ def test_dash_s_response_file_list(self):
76857685
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.txt'])
76867686
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.json'])
76877687

7688+
def test_dash_s_response_file_list_with_comments(self):
7689+
create_file('response_file.txt', '_main\n#_nope_ish_nope\n_malloc\n')
7690+
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.txt'])
7691+
76887692
def test_dash_s_response_file_misssing(self):
76897693
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@foo'])
76907694
self.assertContained('error: foo: file not found parsing argument: EXPORTED_FUNCTIONS=@foo', err)

0 commit comments

Comments
 (0)