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

Side by Side Diff: ppapi/PRESUBMIT.py

Issue 8568025: Pnacl ppapi shim generator (from IDL), based on Noel's first cut. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix presubmit.wq Created 9 years, 1 month 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | ppapi/generators/generator.py » ('j') | ppapi/generators/idl_gen_pnacl.py » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 # Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import os 5 import os
6 import sys 6 import sys
7 import subprocess 7 import subprocess
8 8
9 def RunCmdAndCheck(cmd, ppapi_dir, err_string, output_api):
10 results = []
11 p = subprocess.Popen(cmd, cwd=os.path.join(ppapi_dir, 'generators'),
12 stdout=subprocess.PIPE,
13 stderr=subprocess.PIPE)
14 (p_stdout, p_stderr) = p.communicate()
15 if p.returncode:
16 results.append(
17 output_api.PresubmitError(err_string,
18 long_text=p_stderr))
19 return results
20
21
22 def RunUnittests(input_api, output_api):
23 # Run some Generator unittests if the generator source was changed.
24 results = []
25 files = input_api.LocalPaths()
26 generator_files = []
27 for filename in files:
28 name_parts = filename.split(os.sep)
29 if name_parts[0:2] == ['ppapi', 'generators']:
30 generator_files.append(filename)
31 if generator_files != []:
32 cmd = [ sys.executable, 'idl_gen_pnacl.py', '--wnone', '--test']
33 ppapi_dir = input_api.PresubmitLocalPath()
34 results.extend(RunCmdAndCheck(cmd,
35 ppapi_dir,
36 'PPAPI IDL Pnacl unittest failed.',
37 output_api))
noelallen1 2011/11/23 18:06:11 Should add the regular generator to this, but that
jvoung - send to chromium... 2011/11/23 22:39:28 Do you mean to just run "generator.py" ? I'm not s
jvoung - send to chromium... 2011/11/29 21:13:48 Noel, in a second CL, I can have it run something
38 return results
39
40
9 def CheckChange(input_api, output_api): 41 def CheckChange(input_api, output_api):
10 results = [] 42 results = []
11 43
44 results.extend(RunUnittests(input_api, output_api))
45
12 # Verify all modified *.idl have a matching *.h 46 # Verify all modified *.idl have a matching *.h
13 files = input_api.LocalPaths() 47 files = input_api.LocalPaths()
14 h_files = [] 48 h_files = []
15 idl_files = [] 49 idl_files = []
16 50
17 for filename in files: 51 for filename in files:
18 name, ext = os.path.splitext(filename) 52 name, ext = os.path.splitext(filename)
19 name_parts = name.split(os.sep) 53 name_parts = name.split(os.sep)
20 if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h': 54 if name_parts[0:2] == ['ppapi', 'c'] and ext == '.h':
21 h_files.append('/'.join(name_parts[2:])) 55 h_files.append('/'.join(name_parts[2:]))
(...skipping 22 matching lines...) Expand all
44 # Verify all *.h files match *.idl definitions, use: 78 # Verify all *.h files match *.idl definitions, use:
45 # --test to prevent output to disk 79 # --test to prevent output to disk
46 # --diff to generate a unified diff 80 # --diff to generate a unified diff
47 # --out to pick which files to examine (only the ones in the CL) 81 # --out to pick which files to examine (only the ones in the CL)
48 ppapi_dir = input_api.PresubmitLocalPath() 82 ppapi_dir = input_api.PresubmitLocalPath()
49 cmd = [ sys.executable, 'generator.py', 83 cmd = [ sys.executable, 'generator.py',
50 '--wnone', '--diff', '--test','--cgen', '--range=start,end'] 84 '--wnone', '--diff', '--test','--cgen', '--range=start,end']
51 85
52 # Only generate output for IDL files references (as *.h or *.idl) in this CL 86 # Only generate output for IDL files references (as *.h or *.idl) in this CL
53 cmd.append('--out=' + ','.join([name + '.idl' for name in both])) 87 cmd.append('--out=' + ','.join([name + '.idl' for name in both]))
54 88 results.extend(RunCmdAndCheck(cmd,
55 p = subprocess.Popen(cmd, cwd=os.path.join(ppapi_dir, 'generators'), 89 ppapi_dir,
56 stdout=subprocess.PIPE, 90 'PPAPI IDL Diff detected: Run the generator.',
57 stderr=subprocess.PIPE) 91 output_api))
58 (p_stdout, p_stderr) = p.communicate()
59 if p.returncode:
60 results.append(
61 output_api.PresubmitError('PPAPI IDL Diff detected: Run the generator.',
62 long_text=p_stderr))
63 return results 92 return results
64 93
65 def CheckChangeOnUpload(input_api, output_api): 94 def CheckChangeOnUpload(input_api, output_api):
66 # return [] 95 # return []
67 return CheckChange(input_api, output_api) 96 return CheckChange(input_api, output_api)
68 97
69 def CheckChangeOnCommit(input_api, output_api): 98 def CheckChangeOnCommit(input_api, output_api):
70 # return [] 99 # return []
71 return CheckChange(input_api, output_api) 100 return CheckChange(input_api, output_api)
72
OLDNEW
« no previous file with comments | « no previous file | ppapi/generators/generator.py » ('j') | ppapi/generators/idl_gen_pnacl.py » ('J')

Powered by Google App Engine
This is Rietveld 408576698