From b75298e957f8b147abd132a0f25b8b0f20bfc5a5 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Sun, 3 Mar 2013 18:29:16 +0100 Subject: [PATCH] Don't check for requires in comments --- build.py | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/build.py b/build.py index 3305910d45..4fb0b399f5 100755 --- a/build.py +++ b/build.py @@ -241,6 +241,28 @@ def build_lint_src_timestamp(t): t.touch() +def _strip_comments(lines): + # FIXME this is a horribe hack, we should use a proper JavaScript parser here + in_comment = False + for line in lines: + if in_comment: + index = line.find('*/') + if index != -1: + in_comment = False + yield line[index + 2:] + else: + index = line.find('/*') + if index != -1: + yield line[:index] + in_comment = True + else: + index = line.find('//') + if index != -1: + yield line[:index] + else: + yield line + + @target('build/check-requires-timestamp', SRC, INTERNAL_SRC, EXTERNAL_SRC, EXAMPLES_SRC) def build_check_requires_timestamp(t): unused_count = 0 @@ -279,7 +301,7 @@ def build_check_requires_timestamp(t): requires = set() uses = set() lineno = 0 - for line in open(filename): + for line in _strip_comments(open(filename)): lineno += 1 m = re.match(r'goog.provide\(\'(.*)\'\);', line) if m: