1 # Copyright (c) 2012 Google Inc. 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.
6 """Top-level presubmit script for GYP.
8 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
9 for more details about the presubmit API built into gcl.
15 # From SCons, not done in google style.
16 'test/lib/TestCmd.py',
17 'test/lib/TestCommon.py',
18 'test/lib/TestGyp.py',
20 'pylib/gyp/generator/xcode.py',
24 PYLINT_DISABLED_WARNINGS = [
26 # Many tests include modules they don't use.
28 # Include order doesn't properly include local files?
30 # Some use of built-in names.
32 # Some unused variables.
34 # Operator not preceded/followed by space.
37 # Unnecessary semicolon.
41 # String has no effect (docstring in wrong place).
43 # Comma not followed by space.
45 # Access to a protected member.
53 # Not exception type specified.
55 # No member of that name.
57 # Dangerous default {}.
59 # Others, too many to sort.
60 'W0201', 'W0232', 'E1103', 'W0621', 'W0108', 'W0223', 'W0231',
61 'R0201', 'E0101', 'C0321',
62 # ************* Module copy
63 # W0104:427,12:_test.odict.__setitem__: Statement seems to have no effect
68 def CheckChangeOnUpload(input_api, output_api):
70 report.extend(input_api.canned_checks.PanProjectChecks(
71 input_api, output_api))
75 def CheckChangeOnCommit(input_api, output_api):
78 # Accept any year number from 2009 to the current year.
79 current_year = int(input_api.time.strftime('%Y'))
80 allowed_years = (str(s) for s in reversed(xrange(2009, current_year + 1)))
81 years_re = '(' + '|'.join(allowed_years) + ')'
83 # The (c) is deprecated, but tolerate it until it's removed from all files.
85 r'.*? Copyright (\(c\) )?%(year)s Google Inc\. All rights reserved\.\n'
86 r'.*? Use of this source code is governed by a BSD-style license that '
88 r'.*? found in the LICENSE file\.\n'
93 report.extend(input_api.canned_checks.PanProjectChecks(
94 input_api, output_api, license_header=license))
95 report.extend(input_api.canned_checks.CheckTreeIsOpen(
96 input_api, output_api,
97 'http://gyp-status.appspot.com/status',
98 'http://gyp-status.appspot.com/current'))
102 old_sys_path = sys.path
104 sys.path = ['pylib', 'test/lib'] + sys.path
105 blacklist = PYLINT_BLACKLIST
106 if sys.platform == 'win32':
107 blacklist = [os.path.normpath(x).replace('\\', '\\\\')
108 for x in PYLINT_BLACKLIST]
109 report.extend(input_api.canned_checks.RunPylint(
112 black_list=blacklist,
113 disabled_warnings=PYLINT_DISABLED_WARNINGS))
115 sys.path = old_sys_path
119 def GetPreferredTrySlaves():
120 return ['gyp-win32', 'gyp-win64', 'gyp-linux', 'gyp-mac', 'gyp-android']