1# Copyright 2021 The ANGLE Project 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. 4""" 5See http://dev.chromium.org/developers/how-tos/depottools/presubmit-scripts 6for more details on the presubmit API built into depot_tools. 7""" 8 9import os 10 11 12def _CommonChecks(input_api, output_api): 13 d = os.path.dirname 14 angle_root = d(d(input_api.PresubmitLocalPath())) 15 gen_script = os.path.join(angle_root, 'testing', 'buildbot', 'generate_buildbot_json.py') 16 17 # Validate the format of the mb_config.pyl file. 18 mb_path = os.path.join(angle_root, 'tools', 'mb', 'mb.py') 19 config_path = os.path.join(input_api.PresubmitLocalPath(), 'angle_mb_config.pyl') 20 21 commands = [ 22 input_api.Command( 23 name='generate_buildbot_json', 24 cmd=[ 25 input_api.python_executable, gen_script, '--check', '--verbose', '--pyl-files-dir', 26 input_api.PresubmitLocalPath() 27 ], 28 kwargs={}, 29 message=output_api.PresubmitError), 30 input_api.Command( 31 name='mb_validate', 32 cmd=[ 33 input_api.python_executable, 34 mb_path, 35 'validate', 36 '-f', 37 config_path, 38 ], 39 kwargs={'cwd': input_api.PresubmitLocalPath()}, 40 message=output_api.PresubmitError), 41 ] 42 messages = [] 43 44 messages.extend(input_api.RunTests(commands)) 45 return messages 46 47 48def CheckChangeOnUpload(input_api, output_api): 49 return _CommonChecks(input_api, output_api) 50 51 52def CheckChangeOnCommit(input_api, output_api): 53 return _CommonChecks(input_api, output_api) 54