| # Copyright 2023 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. |
| |
| from functools import cached_property |
| |
| from recipe_engine import recipe_api |
| |
| |
| # TODO(fxbug.dev/122100): Consider deleting this dedicated module since this is |
| # now only a very thin wrapper around the checkout and cmake.build_with_ninja(). |
| class ZlibApi(recipe_api.RecipeApi): |
| """APIs for building zlib.""" |
| |
| def build(self, platform, cmake_extra_args=(), **kwargs): |
| """ |
| Build zlib. |
| |
| Args: |
| platform (api.platform_util.Platform): Target platform. |
| kwargs: Passed through to api.cmake.build_with_ninja(). |
| |
| Returns: |
| Path: zlib install path. |
| """ |
| cmake_extra_args = cmake_extra_args or [] |
| if platform.is_linux or platform.is_fuchsia: |
| # TODO(fxbug.dev/117101): As of https://reviews.llvm.org/D135402, |
| # undefined symbols will be flagged as errors. Namely, gz_intmax is |
| # undefined in zlib. For now, we can disable this error to replicate |
| # the previous builder state. |
| cmake_extra_args += [ |
| "-DCMAKE_SHARED_LINKER_FLAGS=-Wl,--undefined-version", |
| ] |
| return self.m.cmake.build_with_ninja( |
| src_dir=self.checkout, |
| build_type="Release", |
| extra_args=cmake_extra_args, |
| **kwargs, |
| ) |
| |
| @cached_property |
| def checkout(self): |
| """Checkout zlib.""" |
| checkout_dir, _ = self.m.git_checkout( |
| "https://fuchsia.googlesource.com/third_party/zlib", |
| revision="refs/tags/v1.2.11", |
| ) |
| return checkout_dir |