blob: 1942be964f9c9bfb1e771db43fc12fb2d0792486 [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.recipe_api import Property
DEPS = [
"fuchsia/build",
"fuchsia/buildbucket_util",
"fuchsia/checkout",
"fuchsia/kythe",
"recipe_engine/context",
"recipe_engine/properties",
"recipe_engine/time",
]
PROPERTIES = {
"gcs_bucket": Property(
kind=str,
help="GCS bucket for uploading extracted kzip for kythe indexing",
),
"manifest": Property(kind=str, help="Jiri manifest to use"),
"remote": Property(kind=str, help="Remote manifest repository"),
"fint_params_path": Property(kind=str, help="Path to a fint params file"),
}
KYTHE_CORPUS = "fuchsia.googlesource.com/fuchsia"
def RunSteps(api, gcs_bucket, manifest, remote, fint_params_path):
checkout = api.checkout.fuchsia_with_options(
manifest=manifest,
remote=remote,
)
# Build so we have all the generated files.
build_results = api.build.with_options(
checkout=checkout,
fint_params_path=fint_params_path,
build_dir=checkout.root_dir.join("out", "default"),
)
with api.context(cwd=checkout.root_dir):
revision = checkout.project("fuchsia")["revision"]
commit_timestamp = int(api.time.time())
kzip_name_with_revision = "fuchsia_%s_%s+%d.kzip" % (
build_results.set_metadata.target_arch,
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=checkout.root_dir,
build_dir=build_results.build_dir,
compdb_path=build_results.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",
"gcs_bucket": "fuchsia-kythe",
"fint_params_path": "specs/kythe.textproto",
}
props.update(kwargs)
return api.properties(**props)
yield api.buildbucket_util.test("basic") + properties() + api.kythe.valid()
yield (
api.buildbucket_util.test("try", tryjob=True) + properties() + api.kythe.valid()
)