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

Side by Side Diff: webkit/build/action_maketokenizer.py

Issue 27158: Import .gyp files into the Chromium tree (Closed) Base URL: svn://chrome-svn.corp.google.com/chrome/trunk/src/
Patch Set: Created 11 years, 9 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 unified diff | Download patch
« no previous file with comments | « webkit/build/action_makenames.py ('k') | webkit/build/action_useragentstylesheets.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:executable
+ *
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
1 #!/usr/bin/python
2
3 # Copyright (c) 2009 The Chromium Authors. All rights reserved.
4 # Use of this source code is governed by a BSD-style license that can be
5 # found in the LICENSE file.
6
7 # usage: action_maketokenizer.py OUTPUTS -- INPUTS
8 #
9 # Multiple INPUTS may be listed. The sections are separated by -- arguments.
10 #
11 # OUTPUTS must contain a single item: a path to tokenizer.cpp.
12 #
13 # INPUTS must contain exactly two items. The first item must be the path to
14 # maketokenizer. The second item must be the path to tokenizer.flex.
15
16
17 import os
18 import subprocess
19 import sys
20
21
22 def SplitArgsIntoSections(args):
23 sections = []
24 while len(args) > 0:
25 if not '--' in args:
26 # If there is no '--' left, everything remaining is an entire section.
27 dashes = len(args)
28 else:
29 dashes = args.index('--')
30
31 sections.append(args[:dashes])
32
33 # Next time through the loop, look at everything after this '--'.
34 if dashes + 1 == len(args):
35 # If the '--' is at the end of the list, we won't come back through the
36 # loop again. Add an empty section now corresponding to the nothingness
37 # following the final '--'.
38 args = []
39 sections.append(args)
40 else:
41 args = args[dashes + 1:]
42
43 return sections
44
45
46 def main(args):
47 sections = SplitArgsIntoSections(args[1:])
48 assert len(sections) == 2
49 (outputs, inputs) = sections
50
51 assert len(outputs) == 1
52 output = outputs[0]
53
54 assert len(inputs) == 2
55 maketokenizer = inputs[0]
56 flex_input = inputs[1]
57
58 # Build up the command.
59 command = 'flex -t %s | perl %s > %s' % (flex_input, maketokenizer, output)
60
61 # Do it. check_call is new in 2.5, so simulate its behavior with call and
62 # assert.
63 # TODO(mark): Don't use shell=True, build up the pipeline directly.
64 p = subprocess.Popen(command, shell=True)
65 return_code = p.wait()
66 assert return_code == 0
67
68 return return_code
69
70
71 if __name__ == '__main__':
72 sys.exit(main(sys.argv))
OLDNEW
« no previous file with comments | « webkit/build/action_makenames.py ('k') | webkit/build/action_useragentstylesheets.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698