| # Copyright 2018 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 OVMF firmware and uploading them to CIPD. |
| |
| The Open Virtual Machine Firmware (OVMF) project supports firmware for |
| Virtual Machines (e.g., QEMU). The produced OVMF_CODE.fd and |
| OVMF_VARS.fd are used to emulate EFI bootloading in QEMU in order to |
| boot Zircon off of disk. Currently this is only supported for x64. |
| """ |
| |
| DEPS = [ |
| "fuchsia/buildbucket_util", |
| "fuchsia/git", |
| "fuchsia/status_check", |
| "fuchsia/upload", |
| "recipe_engine/cipd", |
| "recipe_engine/context", |
| "recipe_engine/file", |
| "recipe_engine/json", |
| "recipe_engine/path", |
| "recipe_engine/raw_io", |
| "recipe_engine/step", |
| ] |
| |
| # Note that this recipe accepts no properties because the recipe itself is quite |
| # specific, and its required configuration is encoded entirely in the logic. |
| PROPERTIES = {} |
| |
| |
| def RunSteps(api): |
| edk2_repo = "https://fuchsia.googlesource.com/third_party/edk2" |
| checkout_dir = api.path["start_dir"].join("edk2") |
| with api.step.nest("checkout edk2"): |
| revision = api.git.checkout(edk2_repo, checkout_dir) |
| with api.context(cwd=checkout_dir): |
| # BaseTools binary is needed to build OVMF |
| api.step("build BaseTools", ["make", "-C", "BaseTools"]) |
| api.step( |
| "build OVMF binaries", |
| ["./OvmfPkg/build.sh", "--arch=X64", "--buildtarget=RELEASE"], |
| ) |
| |
| ovmf_bin_dir = checkout_dir.join("Build", "OvmfX64", "RELEASE_GCC5", "FV") |
| api.file.copy("relocate License", checkout_dir.join("License.txt"), ovmf_bin_dir) |
| |
| if not api.buildbucket_util.is_tryjob: |
| api.upload.cipd_package( |
| "fuchsia/firmware/ovmf/amd64", |
| ovmf_bin_dir, |
| [api.upload.DirectoryPath(ovmf_bin_dir)], |
| {"git_revision": revision}, |
| repository=edk2_repo, |
| ) |
| |
| |
| def GenTests(api): |
| revision = "abc123" |
| revision_data = api.step_data( |
| "checkout edk2.git rev-parse", api.raw_io.stream_output(revision) |
| ) |
| |
| yield ( |
| api.status_check.test("not_yet_built_for_current_revision") |
| + revision_data |
| + api.override_step_data( |
| "cipd.cipd search fuchsia/firmware/ovmf/amd64 git_revision:%s" % revision, |
| api.json.output({"result": []}), |
| ) |
| ) |
| yield ( |
| api.status_check.test("already_built_for_current_revision") |
| + revision_data |
| + api.override_step_data( |
| "cipd.cipd search fuchsia/firmware/ovmf/amd64 git_revision:%s" % revision, |
| api.cipd.example_search("fuchsia/firmware/ovmf/amd64"), |
| ) |
| ) |