1# Copyright 2017 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. 4 5 6# Recipe for the Skia PerCommit Housekeeper. 7 8PYTHON_VERSION_COMPATIBILITY = "PY2+3" 9 10DEPS = [ 11 'build', 12 'infra', 13 'recipe_engine/context', 14 'recipe_engine/file', 15 'recipe_engine/path', 16 'recipe_engine/properties', 17 'recipe_engine/python', 18 'recipe_engine/raw_io', 19 'recipe_engine/step', 20 'checkout', 21 'run', 22 'vars', 23] 24 25 26def RunSteps(api): 27 # Checkout, compile, etc. 28 api.vars.setup() 29 checkout_root = api.checkout.default_checkout_root 30 api.checkout.bot_update(checkout_root=checkout_root) 31 api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir) 32 33 cwd = api.path['checkout'] 34 35 with api.context(cwd=cwd): 36 # Get a baseline diff. This should be empty, but we want to be flexible for 37 # cases where we have local diffs on purpose. 38 diff1 = api.run( 39 api.step, 40 'git diff #1', 41 cmd=['git', 'diff', '--no-ext-diff'], 42 stdout=api.m.raw_io.output()).stdout.decode('utf-8') 43 44 with api.context(env=api.infra.go_env): 45 api.step('generate gl interfaces', 46 cmd=['make', '-C', 'tools/gpu/gl/interface', 'generate']) 47 48 # Run GN, regenerate the SKSL files, and make sure rewritten #includes work. 49 api.build(checkout_root=checkout_root, 50 out_dir=api.vars.build_dir.join('out', 'Release')) 51 52 # Get a second diff. If this doesn't match the first, then there have been 53 # modifications to the generated files. 54 diff2 = api.run( 55 api.step, 56 'git diff #2', 57 cmd=['git', 'diff', '--no-ext-diff'], 58 stdout=api.m.raw_io.output()).stdout.decode('utf-8') 59 60 api.run( 61 api.python.inline, 62 'compare diffs', 63 program=""" 64diff1 = '''%s''' 65 66diff2 = '''%s''' 67 68if diff1 != diff2: 69 print('Generated files have been edited!') 70 exit(1) 71""" % (diff1, diff2)) 72 73 74def GenTests(api): 75 yield ( 76 api.test('Housekeeper-PerCommit-CheckGeneratedFiles') + 77 api.properties(buildername='Housekeeper-PerCommit-CheckGeneratedFiles', 78 repository='https://skia.googlesource.com/skia.git', 79 revision='abc123', 80 path_config='kitchen', 81 swarm_out_dir='[SWARM_OUT_DIR]') + 82 api.path.exists(api.path['start_dir']) 83 ) 84