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

Side by Side Diff: PRESUBMIT.py

Issue 1163893003: Don't include <stdint.h> from within <machine/_types.h> (Closed) Base URL: https://chromium.googlesource.com/native_client/src/native_client.git@master
Patch Set: Created 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | src/include/win/port_win.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 # Copyright (c) 2012 The Native Client Authors. All rights reserved. 1 # Copyright (c) 2012 The Native Client 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 # Documentation on PRESUBMIT.py can be found at: 5 # Documentation on PRESUBMIT.py can be found at:
6 # http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts 6 # http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts
7 7
8 import os 8 import os
9 import subprocess 9 import subprocess
10 import sys 10 import sys
11 11
12 # List of directories to not apply presubmit project checks, relative 12 # List of directories to not apply presubmit project checks, relative
13 # to the NaCl top directory 13 # to the NaCl top directory
14 EXCLUDE_PROJECT_CHECKS_DIRS = [ 14 EXCLUDE_PROJECT_CHECKS = [
15 # The following contain test data (including automatically generated), 15 # The following contain test data (including automatically generated),
16 # and do not follow our conventions. 16 # and do not follow our conventions.
17 'src/trusted/validator_ragel/testdata/32', 17 'src/trusted/validator_ragel/testdata/32/',
18 'src/trusted/validator_ragel/testdata/64', 18 'src/trusted/validator_ragel/testdata/64/',
19 'src/trusted/validator_x86/testdata/32', 19 'src/trusted/validator_x86/testdata/32/',
20 'src/trusted/validator_x86/testdata/64', 20 'src/trusted/validator_x86/testdata/64/',
21 'src/trusted/validator/x86/decoder/generator/testdata/32', 21 'src/trusted/validator/x86/decoder/generator/testdata/32/',
22 'src/trusted/validator/x86/decoder/generator/testdata/64', 22 'src/trusted/validator/x86/decoder/generator/testdata/64/',
23 # The following directories contains automatically generated source, 23 # The following directories contains automatically generated source,
24 # which may not follow our conventions. 24 # which may not follow our conventions.
25 'src/trusted/validator_x86/gen', 25 'src/trusted/validator_x86/gen/',
26 'src/trusted/validator/x86/decoder/gen', 26 'src/trusted/validator/x86/decoder/gen/',
27 'src/trusted/validator/x86/decoder/generator/gen', 27 'src/trusted/validator/x86/decoder/generator/gen/',
28 'src/trusted/validator/x86/ncval_seg_sfi/gen', 28 'src/trusted/validator/x86/ncval_seg_sfi/gen/',
29 'src/trusted/validator_arm/gen', 29 'src/trusted/validator_arm/gen/',
30 'src/trusted/validator_ragel/gen', 30 'src/trusted/validator_ragel/gen/',
31 # The following files contain code from outside native_client (e.g. newlib)
32 # or are known the contain style violations.
33 'src/trusted/service_runtime/include/sys/',
34 'src/include/win/port_win.h',
35 'src/trusted/service_runtime/include/machine/_types.h'
31 ] 36 ]
32 37
33 NACL_TOP_DIR = os.getcwd() 38 NACL_TOP_DIR = os.getcwd()
34 while not os.path.isfile(os.path.join(NACL_TOP_DIR, 'PRESUBMIT.py')): 39 while not os.path.isfile(os.path.join(NACL_TOP_DIR, 'PRESUBMIT.py')):
35 NACL_TOP_DIR = os.path.dirname(NACL_TOP_DIR) 40 NACL_TOP_DIR = os.path.dirname(NACL_TOP_DIR)
36 assert len(NACL_TOP_DIR) >= 3, "Could not find NaClTopDir" 41 assert len(NACL_TOP_DIR) >= 3, "Could not find NaClTopDir"
37 42
43
38 def CheckGitBranch(): 44 def CheckGitBranch():
39 p = subprocess.Popen("git branch -vv", shell=True, 45 p = subprocess.Popen("git branch -vv", shell=True,
40 stdout=subprocess.PIPE) 46 stdout=subprocess.PIPE)
41 output, _ = p.communicate() 47 output, _ = p.communicate()
42 lines = output.split('\n') 48 lines = output.split('\n')
43 for line in lines: 49 for line in lines:
44 # output format for checked-out branch should be 50 # output format for checked-out branch should be
45 # * branchname hash [TrackedBranchName ... 51 # * branchname hash [TrackedBranchName ...
46 toks = line.split() 52 toks = line.split()
47 if '*' not in toks[0]: 53 if '*' not in toks[0]:
48 continue 54 continue
49 if not ('origin/master' in toks[3] or 55 if not ('origin/master' in toks[3] or
50 'origin/refs/heads/master' in toks[3]): 56 'origin/refs/heads/master' in toks[3]):
51 warning = 'Warning: your current branch:\n' + line 57 warning = 'Warning: your current branch:\n' + line
52 warning += '\nis not tracking origin/master. git cl push may silently ' 58 warning += '\nis not tracking origin/master. git cl push may silently '
53 warning += 'fail to push your change. To fix this, do\n' 59 warning += 'fail to push your change. To fix this, do\n'
54 warning += 'git branch -u origin/master' 60 warning += 'git branch -u origin/master'
55 return warning 61 return warning
56 return None 62 return None
57 print 'Warning: presubmit check could not determine local git branch' 63 print 'Warning: presubmit check could not determine local git branch'
58 return None 64 return None
59 65
66
60 def _CommonChecks(input_api, output_api): 67 def _CommonChecks(input_api, output_api):
61 """Checks for both upload and commit.""" 68 """Checks for both upload and commit."""
62 results = [] 69 results = []
63 results.extend(input_api.canned_checks.PanProjectChecks( 70 results.extend(input_api.canned_checks.PanProjectChecks(
64 input_api, output_api, project_name='Native Client', 71 input_api, output_api, project_name='Native Client',
65 excluded_paths=tuple(EXCLUDE_PROJECT_CHECKS_DIRS))) 72 excluded_paths=tuple(EXCLUDE_PROJECT_CHECKS)))
66 branch_warning = CheckGitBranch() 73 branch_warning = CheckGitBranch()
67 if branch_warning: 74 if branch_warning:
68 results.append(output_api.PresubmitPromptWarning(branch_warning)) 75 results.append(output_api.PresubmitPromptWarning(branch_warning))
69 return results 76 return results
70 77
78
71 def IsFileInDirectories(f, dirs): 79 def IsFileInDirectories(f, dirs):
72 """ Returns true if f is in list of directories""" 80 """ Returns true if f is in list of directories"""
73 for d in dirs: 81 for d in dirs:
74 if d is os.path.commonprefix([f , d]): 82 if d is os.path.commonprefix([f, d]):
75 return True 83 return True
76 return False 84 return False
77 85
86
78 def CheckChangeOnUpload(input_api, output_api): 87 def CheckChangeOnUpload(input_api, output_api):
79 """Verifies all changes in all files. 88 """Verifies all changes in all files.
80 Args: 89 Args:
81 input_api: the limited set of input modules allowed in presubmit. 90 input_api: the limited set of input modules allowed in presubmit.
82 output_api: the limited set of output modules allowed in presubmit. 91 output_api: the limited set of output modules allowed in presubmit.
83 """ 92 """
84 report = [] 93 report = []
85 report.extend(_CommonChecks(input_api, output_api)) 94 report.extend(_CommonChecks(input_api, output_api))
86 95
87 # The commit queue assumes PRESUBMIT.py is standalone. 96 # The commit queue assumes PRESUBMIT.py is standalone.
88 # TODO(bradnelson): Migrate code_hygiene to a common location so that 97 # TODO(bradnelson): Migrate code_hygiene to a common location so that
89 # it can be used by the commit queue. 98 # it can be used by the commit queue.
90 old_sys_path = list(sys.path) 99 old_sys_path = list(sys.path)
91 try: 100 try:
92 sys.path.append(os.path.join(NACL_TOP_DIR, 'tools')) 101 sys.path.append(os.path.join(NACL_TOP_DIR, 'tools'))
93 sys.path.append(os.path.join(NACL_TOP_DIR, 'build')) 102 sys.path.append(os.path.join(NACL_TOP_DIR, 'build'))
94 import code_hygiene 103 import code_hygiene
95 finally: 104 finally:
96 sys.path = old_sys_path 105 sys.path = old_sys_path
97 del old_sys_path 106 del old_sys_path
98 107
99 affected_files = input_api.AffectedFiles(include_deletes=False) 108 affected_files = input_api.AffectedFiles(include_deletes=False)
100 exclude_dirs = [ NACL_TOP_DIR + '/' + x + '/' 109 exclude_dirs = [ NACL_TOP_DIR + '/' + x for x in EXCLUDE_PROJECT_CHECKS ]
101 for x in EXCLUDE_PROJECT_CHECKS_DIRS ]
102 for filename in affected_files: 110 for filename in affected_files:
103 filename = filename.AbsoluteLocalPath() 111 filename = filename.AbsoluteLocalPath()
112 if filename in exclude_dirs:
113 continue
104 if not IsFileInDirectories(filename, exclude_dirs): 114 if not IsFileInDirectories(filename, exclude_dirs):
105 errors, warnings = code_hygiene.CheckFile(filename, False) 115 errors, warnings = code_hygiene.CheckFile(filename, False)
106 for e in errors: 116 for e in errors:
107 report.append(output_api.PresubmitError(e, items=errors[e])) 117 report.append(output_api.PresubmitError(e, items=errors[e]))
108 for w in warnings: 118 for w in warnings:
109 report.append(output_api.PresubmitPromptWarning(w, items=warnings[w])) 119 report.append(output_api.PresubmitPromptWarning(w, items=warnings[w]))
110 120
111 return report 121 return report
112 122
113 123
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after
220 if has_pnacl: 230 if has_pnacl:
221 trybots += PNACL_TOOLCHAIN_TRYBOTS 231 trybots += PNACL_TOOLCHAIN_TRYBOTS
222 if has_toolchain_build: 232 if has_toolchain_build:
223 trybots += TOOLCHAIN_BUILD_TRYBOTS 233 trybots += TOOLCHAIN_BUILD_TRYBOTS
224 if has_others: 234 if has_others:
225 trybots += DEFAULT_TRYBOTS 235 trybots += DEFAULT_TRYBOTS
226 236
227 return { 237 return {
228 'tryserver.nacl': { t: set(['defaulttests']) for t in set(trybots) }, 238 'tryserver.nacl': { t: set(['defaulttests']) for t in set(trybots) },
229 } 239 }
OLDNEW
« no previous file with comments | « no previous file | src/include/win/port_win.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698