Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(357)

Unified Diff: Source/bindings/scripts/blink_idl_lexer.py

Issue 425953002: IDL parser: fix rebuilding of (stale) cached lexer tables (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/bindings/scripts/blink_idl_parser.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/scripts/blink_idl_lexer.py
diff --git a/Source/bindings/scripts/blink_idl_lexer.py b/Source/bindings/scripts/blink_idl_lexer.py
index bbde34268b44c0b97fd797d19523eef48f586005..6bf439641fd3a7e4dfbca8e8024c09e5e95311ed 100644
--- a/Source/bindings/scripts/blink_idl_lexer.py
+++ b/Source/bindings/scripts/blink_idl_lexer.py
@@ -88,7 +88,8 @@ class BlinkIDLLexer(IDLLexer):
for token in tokens:
self._RemoveToken(token)
- def __init__(self, debug=False, optimize=True, outputdir=None):
+ def __init__(self, debug=False, optimize=True, outputdir=None,
+ rewrite_tables=False):
if debug:
# Turn off optimization and caching to help debugging
optimize = False
@@ -98,6 +99,21 @@ class BlinkIDLLexer(IDLLexer):
# as a Python module
sys.path.append(outputdir)
+ if rewrite_tables:
+ tablefile = os.path.join(outputdir, 'lextab.py')
+
+ def unlink(filename):
+ try:
+ os.unlink(filename)
+ except OSError:
+ pass
+
+ unlink(tablefile)
Nils Barth (inactive) 2014/07/29 16:00:25 FWIW, cleaner would be a loop through suffixes, wh
+ # Also remove the .pyc/.pyo files, or they'll be used even if
+ # the .py file doesn't exist.
+ unlink(tablefile + 'c')
+ unlink(tablefile + 'o')
+
IDLLexer.__init__(self)
# Overrides to parent class
self._RemoveTokens(REMOVE_TOKENS)
@@ -108,6 +124,7 @@ class BlinkIDLLexer(IDLLexer):
self._lexobj = lex.lex(object=self,
debug=debug,
optimize=optimize,
+ lextab='lextab',
outputdir=outputdir)
@@ -120,7 +137,10 @@ def main(argv):
except IndexError as err:
print 'Usage: %s OUTPUT_DIR' % argv[0]
return 1
- lexer = BlinkIDLLexer(outputdir=outputdir)
+ # Important: rewrite_tables=True causes the cache file to be deleted if it
+ # exists, thus making sure that PLY doesn't load it instead of regenerating
+ # the parse table.
+ lexer = BlinkIDLLexer(outputdir=outputdir, rewrite_tables=True)
if __name__ == '__main__':
« no previous file with comments | « no previous file | Source/bindings/scripts/blink_idl_parser.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698