| # 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.""" |
| |
| from recipe_engine.recipe_api import Property |
| |
| DEPS = [ |
| "fuchsia/git", |
| "fuchsia/macos_sdk", |
| "fuchsia/upload", |
| "recipe_engine/buildbucket", |
| "recipe_engine/cipd", |
| "recipe_engine/context", |
| "recipe_engine/file", |
| "recipe_engine/path", |
| "recipe_engine/platform", |
| "recipe_engine/properties", |
| "recipe_engine/python", |
| "recipe_engine/raw_io", |
| "recipe_engine/step", |
| ] |
| |
| REPO_CIPD_PKG = ("fuchsia/third_party/repo", "version:1.13.2", "repo") |
| |
| PROPERTIES = { |
| "platform": Property(kind=str, help="CIPD target platform", default=None), |
| } |
| |
| PLATFORM_TO_TARGET = { |
| "linux-amd64": "linux", |
| "linux-arm64": "linux_aarch64", |
| "mac-amd64": "darwin", |
| } |
| |
| |
| def RunSteps(api, platform): |
| 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(additional_sdks=[("MacOSX10.13.sdk", "9f2000")]), api.context( |
| cwd=qemu_dir |
| ): |
| repository = api.git.get_remote_url("aosp") |
| revision = api.git.get_hash() |
| |
| cmd = [ |
| qemu_dir.join("android", "build", "python", "cmake.py"), |
| "--cmake_option", |
| "ANDROIDSTUDIO=OFF", |
| # TODO(nmulcahey): Re-enable when symbol uploads work again. |
| # "--crash", |
| # "prod", |
| "--minbuild", |
| "--dist", |
| install_dir, |
| ] |
| |
| if platform: |
| cmd.extend(["--target", PLATFORM_TO_TARGET[platform]]) |
| |
| api.python("cmake", cmd[0], cmd[1:], 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": |
| if not platform: |
| 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/" + 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.platform.name("linux") |
| ) |
| |
| yield ( |
| api.test("mac") |
| + api.buildbucket.ci_build( |
| project="fuchsia", |
| bucket="prod", |
| git_repo="https://android.googlesource.com/platform/external/qemu/", |
| revision="a" * 40, |
| ) |
| + api.platform.name("mac") |
| ) |
| |
| yield ( |
| api.test("aarch64_cipd_pkg_exists") |
| + api.buildbucket.ci_build( |
| project="fuchsia", |
| bucket="prod", |
| git_repo="https://android.googlesource.com/platform/external/qemu/", |
| revision="a" * 40, |
| ) |
| + api.properties(platform="linux-arm64") |
| ) |
| |
| 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.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", []), |
| ) |
| ) |