Skip to content

Commit

Permalink
Allow comments in exported symbols 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 13, 2024
1 parent 0671dfc commit 9ee8a21
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 1 deletion.
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 @@ -7685,6 +7685,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 9ee8a21

Please sign in to comment.