| Index: cc/PRESUBMIT.py
|
| diff --git a/cc/PRESUBMIT.py b/cc/PRESUBMIT.py
|
| index 060890112f93e9b8b250dbfb5ef3005104b15501..e0346a6f07bed2af641402a6d4ed90aeef999a51 100644
|
| --- a/cc/PRESUBMIT.py
|
| +++ b/cc/PRESUBMIT.py
|
| @@ -8,6 +8,44 @@ See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts for
|
| details on the presubmit API built into gcl.
|
| """
|
|
|
| +import re
|
| +
|
| +CC_SOURCE_FILES=(r'^cc/.*\.(cc|h)$',)
|
| +
|
| +def CheckDChecks(input_api, output_api, white_list=CC_SOURCE_FILES, black_list=None):
|
| + black_list = tuple(black_list or input_api.DEFAULT_BLACK_LIST)
|
| + source_file_filter = lambda x: input_api.FilterSourceFile(x, white_list, black_list)
|
| +
|
| + dcheck_files = []
|
| + assert_files = []
|
| +
|
| + for f in input_api.AffectedSourceFiles(source_file_filter):
|
| + contents = input_api.ReadFile(f, 'rb')
|
| + # Bare DCHECK() is not allowed.
|
| + if re.search(r"(?<!CC_)DCHECK\(", contents):
|
| + # The dcheck header is an exception to this rule.
|
| + if f.LocalPath() == 'cc/dcheck.h':
|
| + continue
|
| + dcheck_files.append(f.LocalPath())
|
| + # WebKit ASSERT() is not allowed.
|
| + if re.search(r"ASSERT\(", contents):
|
| + assert_files.append(f.LocalPath())
|
| +
|
| + if dcheck_files:
|
| + return [output_api.PresubmitError(
|
| + 'These files use DCHECK instead of using CC_DCHECK:',
|
| + items=dcheck_files)]
|
| + if assert_files:
|
| + return [output_api.PresubmitError(
|
| + 'These files use ASSERT instead of using CC_DCHECK:',
|
| + items=assert_files)]
|
| + return []
|
| +
|
| +def CheckChangeOnUpload(input_api, output_api):
|
| + results = []
|
| + results += CheckDChecks(input_api, output_api)
|
| + return results
|
| +
|
| def GetPreferredTrySlaves(project, change):
|
| return [
|
| 'linux_layout_rel',
|
|
|