blob: 24673a3af88b303ae56eb88b212d41aa6de1d9d7 [file] [log] [blame]
# 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 PB.recipes.fuchsia.contrib.breakpad_tools import InputProperties
DEPS = [
"fuchsia/cipd_util",
"fuchsia/git",
"fuchsia/git_checkout",
"fuchsia/status_check",
"recipe_engine/context",
"recipe_engine/file",
"recipe_engine/json",
"recipe_engine/path",
"recipe_engine/platform",
"recipe_engine/step",
]
BREAKPAD_GIT = "https://chromium.googlesource.com/breakpad/breakpad"
DEPOT_TOOLS_GIT = "https://chromium.googlesource.com/chromium/tools/depot_tools.git"
PROPERTIES = InputProperties
def RunSteps(api, props):
url = props.url or BREAKPAD_GIT
ref = props.ref or "refs/heads/main"
revision = api.git.get_remote_branch_head(url, ref)
with api.context(infra_steps=True):
depot_tools_path, _ = api.git_checkout(DEPOT_TOOLS_GIT)
# 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.
step = api.step(
"gclient sync",
["gclient", "sync", "-v", "--output-json", api.json.output()],
)
step.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", api.path.join(*dump_syms_relpath)])
# Create a cipd package definition and then register the package.
api.cipd_util.upload_package(
"fuchsia/tools/breakpad/${platform}",
build_dir,
pkg_paths=[dump_syms_file],
search_tag={"git_revision": revision},
repository=url,
)
def GenTests(api):
yield (
api.status_check.test("default")
+ api.git.get_remote_branch_head(
"git ls-remote", "9eac2058b70615519b2c4d8c6bdbfca1bd079e39"
)
)