blob: 69b221cd09d2307bef0670459d10d84b7e06fa6f [file] [log] [blame]
# Copyright 2019 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 Fuchsia SDKs."""
from recipe_engine.config import List
from recipe_engine.recipe_api import Property
DEPS = [
'infra/build',
'infra/buildbucket_util',
'infra/checkout',
'infra/fuchsia',
'infra/gsutil',
'infra/jiri',
'recipe_engine/buildbucket',
'recipe_engine/isolated',
'recipe_engine/path',
'recipe_engine/properties',
'recipe_engine/step',
]
# These represent the location of the isolated hash in the output of this
# recipe. They need to be kept in sync with sdk.py
ISOLATE_STEP_NAME = 'isolate artifacts'
ISOLATED_OUTPUT_KEY = 'isolated_output_hash'
PROPERTIES = {
'project':
Property(kind=str, help='Jiri remote manifest project'),
'manifest':
Property(kind=str, help='Jiri manifest to use'),
'remote':
Property(kind=str, help='Remote manifest repository'),
'checkout_snapshot':
Property(
kind=bool,
help='Whether or not to checkout from a Jiri snapshot.'
' Snapshot is expected to be found at the location specified by'
' BuildBucket input.',
default=False),
'ninja_targets':
Property(
kind=List(basestring),
help='Ninja targets to build',
default=[
'sdk/archive/core.tar.gz',
'sdk/archive/fuchsia_dart.tar.gz',
]),
'packages':
Property(
kind=List(basestring),
help='Packages to build',
default=['//topaz/packages/sdk:topaz']),
'sdk_id':
Property(kind=str, help='SDK version id'),
'target':
Property(kind=str, help='target CPU architecture'),
}
def RunSteps(api, project, manifest, remote, checkout_snapshot, ninja_targets,
packages, sdk_id, target):
build = api.buildbucket.build
checkout_root = api.path['start_dir'].join('fuchsia')
if checkout_snapshot:
if api.buildbucket_util.is_tryjob:
assert len(build.input.gerrit_changes) == 1
checkout = api.checkout.from_patchset_snapshot(
path=checkout_root, gerrit_change=build.input.gerrit_changes[0])
else:
checkout = api.checkout.from_commit_snapshot(
path=checkout_root, gitiles_commit=build.input.gitiles_commit)
else:
assert manifest
assert remote
checkout = api.checkout.fuchsia_with_options(
path=checkout_root,
build=build,
manifest=manifest,
remote=remote,
project=project,
)
build_output = api.build.with_options(
build_dir=checkout.root_dir.join('out'),
build_images=False,
checkout=checkout,
target=target,
build_type='release',
product='products/core.gni',
# TODO(DX-1415): move SDK tools back to universe_packages.
packages=packages + ['//sdk/bundles:tools'],
gn_args=['build_sdk_archives=true',
'sdk_id="%s"' % sdk_id],
ninja_targets=ninja_targets,
)
sdk_archive_path = build_output.fuchsia_build_dir.join('sdk', 'archive')
isolated = api.isolated.isolated(sdk_archive_path)
for ninja_target in ninja_targets:
isolated.add_file(
path=build_output.fuchsia_build_dir.join(*ninja_target.split('/')))
# Archive the isolated.
sdk_archive_isolated_hash = isolated.archive(ISOLATE_STEP_NAME)
api.step.active_result.presentation.properties[
ISOLATED_OUTPUT_KEY] = sdk_archive_isolated_hash
def GenTests(api):
topaz_properties = api.properties(
project='integration',
manifest='fuchsia/topaz/topaz',
remote='https://fuchsia.googlesource.com/integration',
sdk_id='###SDK_ID###',
target='x64')
yield (api.test('basic') + topaz_properties)
yield (api.test('snapshot') + topaz_properties +
api.properties(checkout_snapshot=True) + api.buildbucket.ci_build())
yield (api.test('snapshot_cq') + topaz_properties +
api.properties(checkout_snapshot=True) + api.buildbucket.try_build())