| # 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 = { |
| "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): |
| # 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, fint_params_path=fint_params_path |
| ) |
| compdb_path = build_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" % ( |
| 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=fuchsia_dir, |
| build_dir=build_results.build_dir, |
| compdb_path=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.status_check.test("basic") + properties() + api.kythe.valid() |
| |
| yield ( |
| api.status_check.test("try") |
| + properties() |
| + api.buildbucket.try_build() |
| + api.kythe.valid() |
| ) |