Skip to content

Commit 2096fba

Browse files
galpeterrerobika
authored andcommitted
Do not add line info into the merged sources by default (#3194)
Previously the #line macro directives were always included in the generated single source output. However, this adds quite a lot of size to the source file (not to the binary) and it is only useful for the library developers. Hence, it is now disabled by default. JerryScript-DCO-1.0-Signed-off-by: Peter Gal [email protected]
1 parent c3bb516 commit 2096fba

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

tools/srcmerger.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,14 +28,15 @@ class SourceMerger(object):
2828

2929
_RE_INCLUDE = re.compile(r'\s*#include ("|<)(.*?)("|>)\n$')
3030

31-
def __init__(self, h_files, extra_includes=None, remove_includes=None):
31+
def __init__(self, h_files, extra_includes=None, remove_includes=None, add_lineinfo=False):
3232
self._log = logging.getLogger('sourcemerger')
3333
self._last_builtin = None
3434
self._processed = []
3535
self._output = []
3636
self._h_files = h_files
3737
self._extra_includes = extra_includes or []
3838
self._remove_includes = remove_includes
39+
self._add_lineinfo = add_lineinfo
3940
# The copyright will be loaded from the first input file
4041
self._copyright = {'lines': [], 'loaded': False}
4142

@@ -60,6 +61,9 @@ def _process_non_include(self, line, file_level):
6061
self._output.append(line)
6162

6263
def _emit_lineinfo(self, line_number, filename):
64+
if not self._add_lineinfo:
65+
return
66+
6367
normalized_path = repr(os.path.normpath(filename))[1:-1]
6468
line_info = '#line %d "%s"\n' % (line_number, normalized_path)
6569

@@ -210,7 +214,7 @@ def run_merger(args):
210214
c_files.pop(name, '')
211215
h_files.pop(name, '')
212216

213-
merger = SourceMerger(h_files, args.push_include, args.remove_include)
217+
merger = SourceMerger(h_files, args.push_include, args.remove_include, args.add_lineinfo)
214218
for input_file in args.input_files:
215219
merger.add_file(input_file)
216220

@@ -242,6 +246,8 @@ def main():
242246
action='store_true', help='Enable auto inclusion of c files under the base-dir')
243247
parser.add_argument('--remove-include', action='append', default=[])
244248
parser.add_argument('--push-include', action='append', default=[])
249+
parser.add_argument('--add-lineinfo', action='store_true', default=False,
250+
help='Enable #line macro insertion into the generated sources')
245251
parser.add_argument('--verbose', '-v', action='store_true', default=False)
246252

247253
args = parser.parse_args()

0 commit comments

Comments
 (0)