blob: e6132a8ac4c916bdb81dc5fd50aa2a20a392aa34 [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 for extracting and uploading a kzip for Fuchsia."""
from recipe_engine.config import List
from recipe_engine.recipe_api import Property
DEPS = [
"fuchsia/build",
"fuchsia/buildbucket_util",
"fuchsia/checkout",
"fuchsia/kythe",
"fuchsia/status_check",
"recipe_engine/buildbucket",
"recipe_engine/context",
"recipe_engine/path",
"recipe_engine/properties",
"recipe_engine/time",
]
PROPERTIES = {
"board": Property(kind=str, help="Board to build"),
"build_type": Property(kind=str, help="The build type"),
"gcs_bucket": Property(
kind=str, help="GCS bucket for uploading extracted kzip for kythe indexing",
),
"manifest": Property(kind=str, help="Jiri manifest to use"),
"packages": Property(kind=List(basestring), help="Packages to build"),
"product": Property(kind=str, help="Product to build"),
"remote": Property(kind=str, help="Remote manifest repository"),
"fint_params_path": Property(kind=str, help="Path to a fint params file"),
"target": Property(kind=str, help="Targets from which to generate a kzip",),
}
KYTHE_CORPUS = "fuchsia.googlesource.com/fuchsia"
def RunSteps(
api,
board,
build_type,
gcs_bucket,
manifest,
product,
remote,
fint_params_path,
target,
):
# Get a clean checkout of fuchsia.git
fuchsia_dir = api.path["start_dir"].join("fuchsia")
checkout = api.checkout.fuchsia_with_options(
path=fuchsia_dir, manifest=manifest, remote=remote,
)
# Build so we have all the generated files.
build_results = api.build.with_options(
checkout=checkout,
board=board,
build_type=build_type,
product=product,
fint_params_path=fint_params_path,
target=target,
)
merged_compdb_path = build_results.gn_results.filtered_compdb([])
with api.context(cwd=fuchsia_dir):
revision = checkout.project("fuchsia")["revision"]
commit_timestamp = int(api.time.time())
kzip_name_with_revision = "fuchsia_%s_%s+%d.kzip" % (
target,
revision,
commit_timestamp,
)
if api.buildbucket_util.is_tryjob:
final_path = "testing/kythe/%s/%s" % (
api.buildbucket_util.id,
kzip_name_with_revision,
)
else:
final_path = "prod/%s" % kzip_name_with_revision
api.kythe.extract_and_upload(
checkout_dir=fuchsia_dir,
build_dir=build_results.build_dir,
compdb_path=merged_compdb_path,
corpus=KYTHE_CORPUS,
gcs_bucket=gcs_bucket,
gcs_filename=final_path,
langs=("cxx", "rust"),
)
def GenTests(api):
def properties(**kwargs):
props = {
"manifest": "flower",
"remote": "https://fuchsia.googlesource.com/integration",
"target": "x64",
"build_type": "debug",
"product": "products/core.gni",
"board": "boards/x64.gni",
"gcs_bucket": "fuchsia-kythe",
"fint_params_path": "specs/kythe.textproto",
}
props.update(kwargs)
return api.properties(**props)
yield api.status_check.test("basic") + properties() + api.kythe.valid()
yield (
api.status_check.test("try")
+ properties()
+ api.buildbucket.try_build()
+ api.kythe.valid()
)