1 # Copyright (c) 2012 The Chromium 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 """Top-level presubmit script for Chromium.
7 See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts
8 for more details about the presubmit API built into gcl.
19 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
20 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
21 r
"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
22 r
"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
27 r
".+[\\\/]pnacl_shim\.c$",
28 r
"^gpu[\\\/]config[\\\/].*_list_json\.cc$",
31 # Fragment of a regular expression that matches C++ and Objective-C++
32 # implementation files.
33 _IMPLEMENTATION_EXTENSIONS
= r
'\.(cc|cpp|cxx|mm)$'
35 # Regular expression that matches code only used for test binaries
37 _TEST_CODE_EXCLUDED_PATHS
= (
38 r
'.*[/\\](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS
,
39 r
'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS
,
40 r
'.+_(api|browser|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
41 _IMPLEMENTATION_EXTENSIONS
,
42 r
'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS
,
43 r
'.*[/\\](test|tool(s)?)[/\\].*',
44 # content_shell is used for running layout tests.
45 r
'content[/\\]shell[/\\].*',
46 # At request of folks maintaining this folder.
47 r
'chrome[/\\]browser[/\\]automation[/\\].*',
48 # Non-production example code.
49 r
'mojo[/\\]examples[/\\].*',
52 _TEST_ONLY_WARNING
= (
53 'You might be calling functions intended only for testing from\n'
54 'production code. It is OK to ignore this warning if you know what\n'
55 'you are doing, as the heuristics used to detect the situation are\n'
56 'not perfect. The commit queue will not block on this warning.\n'
57 'Email joi@chromium.org if you have questions.')
60 _INCLUDE_ORDER_WARNING
= (
61 'Your #include order seems to be broken. Send mail to\n'
62 'marja@chromium.org if this is not the case.')
65 _BANNED_OBJC_FUNCTIONS
= (
69 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
70 'prohibited. Please use CrTrackingArea instead.',
71 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
78 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
80 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
85 'convertPointFromBase:',
87 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
88 'Please use |convertPoint:(point) fromView:nil| instead.',
89 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
94 'convertPointToBase:',
96 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
97 'Please use |convertPoint:(point) toView:nil| instead.',
98 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
103 'convertRectFromBase:',
105 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
106 'Please use |convertRect:(point) fromView:nil| instead.',
107 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
112 'convertRectToBase:',
114 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
115 'Please use |convertRect:(point) toView:nil| instead.',
116 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
121 'convertSizeFromBase:',
123 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
124 'Please use |convertSize:(point) fromView:nil| instead.',
125 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
130 'convertSizeToBase:',
132 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
133 'Please use |convertSize:(point) toView:nil| instead.',
134 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
141 _BANNED_CPP_FUNCTIONS
= (
142 # Make sure that gtest's FRIEND_TEST() macro is not used; the
143 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
144 # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
148 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
149 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
157 'New code should not use ScopedAllowIO. Post a task to the blocking',
158 'pool or the FILE thread instead.',
162 r
"^components[\\\/]breakpad[\\\/]app[\\\/]breakpad_mac\.mm$",
163 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$",
164 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$",
165 r
"^net[\\\/]disk_cache[\\\/]cache_util\.cc$",
171 'The use of SkRefPtr is prohibited. ',
172 'Please use skia::RefPtr instead.'
180 'The indirect use of SkRefPtr via SkAutoRef is prohibited. ',
181 'Please use skia::RefPtr instead.'
189 'The use of SkAutoTUnref is dangerous because it implicitly ',
190 'converts to a raw pointer. Please use skia::RefPtr instead.'
198 'The indirect use of SkAutoTUnref through SkAutoUnref is dangerous ',
199 'because it implicitly converts to a raw pointer. ',
200 'Please use skia::RefPtr instead.'
206 r
'/HANDLE_EINTR\(.*close',
208 'HANDLE_EINTR(close) is invalid. If close fails with EINTR, the file',
209 'descriptor will be closed, and it is incorrect to retry the close.',
210 'Either call close directly and ignore its return value, or wrap close',
211 'in IGNORE_EINTR to use its return value. See http://crbug.com/269623'
217 r
'/IGNORE_EINTR\((?!.*close)',
219 'IGNORE_EINTR is only valid when wrapping close. To wrap other system',
220 'calls, use HANDLE_EINTR. See http://crbug.com/269623',
224 # Files that #define IGNORE_EINTR.
225 r
'^base[\\\/]posix[\\\/]eintr_wrapper\.h$',
226 r
'^ppapi[\\\/]tests[\\\/]test_broker\.cc$',
233 # Please keep sorted.
236 'OS_CAT', # For testing.
250 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
):
251 """Attempts to prevent use of functions intended only for testing in
252 non-testing code. For now this is just a best-effort implementation
253 that ignores header files and may have some false positives. A
254 better implementation would probably need a proper C++ parser.
256 # We only scan .cc files and the like, as the declaration of
257 # for-testing functions in header files are hard to distinguish from
258 # calls to such functions without a proper C++ parser.
259 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
261 base_function_pattern
= r
'ForTest(ing)?|for_test(ing)?'
262 inclusion_pattern
= input_api
.re
.compile(r
'(%s)\s*\(' % base_function_pattern
)
263 comment_pattern
= input_api
.re
.compile(r
'//.*%s' % base_function_pattern
)
264 exclusion_pattern
= input_api
.re
.compile(
265 r
'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
266 base_function_pattern
, base_function_pattern
))
268 def FilterFile(affected_file
):
269 black_list
= (_EXCLUDED_PATHS
+
270 _TEST_CODE_EXCLUDED_PATHS
+
271 input_api
.DEFAULT_BLACK_LIST
)
272 return input_api
.FilterSourceFile(
274 white_list
=(file_inclusion_pattern
, ),
275 black_list
=black_list
)
278 for f
in input_api
.AffectedSourceFiles(FilterFile
):
279 local_path
= f
.LocalPath()
280 lines
= input_api
.ReadFile(f
).splitlines()
283 if (inclusion_pattern
.search(line
) and
284 not comment_pattern
.search(line
) and
285 not exclusion_pattern
.search(line
)):
287 '%s:%d\n %s' % (local_path
, line_number
, line
.strip()))
291 return [output_api
.PresubmitPromptOrNotify(_TEST_ONLY_WARNING
, problems
)]
296 def _CheckNoIOStreamInHeaders(input_api
, output_api
):
297 """Checks to make sure no .h files include <iostream>."""
299 pattern
= input_api
.re
.compile(r
'^#include\s*<iostream>',
300 input_api
.re
.MULTILINE
)
301 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
302 if not f
.LocalPath().endswith('.h'):
304 contents
= input_api
.ReadFile(f
)
305 if pattern
.search(contents
):
309 return [ output_api
.PresubmitError(
310 'Do not #include <iostream> in header files, since it inserts static '
311 'initialization into every file including the header. Instead, '
312 '#include <ostream>. See http://crbug.com/94794',
317 def _CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
):
318 """Checks to make sure no source files use UNIT_TEST"""
320 for f
in input_api
.AffectedFiles():
321 if (not f
.LocalPath().endswith(('.cc', '.mm'))):
324 for line_num
, line
in f
.ChangedContents():
325 if 'UNIT_TEST ' in line
or line
.endswith('UNIT_TEST'):
326 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
330 return [output_api
.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
331 '\n'.join(problems
))]
334 def _CheckNoNewWStrings(input_api
, output_api
):
335 """Checks to make sure we don't introduce use of wstrings."""
337 for f
in input_api
.AffectedFiles():
338 if (not f
.LocalPath().endswith(('.cc', '.h')) or
339 f
.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))):
343 for line_num
, line
in f
.ChangedContents():
344 if 'presubmit: allow wstring' in line
:
346 elif not allowWString
and 'wstring' in line
:
347 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
354 return [output_api
.PresubmitPromptWarning('New code should not use wstrings.'
355 ' If you are calling a cross-platform API that accepts a wstring, '
357 '\n'.join(problems
))]
360 def _CheckNoDEPSGIT(input_api
, output_api
):
361 """Make sure .DEPS.git is never modified manually."""
362 if any(f
.LocalPath().endswith('.DEPS.git') for f
in
363 input_api
.AffectedFiles()):
364 return [output_api
.PresubmitError(
365 'Never commit changes to .DEPS.git. This file is maintained by an\n'
366 'automated system based on what\'s in DEPS and your changes will be\n'
368 'See http://code.google.com/p/chromium/wiki/UsingNewGit#Rolling_DEPS\n'
369 'for more information')]
373 def _CheckNoBannedFunctions(input_api
, output_api
):
374 """Make sure that banned functions are not used."""
378 file_filter
= lambda f
: f
.LocalPath().endswith(('.mm', '.m', '.h'))
379 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
380 for line_num
, line
in f
.ChangedContents():
381 for func_name
, message
, error
in _BANNED_OBJC_FUNCTIONS
:
382 if func_name
in line
:
386 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
387 for message_line
in message
:
388 problems
.append(' %s' % message_line
)
390 file_filter
= lambda f
: f
.LocalPath().endswith(('.cc', '.mm', '.h'))
391 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
392 for line_num
, line
in f
.ChangedContents():
393 for func_name
, message
, error
, excluded_paths
in _BANNED_CPP_FUNCTIONS
:
394 def IsBlacklisted(affected_file
, blacklist
):
395 local_path
= affected_file
.LocalPath()
396 for item
in blacklist
:
397 if input_api
.re
.match(item
, local_path
):
400 if IsBlacklisted(f
, excluded_paths
):
403 if func_name
[0:1] == '/':
404 regex
= func_name
[1:]
405 if input_api
.re
.search(regex
, line
):
407 elif func_name
in line
:
413 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
414 for message_line
in message
:
415 problems
.append(' %s' % message_line
)
419 result
.append(output_api
.PresubmitPromptWarning(
420 'Banned functions were used.\n' + '\n'.join(warnings
)))
422 result
.append(output_api
.PresubmitError(
423 'Banned functions were used.\n' + '\n'.join(errors
)))
427 def _CheckNoPragmaOnce(input_api
, output_api
):
428 """Make sure that banned functions are not used."""
430 pattern
= input_api
.re
.compile(r
'^#pragma\s+once',
431 input_api
.re
.MULTILINE
)
432 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
433 if not f
.LocalPath().endswith('.h'):
435 contents
= input_api
.ReadFile(f
)
436 if pattern
.search(contents
):
440 return [output_api
.PresubmitError(
441 'Do not use #pragma once in header files.\n'
442 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
447 def _CheckNoTrinaryTrueFalse(input_api
, output_api
):
448 """Checks to make sure we don't introduce use of foo ? true : false."""
450 pattern
= input_api
.re
.compile(r
'\?\s*(true|false)\s*:\s*(true|false)')
451 for f
in input_api
.AffectedFiles():
452 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
455 for line_num
, line
in f
.ChangedContents():
456 if pattern
.match(line
):
457 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
461 return [output_api
.PresubmitPromptWarning(
462 'Please consider avoiding the "? true : false" pattern if possible.\n' +
463 '\n'.join(problems
))]
466 def _CheckUnwantedDependencies(input_api
, output_api
):
467 """Runs checkdeps on #include statements added in this
468 change. Breaking - rules is an error, breaking ! rules is a
471 # We need to wait until we have an input_api object and use this
472 # roundabout construct to import checkdeps because this file is
473 # eval-ed and thus doesn't have __file__.
474 original_sys_path
= sys
.path
476 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
477 input_api
.PresubmitLocalPath(), 'tools', 'checkdeps')]
479 from cpp_checker
import CppChecker
480 from rules
import Rule
482 # Restore sys.path to what it was before.
483 sys
.path
= original_sys_path
486 for f
in input_api
.AffectedFiles():
487 if not CppChecker
.IsCppFile(f
.LocalPath()):
490 changed_lines
= [line
for line_num
, line
in f
.ChangedContents()]
491 added_includes
.append([f
.LocalPath(), changed_lines
])
493 deps_checker
= checkdeps
.DepsChecker(input_api
.PresubmitLocalPath())
495 error_descriptions
= []
496 warning_descriptions
= []
497 for path
, rule_type
, rule_description
in deps_checker
.CheckAddedCppIncludes(
499 description_with_path
= '%s\n %s' % (path
, rule_description
)
500 if rule_type
== Rule
.DISALLOW
:
501 error_descriptions
.append(description_with_path
)
503 warning_descriptions
.append(description_with_path
)
506 if error_descriptions
:
507 results
.append(output_api
.PresubmitError(
508 'You added one or more #includes that violate checkdeps rules.',
510 if warning_descriptions
:
511 results
.append(output_api
.PresubmitPromptOrNotify(
512 'You added one or more #includes of files that are temporarily\n'
513 'allowed but being removed. Can you avoid introducing the\n'
514 '#include? See relevant DEPS file(s) for details and contacts.',
515 warning_descriptions
))
519 def _CheckFilePermissions(input_api
, output_api
):
520 """Check that all files have their permissions properly set."""
521 args
= [sys
.executable
, 'tools/checkperms/checkperms.py', '--root',
522 input_api
.change
.RepositoryRoot()]
523 for f
in input_api
.AffectedFiles():
524 args
+= ['--file', f
.LocalPath()]
526 (errors
, stderrdata
) = subprocess
.Popen(args
).communicate()
530 results
.append(output_api
.PresubmitError('checkperms.py failed.',
535 def _CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
):
536 """Makes sure we don't include ui/aura/window_property.h
539 pattern
= input_api
.re
.compile(r
'^#include\s*"ui/aura/window_property.h"')
541 for f
in input_api
.AffectedFiles():
542 if not f
.LocalPath().endswith('.h'):
544 for line_num
, line
in f
.ChangedContents():
545 if pattern
.match(line
):
546 errors
.append(' %s:%d' % (f
.LocalPath(), line_num
))
550 results
.append(output_api
.PresubmitError(
551 'Header files should not include ui/aura/window_property.h', errors
))
555 def _CheckIncludeOrderForScope(scope
, input_api
, file_path
, changed_linenums
):
556 """Checks that the lines in scope occur in the right order.
558 1. C system files in alphabetical order
559 2. C++ system files in alphabetical order
560 3. Project's .h files
563 c_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*\.h>')
564 cpp_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*>')
565 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include ".*')
567 C_SYSTEM_INCLUDES
, CPP_SYSTEM_INCLUDES
, CUSTOM_INCLUDES
= range(3)
569 state
= C_SYSTEM_INCLUDES
572 previous_line_num
= 0
573 problem_linenums
= []
574 for line_num
, line
in scope
:
575 if c_system_include_pattern
.match(line
):
576 if state
!= C_SYSTEM_INCLUDES
:
577 problem_linenums
.append((line_num
, previous_line_num
))
578 elif previous_line
and previous_line
> line
:
579 problem_linenums
.append((line_num
, previous_line_num
))
580 elif cpp_system_include_pattern
.match(line
):
581 if state
== C_SYSTEM_INCLUDES
:
582 state
= CPP_SYSTEM_INCLUDES
583 elif state
== CUSTOM_INCLUDES
:
584 problem_linenums
.append((line_num
, previous_line_num
))
585 elif previous_line
and previous_line
> line
:
586 problem_linenums
.append((line_num
, previous_line_num
))
587 elif custom_include_pattern
.match(line
):
588 if state
!= CUSTOM_INCLUDES
:
589 state
= CUSTOM_INCLUDES
590 elif previous_line
and previous_line
> line
:
591 problem_linenums
.append((line_num
, previous_line_num
))
593 problem_linenums
.append(line_num
)
595 previous_line_num
= line_num
598 for (line_num
, previous_line_num
) in problem_linenums
:
599 if line_num
in changed_linenums
or previous_line_num
in changed_linenums
:
600 warnings
.append(' %s:%d' % (file_path
, line_num
))
604 def _CheckIncludeOrderInFile(input_api
, f
, changed_linenums
):
605 """Checks the #include order for the given file f."""
607 system_include_pattern
= input_api
.re
.compile(r
'\s*#include \<.*')
608 # Exclude the following includes from the check:
609 # 1) #include <.../...>, e.g., <sys/...> includes often need to appear in a
611 # 2) <atlbase.h>, "build/build_config.h"
612 excluded_include_pattern
= input_api
.re
.compile(
613 r
'\s*#include (\<.*/.*|\<atlbase\.h\>|"build/build_config.h")')
614 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include "(?P<FILE>.*)"')
615 # Match the final or penultimate token if it is xxxtest so we can ignore it
616 # when considering the special first include.
617 test_file_tag_pattern
= input_api
.re
.compile(
618 r
'_[a-z]+test(?=(_[a-zA-Z0-9]+)?\.)')
619 if_pattern
= input_api
.re
.compile(
620 r
'\s*#\s*(if|elif|else|endif|define|undef).*')
621 # Some files need specialized order of includes; exclude such files from this
623 uncheckable_includes_pattern
= input_api
.re
.compile(
625 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
627 contents
= f
.NewContents()
631 # Handle the special first include. If the first include file is
632 # some/path/file.h, the corresponding including file can be some/path/file.cc,
633 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
634 # etc. It's also possible that no special first include exists.
635 # If the included file is some/path/file_platform.h the including file could
636 # also be some/path/file_xxxtest_platform.h.
637 including_file_base_name
= test_file_tag_pattern
.sub(
638 '', input_api
.os_path
.basename(f
.LocalPath()))
640 for line
in contents
:
642 if system_include_pattern
.match(line
):
643 # No special first include -> process the line again along with normal
647 match
= custom_include_pattern
.match(line
)
649 match_dict
= match
.groupdict()
650 header_basename
= test_file_tag_pattern
.sub(
651 '', input_api
.os_path
.basename(match_dict
['FILE'])).replace('.h', '')
653 if header_basename
not in including_file_base_name
:
654 # No special first include -> process the line again along with normal
659 # Split into scopes: Each region between #if and #endif is its own scope.
662 for line
in contents
[line_num
:]:
664 if uncheckable_includes_pattern
.match(line
):
666 if if_pattern
.match(line
):
667 scopes
.append(current_scope
)
669 elif ((system_include_pattern
.match(line
) or
670 custom_include_pattern
.match(line
)) and
671 not excluded_include_pattern
.match(line
)):
672 current_scope
.append((line_num
, line
))
673 scopes
.append(current_scope
)
676 warnings
.extend(_CheckIncludeOrderForScope(scope
, input_api
, f
.LocalPath(),
681 def _CheckIncludeOrder(input_api
, output_api
):
682 """Checks that the #include order is correct.
684 1. The corresponding header for source files.
685 2. C system files in alphabetical order
686 3. C++ system files in alphabetical order
687 4. Project's .h files in alphabetical order
689 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
690 these rules separately.
694 for f
in input_api
.AffectedFiles():
695 if f
.LocalPath().endswith(('.cc', '.h')):
696 changed_linenums
= set(line_num
for line_num
, _
in f
.ChangedContents())
697 warnings
.extend(_CheckIncludeOrderInFile(input_api
, f
, changed_linenums
))
701 results
.append(output_api
.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING
,
706 def _CheckForVersionControlConflictsInFile(input_api
, f
):
707 pattern
= input_api
.re
.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
709 for line_num
, line
in f
.ChangedContents():
710 if pattern
.match(line
):
711 errors
.append(' %s:%d %s' % (f
.LocalPath(), line_num
, line
))
715 def _CheckForVersionControlConflicts(input_api
, output_api
):
716 """Usually this is not intentional and will cause a compile failure."""
718 for f
in input_api
.AffectedFiles():
719 errors
.extend(_CheckForVersionControlConflictsInFile(input_api
, f
))
723 results
.append(output_api
.PresubmitError(
724 'Version control conflict markers found, please resolve.', errors
))
728 def _CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
):
729 def FilterFile(affected_file
):
730 """Filter function for use with input_api.AffectedSourceFiles,
731 below. This filters out everything except non-test files from
732 top-level directories that generally speaking should not hard-code
733 service URLs (e.g. src/android_webview/, src/content/ and others).
735 return input_api
.FilterSourceFile(
737 white_list
=(r
'^(android_webview|base|content|net)[\\\/].*', ),
738 black_list
=(_EXCLUDED_PATHS
+
739 _TEST_CODE_EXCLUDED_PATHS
+
740 input_api
.DEFAULT_BLACK_LIST
))
742 base_pattern
= '"[^"]*google\.com[^"]*"'
743 comment_pattern
= input_api
.re
.compile('//.*%s' % base_pattern
)
744 pattern
= input_api
.re
.compile(base_pattern
)
745 problems
= [] # items are (filename, line_number, line)
746 for f
in input_api
.AffectedSourceFiles(FilterFile
):
747 for line_num
, line
in f
.ChangedContents():
748 if not comment_pattern
.search(line
) and pattern
.search(line
):
749 problems
.append((f
.LocalPath(), line_num
, line
))
752 return [output_api
.PresubmitPromptOrNotify(
753 'Most layers below src/chrome/ should not hardcode service URLs.\n'
754 'Are you sure this is correct? (Contact: joi@chromium.org)',
756 problem
[0], problem
[1], problem
[2]) for problem
in problems
])]
761 def _CheckNoAbbreviationInPngFileName(input_api
, output_api
):
762 """Makes sure there are no abbreviations in the name of PNG files.
764 pattern
= input_api
.re
.compile(r
'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
766 for f
in input_api
.AffectedFiles(include_deletes
=False):
767 if pattern
.match(f
.LocalPath()):
768 errors
.append(' %s' % f
.LocalPath())
772 results
.append(output_api
.PresubmitError(
773 'The name of PNG files should not have abbreviations. \n'
774 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
775 'Contact oshima@chromium.org if you have questions.', errors
))
779 def _DepsFilesToCheck(re
, changed_lines
):
780 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
781 a set of DEPS entries that we should look up."""
782 # We ignore deps entries on auto-generated directories.
783 AUTO_GENERATED_DIRS
= ['grit', 'jni']
785 # This pattern grabs the path without basename in the first
786 # parentheses, and the basename (if present) in the second. It
787 # relies on the simple heuristic that if there is a basename it will
788 # be a header file ending in ".h".
789 pattern
= re
.compile(
790 r
"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""")
792 for changed_line
in changed_lines
:
793 m
= pattern
.match(changed_line
)
796 if path
.split('/')[0] not in AUTO_GENERATED_DIRS
:
797 results
.add('%s/DEPS' % m
.group(1))
801 def _CheckAddedDepsHaveTargetApprovals(input_api
, output_api
):
802 """When a dependency prefixed with + is added to a DEPS file, we
803 want to make sure that the change is reviewed by an OWNER of the
804 target file or directory, to avoid layering violations from being
805 introduced. This check verifies that this happens.
807 changed_lines
= set()
808 for f
in input_api
.AffectedFiles():
809 filename
= input_api
.os_path
.basename(f
.LocalPath())
810 if filename
== 'DEPS':
811 changed_lines |
= set(line
.strip()
813 in f
.ChangedContents())
814 if not changed_lines
:
817 virtual_depended_on_files
= _DepsFilesToCheck(input_api
.re
, changed_lines
)
818 if not virtual_depended_on_files
:
821 if input_api
.is_committing
:
823 return [output_api
.PresubmitNotifyResult(
824 '--tbr was specified, skipping OWNERS check for DEPS additions')]
825 if not input_api
.change
.issue
:
826 return [output_api
.PresubmitError(
827 "DEPS approval by OWNERS check failed: this change has "
828 "no Rietveld issue number, so we can't check it for approvals.")]
829 output
= output_api
.PresubmitError
831 output
= output_api
.PresubmitNotifyResult
833 owners_db
= input_api
.owners_db
834 owner_email
, reviewers
= input_api
.canned_checks
._RietveldOwnerAndReviewers
(
836 owners_db
.email_regexp
,
837 approval_needed
=input_api
.is_committing
)
839 owner_email
= owner_email
or input_api
.change
.author_email
841 reviewers_plus_owner
= set(reviewers
)
843 reviewers_plus_owner
.add(owner_email
)
844 missing_files
= owners_db
.files_not_covered_by(virtual_depended_on_files
,
845 reviewers_plus_owner
)
846 unapproved_dependencies
= ["'+%s'," % path
[:-len('/DEPS')]
847 for path
in missing_files
]
849 if unapproved_dependencies
:
851 output('Missing LGTM from OWNERS of directories added to DEPS:\n %s' %
852 '\n '.join(sorted(unapproved_dependencies
)))]
853 if not input_api
.is_committing
:
854 suggested_owners
= owners_db
.reviewers_for(missing_files
, owner_email
)
855 output_list
.append(output(
856 'Suggested missing target path OWNERS:\n %s' %
857 '\n '.join(suggested_owners
or [])))
863 def _CheckSpamLogging(input_api
, output_api
):
864 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
865 black_list
= (_EXCLUDED_PATHS
+
866 _TEST_CODE_EXCLUDED_PATHS
+
867 input_api
.DEFAULT_BLACK_LIST
+
868 (r
"^base[\\\/]logging\.h$",
869 r
"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$",
870 r
"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$",
871 r
"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]"
872 r
"startup_browser_creator\.cc$",
873 r
"^chrome[\\\/]installer[\\\/]setup[\\\/].*",
874 r
"^chrome[\\\/]renderer[\\\/]extensions[\\\/]"
875 r
"logging_native_handler\.cc$",
876 r
"^remoting[\\\/]base[\\\/]logging\.h$",
877 r
"^remoting[\\\/]host[\\\/].*",
878 r
"^sandbox[\\\/]linux[\\\/].*",
879 r
"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",))
880 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
881 x
, white_list
=(file_inclusion_pattern
,), black_list
=black_list
)
886 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
887 contents
= input_api
.ReadFile(f
, 'rb')
888 if re
.search(r
"\bD?LOG\s*\(\s*INFO\s*\)", contents
):
889 log_info
.append(f
.LocalPath())
890 elif re
.search(r
"\bD?LOG_IF\s*\(\s*INFO\s*,", contents
):
891 log_info
.append(f
.LocalPath())
893 if re
.search(r
"\bprintf\(", contents
):
894 printf
.append(f
.LocalPath())
895 elif re
.search(r
"\bfprintf\((stdout|stderr)", contents
):
896 printf
.append(f
.LocalPath())
899 return [output_api
.PresubmitError(
900 'These files spam the console log with LOG(INFO):',
903 return [output_api
.PresubmitError(
904 'These files spam the console log with printf/fprintf:',
909 def _CheckForAnonymousVariables(input_api
, output_api
):
910 """These types are all expected to hold locks while in scope and
911 so should never be anonymous (which causes them to be immediately
913 they_who_must_be_named
= [
917 'SkAutoAlphaRestore',
918 'SkAutoBitmapShaderInstall',
919 'SkAutoBlitterChoose',
920 'SkAutoBounderCommit',
922 'SkAutoCanvasRestore',
923 'SkAutoCommentBlock',
925 'SkAutoDisableDirectionCheck',
926 'SkAutoDisableOvalCheck',
933 'SkAutoMaskFreeImage',
934 'SkAutoMutexAcquire',
935 'SkAutoPathBoundsUpdate',
937 'SkAutoRasterClipValidate',
943 anonymous
= r
'(%s)\s*[({]' % '|'.join(they_who_must_be_named
)
944 # bad: base::AutoLock(lock.get());
945 # not bad: base::AutoLock lock(lock.get());
946 bad_pattern
= input_api
.re
.compile(anonymous
)
947 # good: new base::AutoLock(lock.get())
948 good_pattern
= input_api
.re
.compile(r
'\bnew\s*' + anonymous
)
951 for f
in input_api
.AffectedFiles():
952 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
954 for linenum
, line
in f
.ChangedContents():
955 if bad_pattern
.search(line
) and not good_pattern
.search(line
):
956 errors
.append('%s:%d' % (f
.LocalPath(), linenum
))
959 return [output_api
.PresubmitError(
960 'These lines create anonymous variables that need to be named:',
965 def _CheckCygwinShell(input_api
, output_api
):
966 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
967 x
, white_list
=(r
'.+\.(gyp|gypi)$',))
970 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
971 for linenum
, line
in f
.ChangedContents():
972 if 'msvs_cygwin_shell' in line
:
973 cygwin_shell
.append(f
.LocalPath())
977 return [output_api
.PresubmitError(
978 'These files should not use msvs_cygwin_shell (the default is 0):',
983 def _CheckJavaStyle(input_api
, output_api
):
984 """Runs checkstyle on changed java files and returns errors if any exist."""
985 original_sys_path
= sys
.path
987 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
988 input_api
.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
991 # Restore sys.path to what it was before.
992 sys
.path
= original_sys_path
994 return checkstyle
.RunCheckstyle(
995 input_api
, output_api
, 'tools/android/checkstyle/chromium-style-5.0.xml')
998 def _CommonChecks(input_api
, output_api
):
999 """Checks common to both upload and commit."""
1001 results
.extend(input_api
.canned_checks
.PanProjectChecks(
1002 input_api
, output_api
, excluded_paths
=_EXCLUDED_PATHS
))
1003 results
.extend(_CheckAuthorizedAuthor(input_api
, output_api
))
1005 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
))
1006 results
.extend(_CheckNoIOStreamInHeaders(input_api
, output_api
))
1007 results
.extend(_CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
))
1008 results
.extend(_CheckNoNewWStrings(input_api
, output_api
))
1009 results
.extend(_CheckNoDEPSGIT(input_api
, output_api
))
1010 results
.extend(_CheckNoBannedFunctions(input_api
, output_api
))
1011 results
.extend(_CheckNoPragmaOnce(input_api
, output_api
))
1012 results
.extend(_CheckNoTrinaryTrueFalse(input_api
, output_api
))
1013 results
.extend(_CheckUnwantedDependencies(input_api
, output_api
))
1014 results
.extend(_CheckFilePermissions(input_api
, output_api
))
1015 results
.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
))
1016 results
.extend(_CheckIncludeOrder(input_api
, output_api
))
1017 results
.extend(_CheckForVersionControlConflicts(input_api
, output_api
))
1018 results
.extend(_CheckPatchFiles(input_api
, output_api
))
1019 results
.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
))
1020 results
.extend(_CheckNoAbbreviationInPngFileName(input_api
, output_api
))
1021 results
.extend(_CheckForInvalidOSMacros(input_api
, output_api
))
1022 results
.extend(_CheckAddedDepsHaveTargetApprovals(input_api
, output_api
))
1024 input_api
.canned_checks
.CheckChangeHasNoTabs(
1027 source_file_filter
=lambda x
: x
.LocalPath().endswith('.grd')))
1028 results
.extend(_CheckSpamLogging(input_api
, output_api
))
1029 results
.extend(_CheckForAnonymousVariables(input_api
, output_api
))
1030 results
.extend(_CheckCygwinShell(input_api
, output_api
))
1031 results
.extend(_CheckJavaStyle(input_api
, output_api
))
1032 results
.extend(_CheckForString16(input_api
, output_api
))
1034 if any('PRESUBMIT.py' == f
.LocalPath() for f
in input_api
.AffectedFiles()):
1035 results
.extend(input_api
.canned_checks
.RunUnitTestsInDirectory(
1036 input_api
, output_api
,
1037 input_api
.PresubmitLocalPath(),
1038 whitelist
=[r
'^PRESUBMIT_test\.py$']))
1042 def _CheckSubversionConfig(input_api
, output_api
):
1043 """Verifies the subversion config file is correctly setup.
1045 Checks that autoprops are enabled, returns an error otherwise.
1047 join
= input_api
.os_path
.join
1048 if input_api
.platform
== 'win32':
1049 appdata
= input_api
.environ
.get('APPDATA', '')
1051 return [output_api
.PresubmitError('%APPDATA% is not configured.')]
1052 path
= join(appdata
, 'Subversion', 'config')
1054 home
= input_api
.environ
.get('HOME', '')
1056 return [output_api
.PresubmitError('$HOME is not configured.')]
1057 path
= join(home
, '.subversion', 'config')
1060 'Please look at http://dev.chromium.org/developers/coding-style to\n'
1061 'configure your subversion configuration file. This enables automatic\n'
1062 'properties to simplify the project maintenance.\n'
1063 'Pro-tip: just download and install\n'
1064 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
1067 lines
= open(path
, 'r').read().splitlines()
1068 # Make sure auto-props is enabled and check for 2 Chromium standard
1070 if (not '*.cc = svn:eol-style=LF' in lines
or
1071 not '*.pdf = svn:mime-type=application/pdf' in lines
or
1072 not 'enable-auto-props = yes' in lines
):
1074 output_api
.PresubmitNotifyResult(
1075 'It looks like you have not configured your subversion config '
1076 'file or it is not up-to-date.\n' + error_msg
)
1078 except (OSError, IOError):
1080 output_api
.PresubmitNotifyResult(
1081 'Can\'t find your subversion config file.\n' + error_msg
)
1086 def _CheckAuthorizedAuthor(input_api
, output_api
):
1087 """For non-googler/chromites committers, verify the author's email address is
1090 # TODO(maruel): Add it to input_api?
1093 author
= input_api
.change
.author_email
1095 input_api
.logging
.info('No author, skipping AUTHOR check')
1097 authors_path
= input_api
.os_path
.join(
1098 input_api
.PresubmitLocalPath(), 'AUTHORS')
1100 input_api
.re
.match(r
'[^#]+\s+\<(.+?)\>\s*$', line
)
1101 for line
in open(authors_path
))
1102 valid_authors
= [item
.group(1).lower() for item
in valid_authors
if item
]
1103 if not any(fnmatch
.fnmatch(author
.lower(), valid
) for valid
in valid_authors
):
1104 input_api
.logging
.info('Valid authors are %s', ', '.join(valid_authors
))
1105 return [output_api
.PresubmitPromptWarning(
1106 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
1108 'http://www.chromium.org/developers/contributing-code and read the '
1110 'If you are a chromite, verify the contributor signed the CLA.') %
1115 def _CheckPatchFiles(input_api
, output_api
):
1116 problems
= [f
.LocalPath() for f
in input_api
.AffectedFiles()
1117 if f
.LocalPath().endswith(('.orig', '.rej'))]
1119 return [output_api
.PresubmitError(
1120 "Don't commit .rej and .orig files.", problems
)]
1125 def _DidYouMeanOSMacro(bad_macro
):
1127 return {'A': 'OS_ANDROID',
1137 'W': 'OS_WIN'}[bad_macro
[3].upper()]
1142 def _CheckForInvalidOSMacrosInFile(input_api
, f
):
1143 """Check for sensible looking, totally invalid OS macros."""
1144 preprocessor_statement
= input_api
.re
.compile(r
'^\s*#')
1145 os_macro
= input_api
.re
.compile(r
'defined\((OS_[^)]+)\)')
1147 for lnum
, line
in f
.ChangedContents():
1148 if preprocessor_statement
.search(line
):
1149 for match
in os_macro
.finditer(line
):
1150 if not match
.group(1) in _VALID_OS_MACROS
:
1151 good
= _DidYouMeanOSMacro(match
.group(1))
1152 did_you_mean
= ' (did you mean %s?)' % good
if good
else ''
1153 results
.append(' %s:%d %s%s' % (f
.LocalPath(),
1160 def _CheckForInvalidOSMacros(input_api
, output_api
):
1161 """Check all affected files for invalid OS macros."""
1163 for f
in input_api
.AffectedFiles():
1164 if not f
.LocalPath().endswith(('.py', '.js', '.html', '.css')):
1165 bad_macros
.extend(_CheckForInvalidOSMacrosInFile(input_api
, f
))
1170 return [output_api
.PresubmitError(
1171 'Possibly invalid OS macro[s] found. Please fix your code\n'
1172 'or add your macro to src/PRESUBMIT.py.', bad_macros
)]
1175 def _CheckForString16InFile(input_api
, f
):
1176 """Check for string16 without base:: in front."""
1177 reg
= input_api
.re
.compile(r
'\b(?<!base::)string16\b')
1178 use
= 'using base::string16;'
1179 include
= '#include "base/strings/string16.h"'
1181 for lnum
, line
in f
.ChangedContents():
1182 if reg
.search(line
) and not include
in line
and not use
in f
.NewContents():
1183 results
.append(' %s:%d' % (f
.LocalPath(), lnum
))
1187 def _CheckForString16(input_api
, output_api
):
1188 file_filter
= lambda f
: input_api
.FilterSourceFile(f
,
1190 r
'^android_webview[\\\/]',
1193 r
'^chrome[\\\/]browser[\\\/]',
1195 r
'^components[\\\/]',
1207 black_list
=(_EXCLUDED_PATHS
+ _TEST_CODE_EXCLUDED_PATHS
+
1208 input_api
.DEFAULT_BLACK_LIST
))
1211 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
1212 unprefixed
.extend(_CheckForString16InFile(input_api
, f
))
1217 return [output_api
.PresubmitPromptWarning(
1218 'string16 should be prefixed with base:: namespace.', unprefixed
)]
1221 def CheckChangeOnUpload(input_api
, output_api
):
1223 results
.extend(_CommonChecks(input_api
, output_api
))
1227 def GetDefaultTryConfigs(bots
=None):
1228 """Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
1230 To add tests to this list, they MUST be in the the corresponding master's
1231 gatekeeper config. For example, anything on master.chromium would be closed by
1232 tools/build/masters/master.chromium/master_gatekeeper_cfg.py.
1234 If 'bots' is specified, will only return configurations for bots in that list.
1240 'cacheinvalidation_unittests',
1243 'content_browsertests',
1244 'content_unittests',
1248 'interactive_ui_tests',
1254 'printing_unittests',
1258 # Broken in release.
1260 #'webkit_unit_tests',
1263 linux_aura_tests
= [
1264 'app_list_unittests',
1267 'compositor_unittests',
1268 'content_browsertests',
1269 'content_unittests',
1271 'interactive_ui_tests',
1274 builders_and_tests
= {
1275 # TODO(maruel): Figure out a way to run 'sizes' where people can
1276 # effectively update the perf expectation correctly. This requires a
1277 # clobber=True build running 'sizes'. 'sizes' is not accurate with
1278 # incremental build. Reference:
1279 # http://chromium.org/developers/tree-sheriffs/perf-sheriffs.
1280 # TODO(maruel): An option would be to run 'sizes' but not count a failure
1281 # of this step as a try job failure.
1282 'android_aosp': ['compile'],
1283 'android_clang_dbg': ['slave_steps'],
1284 'android_dbg': ['slave_steps'],
1285 'cros_x86': ['defaulttests'],
1286 'ios_dbg_simulator': [
1289 'content_unittests',
1296 'ios_rel_device': ['compile'],
1297 'linux_asan': ['defaulttests'],
1298 #TODO(stip): Change the name of this builder to reflect that it's release.
1299 'linux_aura': linux_aura_tests
,
1300 'linux_chromeos_asan': ['defaulttests'],
1301 'linux_chromeos_clang': ['compile'],
1302 # Note: It is a Release builder even if its name convey otherwise.
1303 'linux_chromeos': standard_tests
+ [
1304 'app_list_unittests',
1307 'chromeos_unittests',
1308 'components_unittests',
1312 'google_apis_unittests',
1313 'sandbox_linux_unittests',
1315 'linux_clang': ['compile'],
1316 'linux_rel': standard_tests
+ [
1318 'chromedriver2_unittests',
1319 'components_unittests',
1320 'google_apis_unittests',
1322 'remoting_unittests',
1323 'sandbox_linux_unittests',
1324 'sync_integration_tests',
1327 'mac_rel': standard_tests
+ [
1328 'app_list_unittests',
1330 'chromedriver2_unittests',
1331 'components_unittests',
1332 'google_apis_unittests',
1333 'message_center_unittests',
1335 'remoting_unittests',
1336 'sync_integration_tests',
1337 'telemetry_unittests',
1340 'win_rel': standard_tests
+ [
1341 'app_list_unittests',
1345 'chrome_elf_unittests',
1346 'chromedriver2_unittests',
1347 'components_unittests',
1348 'compositor_unittests',
1350 'google_apis_unittests',
1351 'installer_util_unittests',
1352 'mini_installer_test',
1354 'remoting_unittests',
1355 'sync_integration_tests',
1356 'telemetry_unittests',
1364 swarm_enabled_builders
= (
1370 swarm_enabled_tests
= (
1373 'interactive_ui_tests',
1378 for bot
in builders_and_tests
:
1379 if bot
in swarm_enabled_builders
:
1380 builders_and_tests
[bot
] = [x
+ '_swarm' if x
in swarm_enabled_tests
else x
1381 for x
in builders_and_tests
[bot
]]
1384 return [(bot
, set(builders_and_tests
[bot
])) for bot
in bots
]
1386 return [(bot
, set(tests
)) for bot
, tests
in builders_and_tests
.iteritems()]
1389 def CheckChangeOnCommit(input_api
, output_api
):
1391 results
.extend(_CommonChecks(input_api
, output_api
))
1392 # TODO(thestig) temporarily disabled, doesn't work in third_party/
1393 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
1394 # input_api, output_api, sources))
1395 # Make sure the tree is 'open'.
1396 results
.extend(input_api
.canned_checks
.CheckTreeIsOpen(
1399 json_url
='http://chromium-status.appspot.com/current?format=json'))
1400 results
.extend(input_api
.canned_checks
.CheckRietveldTryJobExecution(input_api
,
1401 output_api
, 'http://codereview.chromium.org',
1402 ('win_rel', 'linux_rel', 'mac_rel, win:compile'),
1403 'tryserver@chromium.org'))
1405 results
.extend(input_api
.canned_checks
.CheckChangeHasBugField(
1406 input_api
, output_api
))
1407 results
.extend(input_api
.canned_checks
.CheckChangeHasDescription(
1408 input_api
, output_api
))
1409 results
.extend(_CheckSubversionConfig(input_api
, output_api
))
1413 def GetPreferredTrySlaves(project
, change
):
1414 files
= change
.LocalPaths()
1416 if not files
or all(re
.search(r
'[\\/]OWNERS$', f
) for f
in files
):
1419 if all(re
.search('\.(m|mm)$|(^|[/_])mac[/_.]', f
) for f
in files
):
1420 return GetDefaultTryConfigs(['mac', 'mac_rel'])
1421 if all(re
.search('(^|[/_])win[/_.]', f
) for f
in files
):
1422 return GetDefaultTryConfigs(['win', 'win_rel'])
1423 if all(re
.search('(^|[/_])android[/_.]', f
) for f
in files
):
1424 return GetDefaultTryConfigs([
1426 'android_clang_dbg',
1429 if all(re
.search('^native_client_sdk', f
) for f
in files
):
1430 return GetDefaultTryConfigs([
1435 if all(re
.search('[/_]ios[/_.]', f
) for f
in files
):
1436 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
1438 trybots
= GetDefaultTryConfigs([
1439 'android_clang_dbg',
1441 'ios_dbg_simulator',
1455 # Match things like path/aura/file.cc and path/file_aura.cc.
1456 # Same for chromeos.
1457 if any(re
.search('[/_](aura|chromeos)', f
) for f
in files
):
1458 trybots
.extend(GetDefaultTryConfigs([
1459 'linux_chromeos_asan', 'linux_chromeos_clang']))
1461 # If there are gyp changes to base, build, or chromeos, run a full cros build
1462 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1463 # files have a much higher chance of breaking the cros build, which is
1464 # differnt from the linux_chromeos build that most chrome developers test
1466 if any(re
.search('^(base|build|chromeos).*\.gypi?$', f
) for f
in files
):
1467 trybots
.extend(GetDefaultTryConfigs(['cros_x86']))
1469 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1470 # unless they're .gyp(i) files as changes to those files can break the gyp
1472 if (not all(re
.search('^chrome', f
) for f
in files
) or
1473 any(re
.search('\.gypi?$', f
) for f
in files
)):
1474 trybots
.extend(GetDefaultTryConfigs(['android_aosp']))