meson: Override dependencies to improve usage as a subproject

With this change, harfbuzz can be consumed as a subproject without
making any changes to the build files of a project. All you need to do
is provide a wrap file with a `[provide]` section:

https://mesonbuild.com/Wrap-dependency-system-manual.html#provide-section

This is also necessary because otherwise projects need to hard-code
the subproject name, which might be `harfbuzz` when using `wrap-git` or
`harfbuzz-6.0.0` when using `wrap-file` (to build from a release
tarball). This can cause conflicts between different subprojects that
consume harfbuzz differently.

Other projects like glib, cairo, pango, etc already do this.
This commit is contained in:
Nirbheek Chauhan 2022-12-18 07:10:32 +05:30 committed by خالد حسني (Khaled Hosny)
parent 206957aee4
commit 7be06f6377
1 changed files with 4 additions and 0 deletions

View File

@ -535,6 +535,7 @@ libharfbuzz_dep = declare_dependency(
link_with: libharfbuzz,
include_directories: incsrc,
dependencies: harfbuzz_deps)
meson.override_dependency('harfbuzz', libharfbuzz_dep)
# harfbuzz-subset
harfbuzz_subset_def = custom_target('harfbuzz-subset.def',
@ -567,6 +568,7 @@ libharfbuzz_subset_dep = declare_dependency(
link_with: libharfbuzz_subset,
include_directories: incsrc,
dependencies: [m_dep])
meson.override_dependency('harfbuzz-subset', libharfbuzz_subset_dep)
if get_option('tests').enabled()
# TODO: MSVC gives the following,
@ -663,6 +665,7 @@ if have_icu and not have_icu_builtin
link_with: libharfbuzz_icu,
include_directories: incsrc,
dependencies: icu_dep)
meson.override_dependency('harfbuzz-icu', libharfbuzz_icu_dep)
pkgmod.generate(libharfbuzz_icu,
description: 'HarfBuzz text shaping library ICU integration',
@ -776,6 +779,7 @@ if have_gobject
include_directories: incsrc,
sources: build_gir ? hb_gen_files_gir : hb_gobject_sources,
dependencies: [glib_dep, gobject_dep])
meson.override_dependency('harfbuzz-gobject', libharfbuzz_gobject_dep)
pkgmod.generate(libharfbuzz_gobject,
description: 'HarfBuzz text shaping library GObject integration',