| # 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.""" |
| |
| from recipe_engine.config import Enum |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| 'infra/git', |
| 'infra/gitiles', |
| '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): |
| api.gitiles.ensure_gitiles() |
| |
| revision = api.gitiles.refs(url).get(ref, None) |
| cipd_pkg_name = 'fuchsia/tools/breakpad/${platform}' |
| pins = api.cipd.search(cipd_pkg_name, 'git_revision:%s' % revision) |
| if len(pins) > 0: |
| api.step('Package is up-to-date', cmd=None) |
| return |
| |
| 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 = src_dir.join('src', 'tools', api.platform.name) |
| dump_syms_file = build_dir.join('dump_syms', 'dump_syms') |
| sym_upload_file = build_dir.join('symupload', 'sym_upload') |
| api.step('configure', [src_dir.join('configure')]) |
| api.step('build', ['make', dump_syms_file, sym_upload_file]) |
| |
| # Create a cipd package definition and then register the package. |
| pkg_def = api.cipd.PackageDefinition( |
| package_name=cipd_pkg_name, package_root=build_dir, install_mode='copy') |
| pkg_def.add_file(dump_syms_file) |
| pkg_def.add_file(sym_upload_file) |
| pkg_def.add_version_file('.versions/breakpad-tools.cipd_version') |
| |
| cipd_pkg_file = api.path['cleanup'].join('breakpad-tools.cipd') |
| |
| api.cipd.build_from_pkg( |
| pkg_def=pkg_def, |
| output_package=cipd_pkg_file, |
| ) |
| step_result = api.cipd.register( |
| package_name=cipd_pkg_name, |
| package_path=cipd_pkg_file, |
| refs=['latest'], |
| tags={ |
| 'git_repository': url, |
| 'git_revision': revision, |
| }, |
| ) |
| |
| |
| 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 search fuchsia/tools/breakpad/${platform} ' |
| + 'git_revision:' + revision, api.json.output({ |
| 'result': [] |
| }))) |