blob: e3d3e9cfc0583e0be822d6f9d455333ef6defa4f [file] [log] [blame]
# Copyright 2020 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.
from recipe_engine import recipe_api
class ToolchainApi(recipe_api.RecipeApi):
"""Helpers for building Fuchsia toolchains."""
def strip_runtimes(
self, name, spec, path, build_id_subpath, readelf, dump_syms=None, objcopy=None
):
"""Prepares runtimes for deployment and generates a runtime.json file.
Given a spec in the schema of runtime.json, does the following:
- Strips the runtime binaries (optional)
- Creates the .build-id repo (optional)
- Creates the breakpad .sym file and places in .build-id (optional)
The path to the debug binary and (optional) sym file are then
included in the final runtime.json output, which is saved to a file.
Args:
name (str): Step name.
spec (list): The runtime spec.
//zircon/public/gn/toolchain/clang.gni:clang_runtime sets the schema.
"dist" keys may optionally be a glob pattern matching exactly one
file. "soname", "debug", and "breakpad" keys will be filled in.
path (Path): The path where runtime.json will be generated.
build_id_subpath (str): The subpath relative to path where the
build-id repo lives.
readelf (Path): The path to a readelf binary.
dump_syms (Path or None): An optional path to dump_syms for
generating Breakpad symbols.
objcopy (Path or None): An optional path to llvm-objcopy for
stripping the supplied runtimes. The .build-id repo is
populated for you if this is supplied.
"""
runtimes_args = [
"--dir",
path,
"--build-id-repo",
build_id_subpath,
"--readelf",
readelf,
]
if dump_syms:
runtimes_args += ["--dump_syms", dump_syms]
if objcopy:
runtimes_args += ["--objcopy", objcopy]
self.m.python(
name,
script=self.resource("runtimes.py"),
venv=True,
args=runtimes_args,
stdin=self.m.json.input(spec),
stdout=self.m.json.output(
leak_to=path.join("runtime.json"), name="runtime.json"
),
)