| # Copyright 2018 The Fuchsia 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 building some Breakpad tools.""" |
| |
| import os |
| |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| 'fuchsia/git', |
| 'fuchsia/gitiles', |
| 'fuchsia/upload', |
| 'recipe_engine/cipd', |
| 'recipe_engine/context', |
| 'recipe_engine/file', |
| 'recipe_engine/json', |
| 'recipe_engine/path', |
| 'recipe_engine/platform', |
| 'recipe_engine/properties', |
| 'recipe_engine/raw_io', |
| 'recipe_engine/step', |
| ] |
| |
| BREAKPAD_GIT = 'https://chromium.googlesource.com/breakpad/breakpad' |
| DEPOT_TOOLS_GIT = 'https://chromium.googlesource.com/chromium/tools/depot_tools.git' |
| |
| PROPERTIES = { |
| 'url': |
| Property(kind=str, help='Git repository URL', default=BREAKPAD_GIT), |
| 'ref': |
| Property(kind=str, help='Git reference', default='refs/heads/master'), |
| } |
| |
| |
| def RunSteps(api, url, ref): |
| revision = api.gitiles.refs(url).get(ref, None) |
| |
| depot_tools_path = api.path['start_dir'].join('depot_tools') |
| with api.context(infra_steps=True): |
| api.git.checkout(DEPOT_TOOLS_GIT, depot_tools_path) |
| |
| # Use gclient to fetch the DEPS. |
| tree_root_dir = api.path['start_dir'].join('breakpad') |
| |
| api.file.ensure_directory('makedirs breakpad', tree_root_dir) |
| |
| with api.context( |
| infra_steps=True, |
| cwd=tree_root_dir, |
| env_prefixes={'PATH': [depot_tools_path]}): |
| |
| # The gclient root is breakpad/. |
| api.step('gclient config', [ |
| 'gclient', |
| 'config', |
| '--name=src', |
| '--unmanaged', |
| '-v', |
| url, |
| ]) |
| |
| # This first sync seems redundant, but is necessary on a clean tree, |
| # otherwise the root git repo won't yet have been pulled, so there won't be |
| # anything for git to pin. |
| api.step('gclient sync', [ |
| 'gclient', |
| 'sync', |
| ]) |
| |
| # The code is pulled by gclient sync inside breakpad/src, which is then |
| # pinned to the specified revision. |
| src_dir = tree_root_dir.join('src') |
| with api.context(cwd=src_dir): |
| api.step('pin git', ['git', 'checkout', revision]) |
| |
| # This sync updates the dependencies to those matching |revision| as |
| # specified by DEPS in the root git repo. |
| api.step('gclient sync', [ |
| 'gclient', |
| 'sync', |
| '-v', |
| '--output-json', |
| api.json.output(), |
| ]) |
| api.step.active_result.presentation.properties['got_revision'] = revision |
| |
| # Build the two required tools, dump_syms and sym_upload using configure and |
| # make. |
| build_dir_relpath = ['src', 'tools', api.platform.name] |
| dump_syms_relpath = build_dir_relpath + ['dump_syms', 'dump_syms'] |
| build_dir = src_dir.join(*build_dir_relpath) |
| dump_syms_file = src_dir.join(*dump_syms_relpath) |
| with api.context(cwd=src_dir): |
| api.step('configure', ['./configure']) |
| # make targets must be relative paths. |
| api.step('build', [ |
| 'make', |
| os.path.join(*dump_syms_relpath), |
| ]) |
| |
| # Create a cipd package definition and then register the package. |
| api.upload.cipd_package( |
| 'fuchsia/tools/breakpad/${platform}', |
| build_dir, [ |
| api.upload.FilePath(dump_syms_file), |
| ], {'git_revision': revision}, |
| repository=url) |
| |
| |
| def GenTests(api): |
| revision = '9eac2058b70615519b2c4d8c6bdbfca1bd079e39' |
| refs_data = api.gitiles.refs('refs', ('refs/heads/master', revision)) |
| yield (api.test('default') + refs_data) |
| yield (api.test('new_version') + refs_data + api.step_data( |
| 'cipd.cipd search fuchsia/tools/breakpad/${platform} ' + 'git_revision:' + |
| revision, api.json.output({'result': []}))) |