2017-07-28 11:35:28 +00:00
|
|
|
# Copyright 2017 The Chromium Authors. All rights reserved.
|
|
|
|
# Use of this source code is governed by a BSD-style license that can be
|
|
|
|
# found in the LICENSE file.
|
|
|
|
|
|
|
|
|
|
|
|
# Recipe for the Skia PerCommit Housekeeper.
|
|
|
|
|
|
|
|
DEPS = [
|
2018-05-14 16:50:38 +00:00
|
|
|
'build',
|
2019-03-28 16:19:45 +00:00
|
|
|
'infra',
|
2017-07-28 11:35:28 +00:00
|
|
|
'recipe_engine/context',
|
2018-05-04 17:46:15 +00:00
|
|
|
'recipe_engine/file',
|
2017-07-28 11:35:28 +00:00
|
|
|
'recipe_engine/path',
|
|
|
|
'recipe_engine/properties',
|
|
|
|
'recipe_engine/python',
|
|
|
|
'recipe_engine/raw_io',
|
|
|
|
'recipe_engine/step',
|
2018-05-24 13:14:18 +00:00
|
|
|
'checkout',
|
2017-07-28 11:35:28 +00:00
|
|
|
'run',
|
|
|
|
'vars',
|
|
|
|
]
|
|
|
|
|
|
|
|
|
|
|
|
def RunSteps(api):
|
|
|
|
# Checkout, compile, etc.
|
2018-05-04 17:46:15 +00:00
|
|
|
api.vars.setup()
|
2018-05-24 13:14:18 +00:00
|
|
|
checkout_root = api.checkout.default_checkout_root
|
|
|
|
api.checkout.bot_update(checkout_root=checkout_root)
|
2018-05-04 17:46:15 +00:00
|
|
|
api.file.ensure_directory('makedirs tmp_dir', api.vars.tmp_dir)
|
2017-07-28 11:35:28 +00:00
|
|
|
|
|
|
|
cwd = api.path['checkout']
|
|
|
|
|
|
|
|
with api.context(cwd=cwd):
|
|
|
|
# Get a baseline diff. This should be empty, but we want to be flexible for
|
|
|
|
# cases where we have local diffs on purpose.
|
|
|
|
diff1 = api.run(
|
|
|
|
api.step,
|
|
|
|
'git diff #1',
|
|
|
|
cmd=['git', 'diff', '--no-ext-diff'],
|
|
|
|
stdout=api.m.raw_io.output()).stdout
|
|
|
|
|
2019-03-28 16:19:45 +00:00
|
|
|
with api.context(env=api.infra.go_env):
|
|
|
|
api.step('generate gl interfaces',
|
|
|
|
cmd=['make', '-C', 'tools/gpu/gl/interface', 'generate'])
|
|
|
|
|
2017-07-28 11:35:28 +00:00
|
|
|
# Touch all .fp files so that the generated files are rebuilt.
|
|
|
|
api.run(
|
|
|
|
api.python.inline,
|
|
|
|
'touch fp files',
|
|
|
|
program="""import os
|
|
|
|
import subprocess
|
|
|
|
|
|
|
|
for r, d, files in os.walk('%s'):
|
|
|
|
for f in files:
|
|
|
|
if f.endswith('.fp'):
|
|
|
|
path = os.path.join(r, f)
|
|
|
|
print 'touch %%s' %% path
|
|
|
|
subprocess.check_call(['touch', path])
|
|
|
|
""" % cwd)
|
|
|
|
|
2019-07-25 16:33:48 +00:00
|
|
|
# Run GN, regenerate the SKSL files, and make sure rewritten #includes work.
|
2018-05-18 11:36:55 +00:00
|
|
|
api.build(checkout_root=checkout_root,
|
|
|
|
out_dir=api.vars.build_dir.join('out', 'Release'))
|
2017-07-28 11:35:28 +00:00
|
|
|
|
|
|
|
# Get a second diff. If this doesn't match the first, then there have been
|
|
|
|
# modifications to the generated files.
|
|
|
|
diff2 = api.run(
|
|
|
|
api.step,
|
|
|
|
'git diff #2',
|
|
|
|
cmd=['git', 'diff', '--no-ext-diff'],
|
|
|
|
stdout=api.m.raw_io.output()).stdout
|
|
|
|
|
|
|
|
api.run(
|
|
|
|
api.python.inline,
|
|
|
|
'compare diffs',
|
|
|
|
program="""
|
|
|
|
diff1 = '''%s'''
|
|
|
|
|
|
|
|
diff2 = '''%s'''
|
|
|
|
|
|
|
|
if diff1 != diff2:
|
|
|
|
print 'Generated files have been edited!'
|
|
|
|
exit(1)
|
|
|
|
""" % (diff1, diff2))
|
|
|
|
|
|
|
|
|
|
|
|
def GenTests(api):
|
|
|
|
yield (
|
|
|
|
api.test('Housekeeper-PerCommit-CheckGeneratedFiles') +
|
|
|
|
api.properties(buildername='Housekeeper-PerCommit-CheckGeneratedFiles',
|
|
|
|
repository='https://skia.googlesource.com/skia.git',
|
|
|
|
revision='abc123',
|
|
|
|
path_config='kitchen',
|
|
|
|
swarm_out_dir='[SWARM_OUT_DIR]') +
|
2020-04-03 15:59:37 +00:00
|
|
|
api.path.exists(api.path['start_dir'])
|
2017-07-28 11:35:28 +00:00
|
|
|
)
|