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.
18 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_rules.py",
19 r
"^native_client_sdk[\\\/]src[\\\/]build_tools[\\\/]make_simple.py",
20 r
"^native_client_sdk[\\\/]src[\\\/]tools[\\\/].*.mk",
21 r
"^net[\\\/]tools[\\\/]spdyshark[\\\/].*",
26 r
".+[\\\/]pnacl_shim\.c$",
27 r
"^gpu[\\\/]config[\\\/].*_list_json\.cc$",
30 # TestRunner library is temporarily excluded from pan-project checks until
31 # it's transitioned to chromium coding style.
33 r
"^content[\\\/]shell[\\\/]renderer[\\\/]test_runner[\\\/].*",
34 r
"^content[\\\/]shell[\\\/]common[\\\/]test_runner[\\\/].*",
37 # Fragment of a regular expression that matches C++ and Objective-C++
38 # implementation files.
39 _IMPLEMENTATION_EXTENSIONS
= r
'\.(cc|cpp|cxx|mm)$'
41 # Regular expression that matches code only used for test binaries
43 _TEST_CODE_EXCLUDED_PATHS
= (
44 r
'.*[/\\](fake_|test_|mock_).+%s' % _IMPLEMENTATION_EXTENSIONS
,
45 r
'.+_test_(base|support|util)%s' % _IMPLEMENTATION_EXTENSIONS
,
46 r
'.+_(api|browser|kif|perf|pixel|unit|ui)?test(_[a-z]+)?%s' %
47 _IMPLEMENTATION_EXTENSIONS
,
48 r
'.+profile_sync_service_harness%s' % _IMPLEMENTATION_EXTENSIONS
,
49 r
'.*[/\\](test|tool(s)?)[/\\].*',
50 # content_shell is used for running layout tests.
51 r
'content[/\\]shell[/\\].*',
52 # At request of folks maintaining this folder.
53 r
'chrome[/\\]browser[/\\]automation[/\\].*',
54 # Non-production example code.
55 r
'mojo[/\\]examples[/\\].*',
58 _TEST_ONLY_WARNING
= (
59 'You might be calling functions intended only for testing from\n'
60 'production code. It is OK to ignore this warning if you know what\n'
61 'you are doing, as the heuristics used to detect the situation are\n'
62 'not perfect. The commit queue will not block on this warning.\n'
63 'Email joi@chromium.org if you have questions.')
66 _INCLUDE_ORDER_WARNING
= (
67 'Your #include order seems to be broken. Send mail to\n'
68 'marja@chromium.org if this is not the case.')
71 _BANNED_OBJC_FUNCTIONS
= (
75 'The use of -[NSView addTrackingRect:owner:userData:assumeInside:] is'
76 'prohibited. Please use CrTrackingArea instead.',
77 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
84 'The use of NSTrackingAreas is prohibited. Please use CrTrackingArea',
86 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
91 'convertPointFromBase:',
93 'The use of -[NSView convertPointFromBase:] is almost certainly wrong.',
94 'Please use |convertPoint:(point) fromView:nil| instead.',
95 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
100 'convertPointToBase:',
102 'The use of -[NSView convertPointToBase:] is almost certainly wrong.',
103 'Please use |convertPoint:(point) toView:nil| instead.',
104 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
109 'convertRectFromBase:',
111 'The use of -[NSView convertRectFromBase:] is almost certainly wrong.',
112 'Please use |convertRect:(point) fromView:nil| instead.',
113 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
118 'convertRectToBase:',
120 'The use of -[NSView convertRectToBase:] is almost certainly wrong.',
121 'Please use |convertRect:(point) toView:nil| instead.',
122 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
127 'convertSizeFromBase:',
129 'The use of -[NSView convertSizeFromBase:] is almost certainly wrong.',
130 'Please use |convertSize:(point) fromView:nil| instead.',
131 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
136 'convertSizeToBase:',
138 'The use of -[NSView convertSizeToBase:] is almost certainly wrong.',
139 'Please use |convertSize:(point) toView:nil| instead.',
140 'http://dev.chromium.org/developers/coding-style/cocoa-dos-and-donts',
147 _BANNED_CPP_FUNCTIONS
= (
148 # Make sure that gtest's FRIEND_TEST() macro is not used; the
149 # FRIEND_TEST_ALL_PREFIXES() macro from base/gtest_prod_util.h should be
150 # used instead since that allows for FLAKY_ and DISABLED_ prefixes.
154 'Chromium code should not use gtest\'s FRIEND_TEST() macro. Include',
155 'base/gtest_prod_util.h and use FRIEND_TEST_ALL_PREFIXES() instead.',
163 'New code should not use ScopedAllowIO. Post a task to the blocking',
164 'pool or the FILE thread instead.',
168 r
"^components[\\\/]breakpad[\\\/]app[\\\/]breakpad_mac\.mm$",
169 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$",
170 r
"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$",
171 r
"^net[\\\/]disk_cache[\\\/]cache_util\.cc$",
177 'The use of SkRefPtr is prohibited. ',
178 'Please use skia::RefPtr instead.'
186 'The indirect use of SkRefPtr via SkAutoRef is prohibited. ',
187 'Please use skia::RefPtr instead.'
195 'The use of SkAutoTUnref is dangerous because it implicitly ',
196 'converts to a raw pointer. Please use skia::RefPtr instead.'
204 'The indirect use of SkAutoTUnref through SkAutoUnref is dangerous ',
205 'because it implicitly converts to a raw pointer. ',
206 'Please use skia::RefPtr instead.'
212 r
'/HANDLE_EINTR\(.*close',
214 'HANDLE_EINTR(close) is invalid. If close fails with EINTR, the file',
215 'descriptor will be closed, and it is incorrect to retry the close.',
216 'Either call close directly and ignore its return value, or wrap close',
217 'in IGNORE_EINTR to use its return value. See http://crbug.com/269623'
223 r
'/IGNORE_EINTR\((?!.*close)',
225 'IGNORE_EINTR is only valid when wrapping close. To wrap other system',
226 'calls, use HANDLE_EINTR. See http://crbug.com/269623',
230 # Files that #define IGNORE_EINTR.
231 r
'^base[\\\/]posix[\\\/]eintr_wrapper\.h$',
232 r
'^ppapi[\\\/]tests[\\\/]test_broker\.cc$',
239 # Please keep sorted.
242 'OS_CAT', # For testing.
256 def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
):
257 """Attempts to prevent use of functions intended only for testing in
258 non-testing code. For now this is just a best-effort implementation
259 that ignores header files and may have some false positives. A
260 better implementation would probably need a proper C++ parser.
262 # We only scan .cc files and the like, as the declaration of
263 # for-testing functions in header files are hard to distinguish from
264 # calls to such functions without a proper C++ parser.
265 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
267 base_function_pattern
= r
'ForTest(ing)?|for_test(ing)?'
268 inclusion_pattern
= input_api
.re
.compile(r
'(%s)\s*\(' % base_function_pattern
)
269 comment_pattern
= input_api
.re
.compile(r
'//.*%s' % base_function_pattern
)
270 exclusion_pattern
= input_api
.re
.compile(
271 r
'::[A-Za-z0-9_]+(%s)|(%s)[^;]+\{' % (
272 base_function_pattern
, base_function_pattern
))
274 def FilterFile(affected_file
):
275 black_list
= (_EXCLUDED_PATHS
+
276 _TEST_CODE_EXCLUDED_PATHS
+
277 input_api
.DEFAULT_BLACK_LIST
)
278 return input_api
.FilterSourceFile(
280 white_list
=(file_inclusion_pattern
, ),
281 black_list
=black_list
)
284 for f
in input_api
.AffectedSourceFiles(FilterFile
):
285 local_path
= f
.LocalPath()
286 for line_number
, line
in f
.ChangedContents():
287 if (inclusion_pattern
.search(line
) and
288 not comment_pattern
.search(line
) and
289 not exclusion_pattern
.search(line
)):
291 '%s:%d\n %s' % (local_path
, line_number
, line
.strip()))
294 return [output_api
.PresubmitPromptOrNotify(_TEST_ONLY_WARNING
, problems
)]
299 def _CheckNoIOStreamInHeaders(input_api
, output_api
):
300 """Checks to make sure no .h files include <iostream>."""
302 pattern
= input_api
.re
.compile(r
'^#include\s*<iostream>',
303 input_api
.re
.MULTILINE
)
304 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
305 if not f
.LocalPath().endswith('.h'):
307 contents
= input_api
.ReadFile(f
)
308 if pattern
.search(contents
):
312 return [ output_api
.PresubmitError(
313 'Do not #include <iostream> in header files, since it inserts static '
314 'initialization into every file including the header. Instead, '
315 '#include <ostream>. See http://crbug.com/94794',
320 def _CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
):
321 """Checks to make sure no source files use UNIT_TEST"""
323 for f
in input_api
.AffectedFiles():
324 if (not f
.LocalPath().endswith(('.cc', '.mm'))):
327 for line_num
, line
in f
.ChangedContents():
328 if 'UNIT_TEST ' in line
or line
.endswith('UNIT_TEST'):
329 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
333 return [output_api
.PresubmitPromptWarning('UNIT_TEST is only for headers.\n' +
334 '\n'.join(problems
))]
337 def _CheckNoNewWStrings(input_api
, output_api
):
338 """Checks to make sure we don't introduce use of wstrings."""
340 for f
in input_api
.AffectedFiles():
341 if (not f
.LocalPath().endswith(('.cc', '.h')) or
342 f
.LocalPath().endswith(('test.cc', '_win.cc', '_win.h'))):
346 for line_num
, line
in f
.ChangedContents():
347 if 'presubmit: allow wstring' in line
:
349 elif not allowWString
and 'wstring' in line
:
350 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
357 return [output_api
.PresubmitPromptWarning('New code should not use wstrings.'
358 ' If you are calling a cross-platform API that accepts a wstring, '
360 '\n'.join(problems
))]
363 def _CheckNoDEPSGIT(input_api
, output_api
):
364 """Make sure .DEPS.git is never modified manually."""
365 if any(f
.LocalPath().endswith('.DEPS.git') for f
in
366 input_api
.AffectedFiles()):
367 return [output_api
.PresubmitError(
368 'Never commit changes to .DEPS.git. This file is maintained by an\n'
369 'automated system based on what\'s in DEPS and your changes will be\n'
371 'See http://code.google.com/p/chromium/wiki/UsingNewGit#Rolling_DEPS\n'
372 'for more information')]
376 def _CheckNoBannedFunctions(input_api
, output_api
):
377 """Make sure that banned functions are not used."""
381 file_filter
= lambda f
: f
.LocalPath().endswith(('.mm', '.m', '.h'))
382 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
383 for line_num
, line
in f
.ChangedContents():
384 for func_name
, message
, error
in _BANNED_OBJC_FUNCTIONS
:
385 if func_name
in line
:
389 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
390 for message_line
in message
:
391 problems
.append(' %s' % message_line
)
393 file_filter
= lambda f
: f
.LocalPath().endswith(('.cc', '.mm', '.h'))
394 for f
in input_api
.AffectedFiles(file_filter
=file_filter
):
395 for line_num
, line
in f
.ChangedContents():
396 for func_name
, message
, error
, excluded_paths
in _BANNED_CPP_FUNCTIONS
:
397 def IsBlacklisted(affected_file
, blacklist
):
398 local_path
= affected_file
.LocalPath()
399 for item
in blacklist
:
400 if input_api
.re
.match(item
, local_path
):
403 if IsBlacklisted(f
, excluded_paths
):
406 if func_name
[0:1] == '/':
407 regex
= func_name
[1:]
408 if input_api
.re
.search(regex
, line
):
410 elif func_name
in line
:
416 problems
.append(' %s:%d:' % (f
.LocalPath(), line_num
))
417 for message_line
in message
:
418 problems
.append(' %s' % message_line
)
422 result
.append(output_api
.PresubmitPromptWarning(
423 'Banned functions were used.\n' + '\n'.join(warnings
)))
425 result
.append(output_api
.PresubmitError(
426 'Banned functions were used.\n' + '\n'.join(errors
)))
430 def _CheckNoPragmaOnce(input_api
, output_api
):
431 """Make sure that banned functions are not used."""
433 pattern
= input_api
.re
.compile(r
'^#pragma\s+once',
434 input_api
.re
.MULTILINE
)
435 for f
in input_api
.AffectedSourceFiles(input_api
.FilterSourceFile
):
436 if not f
.LocalPath().endswith('.h'):
438 contents
= input_api
.ReadFile(f
)
439 if pattern
.search(contents
):
443 return [output_api
.PresubmitError(
444 'Do not use #pragma once in header files.\n'
445 'See http://www.chromium.org/developers/coding-style#TOC-File-headers',
450 def _CheckNoTrinaryTrueFalse(input_api
, output_api
):
451 """Checks to make sure we don't introduce use of foo ? true : false."""
453 pattern
= input_api
.re
.compile(r
'\?\s*(true|false)\s*:\s*(true|false)')
454 for f
in input_api
.AffectedFiles():
455 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
458 for line_num
, line
in f
.ChangedContents():
459 if pattern
.match(line
):
460 problems
.append(' %s:%d' % (f
.LocalPath(), line_num
))
464 return [output_api
.PresubmitPromptWarning(
465 'Please consider avoiding the "? true : false" pattern if possible.\n' +
466 '\n'.join(problems
))]
469 def _CheckUnwantedDependencies(input_api
, output_api
):
470 """Runs checkdeps on #include statements added in this
471 change. Breaking - rules is an error, breaking ! rules is a
474 # We need to wait until we have an input_api object and use this
475 # roundabout construct to import checkdeps because this file is
476 # eval-ed and thus doesn't have __file__.
477 original_sys_path
= sys
.path
479 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
480 input_api
.PresubmitLocalPath(), 'tools', 'checkdeps')]
482 from cpp_checker
import CppChecker
483 from rules
import Rule
485 # Restore sys.path to what it was before.
486 sys
.path
= original_sys_path
489 for f
in input_api
.AffectedFiles():
490 if not CppChecker
.IsCppFile(f
.LocalPath()):
493 changed_lines
= [line
for line_num
, line
in f
.ChangedContents()]
494 added_includes
.append([f
.LocalPath(), changed_lines
])
496 deps_checker
= checkdeps
.DepsChecker(input_api
.PresubmitLocalPath())
498 error_descriptions
= []
499 warning_descriptions
= []
500 for path
, rule_type
, rule_description
in deps_checker
.CheckAddedCppIncludes(
502 description_with_path
= '%s\n %s' % (path
, rule_description
)
503 if rule_type
== Rule
.DISALLOW
:
504 error_descriptions
.append(description_with_path
)
506 warning_descriptions
.append(description_with_path
)
509 if error_descriptions
:
510 results
.append(output_api
.PresubmitError(
511 'You added one or more #includes that violate checkdeps rules.',
513 if warning_descriptions
:
514 results
.append(output_api
.PresubmitPromptOrNotify(
515 'You added one or more #includes of files that are temporarily\n'
516 'allowed but being removed. Can you avoid introducing the\n'
517 '#include? See relevant DEPS file(s) for details and contacts.',
518 warning_descriptions
))
522 def _CheckFilePermissions(input_api
, output_api
):
523 """Check that all files have their permissions properly set."""
524 args
= [sys
.executable
, 'tools/checkperms/checkperms.py', '--root',
525 input_api
.change
.RepositoryRoot()]
526 for f
in input_api
.AffectedFiles():
527 args
+= ['--file', f
.LocalPath()]
528 checkperms
= input_api
.subprocess
.Popen(args
,
529 stdout
=input_api
.subprocess
.PIPE
)
530 errors
= checkperms
.communicate()[0].strip()
532 return [output_api
.PresubmitError('checkperms.py failed.',
533 errors
.splitlines())]
537 def _CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
):
538 """Makes sure we don't include ui/aura/window_property.h
541 pattern
= input_api
.re
.compile(r
'^#include\s*"ui/aura/window_property.h"')
543 for f
in input_api
.AffectedFiles():
544 if not f
.LocalPath().endswith('.h'):
546 for line_num
, line
in f
.ChangedContents():
547 if pattern
.match(line
):
548 errors
.append(' %s:%d' % (f
.LocalPath(), line_num
))
552 results
.append(output_api
.PresubmitError(
553 'Header files should not include ui/aura/window_property.h', errors
))
557 def _CheckIncludeOrderForScope(scope
, input_api
, file_path
, changed_linenums
):
558 """Checks that the lines in scope occur in the right order.
560 1. C system files in alphabetical order
561 2. C++ system files in alphabetical order
562 3. Project's .h files
565 c_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*\.h>')
566 cpp_system_include_pattern
= input_api
.re
.compile(r
'\s*#include <.*>')
567 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include ".*')
569 C_SYSTEM_INCLUDES
, CPP_SYSTEM_INCLUDES
, CUSTOM_INCLUDES
= range(3)
571 state
= C_SYSTEM_INCLUDES
574 previous_line_num
= 0
575 problem_linenums
= []
576 for line_num
, line
in scope
:
577 if c_system_include_pattern
.match(line
):
578 if state
!= C_SYSTEM_INCLUDES
:
579 problem_linenums
.append((line_num
, previous_line_num
))
580 elif previous_line
and previous_line
> line
:
581 problem_linenums
.append((line_num
, previous_line_num
))
582 elif cpp_system_include_pattern
.match(line
):
583 if state
== C_SYSTEM_INCLUDES
:
584 state
= CPP_SYSTEM_INCLUDES
585 elif state
== CUSTOM_INCLUDES
:
586 problem_linenums
.append((line_num
, previous_line_num
))
587 elif previous_line
and previous_line
> line
:
588 problem_linenums
.append((line_num
, previous_line_num
))
589 elif custom_include_pattern
.match(line
):
590 if state
!= CUSTOM_INCLUDES
:
591 state
= CUSTOM_INCLUDES
592 elif previous_line
and previous_line
> line
:
593 problem_linenums
.append((line_num
, previous_line_num
))
595 problem_linenums
.append(line_num
)
597 previous_line_num
= line_num
600 for (line_num
, previous_line_num
) in problem_linenums
:
601 if line_num
in changed_linenums
or previous_line_num
in changed_linenums
:
602 warnings
.append(' %s:%d' % (file_path
, line_num
))
606 def _CheckIncludeOrderInFile(input_api
, f
, changed_linenums
):
607 """Checks the #include order for the given file f."""
609 system_include_pattern
= input_api
.re
.compile(r
'\s*#include \<.*')
610 # Exclude the following includes from the check:
611 # 1) #include <.../...>, e.g., <sys/...> includes often need to appear in a
613 # 2) <atlbase.h>, "build/build_config.h"
614 excluded_include_pattern
= input_api
.re
.compile(
615 r
'\s*#include (\<.*/.*|\<atlbase\.h\>|"build/build_config.h")')
616 custom_include_pattern
= input_api
.re
.compile(r
'\s*#include "(?P<FILE>.*)"')
617 # Match the final or penultimate token if it is xxxtest so we can ignore it
618 # when considering the special first include.
619 test_file_tag_pattern
= input_api
.re
.compile(
620 r
'_[a-z]+test(?=(_[a-zA-Z0-9]+)?\.)')
621 if_pattern
= input_api
.re
.compile(
622 r
'\s*#\s*(if|elif|else|endif|define|undef).*')
623 # Some files need specialized order of includes; exclude such files from this
625 uncheckable_includes_pattern
= input_api
.re
.compile(
627 '("ipc/.*macros\.h"|<windows\.h>|".*gl.*autogen.h")\s*')
629 contents
= f
.NewContents()
633 # Handle the special first include. If the first include file is
634 # some/path/file.h, the corresponding including file can be some/path/file.cc,
635 # some/other/path/file.cc, some/path/file_platform.cc, some/path/file-suffix.h
636 # etc. It's also possible that no special first include exists.
637 # If the included file is some/path/file_platform.h the including file could
638 # also be some/path/file_xxxtest_platform.h.
639 including_file_base_name
= test_file_tag_pattern
.sub(
640 '', input_api
.os_path
.basename(f
.LocalPath()))
642 for line
in contents
:
644 if system_include_pattern
.match(line
):
645 # No special first include -> process the line again along with normal
649 match
= custom_include_pattern
.match(line
)
651 match_dict
= match
.groupdict()
652 header_basename
= test_file_tag_pattern
.sub(
653 '', input_api
.os_path
.basename(match_dict
['FILE'])).replace('.h', '')
655 if header_basename
not in including_file_base_name
:
656 # No special first include -> process the line again along with normal
661 # Split into scopes: Each region between #if and #endif is its own scope.
664 for line
in contents
[line_num
:]:
666 if uncheckable_includes_pattern
.match(line
):
668 if if_pattern
.match(line
):
669 scopes
.append(current_scope
)
671 elif ((system_include_pattern
.match(line
) or
672 custom_include_pattern
.match(line
)) and
673 not excluded_include_pattern
.match(line
)):
674 current_scope
.append((line_num
, line
))
675 scopes
.append(current_scope
)
678 warnings
.extend(_CheckIncludeOrderForScope(scope
, input_api
, f
.LocalPath(),
683 def _CheckIncludeOrder(input_api
, output_api
):
684 """Checks that the #include order is correct.
686 1. The corresponding header for source files.
687 2. C system files in alphabetical order
688 3. C++ system files in alphabetical order
689 4. Project's .h files in alphabetical order
691 Each region separated by #if, #elif, #else, #endif, #define and #undef follows
692 these rules separately.
696 for f
in input_api
.AffectedFiles():
697 if f
.LocalPath().endswith(('.cc', '.h')):
698 changed_linenums
= set(line_num
for line_num
, _
in f
.ChangedContents())
699 warnings
.extend(_CheckIncludeOrderInFile(input_api
, f
, changed_linenums
))
703 results
.append(output_api
.PresubmitPromptOrNotify(_INCLUDE_ORDER_WARNING
,
708 def _CheckForVersionControlConflictsInFile(input_api
, f
):
709 pattern
= input_api
.re
.compile('^(?:<<<<<<<|>>>>>>>) |^=======$')
711 for line_num
, line
in f
.ChangedContents():
712 if pattern
.match(line
):
713 errors
.append(' %s:%d %s' % (f
.LocalPath(), line_num
, line
))
717 def _CheckForVersionControlConflicts(input_api
, output_api
):
718 """Usually this is not intentional and will cause a compile failure."""
720 for f
in input_api
.AffectedFiles():
721 errors
.extend(_CheckForVersionControlConflictsInFile(input_api
, f
))
725 results
.append(output_api
.PresubmitError(
726 'Version control conflict markers found, please resolve.', errors
))
730 def _CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
):
731 def FilterFile(affected_file
):
732 """Filter function for use with input_api.AffectedSourceFiles,
733 below. This filters out everything except non-test files from
734 top-level directories that generally speaking should not hard-code
735 service URLs (e.g. src/android_webview/, src/content/ and others).
737 return input_api
.FilterSourceFile(
739 white_list
=(r
'^(android_webview|base|content|net)[\\\/].*', ),
740 black_list
=(_EXCLUDED_PATHS
+
741 _TEST_CODE_EXCLUDED_PATHS
+
742 input_api
.DEFAULT_BLACK_LIST
))
744 base_pattern
= '"[^"]*google\.com[^"]*"'
745 comment_pattern
= input_api
.re
.compile('//.*%s' % base_pattern
)
746 pattern
= input_api
.re
.compile(base_pattern
)
747 problems
= [] # items are (filename, line_number, line)
748 for f
in input_api
.AffectedSourceFiles(FilterFile
):
749 for line_num
, line
in f
.ChangedContents():
750 if not comment_pattern
.search(line
) and pattern
.search(line
):
751 problems
.append((f
.LocalPath(), line_num
, line
))
754 return [output_api
.PresubmitPromptOrNotify(
755 'Most layers below src/chrome/ should not hardcode service URLs.\n'
756 'Are you sure this is correct? (Contact: joi@chromium.org)',
758 problem
[0], problem
[1], problem
[2]) for problem
in problems
])]
763 def _CheckNoAbbreviationInPngFileName(input_api
, output_api
):
764 """Makes sure there are no abbreviations in the name of PNG files.
766 pattern
= input_api
.re
.compile(r
'.*_[a-z]_.*\.png$|.*_[a-z]\.png$')
768 for f
in input_api
.AffectedFiles(include_deletes
=False):
769 if pattern
.match(f
.LocalPath()):
770 errors
.append(' %s' % f
.LocalPath())
774 results
.append(output_api
.PresubmitError(
775 'The name of PNG files should not have abbreviations. \n'
776 'Use _hover.png, _center.png, instead of _h.png, _c.png.\n'
777 'Contact oshima@chromium.org if you have questions.', errors
))
781 def _FilesToCheckForIncomingDeps(re
, changed_lines
):
782 """Helper method for _CheckAddedDepsHaveTargetApprovals. Returns
783 a set of DEPS entries that we should look up.
785 For a directory (rather than a specific filename) we fake a path to
786 a specific filename by adding /DEPS. This is chosen as a file that
787 will seldom or never be subject to per-file include_rules.
789 # We ignore deps entries on auto-generated directories.
790 AUTO_GENERATED_DIRS
= ['grit', 'jni']
792 # This pattern grabs the path without basename in the first
793 # parentheses, and the basename (if present) in the second. It
794 # relies on the simple heuristic that if there is a basename it will
795 # be a header file ending in ".h".
796 pattern
= re
.compile(
797 r
"""['"]\+([^'"]+?)(/[a-zA-Z0-9_]+\.h)?['"].*""")
799 for changed_line
in changed_lines
:
800 m
= pattern
.match(changed_line
)
803 if path
.split('/')[0] not in AUTO_GENERATED_DIRS
:
805 results
.add('%s%s' % (path
, m
.group(2)))
807 results
.add('%s/DEPS' % path
)
811 def _CheckAddedDepsHaveTargetApprovals(input_api
, output_api
):
812 """When a dependency prefixed with + is added to a DEPS file, we
813 want to make sure that the change is reviewed by an OWNER of the
814 target file or directory, to avoid layering violations from being
815 introduced. This check verifies that this happens.
817 changed_lines
= set()
818 for f
in input_api
.AffectedFiles():
819 filename
= input_api
.os_path
.basename(f
.LocalPath())
820 if filename
== 'DEPS':
821 changed_lines |
= set(line
.strip()
823 in f
.ChangedContents())
824 if not changed_lines
:
827 virtual_depended_on_files
= _FilesToCheckForIncomingDeps(input_api
.re
,
829 if not virtual_depended_on_files
:
832 if input_api
.is_committing
:
834 return [output_api
.PresubmitNotifyResult(
835 '--tbr was specified, skipping OWNERS check for DEPS additions')]
836 if not input_api
.change
.issue
:
837 return [output_api
.PresubmitError(
838 "DEPS approval by OWNERS check failed: this change has "
839 "no Rietveld issue number, so we can't check it for approvals.")]
840 output
= output_api
.PresubmitError
842 output
= output_api
.PresubmitNotifyResult
844 owners_db
= input_api
.owners_db
845 owner_email
, reviewers
= input_api
.canned_checks
._RietveldOwnerAndReviewers
(
847 owners_db
.email_regexp
,
848 approval_needed
=input_api
.is_committing
)
850 owner_email
= owner_email
or input_api
.change
.author_email
852 reviewers_plus_owner
= set(reviewers
)
854 reviewers_plus_owner
.add(owner_email
)
855 missing_files
= owners_db
.files_not_covered_by(virtual_depended_on_files
,
856 reviewers_plus_owner
)
858 # We strip the /DEPS part that was added by
859 # _FilesToCheckForIncomingDeps to fake a path to a file in a
862 start_deps
= path
.rfind('/DEPS')
864 return path
[:start_deps
]
867 unapproved_dependencies
= ["'+%s'," % StripDeps(path
)
868 for path
in missing_files
]
870 if unapproved_dependencies
:
872 output('Missing LGTM from OWNERS of dependencies added to DEPS:\n %s' %
873 '\n '.join(sorted(unapproved_dependencies
)))]
874 if not input_api
.is_committing
:
875 suggested_owners
= owners_db
.reviewers_for(missing_files
, owner_email
)
876 output_list
.append(output(
877 'Suggested missing target path OWNERS:\n %s' %
878 '\n '.join(suggested_owners
or [])))
884 def _CheckSpamLogging(input_api
, output_api
):
885 file_inclusion_pattern
= r
'.+%s' % _IMPLEMENTATION_EXTENSIONS
886 black_list
= (_EXCLUDED_PATHS
+
887 _TEST_CODE_EXCLUDED_PATHS
+
888 input_api
.DEFAULT_BLACK_LIST
+
889 (r
"^base[\\\/]logging\.h$",
890 r
"^base[\\\/]logging\.cc$",
891 r
"^chrome[\\\/]app[\\\/]chrome_main_delegate\.cc$",
892 r
"^chrome[\\\/]browser[\\\/]chrome_browser_main\.cc$",
893 r
"^chrome[\\\/]browser[\\\/]ui[\\\/]startup[\\\/]"
894 r
"startup_browser_creator\.cc$",
895 r
"^chrome[\\\/]installer[\\\/]setup[\\\/].*",
896 r
"^chrome[\\\/]renderer[\\\/]extensions[\\\/]"
897 r
"logging_native_handler\.cc$",
898 r
"^content[\\\/]common[\\\/]gpu[\\\/]client[\\\/]"
899 r
"gl_helper_benchmark\.cc$",
900 r
"^remoting[\\\/]base[\\\/]logging\.h$",
901 r
"^remoting[\\\/]host[\\\/].*",
902 r
"^sandbox[\\\/]linux[\\\/].*",
903 r
"^tools[\\\/]telemetry[\\\/]telemetry[\\\/]core[\\\/]"
905 r
"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$",))
906 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
907 x
, white_list
=(file_inclusion_pattern
,), black_list
=black_list
)
912 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
913 contents
= input_api
.ReadFile(f
, 'rb')
914 if re
.search(r
"\bD?LOG\s*\(\s*INFO\s*\)", contents
):
915 log_info
.append(f
.LocalPath())
916 elif re
.search(r
"\bD?LOG_IF\s*\(\s*INFO\s*,", contents
):
917 log_info
.append(f
.LocalPath())
919 if re
.search(r
"\bprintf\(", contents
):
920 printf
.append(f
.LocalPath())
921 elif re
.search(r
"\bfprintf\((stdout|stderr)", contents
):
922 printf
.append(f
.LocalPath())
925 return [output_api
.PresubmitError(
926 'These files spam the console log with LOG(INFO):',
929 return [output_api
.PresubmitError(
930 'These files spam the console log with printf/fprintf:',
935 def _CheckForAnonymousVariables(input_api
, output_api
):
936 """These types are all expected to hold locks while in scope and
937 so should never be anonymous (which causes them to be immediately
939 they_who_must_be_named
= [
943 'SkAutoAlphaRestore',
944 'SkAutoBitmapShaderInstall',
945 'SkAutoBlitterChoose',
946 'SkAutoBounderCommit',
948 'SkAutoCanvasRestore',
949 'SkAutoCommentBlock',
951 'SkAutoDisableDirectionCheck',
952 'SkAutoDisableOvalCheck',
959 'SkAutoMaskFreeImage',
960 'SkAutoMutexAcquire',
961 'SkAutoPathBoundsUpdate',
963 'SkAutoRasterClipValidate',
969 anonymous
= r
'(%s)\s*[({]' % '|'.join(they_who_must_be_named
)
970 # bad: base::AutoLock(lock.get());
971 # not bad: base::AutoLock lock(lock.get());
972 bad_pattern
= input_api
.re
.compile(anonymous
)
973 # good: new base::AutoLock(lock.get())
974 good_pattern
= input_api
.re
.compile(r
'\bnew\s*' + anonymous
)
977 for f
in input_api
.AffectedFiles():
978 if not f
.LocalPath().endswith(('.cc', '.h', '.inl', '.m', '.mm')):
980 for linenum
, line
in f
.ChangedContents():
981 if bad_pattern
.search(line
) and not good_pattern
.search(line
):
982 errors
.append('%s:%d' % (f
.LocalPath(), linenum
))
985 return [output_api
.PresubmitError(
986 'These lines create anonymous variables that need to be named:',
991 def _CheckCygwinShell(input_api
, output_api
):
992 source_file_filter
= lambda x
: input_api
.FilterSourceFile(
993 x
, white_list
=(r
'.+\.(gyp|gypi)$',))
996 for f
in input_api
.AffectedSourceFiles(source_file_filter
):
997 for linenum
, line
in f
.ChangedContents():
998 if 'msvs_cygwin_shell' in line
:
999 cygwin_shell
.append(f
.LocalPath())
1003 return [output_api
.PresubmitError(
1004 'These files should not use msvs_cygwin_shell (the default is 0):',
1005 items
=cygwin_shell
)]
1009 def _CheckJavaStyle(input_api
, output_api
):
1010 """Runs checkstyle on changed java files and returns errors if any exist."""
1011 original_sys_path
= sys
.path
1013 sys
.path
= sys
.path
+ [input_api
.os_path
.join(
1014 input_api
.PresubmitLocalPath(), 'tools', 'android', 'checkstyle')]
1017 # Restore sys.path to what it was before.
1018 sys
.path
= original_sys_path
1020 return checkstyle
.RunCheckstyle(
1021 input_api
, output_api
, 'tools/android/checkstyle/chromium-style-5.0.xml')
1024 def _CommonChecks(input_api
, output_api
):
1025 """Checks common to both upload and commit."""
1027 results
.extend(input_api
.canned_checks
.PanProjectChecks(
1028 input_api
, output_api
,
1029 excluded_paths
=_EXCLUDED_PATHS
+ _TESTRUNNER_PATHS
))
1030 results
.extend(_CheckAuthorizedAuthor(input_api
, output_api
))
1032 _CheckNoProductionCodeUsingTestOnlyFunctions(input_api
, output_api
))
1033 results
.extend(_CheckNoIOStreamInHeaders(input_api
, output_api
))
1034 results
.extend(_CheckNoUNIT_TESTInSourceFiles(input_api
, output_api
))
1035 results
.extend(_CheckNoNewWStrings(input_api
, output_api
))
1036 results
.extend(_CheckNoDEPSGIT(input_api
, output_api
))
1037 results
.extend(_CheckNoBannedFunctions(input_api
, output_api
))
1038 results
.extend(_CheckNoPragmaOnce(input_api
, output_api
))
1039 results
.extend(_CheckNoTrinaryTrueFalse(input_api
, output_api
))
1040 results
.extend(_CheckUnwantedDependencies(input_api
, output_api
))
1041 results
.extend(_CheckFilePermissions(input_api
, output_api
))
1042 results
.extend(_CheckNoAuraWindowPropertyHInHeaders(input_api
, output_api
))
1043 results
.extend(_CheckIncludeOrder(input_api
, output_api
))
1044 results
.extend(_CheckForVersionControlConflicts(input_api
, output_api
))
1045 results
.extend(_CheckPatchFiles(input_api
, output_api
))
1046 results
.extend(_CheckHardcodedGoogleHostsInLowerLayers(input_api
, output_api
))
1047 results
.extend(_CheckNoAbbreviationInPngFileName(input_api
, output_api
))
1048 results
.extend(_CheckForInvalidOSMacros(input_api
, output_api
))
1049 results
.extend(_CheckAddedDepsHaveTargetApprovals(input_api
, output_api
))
1051 input_api
.canned_checks
.CheckChangeHasNoTabs(
1054 source_file_filter
=lambda x
: x
.LocalPath().endswith('.grd')))
1055 results
.extend(_CheckSpamLogging(input_api
, output_api
))
1056 results
.extend(_CheckForAnonymousVariables(input_api
, output_api
))
1057 results
.extend(_CheckCygwinShell(input_api
, output_api
))
1058 results
.extend(_CheckJavaStyle(input_api
, output_api
))
1060 if any('PRESUBMIT.py' == f
.LocalPath() for f
in input_api
.AffectedFiles()):
1061 results
.extend(input_api
.canned_checks
.RunUnitTestsInDirectory(
1062 input_api
, output_api
,
1063 input_api
.PresubmitLocalPath(),
1064 whitelist
=[r
'^PRESUBMIT_test\.py$']))
1068 def _CheckSubversionConfig(input_api
, output_api
):
1069 """Verifies the subversion config file is correctly setup.
1071 Checks that autoprops are enabled, returns an error otherwise.
1073 join
= input_api
.os_path
.join
1074 if input_api
.platform
== 'win32':
1075 appdata
= input_api
.environ
.get('APPDATA', '')
1077 return [output_api
.PresubmitError('%APPDATA% is not configured.')]
1078 path
= join(appdata
, 'Subversion', 'config')
1080 home
= input_api
.environ
.get('HOME', '')
1082 return [output_api
.PresubmitError('$HOME is not configured.')]
1083 path
= join(home
, '.subversion', 'config')
1086 'Please look at http://dev.chromium.org/developers/coding-style to\n'
1087 'configure your subversion configuration file. This enables automatic\n'
1088 'properties to simplify the project maintenance.\n'
1089 'Pro-tip: just download and install\n'
1090 'http://src.chromium.org/viewvc/chrome/trunk/tools/build/slave/config\n')
1093 lines
= open(path
, 'r').read().splitlines()
1094 # Make sure auto-props is enabled and check for 2 Chromium standard
1096 if (not '*.cc = svn:eol-style=LF' in lines
or
1097 not '*.pdf = svn:mime-type=application/pdf' in lines
or
1098 not 'enable-auto-props = yes' in lines
):
1100 output_api
.PresubmitNotifyResult(
1101 'It looks like you have not configured your subversion config '
1102 'file or it is not up-to-date.\n' + error_msg
)
1104 except (OSError, IOError):
1106 output_api
.PresubmitNotifyResult(
1107 'Can\'t find your subversion config file.\n' + error_msg
)
1112 def _CheckAuthorizedAuthor(input_api
, output_api
):
1113 """For non-googler/chromites committers, verify the author's email address is
1116 # TODO(maruel): Add it to input_api?
1119 author
= input_api
.change
.author_email
1121 input_api
.logging
.info('No author, skipping AUTHOR check')
1123 authors_path
= input_api
.os_path
.join(
1124 input_api
.PresubmitLocalPath(), 'AUTHORS')
1126 input_api
.re
.match(r
'[^#]+\s+\<(.+?)\>\s*$', line
)
1127 for line
in open(authors_path
))
1128 valid_authors
= [item
.group(1).lower() for item
in valid_authors
if item
]
1129 if not any(fnmatch
.fnmatch(author
.lower(), valid
) for valid
in valid_authors
):
1130 input_api
.logging
.info('Valid authors are %s', ', '.join(valid_authors
))
1131 return [output_api
.PresubmitPromptWarning(
1132 ('%s is not in AUTHORS file. If you are a new contributor, please visit'
1134 'http://www.chromium.org/developers/contributing-code and read the '
1136 'If you are a chromite, verify the contributor signed the CLA.') %
1141 def _CheckPatchFiles(input_api
, output_api
):
1142 problems
= [f
.LocalPath() for f
in input_api
.AffectedFiles()
1143 if f
.LocalPath().endswith(('.orig', '.rej'))]
1145 return [output_api
.PresubmitError(
1146 "Don't commit .rej and .orig files.", problems
)]
1151 def _DidYouMeanOSMacro(bad_macro
):
1153 return {'A': 'OS_ANDROID',
1163 'W': 'OS_WIN'}[bad_macro
[3].upper()]
1168 def _CheckForInvalidOSMacrosInFile(input_api
, f
):
1169 """Check for sensible looking, totally invalid OS macros."""
1170 preprocessor_statement
= input_api
.re
.compile(r
'^\s*#')
1171 os_macro
= input_api
.re
.compile(r
'defined\((OS_[^)]+)\)')
1173 for lnum
, line
in f
.ChangedContents():
1174 if preprocessor_statement
.search(line
):
1175 for match
in os_macro
.finditer(line
):
1176 if not match
.group(1) in _VALID_OS_MACROS
:
1177 good
= _DidYouMeanOSMacro(match
.group(1))
1178 did_you_mean
= ' (did you mean %s?)' % good
if good
else ''
1179 results
.append(' %s:%d %s%s' % (f
.LocalPath(),
1186 def _CheckForInvalidOSMacros(input_api
, output_api
):
1187 """Check all affected files for invalid OS macros."""
1189 for f
in input_api
.AffectedFiles():
1190 if not f
.LocalPath().endswith(('.py', '.js', '.html', '.css')):
1191 bad_macros
.extend(_CheckForInvalidOSMacrosInFile(input_api
, f
))
1196 return [output_api
.PresubmitError(
1197 'Possibly invalid OS macro[s] found. Please fix your code\n'
1198 'or add your macro to src/PRESUBMIT.py.', bad_macros
)]
1201 def CheckChangeOnUpload(input_api
, output_api
):
1203 results
.extend(_CommonChecks(input_api
, output_api
))
1207 def GetDefaultTryConfigs(bots
=None):
1208 """Returns a list of ('bot', set(['tests']), optionally filtered by [bots].
1210 To add tests to this list, they MUST be in the the corresponding master's
1211 gatekeeper config. For example, anything on master.chromium would be closed by
1212 tools/build/masters/master.chromium/master_gatekeeper_cfg.py.
1214 If 'bots' is specified, will only return configurations for bots in that list.
1220 'cacheinvalidation_unittests',
1223 'content_browsertests',
1224 'content_unittests',
1228 'interactive_ui_tests',
1234 'printing_unittests',
1238 # Broken in release.
1240 #'webkit_unit_tests',
1243 linux_aura_tests
= [
1244 'app_list_unittests',
1247 'compositor_unittests',
1248 'content_browsertests',
1249 'content_unittests',
1251 'interactive_ui_tests',
1254 builders_and_tests
= {
1255 # TODO(maruel): Figure out a way to run 'sizes' where people can
1256 # effectively update the perf expectation correctly. This requires a
1257 # clobber=True build running 'sizes'. 'sizes' is not accurate with
1258 # incremental build. Reference:
1259 # http://chromium.org/developers/tree-sheriffs/perf-sheriffs.
1260 # TODO(maruel): An option would be to run 'sizes' but not count a failure
1261 # of this step as a try job failure.
1262 'android_aosp': ['compile'],
1263 'android_clang_dbg': ['slave_steps'],
1264 'android_dbg': ['slave_steps'],
1265 'cros_x86': ['defaulttests'],
1266 'ios_dbg_simulator': [
1269 'content_unittests',
1276 'ios_rel_device': ['compile'],
1277 'linux_asan': ['defaulttests'],
1278 #TODO(stip): Change the name of this builder to reflect that it's release.
1279 'linux_aura': linux_aura_tests
,
1280 'linux_chromeos_asan': ['defaulttests'],
1281 'linux_chromeos_clang': ['compile'],
1282 # Note: It is a Release builder even if its name convey otherwise.
1283 'linux_chromeos': standard_tests
+ [
1284 'app_list_unittests',
1287 'chromeos_unittests',
1288 'components_unittests',
1292 'google_apis_unittests',
1293 'sandbox_linux_unittests',
1295 'linux_chromium_dbg': ['defaulttests'],
1296 'linux_chromium_rel': ['defaulttests'],
1297 'linux_clang': ['compile'],
1298 'linux_nacl_sdk_build': ['compile'],
1299 'linux_rel': standard_tests
+ [
1301 'chromedriver_unittests',
1302 'components_unittests',
1303 'google_apis_unittests',
1305 'remoting_unittests',
1306 'sandbox_linux_unittests',
1307 'sync_integration_tests',
1308 'telemetry_perf_unittests',
1309 'telemetry_unittests',
1312 'mac_chromium_dbg': ['defaulttests'],
1313 'mac_chromium_rel': ['defaulttests'],
1314 'mac_nacl_sdk_build': ['compile'],
1315 'mac_rel': standard_tests
+ [
1316 'app_list_unittests',
1318 'chromedriver_unittests',
1319 'components_unittests',
1320 'google_apis_unittests',
1321 'message_center_unittests',
1323 'remoting_unittests',
1324 'sync_integration_tests',
1325 'telemetry_perf_unittests',
1326 'telemetry_unittests',
1329 'win_nacl_sdk_build': ['compile'],
1330 'win_rel': standard_tests
+ [
1331 'app_list_unittests',
1335 'chrome_elf_unittests',
1336 'chromedriver_unittests',
1337 'components_unittests',
1338 'compositor_unittests',
1340 'google_apis_unittests',
1341 'installer_util_unittests',
1342 'mini_installer_test',
1344 'remoting_unittests',
1345 'sync_integration_tests',
1346 'telemetry_perf_unittests',
1347 'telemetry_unittests',
1355 swarm_enabled_builders
= (
1361 swarm_enabled_tests
= (
1364 'interactive_ui_tests',
1369 for bot
in builders_and_tests
:
1370 if bot
in swarm_enabled_builders
:
1371 builders_and_tests
[bot
] = [x
+ '_swarm' if x
in swarm_enabled_tests
else x
1372 for x
in builders_and_tests
[bot
]]
1375 return [(bot
, set(builders_and_tests
[bot
])) for bot
in bots
]
1377 return [(bot
, set(tests
)) for bot
, tests
in builders_and_tests
.iteritems()]
1380 def CheckChangeOnCommit(input_api
, output_api
):
1382 results
.extend(_CommonChecks(input_api
, output_api
))
1383 # TODO(thestig) temporarily disabled, doesn't work in third_party/
1384 #results.extend(input_api.canned_checks.CheckSvnModifiedDirectories(
1385 # input_api, output_api, sources))
1386 # Make sure the tree is 'open'.
1387 results
.extend(input_api
.canned_checks
.CheckTreeIsOpen(
1390 json_url
='http://chromium-status.appspot.com/current?format=json'))
1391 results
.extend(input_api
.canned_checks
.CheckRietveldTryJobExecution(input_api
,
1392 output_api
, 'http://codereview.chromium.org',
1393 ('win_rel', 'linux_rel', 'mac_rel, win:compile'),
1394 'tryserver@chromium.org'))
1396 results
.extend(input_api
.canned_checks
.CheckChangeHasBugField(
1397 input_api
, output_api
))
1398 results
.extend(input_api
.canned_checks
.CheckChangeHasDescription(
1399 input_api
, output_api
))
1400 results
.extend(_CheckSubversionConfig(input_api
, output_api
))
1404 def GetPreferredTrySlaves(project
, change
):
1405 files
= change
.LocalPaths()
1407 if not files
or all(re
.search(r
'[\\/]OWNERS$', f
) for f
in files
):
1410 if all(re
.search('\.(m|mm)$|(^|[/_])mac[/_.]', f
) for f
in files
):
1411 return GetDefaultTryConfigs(['mac', 'mac_rel'])
1412 if all(re
.search('(^|[/_])win[/_.]', f
) for f
in files
):
1413 return GetDefaultTryConfigs(['win', 'win_rel'])
1414 if all(re
.search('(^|[/_])android[/_.]', f
) for f
in files
):
1415 return GetDefaultTryConfigs([
1417 'android_clang_dbg',
1420 if all(re
.search('[/_]ios[/_.]', f
) for f
in files
):
1421 return GetDefaultTryConfigs(['ios_rel_device', 'ios_dbg_simulator'])
1423 trybots
= GetDefaultTryConfigs([
1424 'android_clang_dbg',
1426 'ios_dbg_simulator',
1432 'linux_nacl_sdk_build',
1435 'mac_nacl_sdk_build',
1438 'win_nacl_sdk_build',
1443 # Match things like path/aura/file.cc and path/file_aura.cc.
1444 # Same for chromeos.
1445 if any(re
.search('[/_](aura|chromeos)', f
) for f
in files
):
1446 trybots
.extend(GetDefaultTryConfigs([
1447 'linux_chromeos_asan', 'linux_chromeos_clang']))
1449 # If there are gyp changes to base, build, or chromeos, run a full cros build
1450 # in addition to the shorter linux_chromeos build. Changes to high level gyp
1451 # files have a much higher chance of breaking the cros build, which is
1452 # differnt from the linux_chromeos build that most chrome developers test
1454 if any(re
.search('^(base|build|chromeos).*\.gypi?$', f
) for f
in files
):
1455 trybots
.extend(GetDefaultTryConfigs(['cros_x86']))
1457 # The AOSP bot doesn't build the chrome/ layer, so ignore any changes to it
1458 # unless they're .gyp(i) files as changes to those files can break the gyp
1460 if (not all(re
.search('^chrome', f
) for f
in files
) or
1461 any(re
.search('\.gypi?$', f
) for f
in files
)):
1462 trybots
.extend(GetDefaultTryConfigs(['android_aosp']))