From b91d4b8d75ba8f4b5dbba5d787d84eb6571b0842 Mon Sep 17 00:00:00 2001 From: Khaled Hosny Date: Wed, 4 Mar 2026 13:20:08 +0200 Subject: [PATCH] Add meson options to disable building harfbuzz-subset --- meson.build | 6 +++- meson_options.txt | 2 ++ perf/meson.build | 30 ++++++++-------- src/meson.build | 78 ++++++++++++++++++++++------------------ test/api/meson.build | 3 ++ test/fuzzing/meson.build | 59 ++++++++++++++++++------------ test/threads/meson.build | 28 ++++++++------- util/meson.build | 46 +++++++++++++----------- 8 files changed, 146 insertions(+), 106 deletions(-) diff --git a/meson.build b/meson.build index 80a8aa127..50e4ea26f 100644 --- a/meson.build +++ b/meson.build @@ -419,7 +419,11 @@ endif configure_file(output: 'config.h', configuration: conf) alias_target('lib', libharfbuzz) -alias_target('libs', libharfbuzz, libharfbuzz_subset) +libs = [libharfbuzz] +if not get_option('subset').disabled() + libs += [libharfbuzz_subset] +endif +alias_target('libs', libs) # Re glib, see https://github.com/harfbuzz/harfbuzz/issues/4153#issuecomment-2646347531 add_test_setup('default', diff --git a/meson_options.txt b/meson_options.txt index 69310c4d0..ce856eae1 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -33,6 +33,8 @@ option('raster', type: 'feature', value: 'enabled', description: 'Enable HarfBuzz glyph rasterization library') option('vector', type: 'feature', value: 'enabled', description: 'Enable HarfBuzz glyph vector drawing library') +option('subset', type: 'feature', value: 'enabled', + description: 'Enable HarfBuzz font subsetting and instancing library') # Common feature options option('tests', type: 'feature', value: 'enabled', yield: true, diff --git a/perf/meson.build b/perf/meson.build index 4b840b534..e649b080b 100644 --- a/perf/meson.build +++ b/perf/meson.build @@ -26,19 +26,21 @@ foreach source : benchmarks ), workdir: meson.current_source_dir() / '..', timeout: 100) endforeach -benchmarks_subset = [ - 'benchmark-subset.cc', -] +if not get_option('subset').disabled() + benchmarks_subset = [ + 'benchmark-subset.cc', + ] -foreach source : benchmarks_subset - benchmark_name = source.split('.')[0] - benchmark(benchmark_name, executable(benchmark_name, source, - dependencies: [ - google_benchmark_dep, libharfbuzz_dep, libharfbuzz_subset_dep - ], - cpp_args: [], - include_directories: [incconfig, incsrc], - install: false, - ), workdir: meson.current_source_dir() / '..', timeout: 100) -endforeach + foreach source : benchmarks_subset + benchmark_name = source.split('.')[0] + benchmark(benchmark_name, executable(benchmark_name, source, + dependencies: [ + google_benchmark_dep, libharfbuzz_dep, libharfbuzz_subset_dep + ], + cpp_args: [], + include_directories: [incconfig, incsrc], + install: false, + ), workdir: meson.current_source_dir() / '..', timeout: 100) + endforeach +endif diff --git a/src/meson.build b/src/meson.build index 258e412c4..e0e4df4d9 100644 --- a/src/meson.build +++ b/src/meson.build @@ -667,37 +667,40 @@ libharfbuzz_dep = declare_dependency( meson.override_dependency('harfbuzz', libharfbuzz_dep) # harfbuzz-subset -harfbuzz_subset_def = custom_target('harfbuzz-subset.def', - command: gen_def_cmd, - input: hb_subset_headers, - output: 'harfbuzz-subset.def') -defs_list += [harfbuzz_subset_def] +libharfbuzz_subset_dep = null_dep +if not get_option('subset').disabled() + harfbuzz_subset_def = custom_target('harfbuzz-subset.def', + command: gen_def_cmd, + input: hb_subset_headers, + output: 'harfbuzz-subset.def') + defs_list += [harfbuzz_subset_def] -libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, - include_directories: incconfig, - dependencies: [m_dep], - link_with: [libharfbuzz], - cpp_args: cpp_args + extra_hb_cpp_args, - soversion: hb_so_version, - version: version, - install: true, - darwin_versions: darwin_versions, - link_language: chosen_linker, -) + libharfbuzz_subset = library('harfbuzz-subset', hb_subset_sources, + include_directories: incconfig, + dependencies: [m_dep], + link_with: [libharfbuzz], + cpp_args: cpp_args + extra_hb_cpp_args, + soversion: hb_so_version, + version: version, + install: true, + darwin_versions: darwin_versions, + link_language: chosen_linker, + ) -custom_target('harfbuzz-subset.cc', - build_by_default: true, - output: 'harfbuzz-subset.cc', - input: hb_base_sources + hb_subset_sources, - command: [find_program('gen-harfbuzzcc.py'), - '@OUTPUT@', meson.current_source_dir(), '@INPUT@'], -) + custom_target('harfbuzz-subset.cc', + build_by_default: true, + output: 'harfbuzz-subset.cc', + input: hb_base_sources + hb_subset_sources, + command: [find_program('gen-harfbuzzcc.py'), + '@OUTPUT@', meson.current_source_dir(), '@INPUT@'], + ) -libharfbuzz_subset_dep = declare_dependency( - link_with: libharfbuzz_subset, - include_directories: incsrc, - dependencies: [m_dep]) -meson.override_dependency('harfbuzz-subset', libharfbuzz_subset_dep) + libharfbuzz_subset_dep = declare_dependency( + link_with: libharfbuzz_subset, + include_directories: incsrc, + dependencies: [m_dep]) + meson.override_dependency('harfbuzz-subset', libharfbuzz_subset_dep) +endif hb_raster_sources = [ 'hb-raster.cc', @@ -945,12 +948,14 @@ pkgmod.generate(libharfbuzz, version: meson.project_version(), ) -pkgmod.generate(libharfbuzz_subset, - description: 'HarfBuzz font subsetter', - requires: ['harfbuzz = @0@'.format(meson.project_version())], - subdirs: [meson.project_name()], - version: meson.project_version(), -) +if not get_option('subset').disabled() + pkgmod.generate(libharfbuzz_subset, + description: 'HarfBuzz font subsetter', + requires: ['harfbuzz = @0@'.format(meson.project_version())], + subdirs: [meson.project_name()], + version: meson.project_version(), + ) +endif libharfbuzz_icu_dep = null_dep if have_icu and not have_icu_builtin @@ -1240,4 +1245,7 @@ if get_option('tests').enabled() ) endif -install_headers(hb_headers + hb_subset_headers, subdir: meson.project_name()) +install_headers(hb_headers, subdir: meson.project_name()) +if not get_option('subset').disabled() + install_headers(hb_subset_headers, subdir: meson.project_name()) +endif diff --git a/test/api/meson.build b/test/api/meson.build index 0c250fc1f..e867fe23f 100644 --- a/test/api/meson.build +++ b/test/api/meson.build @@ -108,6 +108,9 @@ foreach source : tests libharfbuzz_icu_dep] suite = ['api'] if test_name.contains('-subset') or test_name.contains('-instance') + if get_option('subset').disabled() + continue + endif deps += libharfbuzz_subset_dep suite += 'subset' endif diff --git a/test/fuzzing/meson.build b/test/fuzzing/meson.build index 5bd48fb9a..3e02384db 100644 --- a/test/fuzzing/meson.build +++ b/test/fuzzing/meson.build @@ -25,11 +25,20 @@ foreach file_name : tests extra_cpp_args += '-DHB_EXPERIMENTAL_API' endif + if (test_name.contains('subset') or test_name.contains('repacker')) and get_option('subset').disabled() + continue + endif + + link_with_libs = [libharfbuzz] + if not get_option('subset').disabled() + link_with_libs += [libharfbuzz_subset] + endif + exe = executable(test_name, sources, cpp_args: cpp_args + extra_cpp_args, include_directories: [incconfig, incsrc], link_args: fuzzer_ldflags, - link_with: [libharfbuzz, libharfbuzz_subset], + link_with: link_with_libs, install: false, ) set_variable('@0@_exe'.format(test_name.underscorify()), exe) @@ -87,29 +96,33 @@ foreach chunk : fonts_glob_chunks i += 1 endforeach -i = 0 -foreach chunk : fonts_glob_chunks + subset_fonts_glob_chunks - test('subset-fuzzer-chunk-@0@'.format(i), - hb_subset_fuzzer_exe, - args: chunk, - workdir: meson.current_build_dir() / '..' / '..', - protocol: 'tap', - suite: ['fuzzing'], - ) - i += 1 -endforeach +if not get_option('subset').disabled() + i = 0 + foreach chunk : fonts_glob_chunks + subset_fonts_glob_chunks + test('subset-fuzzer-chunk-@0@'.format(i), + hb_subset_fuzzer_exe, + args: chunk, + workdir: meson.current_build_dir() / '..' / '..', + protocol: 'tap', + suite: ['fuzzing'], + ) + i += 1 + endforeach +endif -i = 0 -foreach chunk : graphs_glob_chunks - test('repacker-fuzzer-chunk-@0@'.format(i), - hb_repacker_fuzzer_exe, - args: chunk, - workdir: meson.current_build_dir() / '..' / '..', - protocol: 'tap', - suite: ['fuzzing'], - ) - i += 1 -endforeach +if not get_option('subset').disabled() + i = 0 + foreach chunk : graphs_glob_chunks + test('repacker-fuzzer-chunk-@0@'.format(i), + hb_repacker_fuzzer_exe, + args: chunk, + workdir: meson.current_build_dir() / '..' / '..', + protocol: 'tap', + suite: ['fuzzing'], + ) + i += 1 + endforeach +endif i = 0 foreach chunk : sets_glob_chunks diff --git a/test/threads/meson.build b/test/threads/meson.build index 1848a1c6e..a6d27ac61 100644 --- a/test/threads/meson.build +++ b/test/threads/meson.build @@ -13,16 +13,18 @@ test('shape_threads', executable('hb-shape-threads', 'hb-shape-threads.cc', ) -test('subset_threads', executable('hb-subset-threads', 'hb-subset-threads.cc', - dependencies: [ - thread_dep - ], - cpp_args: [], - include_directories: [incconfig, incsrc], - link_with: [libharfbuzz, libharfbuzz_subset], - install: false, - ), - workdir: meson.current_source_dir() / '..' / '..', - timeout: 300, - suite: ['threads', 'slow'], -) +if not get_option('subset').disabled() + test('subset_threads', executable('hb-subset-threads', 'hb-subset-threads.cc', + dependencies: [ + thread_dep + ], + cpp_args: [], + include_directories: [incconfig, incsrc], + link_with: [libharfbuzz, libharfbuzz_subset], + install: false, + ), + workdir: meson.current_source_dir() / '..' / '..', + timeout: 300, + suite: ['threads', 'slow'], + ) +endif diff --git a/util/meson.build b/util/meson.build index 84d453b81..26c40e067 100644 --- a/util/meson.build +++ b/util/meson.build @@ -158,14 +158,18 @@ if conf.get('HAVE_GLIB', 0) == 1 ) meson.override_find_program('hb-info', hb_info) - hb_subset = executable('hb-subset', hb_subset_cli_sources, - cpp_args: cpp_args, - include_directories: [incconfig, incsrc], - dependencies: util_deps, - link_with: [libharfbuzz, libharfbuzz_subset], - install: true, - ) - meson.override_find_program('hb-subset', hb_subset) + if not get_option('subset').disabled() + hb_subset = executable('hb-subset', hb_subset_cli_sources, + cpp_args: cpp_args, + include_directories: [incconfig, incsrc], + dependencies: util_deps, + link_with: [libharfbuzz, libharfbuzz_subset], + install: true, + ) + meson.override_find_program('hb-subset', hb_subset) + else + hb_subset = disabler() + endif if help2man.found() foreach binary: [hb_shape, hb_vector, hb_info, hb_subset] @@ -183,18 +187,20 @@ if conf.get('HAVE_GLIB', 0) == 1 endif if get_option('experimental_api') - test('test-hb-subset-parsing', - executable('test-hb-subset-parsing', - ['test-hb-subset-parsing.c'], - cpp_args: cpp_args, - c_args: ['-DHB_EXPERIMENTAL_API'], - include_directories: [incconfig, incsrc], - dependencies: util_deps, - link_with: [libharfbuzz, libharfbuzz_subset], - install: false, - ), - workdir : meson.current_source_dir(), - suite: ['util']) + if not get_option('subset').disabled() + test('test-hb-subset-parsing', + executable('test-hb-subset-parsing', + ['test-hb-subset-parsing.c'], + cpp_args: cpp_args, + c_args: ['-DHB_EXPERIMENTAL_API'], + include_directories: [incconfig, incsrc], + dependencies: util_deps, + link_with: [libharfbuzz, libharfbuzz_subset], + install: false, + ), + workdir : meson.current_source_dir(), + suite: ['util']) + endif endif else # Disable tests that use this