blob: b25a72268078c34f230843b733148802d0f8e6ea [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.
"""Recipe to build the Linux host sysroot and upload it to CIPD."""
from recipe_engine.config import List
from recipe_engine.recipe_api import Property
DEPS = [
"fuchsia/build",
"fuchsia/build_input_resolver",
"fuchsia/checkout",
"fuchsia/status_check",
"fuchsia/upload",
"recipe_engine/buildbucket",
"recipe_engine/path",
"recipe_engine/properties",
"recipe_engine/step",
]
PROPERTIES = {
"manifest": Property(kind=str, help="Jiri manifest to use"),
"remote": Property(kind=str, help="Remote manifest repository"),
"board": Property(kind=str, help="Board to build"),
"build_type": Property(kind=str, help="The build type"),
"product": Property(kind=str, help="Product to build"),
"fint_params_path": Property(kind=str, help="Path to a fint params file"),
"target": Property(kind=str, help="Target to build"),
}
PACKAGE = "fuchsia/third_party/sysroot/linux"
def RunSteps(
api, manifest, remote, board, build_type, product, fint_params_path, target,
):
api.build_input_resolver.resolve(
default_project_url="https://fuchsia.googlesource.com/fuchsia"
)
bb_build = api.buildbucket.build
checkout = api.checkout.fuchsia_with_options(
path=api.path["start_dir"].join("linux_sysroot"),
manifest=manifest,
remote=remote,
)
build_results = api.build.with_options(
checkout=checkout,
board=board,
build_type=build_type,
product=product,
fint_params_path=fint_params_path,
target=target,
)
packages_lockfile = checkout.root_dir.join(
"tools", "debroot", "cmd", "packages.lock"
)
sysroot_dir = api.path.mkdtemp("sysroot")
debroot = build_results.tool("debroot")
api.step(
"generate sysroot",
[debroot, "install", "-out", sysroot_dir, packages_lockfile,],
)
commit = bb_build.input.gitiles_commit
repository = "https://%s/%s" % (commit.host, commit.project)
api.upload.cipd_package(
PACKAGE,
sysroot_dir,
[api.upload.DirectoryPath(sysroot_dir)],
search_tag={"git_revision": commit.id},
repository=repository,
)
def GenTests(api):
yield (
api.status_check.test("basic")
+ api.buildbucket.ci_build(git_repo="https://fuchsia.googlesource.com/fuchsia")
+ api.properties(
manifest="minimal",
remote="https://fuchsia.googlesource.com/fuchsia",
board="boards/x64.gni",
build_type="release",
fint_params_path="specs/linux-sysroot.textproto",
product="products/core.gni",
target="x64",
)
)