| # Copyright 2019 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 AEMU.""" |
| |
| DEPS = [ |
| 'fuchsia/git', |
| 'fuchsia/macos_sdk', |
| 'fuchsia/upload', |
| 'recipe_engine/buildbucket', |
| 'recipe_engine/cipd', |
| 'recipe_engine/context', |
| 'recipe_engine/file', |
| 'recipe_engine/isolated', |
| 'recipe_engine/path', |
| 'recipe_engine/platform', |
| 'recipe_engine/python', |
| 'recipe_engine/raw_io', |
| 'recipe_engine/runtime', |
| 'recipe_engine/step', |
| ] |
| |
| REPO_CIPD_PKG = ('fuchsia/third_party/repo', 'version:1.13.2', 'repo') |
| |
| |
| def RunSteps(api): |
| cipd_dir = api.path['start_dir'].join('cipd') |
| pkgs = api.cipd.EnsureFile() |
| pkgs.add_package(*REPO_CIPD_PKG) |
| api.cipd.ensure(cipd_dir, pkgs) |
| |
| repo_dir = cipd_dir.join('repo') |
| |
| src_dir = api.path['start_dir'].join('aemu', 'src') |
| api.file.ensure_directory('aemu src dir', src_dir) |
| install_dir = api.path['start_dir'].join('aemu', 'install') |
| with api.context(cwd=src_dir): |
| api.step('repo init', [ |
| repo_dir.join('repo'), 'init', '-u', |
| 'https://android.googlesource.com/platform/manifest', '-b', |
| 'emu-master-dev' |
| ]) |
| api.step('repo sync', |
| [repo_dir.join('repo'), 'sync', |
| '-j%d' % api.platform.cpu_count]) |
| qemu_dir = src_dir.join('external', 'qemu') |
| |
| with api.macos_sdk(), api.context(cwd=qemu_dir): |
| repository = api.git.get_remote_url('aosp') |
| revision = api.git.get_hash() |
| |
| api.python( |
| 'cmake', |
| qemu_dir.join('android', 'build', 'python', 'cmake.py'), [ |
| '--cmake_option', |
| 'ANDROIDSTUDIO=OFF', |
| '--crash', |
| 'prod', |
| '--minbuild', |
| '--dist', |
| install_dir, |
| ], |
| venv=api.resource('cmake.vpython')) |
| |
| pkg_dir = qemu_dir.join('objs', 'distribution', 'emulator') |
| |
| api.upload.upload_isolated(pkg_dir) |
| |
| if api.buildbucket.builder_id.bucket == 'prod': |
| host_platform = '%s-%s' % (api.platform.name.replace('win', 'windows'), { |
| 'intel': { |
| 32: '386', |
| 64: 'amd64', |
| }, |
| 'arm': { |
| 32: 'armv6', |
| 64: 'arm64', |
| }, |
| }[api.platform.arch][api.platform.bits]) |
| |
| api.upload.cipd_package( |
| 'fuchsia/third_party/aemu/' + host_platform, |
| pkg_dir, [api.upload.DirectoryPath(pkg_dir)], |
| {'git_revision': revision}, |
| repository=repository) |
| |
| |
| def GenTests(api): |
| yield (api.test('cipd_pkg_exists') + api.buildbucket.ci_build( |
| project='fuchsia', |
| bucket='prod', |
| git_repo='https://android.googlesource.com/platform/external/qemu/', |
| revision='a' * 40, |
| ) + api.runtime(is_luci=True, is_experimental=False) + |
| api.platform.name('linux')) |
| yield ( |
| api.test('cipd_pkg_new') + api.buildbucket.ci_build( |
| project='fuchsia', |
| bucket='prod', |
| git_repo='https://android.googlesource.com/platform/external/qemu/', |
| revision='a' * 40, |
| ) + api.runtime(is_luci=True, is_experimental=False) + |
| api.step_data('git rev-parse', api.raw_io.stream_output('a' * 40)) + |
| api.platform.name('linux') + api.step_data( |
| 'cipd.cipd search fuchsia/third_party/aemu/linux-amd64 ' + |
| 'git_revision:' + 'a' * 40, |
| api.cipd.example_search('fuchsia/third_party/aemu/linux-amd64', []))) |