Flutter Engine
The Flutter Engine
check_deps.py
Go to the documentation of this file.
1#!/usr/bin/env python
2#
3# Copyright 2019 Google LLC
4#
5# Use of this source code is governed by a BSD-style license that can be
6# found in the LICENSE file.
7
8
9"""Check the DEPS file for correctness."""
10
11
12from __future__ import print_function
13import os
14import re
15import subprocess
16import sys
17
18import utils
19
20
21INFRA_BOTS_DIR = os.path.dirname(os.path.realpath(__file__))
22SKIA_DIR = os.path.abspath(os.path.join(INFRA_BOTS_DIR, os.pardir, os.pardir))
23
24
25def main():
26 """Load the DEPS file and verify that all entries are valid."""
27 # Find gclient.py and run that instead of simply "gclient", which calls into
28 # update_depot_tools.
29 gclient = subprocess.check_output([
30 utils.WHICH, utils.GCLIENT]).decode('utf-8')
31 gclient_py = os.path.join(os.path.dirname(gclient), 'gclient.py')
32 python = sys.executable or 'python'
33
34 # Obtain the DEPS mapping.
35 output = subprocess.check_output(
36 [python, gclient_py, 'revinfo'], cwd=SKIA_DIR).decode('utf-8')
37
38 # Check each entry.
39 errs = []
40 for e in output.rstrip().splitlines():
41 split = e.split(': ')
42 if len(split) != 2:
43 errs.append(
44 'Failed to parse `gclient revinfo` output; invalid format: %s' % e)
45 continue
46 if split[0] == 'skia':
47 continue
48 split = split[1].split('@')
49 if len(split) != 2:
50 errs.append(
51 'Failed to parse `gclient revinfo` output; invalid format: %s' % e)
52 continue
53 repo = split[0]
54 rev = split[1]
55 if 'chrome-infra-packages' in repo:
56 continue
57 if not 'googlesource.com' in repo:
58 errs.append(
59 'DEPS must be hosted on googlesource.com; %s is not allowed. '
60 'See http://go/new-skia-git-mirror' % repo)
61 if not re.match(r'^[a-z0-9]{40}$', rev):
62 errs.append('%s: "%s" does not look like a commit hash.' % (repo, rev))
63 if errs:
64 print('Found problems in DEPS:', file=sys.stderr)
65 for err in errs:
66 print(err, file=sys.stderr)
67 sys.exit(1)
68
69
70if __name__ == '__main__':
71 main()
def main()
Definition: check_deps.py:25
Definition: main.py:1
def print(*args, **kwargs)
Definition: run_tests.py:49
static DecodeResult decode(std::string path)
Definition: png_codec.cpp:124