1# Copyright (C) 2021 The Android Open Source Project 2# 3# Licensed under the Apache License, Version 2.0 (the "License"); 4# you may not use this file except in compliance with the License. 5# You may obtain a copy of the License at 6# 7# http://www.apache.org/licenses/LICENSE-2.0 8# 9# Unless required by applicable law or agreed to in writing, software 10# distributed under the License is distributed on an "AS IS" BASIS, 11# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12# See the License for the specific language governing permissions and 13# limitations under the License. 14"""Recipe for building Perfetto.""" 15 16from recipe_engine.recipe_api import Property 17 18DEPS = [ 19 'recipe_engine/buildbucket', 20 'recipe_engine/context', 21 'recipe_engine/file', 22 'recipe_engine/path', 23 'recipe_engine/platform', 24 'recipe_engine/properties', 25 'recipe_engine/step', 26] 27 28PROPERTIES = { 29 'repository': 30 Property( 31 kind=str, 32 default='https://android.googlesource.com/platform/external/perfetto' 33 ), 34} 35 36ARTIFACTS = ['trace_processor_shell'] 37 38 39def RunSteps(api, repository): 40 builder_cache_dir = api.path['cache'].join('builder') 41 src_dir = builder_cache_dir.join('perfetto') 42 43 # Fetch the Perfetto repo. 44 with api.step.nest('git'), api.context(infra_steps=True): 45 api.file.ensure_directory('ensure source dir', src_dir) 46 api.step('init', ['git', 'init', src_dir]) 47 with api.context(cwd=src_dir): 48 build_input = api.buildbucket.build_input 49 ref = ( 50 build_input.gitiles_commit.id 51 if build_input.gitiles_commit else 'refs/heads/master') 52 # Fetch tags so `git describe` works. 53 api.step('fetch', ['git', 'fetch', '--tags', repository, ref]) 54 api.step('checkout', ['git', 'checkout', 'FETCH_HEAD']) 55 56 # Pull all deps here. 57 # There should be no need for internet access for building Perfetto beyond 58 # this point. 59 with api.context(cwd=src_dir, infra_steps=True): 60 api.step('build-deps', ['tools/install-build-deps', '--ui', '--android']) 61 62 # Buld Perfetto. 63 with api.context(cwd=src_dir): 64 api.step('gn gen', ['tools/gn', 'gen', 'out/dist', '--args=is_debug=false']) 65 api.step('ninja', ['tools/ninja', '-C', 'out/dist']) 66 67 68def GenTests(api): 69 for platform in ('linux',): 70 yield (api.test('ci_' + platform) + api.platform.name(platform) + 71 api.buildbucket.ci_build( 72 project='perfetto', 73 git_repo='android.googlesource.com/platform/external/perfetto', 74 )) 75