| # Copyright 2016 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 Bloaty.""" |
| |
| from PB.recipes.fuchsia.contrib.bloaty import InputProperties |
| |
| DEPS = [ |
| "fuchsia/buildbucket_util", |
| "fuchsia/cipd_util", |
| "fuchsia/cmake", |
| "fuchsia/git_checkout", |
| "fuchsia/goma", |
| "fuchsia/linux_sdk", |
| "fuchsia/macos_sdk", |
| "fuchsia/ninja", |
| "fuchsia/platform_util", |
| "recipe_engine/cipd", |
| "recipe_engine/context", |
| "recipe_engine/file", |
| "recipe_engine/path", |
| "recipe_engine/platform", |
| "recipe_engine/properties", |
| "recipe_engine/step", |
| ] |
| |
| PROPERTIES = InputProperties |
| |
| |
| def RunSteps(api, props): |
| repo = props.repository or "https://fuchsia.googlesource.com/third_party/bloaty" |
| target_platform = api.platform_util.platform( |
| props.platform or api.platform_util.host.platform |
| ) |
| |
| checkout_root, revision = api.git_checkout(repo, rebase_merges=True) |
| |
| build_dir = api.path.start_dir / "bloaty_build" |
| api.file.ensure_directory("ensure build dir", build_dir) |
| |
| cipd_dir = api.path.start_dir / "cipd" |
| with api.step.nest("ensure_packages"), api.context(infra_steps=True): |
| pkgs = api.cipd.EnsureFile() |
| pkgs.add_package( |
| "fuchsia/third_party/clang/${platform}", |
| "git_revision:7a34dca0f3918ab1c0397e56dd64a3c04164c8b6", |
| ) |
| pkgs.add_package( |
| "fuchsia/rust/${platform}", |
| "git_revision:cbe7c5ce705896d4e22bf6096590bc1f17993b78", |
| ) |
| api.cipd.ensure(cipd_dir, pkgs) |
| |
| with api.goma(): |
| env = {"RUSTC": cipd_dir.joinpath("bin", "rustc")} |
| with api.linux_sdk(), api.macos_sdk(), api.context(env=env): |
| options = ( |
| [ |
| f"-DCMAKE_LINKER={cipd_dir.joinpath('bin', 'ld.lld')}", |
| f"-DCMAKE_NM={cipd_dir.joinpath('bin', 'llvm-nm')}", |
| f"-DCMAKE_OBJCOPY={cipd_dir.joinpath('bin', 'llvm-objcopy')}", |
| f"-DCMAKE_OBJDUMP={cipd_dir.joinpath('bin', 'llvm-objdump')}", |
| f"-DCMAKE_RANLIB={cipd_dir.joinpath('bin', 'llvm-ranlib')}", |
| f"-DCMAKE_STRIP={cipd_dir.joinpath('bin', 'llvm-strip')}", |
| "-DCMAKE_EXE_LINKER_FLAGS=-static-libstdc++ -ldl -lpthread", |
| ] |
| if target_platform.is_linux |
| else [] |
| ) |
| api.cmake.build_with_ninja( |
| src_dir=checkout_root, |
| build_dir=build_dir, |
| build_type="Release", |
| ninja_jobs=api.goma.jobs, |
| extra_args=[ |
| f"-DCMAKE_C_COMPILER_LAUNCHER={api.goma.goma_dir / 'gomacc'}", |
| f"-DCMAKE_C_COMPILER={cipd_dir.joinpath('bin', 'clang')}", |
| f"-DCMAKE_C_COMPILER_TARGET={target_platform.triple}", |
| f"-DCMAKE_CXX_COMPILER_LAUNCHER={api.goma.goma_dir / 'gomacc'}", |
| f"-DCMAKE_CXX_COMPILER={cipd_dir.joinpath('bin', 'clang++')}", |
| f"-DCMAKE_CXX_COMPILER_TARGET={target_platform.triple}", |
| f"-DRUST_TOOLCHAIN_PREFIX={cipd_dir / 'bin'}", |
| ] |
| + options, |
| ) |
| api.ninja( |
| "test", |
| ["test"], |
| build_dir=build_dir, |
| ) |
| |
| if not api.buildbucket_util.is_dev_or_try: |
| api.cipd_util.upload_package( |
| pkg_name=f"fuchsia/third_party/bloaty/{target_platform}", |
| pkg_root=build_dir, |
| pkg_paths=[build_dir / "bloaty"], |
| search_tag={"git_revision": revision}, |
| repository=repo, |
| ) |
| |
| |
| def GenTests(api): |
| yield ( |
| api.buildbucket_util.test("linux_ci", repo="third_party/bloaty") |
| + api.properties(platform="linux-amd64") |
| ) |
| yield ( |
| api.buildbucket_util.test("mac_try", tryjob=True, repo="third_party/bloaty") |
| + api.platform.name("mac") |
| + api.properties(platform="mac-amd64") |
| ) |