macos.py 1.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. # -*- coding: UTF-8 -*-
  2. # Copyright (c) 2017 The ungoogled-chromium Authors. All rights reserved.
  3. # Use of this source code is governed by a BSD-style license that can be
  4. # found in the LICENSE file.
  5. """macOS-specific build files generation code"""
  6. import shutil
  7. import pathlib
  8. from .. import _common
  9. from .. import export_resources as _export_resources
  10. from .. import build_gn as _build_gn
  11. from . import _common as _build_files_common
  12. _BUILD_FILES_DIR = "ungoogled_macos"
  13. def _get_packaging_resources():
  14. return _common.get_resources_dir() / _common.PACKAGING_DIR / "macos"
  15. def generate_build_files(resources, output_dir, build_output, apply_domain_substitution):
  16. """
  17. Generates the `macos` directory in `output_dir` using resources from
  18. `resources`
  19. """
  20. gn_flags = resources.read_gn_flags()
  21. build_file_subs = dict(
  22. build_output=build_output,
  23. build_gn_command=_build_gn.construct_gn_command(
  24. pathlib.Path(build_output) / "gn",
  25. gn_flags,
  26. shell=True
  27. ),
  28. build_files_dir=_BUILD_FILES_DIR,
  29. gn_args_string=" ".join(
  30. [flag + "=" + value for flag, value in gn_flags.items()]
  31. ),
  32. chromium_version=resources.read_version()[0],
  33. release_revision=resources.read_version()[1]
  34. )
  35. macos_dir = output_dir / _BUILD_FILES_DIR
  36. macos_dir.mkdir(exist_ok=True)
  37. # Build script
  38. shutil.copy(
  39. str(_get_packaging_resources() / "build.sh.in"),
  40. str(macos_dir / "build.sh.in")
  41. )
  42. _build_files_common.generate_from_templates(macos_dir, build_file_subs)
  43. # Patches
  44. _export_resources.export_patches_dir(resources, macos_dir / _common.PATCHES_DIR,
  45. apply_domain_substitution)
  46. _common.write_list(macos_dir / _common.PATCHES_DIR / "series",
  47. resources.read_patch_order())