From 2096fba571366a71f421480781c074e5526e7db1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20G=C3=A1l?= Date: Thu, 3 Oct 2019 09:25:53 +0200 Subject: [PATCH] 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 pgal.u-szeged@partner.samsung.com --- tools/srcmerger.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tools/srcmerger.py b/tools/srcmerger.py index dcc119ece..48dd4745f 100644 --- a/tools/srcmerger.py +++ b/tools/srcmerger.py @@ -28,7 +28,7 @@ class SourceMerger(object): _RE_INCLUDE = re.compile(r'\s*#include ("|<)(.*?)("|>)\n$') - def __init__(self, h_files, extra_includes=None, remove_includes=None): + def __init__(self, h_files, extra_includes=None, remove_includes=None, add_lineinfo=False): self._log = logging.getLogger('sourcemerger') self._last_builtin = None self._processed = [] @@ -36,6 +36,7 @@ class SourceMerger(object): self._h_files = h_files self._extra_includes = extra_includes or [] self._remove_includes = remove_includes + self._add_lineinfo = add_lineinfo # The copyright will be loaded from the first input file self._copyright = {'lines': [], 'loaded': False} @@ -60,6 +61,9 @@ class SourceMerger(object): self._output.append(line) def _emit_lineinfo(self, line_number, filename): + if not self._add_lineinfo: + return + normalized_path = repr(os.path.normpath(filename))[1:-1] line_info = '#line %d "%s"\n' % (line_number, normalized_path) @@ -210,7 +214,7 @@ def run_merger(args): c_files.pop(name, '') h_files.pop(name, '') - merger = SourceMerger(h_files, args.push_include, args.remove_include) + merger = SourceMerger(h_files, args.push_include, args.remove_include, args.add_lineinfo) for input_file in args.input_files: merger.add_file(input_file) @@ -242,6 +246,8 @@ def main(): action='store_true', help='Enable auto inclusion of c files under the base-dir') parser.add_argument('--remove-include', action='append', default=[]) parser.add_argument('--push-include', action='append', default=[]) + parser.add_argument('--add-lineinfo', action='store_true', default=False, + help='Enable #line macro insertion into the generated sources') parser.add_argument('--verbose', '-v', action='store_true', default=False) args = parser.parse_args()