| # 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/git', |
| 'fuchsia/upload', |
| 'recipe_engine/cipd', |
| 'recipe_engine/context', |
| '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') |
| 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.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('git rev-parse', |
| api.raw_io.stream_output(revision)) |
| |
| yield (api.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.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'))) |