| # 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 PB.recipes.fuchsia.contrib.kythe import InputProperties |
| |
| DEPS = [ |
| "fuchsia/build", |
| "fuchsia/buildbucket_util", |
| "fuchsia/checkout", |
| "fuchsia/kythe", |
| "recipe_engine/context", |
| "recipe_engine/properties", |
| "recipe_engine/time", |
| ] |
| |
| PROPERTIES = InputProperties |
| |
| # Indexing the `main` branch only. |
| KYTHE_CORPUS = "fuchsia.googlesource.com/fuchsia//main" |
| |
| |
| def RunSteps(api, props): |
| checkout = api.checkout.fuchsia_with_options( |
| manifest=props.manifest, |
| remote=props.remote, |
| ) |
| |
| # Build so we have all the generated files. |
| build_results = api.build.with_options( |
| checkout=checkout, |
| fint_params_path=props.fint_params_path, |
| # This path will eventually be present in code search so it should |
| # follow what a user would expect to be the default. |
| 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 = ( |
| f"fuchsia_{build_results.set_metadata.target_arch}_{revision}+" |
| f"{commit_timestamp}.kzip" |
| ) |
| |
| if api.buildbucket_util.is_dev_or_try: |
| final_path = ( |
| f"testing/kythe/{api.buildbucket_util.id}/{kzip_name_with_revision}" |
| ) |
| else: |
| final_path = f"prod/{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=props.gcs_bucket, |
| gcs_filename=final_path, |
| # TODO(https://fxbug.dev/123061): Maybe re-enable "rust" here. |
| langs=("cxx"), |
| vnames_path=build_results.vnames_json_path, |
| ) |
| |
| |
| 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() |
| ) |