blob: f4674d698e4717ad46ce78ab40fd159f6f6b0b1a [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.recipe_api import Property
DEPS = [
'fuchsia/build',
'fuchsia/build_input_resolver',
'fuchsia/checkout',
'fuchsia/fuchsia',
'fuchsia/upload',
'recipe_engine/buildbucket',
'recipe_engine/context',
'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'),
}
PACKAGE = 'fuchsia/third_party/sysroot/linux'
def RunSteps(api, manifest, remote):
api.build_input_resolver.resolve(
default_project_url='https://fuchsia.googlesource.com/fuchsia')
bb_build = api.buildbucket.build
with api.step.nest('checkout'), api.context(infra_steps=True):
checkout = api.checkout.fuchsia_with_options(
path=api.path['start_dir'].join('linux_sysroot'),
manifest=manifest,
remote=remote,
build=bb_build,
)
build_results = api.build.with_options(
build_dir=checkout.root_dir.join('out'),
checkout=checkout,
target='x64',
product='products/core.gni',
build_type='release',
packages=['//tools/debroot:debroot'],
)
packages_lockfile = checkout.root_dir.join('tools', 'debroot', 'cmd',
'packages.lock')
sysroot_dir = api.path.mkdtemp('sysroot')
debroot = build_results.tool('debroot')
assert debroot, 'failed to find debroot in tools_path manifest'
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.fuchsia.test(
'basic',
properties={
'manifest': 'minimal',
'remote': 'https://fuchsia.googlesource.com',
},
)