meson: build a separate library for harfbuzz-icu

This adds a seperate library like with autotools.

This also fixes the ico feature option which was just set to required:false
when disabled instead of really disabling it.
Disabling is still broken with msvc because it then tries to find the library
another way, but that's broken for all other deps as well so I left it as is.

For tests only test-unicode.c is using icu specific functions so split it out
into its own category which depends on harfbuzz-icu.

Fixes #2338
This commit is contained in:
Christoph Reiter 2020-04-18 20:22:45 +02:00 committed by Ebrahim Byagowi
parent 2354a90008
commit 8ae06c9489
3 changed files with 47 additions and 9 deletions

View File

@ -95,9 +95,13 @@ cairo_dep = dependency('cairo', required: false)
fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'), fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'),
fallback: ['fontconfig', 'fontconfig_dep']) fallback: ['fontconfig', 'fontconfig_dep'])
graphite2_dep = dependency('graphite2', required: get_option('graphite')) graphite2_dep = dependency('graphite2', required: get_option('graphite'))
icu_dep = dependency('icu-uc', required: get_option('icu').enabled() and cpp.get_id() != 'msvc') icu_dep = dependency('icu-uc', required: false)
m_dep = cpp.find_library('m', required: false) m_dep = cpp.find_library('m', required: false)
if not icu_dep.found() and get_option('icu').enabled()
icu_dep = dependency('icu-uc', required: cpp.get_id() != 'msvc')
endif
if not icu_dep.found() and cpp.get_id() == 'msvc' if not icu_dep.found() and cpp.get_id() == 'msvc'
if cpp.has_header('unicode/uchar.h') and \ if cpp.has_header('unicode/uchar.h') and \
cpp.has_header('unicode/unorm2.h') and \ cpp.has_header('unicode/unorm2.h') and \
@ -187,7 +191,6 @@ endif
if icu_dep.found() if icu_dep.found()
conf.set('HAVE_ICU', 1) conf.set('HAVE_ICU', 1)
conf.set('HAVE_ICU_BUILTIN', 1) conf.set('HAVE_ICU_BUILTIN', 1)
deps += [icu_dep]
endif endif
if freetype_dep.found() if freetype_dep.found()

View File

@ -325,12 +325,6 @@ if get_option('amalgam')
hb_sources = ['harfbuzz.cc'] hb_sources = ['harfbuzz.cc']
endif endif
# FIXME: move into harfbuzz-icu module
if conf.get('HAVE_ICU', 0) == 1
hb_sources += hb_icu_sources
hb_headers += hb_icu_headers
endif
# harfbuzz # harfbuzz
gen_def = find_program('gen-def.py') gen_def = find_program('gen-def.py')
harfbuzz_def = custom_target('harfbuzz.def', harfbuzz_def = custom_target('harfbuzz.def',
@ -491,6 +485,33 @@ pkgmod.generate(libharfbuzz_subset,
version: meson.project_version(), version: meson.project_version(),
) )
have_icu = conf.get('HAVE_ICU', 0) == 1
if have_icu
libharfbuzz_icu = library('harfbuzz-icu', [hb_icu_sources, hb_icu_headers],
include_directories: incconfig,
dependencies: icu_dep,
link_with: [libharfbuzz],
cpp_args: cpp_args + extra_hb_cpp_args,
soversion: hb_so_version,
version: version,
install: true,
name_prefix: hb_lib_prefix)
libharfbuzz_icu_dep = declare_dependency(
link_with: libharfbuzz_icu,
include_directories: incsrc,
dependencies: deps)
pkgmod.generate(libharfbuzz_icu,
description: 'HarfBuzz text shaping library ICU integration',
subdirs: [meson.project_name()],
version: meson.project_version(),
)
else
libharfbuzz_icu_dep = dependency('', required: false)
endif
have_gobject = conf.get('HAVE_GOBJECT', 0) == 1 have_gobject = conf.get('HAVE_GOBJECT', 0) == 1
cmake_config = configuration_data() cmake_config = configuration_data()

View File

@ -24,7 +24,6 @@ if conf.get('HAVE_GLIB', 0) == 1
'test-ot-metrics-tt-var.c', 'test-ot-metrics-tt-var.c',
'test-set.c', 'test-set.c',
'test-shape.c', 'test-shape.c',
'test-unicode.c',
'test-var-coords.c', 'test-var-coords.c',
'test-version.c', 'test-version.c',
] ]
@ -51,6 +50,11 @@ if conf.get('HAVE_GLIB', 0) == 1
'test-subset-cbdt.c', 'test-subset-cbdt.c',
] ]
icu_tests = []
if conf.get('HAVE_ICU', 0) == 1
icu_tests += 'test-unicode.c'
endif
if conf.get('HAVE_FREETYPE', 0) == 1 if conf.get('HAVE_FREETYPE', 0) == 1
tests += 'test-ot-math.c' tests += 'test-ot-math.c'
endif endif
@ -86,6 +90,16 @@ if conf.get('HAVE_GLIB', 0) == 1
install: false, install: false,
), env: env) ), env: env)
endforeach endforeach
foreach source : icu_tests
test_name = source.split('.')[0]
test(test_name, executable(test_name, source,
include_directories: [incconfig, incsrc],
dependencies: deps,
link_with: [libharfbuzz, libharfbuzz_icu],
install: false,
), env: env)
endforeach
else else
message('You need to have glib support enabled to run test/api tests') message('You need to have glib support enabled to run test/api tests')
endif endif