michael@0: # Copyright (c) 2012 Google Inc. All rights reserved. michael@0: # Use of this source code is governed by a BSD-style license that can be michael@0: # found in the LICENSE file. michael@0: michael@0: michael@0: """Top-level presubmit script for GYP. michael@0: michael@0: See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts michael@0: for more details about the presubmit API built into gcl. michael@0: """ michael@0: michael@0: michael@0: PYLINT_BLACKLIST = [ michael@0: # TODO: fix me. michael@0: # From SCons, not done in google style. michael@0: 'test/lib/TestCmd.py', michael@0: 'test/lib/TestCommon.py', michael@0: 'test/lib/TestGyp.py', michael@0: # Needs style fix. michael@0: 'pylib/gyp/generator/scons.py', michael@0: 'pylib/gyp/generator/xcode.py', michael@0: ] michael@0: michael@0: michael@0: PYLINT_DISABLED_WARNINGS = [ michael@0: # TODO: fix me. michael@0: # Many tests include modules they don't use. michael@0: 'W0611', michael@0: # Include order doesn't properly include local files? michael@0: 'F0401', michael@0: # Some use of built-in names. michael@0: 'W0622', michael@0: # Some unused variables. michael@0: 'W0612', michael@0: # Operator not preceded/followed by space. michael@0: 'C0323', michael@0: 'C0322', michael@0: # Unnecessary semicolon. michael@0: 'W0301', michael@0: # Unused argument. michael@0: 'W0613', michael@0: # String has no effect (docstring in wrong place). michael@0: 'W0105', michael@0: # Comma not followed by space. michael@0: 'C0324', michael@0: # Access to a protected member. michael@0: 'W0212', michael@0: # Bad indent. michael@0: 'W0311', michael@0: # Line too long. michael@0: 'C0301', michael@0: # Undefined variable. michael@0: 'E0602', michael@0: # Not exception type specified. michael@0: 'W0702', michael@0: # No member of that name. michael@0: 'E1101', michael@0: # Dangerous default {}. michael@0: 'W0102', michael@0: # Others, too many to sort. michael@0: 'W0201', 'W0232', 'E1103', 'W0621', 'W0108', 'W0223', 'W0231', michael@0: 'R0201', 'E0101', 'C0321', michael@0: # ************* Module copy michael@0: # W0104:427,12:_test.odict.__setitem__: Statement seems to have no effect michael@0: 'W0104', michael@0: ] michael@0: michael@0: michael@0: def CheckChangeOnUpload(input_api, output_api): michael@0: report = [] michael@0: report.extend(input_api.canned_checks.PanProjectChecks( michael@0: input_api, output_api)) michael@0: return report michael@0: michael@0: michael@0: def CheckChangeOnCommit(input_api, output_api): michael@0: report = [] michael@0: license = ( michael@0: r'.*? Copyright \(c\) %(year)s Google Inc\. All rights reserved\.\n' michael@0: r'.*? Use of this source code is governed by a BSD-style license that ' michael@0: r'can be\n' michael@0: r'.*? found in the LICENSE file\.\n' michael@0: ) % { michael@0: 'year': input_api.time.strftime('%Y'), michael@0: } michael@0: michael@0: report.extend(input_api.canned_checks.PanProjectChecks( michael@0: input_api, output_api, license_header=license)) michael@0: report.extend(input_api.canned_checks.CheckTreeIsOpen( michael@0: input_api, output_api, michael@0: 'http://gyp-status.appspot.com/status', michael@0: 'http://gyp-status.appspot.com/current')) michael@0: michael@0: import sys michael@0: old_sys_path = sys.path michael@0: try: michael@0: sys.path = ['pylib', 'test/lib'] + sys.path michael@0: report.extend(input_api.canned_checks.RunPylint( michael@0: input_api, michael@0: output_api, michael@0: black_list=PYLINT_BLACKLIST, michael@0: disabled_warnings=PYLINT_DISABLED_WARNINGS)) michael@0: finally: michael@0: sys.path = old_sys_path michael@0: return report michael@0: michael@0: michael@0: def GetPreferredTrySlaves(): michael@0: return ['gyp-win32', 'gyp-win64', 'gyp-linux', 'gyp-mac']