diff options
author | Allan Sandfeld Jensen <allan.jensen@theqtcompany.com> | 2016-05-09 14:22:11 +0200 |
---|---|---|
committer | Allan Sandfeld Jensen <allan.jensen@qt.io> | 2016-05-09 15:11:45 +0000 |
commit | 2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c (patch) | |
tree | e75f511546c5fd1a173e87c1f9fb11d7ac8d1af3 /chromium/PRESUBMIT.py | |
parent | a4f3d46271c57e8155ba912df46a05559d14726e (diff) | |
download | qtwebengine-chromium-2ddb2d3e14eef3de7dbd0cef553d669b9ac2361c.tar.gz |
BASELINE: Update Chromium to 51.0.2704.41
Also adds in all smaller components by reversing logic for exclusion.
Change-Id: Ibf90b506e7da088ea2f65dcf23f2b0992c504422
Reviewed-by: Joerg Bornemann <joerg.bornemann@theqtcompany.com>
Diffstat (limited to 'chromium/PRESUBMIT.py')
-rw-r--r-- | chromium/PRESUBMIT.py | 185 |
1 files changed, 152 insertions, 33 deletions
diff --git a/chromium/PRESUBMIT.py b/chromium/PRESUBMIT.py index 96095b7b34a..7d32ad5388b 100644 --- a/chromium/PRESUBMIT.py +++ b/chromium/PRESUBMIT.py @@ -166,20 +166,24 @@ _BANNED_CPP_FUNCTIONS = ( ( r"^base[\\\/]process[\\\/]process_linux\.cc$", r"^base[\\\/]process[\\\/]process_metrics_linux\.cc$", - r"^blimp[\\\/]engine[\\\/]browser[\\\/]blimp_browser_main_parts\.cc$", + r"^blimp[\\\/]engine[\\\/]app[\\\/]blimp_browser_main_parts\.cc$", r"^chrome[\\\/]browser[\\\/]chromeos[\\\/]boot_times_recorder\.cc$", + r"^chrome[\\\/]browser[\\\/]lifetime[\\\/]application_lifetime\.cc$", r"^chrome[\\\/]browser[\\\/]chromeos[\\\/]" "customization_document_browsertest\.cc$", r"^components[\\\/]crash[\\\/]app[\\\/]breakpad_mac\.mm$", + r"^content[\\\/]shell[\\\/]browser[\\\/]layout_test[\\\/]" + + r"test_info_extractor\.cc$", r"^content[\\\/]shell[\\\/]browser[\\\/]shell_browser_main\.cc$", r"^content[\\\/]shell[\\\/]browser[\\\/]shell_message_filter\.cc$", r"^mojo[\\\/]edk[\\\/]embedder[\\\/]" + r"simple_platform_shared_buffer_posix\.cc$", r"^net[\\\/]disk_cache[\\\/]cache_util\.cc$", r"^net[\\\/]url_request[\\\/]test_url_fetcher_factory\.cc$", - r"^remoting[\\\/]host[\\\/]gnubby_auth_handler_posix\.cc$", + r"^remoting[\\\/]host[\\\/]security_key[\\\/]" + "gnubby_auth_handler_linux\.cc$", r"^ui[\\\/]ozone[\\\/]platform[\\\/]drm[\\\/]host[\\\/]" - "drm_display_host_manager_core\.cc$", + "drm_display_host_manager\.cc$", ), ), ( @@ -266,6 +270,14 @@ _BANNED_CPP_FUNCTIONS = ( r'^base[\\\/]message_loop[\\\/].*', ), ), + ( + '#pragma comment(lib,', + ( + 'Specify libraries to link with in build files and not in the source.', + ), + True, + (), + ), ) _IPC_ENUM_TRAITS_DEPRECATED = ( @@ -294,6 +306,17 @@ _VALID_OS_MACROS = ( ) +_ANDROID_SPECIFIC_PYDEPS_FILES = [ + 'build/android/test_runner.pydeps', +] + +_GENERIC_PYDEPS_FILES = [ + 'build/secondary/tools/swarming_client/isolate.pydeps', +] + +_ALL_PYDEPS_FILES = _ANDROID_SPECIFIC_PYDEPS_FILES + _GENERIC_PYDEPS_FILES + + def _CheckNoProductionCodeUsingTestOnlyFunctions(input_api, output_api): """Attempts to prevent use of functions intended only for testing in non-testing code. For now this is just a best-effort implementation @@ -670,7 +693,10 @@ def _CheckFilePermissions(input_api, output_api): """Check that all files have their permissions properly set.""" if input_api.platform == 'win32': return [] - args = [input_api.python_executable, 'tools/checkperms/checkperms.py', + checkperms_tool = input_api.os_path.join( + input_api.PresubmitLocalPath(), + 'tools', 'checkperms', 'checkperms.py') + args = [input_api.python_executable, checkperms_tool, '--root', input_api.change.RepositoryRoot()] for f in input_api.AffectedFiles(): args += ['--file', f.LocalPath()] @@ -982,7 +1008,11 @@ def _CheckAddedDepsHaveTargetApprovals(input_api, output_api): introduced. This check verifies that this happens. """ changed_lines = set() - for f in input_api.AffectedFiles(): + + file_filter = lambda f: not input_api.re.match( + r"^third_party[\\\/]WebKit[\\\/].*", f.LocalPath()) + for f in input_api.AffectedFiles(include_deletes=False, + file_filter=file_filter): filename = input_api.os_path.basename(f.LocalPath()) if filename == 'DEPS': changed_lines |= set(line.strip() @@ -1081,6 +1111,7 @@ def _CheckSpamLogging(input_api, output_api): r"^sandbox[\\\/]linux[\\\/].*", r"^tools[\\\/]", r"^ui[\\\/]aura[\\\/]bench[\\\/]bench_main\.cc$", + r"^ui[\\\/]ozone[\\\/]platform[\\\/]cast[\\\/]", r"^storage[\\\/]browser[\\\/]fileapi[\\\/]" + r"dump_file_system.cc$",)) source_file_filter = lambda x: input_api.FilterSourceFile( @@ -1489,6 +1520,99 @@ def _CheckAndroidNewMdpiAssetLocation(input_api, output_api): return results +class PydepsChecker(object): + def __init__(self, input_api, pydeps_files): + self._file_cache = {} + self._input_api = input_api + self._pydeps_files = pydeps_files + + def _LoadFile(self, path): + """Returns the list of paths within a .pydeps file relative to //.""" + if path not in self._file_cache: + with open(path) as f: + self._file_cache[path] = f.read() + return self._file_cache[path] + + def _ComputeNormalizedPydepsEntries(self, pydeps_path): + """Returns an interable of paths within the .pydep, relativized to //.""" + os_path = self._input_api.os_path + pydeps_dir = os_path.dirname(pydeps_path) + entries = (l.rstrip() for l in self._LoadFile(pydeps_path).splitlines() + if not l.startswith('*')) + return (os_path.normpath(os_path.join(pydeps_dir, e)) for e in entries) + + def _CreateFilesToPydepsMap(self): + """Returns a map of local_path -> list_of_pydeps.""" + ret = {} + for pydep_local_path in self._pydeps_files: + for path in self._ComputeNormalizedPydepsEntries(pydep_local_path): + ret.setdefault(path, []).append(pydep_local_path) + return ret + + def ComputeAffectedPydeps(self): + """Returns an iterable of .pydeps files that might need regenerating.""" + affected_pydeps = set() + file_to_pydeps_map = None + for f in self._input_api.AffectedFiles(include_deletes=True): + local_path = f.LocalPath() + if local_path == 'DEPS': + return self._pydeps_files + elif local_path.endswith('.pydeps'): + if local_path in self._pydeps_files: + affected_pydeps.add(local_path) + elif local_path.endswith('.py'): + if file_to_pydeps_map is None: + file_to_pydeps_map = self._CreateFilesToPydepsMap() + affected_pydeps.update(file_to_pydeps_map.get(local_path, ())) + return affected_pydeps + + def DetermineIfStale(self, pydeps_path): + """Runs print_python_deps.py to see if the files is stale.""" + old_pydeps_data = self._LoadFile(pydeps_path).splitlines() + cmd = old_pydeps_data[1][1:].strip() + new_pydeps_data = self._input_api.subprocess.check_output( + cmd + ' --output ""', shell=True) + if old_pydeps_data[2:] != new_pydeps_data.splitlines()[2:]: + return cmd + + +def _CheckPydepsNeedsUpdating(input_api, output_api, checker_for_tests=None): + """Checks if a .pydeps file needs to be regenerated.""" + # TODO(agrieve): Update when there's a better way to detect this: crbug/570091 + is_android = input_api.os_path.exists('third_party/android_tools') + pydeps_files = _ALL_PYDEPS_FILES if is_android else _GENERIC_PYDEPS_FILES + results = [] + # First, check for new / deleted .pydeps. + for f in input_api.AffectedFiles(include_deletes=True): + if f.LocalPath().endswith('.pydeps'): + if f.Action() == 'D' and f.LocalPath() in _ALL_PYDEPS_FILES: + results.append(output_api.PresubmitError( + 'Please update _ALL_PYDEPS_FILES within //PRESUBMIT.py to ' + 'remove %s' % f.LocalPath())) + elif f.Action() != 'D' and f.LocalPath() not in _ALL_PYDEPS_FILES: + results.append(output_api.PresubmitError( + 'Please update _ALL_PYDEPS_FILES within //PRESUBMIT.py to ' + 'include %s' % f.LocalPath())) + + if results: + return results + + checker = checker_for_tests or PydepsChecker(input_api, pydeps_files) + + for pydep_path in checker.ComputeAffectedPydeps(): + try: + cmd = checker.DetermineIfStale(pydep_path) + if cmd: + results.append(output_api.PresubmitError( + 'File is stale: %s\nTo regenerate, run:\n\n %s' % + (pydep_path, cmd))) + except input_api.subprocess.CalledProcessError as error: + return [output_api.PresubmitError('Error running: %s' % error.cmd, + long_text=error.output)] + + return results + + def _CheckForCopyrightedCode(input_api, output_api): """Verifies that newly added code doesn't contain copyrighted material and is properly licensed under the standard Chromium license. @@ -1539,6 +1663,26 @@ def _CheckSingletonInHeaders(input_api, output_api): return [] +def _CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api): + """Checks for old style compiled_resources.gyp files.""" + is_compiled_resource = lambda fp: fp.endswith('compiled_resources.gyp') + + added_compiled_resources = filter(is_compiled_resource, [ + f.LocalPath() for f in input_api.AffectedFiles() if f.Action() == 'A' + ]) + + if not added_compiled_resources: + return [] + + return [output_api.PresubmitError( + "Found new compiled_resources.gyp files:\n%s\n\n" + "compiled_resources.gyp files are deprecated,\n" + "please use compiled_resources2.gyp instead:\n" + "https://chromium.googlesource.com/chromium/src/+/master/docs/closure_compilation.md" + % + "\n".join(added_compiled_resources))] + + _DEPRECATED_CSS = [ # Values ( "-webkit-box", "flex" ), @@ -1578,6 +1722,7 @@ def _CheckNoDeprecatedCSS(input_api, output_api): r"^chrome/docs", r"^components/dom_distiller/core/css/distilledpage_ios.css", r"^components/flags_ui/resources/apple_flags.css", + r"^components/neterror/resources/neterror.css", r"^native_client_sdk")) file_filter = lambda f: input_api.FilterSourceFile( f, white_list=file_inclusion_pattern, black_list=black_list) @@ -1670,6 +1815,8 @@ def _CommonChecks(input_api, output_api): results.extend(_CheckForCopyrightedCode(input_api, output_api)) results.extend(_CheckForWindowsLineEndings(input_api, output_api)) results.extend(_CheckSingletonInHeaders(input_api, output_api)) + results.extend(_CheckNoDeprecatedCompiledResourcesGYP(input_api, output_api)) + results.extend(_CheckPydepsNeedsUpdating(input_api, output_api)) if any('PRESUBMIT.py' == f.LocalPath() for f in input_api.AffectedFiles()): results.extend(input_api.canned_checks.RunUnitTestsInDirectory( @@ -1910,7 +2057,6 @@ def GetTryServerMasterForBot(bot): # Potentially ambiguous bot names are listed explicitly. master_map = { 'chromium_presubmit': 'tryserver.chromium.linux', - 'blink_presubmit': 'tryserver.chromium.linux', 'tools_build_presubmit': 'tryserver.chromium.linux', } master = master_map.get(bot) @@ -1951,30 +2097,3 @@ def CheckChangeOnCommit(input_api, output_api): results.extend(input_api.canned_checks.CheckChangeHasDescription( input_api, output_api)) return results - - -def GetPreferredTryMasters(project, change): - import json - import os.path - import platform - import subprocess - - cq_config_path = os.path.join( - change.RepositoryRoot(), 'infra', 'config', 'cq.cfg') - # commit_queue.py below is a script in depot_tools directory, which has a - # 'builders' command to retrieve a list of CQ builders from the CQ config. - is_win = platform.system() == 'Windows' - masters = json.loads(subprocess.check_output( - ['commit_queue', 'builders', cq_config_path], shell=is_win)) - - try_config = {} - for master in masters: - try_config.setdefault(master, {}) - for builder in masters[master]: - # Do not trigger presubmit builders, since they're likely to fail - # (e.g. OWNERS checks before finished code review), and we're - # running local presubmit anyway. - if 'presubmit' not in builder: - try_config[master][builder] = ['defaulttests'] - - return try_config |