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
3 # found in the LICENSE file.
5 # Documentation on PRESUBMIT.py can be found at:
6 # http://www.chromium.org/developers/how-tos/depottools/presubmit-scripts
11 # List of directories to not apply presubmit project checks, relative
12 # to the NaCl top directory
13 EXCLUDE_PROJECT_CHECKS_DIRS = [
14 # The following contain test data (including automatically generated),
15 # and do not follow our conventions.
16 'src/trusted/validator_ragel/testdata/32',
17 'src/trusted/validator_ragel/testdata/64',
18 'src/trusted/validator_x86/testdata/32',
19 'src/trusted/validator_x86/testdata/64',
20 'src/trusted/validator/x86/decoder/generator/testdata/32',
21 'src/trusted/validator/x86/decoder/generator/testdata/64',
22 # The following directories contains automatically generated source,
23 # which may not follow our conventions.
24 'src/trusted/validator_x86/gen',
25 'src/trusted/validator/x86/decoder/gen',
26 'src/trusted/validator/x86/decoder/generator/gen',
27 'src/trusted/validator/x86/ncval_seg_sfi/gen',
28 'src/trusted/validator_arm/gen',
29 'src/trusted/validator_ragel/gen',
33 # git-cl and gcl run PRESUBMIT.py with the current directory set to
34 # the native_client directory (which may have a different basename
35 # in a standalone checkout).
38 def _CommonChecks(input_api, output_api):
39 """Checks for both upload and commit."""
41 results.extend(input_api.canned_checks.PanProjectChecks(
42 input_api, output_api, project_name='Native Client',
43 excluded_paths=tuple(EXCLUDE_PROJECT_CHECKS_DIRS)))
46 def IsFileInDirectories(f, dirs):
47 """ Returns true if f is in list of directories"""
49 if d is os.path.commonprefix([f , d]):
53 def CheckChangeOnUpload(input_api, output_api):
54 """Verifies all changes in all files.
56 input_api: the limited set of input modules allowed in presubmit.
57 output_api: the limited set of output modules allowed in presubmit.
60 report.extend(_CommonChecks(input_api, output_api))
62 # The commit queue assumes PRESUBMIT.py is standalone.
63 # TODO(bradnelson): Migrate code_hygiene to a common location so that
64 # it can be used by the commit queue.
65 old_sys_path = list(sys.path)
67 sys.path.append(os.path.join(NaClTopDir(), 'tools'))
68 sys.path.append(os.path.join(NaClTopDir(), 'build'))
71 sys.path = old_sys_path
74 affected_files = input_api.AffectedFiles(include_deletes=False)
75 exclude_dirs = [ NaClTopDir() + '/' + x + '/'
76 for x in EXCLUDE_PROJECT_CHECKS_DIRS ]
77 for filename in affected_files:
78 filename = filename.AbsoluteLocalPath()
79 if not IsFileInDirectories(filename, exclude_dirs):
80 errors, warnings = code_hygiene.CheckFile(filename, False)
82 report.append(output_api.PresubmitError(e, items=errors[e]))
84 report.append(output_api.PresubmitPromptWarning(w, items=warnings[w]))
89 def CheckChangeOnCommit(input_api, output_api):
90 """Verifies all changes in all files and verifies that the
91 tree is open and can accept a commit.
93 input_api: the limited set of input modules allowed in presubmit.
94 output_api: the limited set of output modules allowed in presubmit.
97 report.extend(CheckChangeOnUpload(input_api, output_api))
98 report.extend(input_api.canned_checks.CheckTreeIsOpen(
99 input_api, output_api,
100 json_url='http://nativeclient-status.appspot.com/current?format=json'))
105 'nacl-precise32_newlib_dbg',
106 'nacl-precise32_newlib_opt',
107 'nacl-precise32_glibc_opt',
108 'nacl-precise64_newlib_dbg',
109 'nacl-precise64_newlib_opt',
110 'nacl-precise64_glibc_opt',
111 'nacl-mac10.6_newlib_opt',
112 'nacl-mac10.6_glibc_opt',
113 'nacl-mac10.6_64_newlib_dbg',
114 'nacl-mac10.6_64_glibc_opt',
115 'nacl-mac10.7_newlib_opt',
116 'nacl-mac10.7_glibc_opt',
117 'nacl-mac10.7_64_newlib_dbg',
118 'nacl-mac10.7_64_glibc_opt',
119 'nacl-mac10.8_32_newlib_dbg',
120 'nacl-mac10.8_32_glibc_opt',
121 'nacl-mac10.8_64_newlib_dbg',
122 'nacl-mac10.8_64_glibc_opt',
123 'nacl-win32_newlib_opt',
124 'nacl-win32_glibc_opt',
125 'nacl-win64_newlib_dbg',
126 'nacl-win64_newlib_opt',
127 'nacl-win64_glibc_opt',
128 'nacl-win8-64_newlib_dbg',
129 'nacl-win8-64_newlib_opt',
130 'nacl-arm_opt_panda',
132 'nacl-win7_64_arm_newlib_opt',
133 'nacl-mac10.7_arm_newlib_opt',
134 'nacl-precise64_arm_newlib_opt',
136 'nacl-precise_64-newlib-dbg-clang',
137 'nacl-mac10.6-newlib-dbg-clang',
139 'nacl-precise_64-newlib-arm_qemu-pnacl',
140 'nacl-precise_64-newlib-x86_32-pnacl',
141 'nacl-precise_64-newlib-x86_64-pnacl',
142 'nacl-mac10.8_newlib_opt_pnacl',
143 'nacl-win7_64_newlib_opt_pnacl',
145 'nacl-arm_perf_panda',
146 'nacl-precise_64-newlib-x86_32-pnacl-spec',
147 'nacl-precise_64-newlib-x86_64-pnacl-spec',
150 PNACL_TOOLCHAIN_TRYBOTS = [
151 'nacl-toolchain-linux-pnacl-x86_64',
152 'nacl-toolchain-linux-pnacl-x86_32',
153 'nacl-toolchain-mac-pnacl-x86_32',
154 'nacl-toolchain-win7-pnacl-x86_64',
157 TOOLCHAIN_BUILD_TRYBOTS = [
158 'nacl-toolchain-precise64-newlib-arm',
159 'nacl-toolchain-mac-newlib-arm',
163 def GetPreferredTryMasters(_, change):
166 has_toolchain_build = False
169 for file in change.AffectedFiles(include_dirs=True):
170 if IsFileInDirectories(file.AbsoluteLocalPath(),
171 [os.path.join(NaClTopDir(), 'build'),
172 os.path.join(NaClTopDir(), 'buildbot'),
173 os.path.join(NaClTopDir(), 'pynacl')]):
174 # Buildbot and infrastructure changes should trigger all the try bots.
176 has_toolchain_build = True
179 elif IsFileInDirectories(file.AbsoluteLocalPath(),
180 [os.path.join(NaClTopDir(), 'pnacl')]):
182 elif IsFileInDirectories(file.AbsoluteLocalPath(),
183 [os.path.join(NaClTopDir(), 'toolchain_build')]):
184 has_toolchain_build = True
190 trybots += PNACL_TOOLCHAIN_TRYBOTS
191 if has_toolchain_build:
192 trybots += TOOLCHAIN_BUILD_TRYBOTS
194 trybots += DEFAULT_TRYBOTS
197 'tryserver.nacl': { t: set(['defaulttests']) for t in trybots },