Skip to content

Commit

Permalink
Allow comments in response files.
Browse files Browse the repository at this point in the history
It can be useful to have comments in a response file for exported
symbols to explain what some stuff might be in there for.
  • Loading branch information
waywardmonkeys committed Feb 14, 2024
1 parent 145b146 commit cdfc332
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 1 deletion.
2 changes: 2 additions & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ See docs/process.md for more on how version tagging works.
#21276)
- Added concept of external ports which live outside emscripten and are
loaded on demand using the syntax `--use-port=/path/to/my_port.py` (#21316)
- Allow comments in response files. Any line starting with `#` is now ignored.
This is useful when listing exported symbols. (#21330)


3.1.53 - 01/29/24
Expand Down
3 changes: 3 additions & 0 deletions docs/emcc.txt
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,9 @@ Options that are modified or new in *emcc* are listed below:

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

* The file may contain comments where the first character of the
line is "'#'".

Note:

Options can be specified as a single argument with or without a
Expand Down
2 changes: 1 addition & 1 deletion emcc.py
Original file line number Diff line number Diff line change
Expand Up @@ -1450,7 +1450,7 @@ def parse_symbol_list_file(contents):
kind of quoting or escaping.
"""
values = contents.splitlines()
return [v.strip() for v in values]
return [v.strip() for v in values if not v.startswith('#')]


def parse_value(text, expected_type):
Expand Down
2 changes: 2 additions & 0 deletions site/source/docs/tools_reference/emcc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ Options that are modified or new in *emcc* are listed below:

- 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"]``.
- The specified file path must be absolute, not relative.
- The file may contain comments where the first character of the line is ``'#'``.


.. note:: Options can be specified as a single argument with or without a space
between the ``-s`` and option name. e.g. ``-sFOO`` or ``-s FOO``.
Expand Down
4 changes: 4 additions & 0 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -7714,6 +7714,10 @@ def test_dash_s_response_file_list(self):
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.txt'])
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.json'])

def test_dash_s_response_file_list_with_comments(self):
create_file('response_file.txt', '_main\n#_nope_ish_nope\n_malloc\n')
self.run_process([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@response_file.txt'])

def test_dash_s_response_file_misssing(self):
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sEXPORTED_FUNCTIONS=@foo'])
self.assertContained('error: foo: file not found parsing argument: EXPORTED_FUNCTIONS=@foo', err)
Expand Down

0 comments on commit cdfc332

Please sign in to comment.