mirror of
https://github.com/love2d/megasource.git
synced 2026-08-23 05:55:28 +02:00
update harfbuzz to 10.1.0
This commit is contained in:
+175
-57
@@ -1,43 +1,61 @@
|
||||
project('harfbuzz', 'c', 'cpp',
|
||||
meson_version: '>= 0.55.0',
|
||||
version: '5.3.1',
|
||||
version: '10.1.0',
|
||||
default_options: [
|
||||
'cpp_rtti=false', # Just to support msvc, we are passing -fno-exceptions also anyway
|
||||
'cpp_eh=none', # Just to support msvc, we are passing -fno-exceptions also anyway
|
||||
# 'cpp_rtti=false', # Do NOT enable, wraps inherit it and ICU needs RTTI
|
||||
'cpp_std=c++11',
|
||||
'wrap_mode=nofallback', # Use --wrap-mode=default to revert, https://github.com/harfbuzz/harfbuzz/pull/2548
|
||||
],
|
||||
)
|
||||
|
||||
glib_min_version = '>= 2.30.0'
|
||||
cairo_min_version = '>= 1.10.0'
|
||||
chafa_min_version = '>= 1.6.0'
|
||||
icu_min_version = '>= 49.0'
|
||||
graphite2_min_version = '>= 1.2.0'
|
||||
|
||||
freetype_min_version_actual = '>= 2.4.2'
|
||||
freetype_min_version = '>= 12.0.6' # Corresponds to `freetype_min_version_actual`
|
||||
|
||||
hb_version_arr = meson.project_version().split('.')
|
||||
hb_version_major = hb_version_arr[0].to_int()
|
||||
hb_version_minor = hb_version_arr[1].to_int()
|
||||
hb_version_micro = hb_version_arr[2].to_int()
|
||||
|
||||
# libtool versioning
|
||||
hb_version_int = hb_version_major*10000 + hb_version_minor*100 + hb_version_micro
|
||||
hb_version_int = 60000 + hb_version_major*100 + hb_version_minor*10 + hb_version_micro
|
||||
hb_libtool_version_info = '@0@:0:@0@'.format(hb_version_int)
|
||||
|
||||
pkgmod = import('pkgconfig')
|
||||
cpp = meson.get_compiler('cpp')
|
||||
null_dep = dependency('', required: false)
|
||||
|
||||
# Only perform these checks if cpp_std is c++11 as setting -std directly
|
||||
# produces a warning from meson.
|
||||
if get_option('cpp_std') == 'c++11'
|
||||
# Enforce C++14 requirement for MSVC STL
|
||||
if cpp.get_id() == 'clang' and cpp.get_define('_MSC_FULL_VER') != ''
|
||||
add_project_arguments('-std=c++14', language: 'cpp')
|
||||
elif cpp.get_id() == 'clang-cl'
|
||||
# Clang-cl produces a warning when using -std=c++14, but not when using /std:c++14
|
||||
add_project_arguments('/std:c++14', language : 'cpp')
|
||||
endif
|
||||
endif
|
||||
|
||||
if cpp.get_argument_syntax() == 'msvc'
|
||||
# Ignore several spurious warnings for things HarfBuzz does very commonly.
|
||||
# If a warning is completely useless and spammy, use '/wdXXXX' to suppress it
|
||||
# If a warning is harmless but hard to fix, use '/woXXXX' so it's shown once
|
||||
# NOTE: Only add warnings here if you are sure they're spurious
|
||||
msvc_args = [
|
||||
'/wd4018', # implicit signed/unsigned conversion
|
||||
'/wd4146', # unary minus on unsigned (beware INT_MIN)
|
||||
'/wd4244', # lossy type conversion (e.g. double -> int)
|
||||
'/wd4305', # truncating type conversion (e.g. double -> float)
|
||||
'/bigobj', # hb-subset.cc -- compile error C1128: number of sections exceeded object file format limit
|
||||
cpp.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
|
||||
]
|
||||
add_project_arguments(msvc_args, language: ['c', 'cpp'])
|
||||
# Disable SAFESEH with MSVC for libs that use external deps that are built with MinGW
|
||||
# noseh_link_args = ['/SAFESEH:NO']
|
||||
# disable exception handling
|
||||
add_project_arguments(['/EHs-', '/EHc-'], language: 'cpp')
|
||||
endif
|
||||
|
||||
add_project_link_arguments(cpp.get_supported_link_arguments([
|
||||
@@ -71,51 +89,105 @@ check_headers = [
|
||||
]
|
||||
|
||||
check_funcs = [
|
||||
['atexit'],
|
||||
['mprotect'],
|
||||
['sysconf'],
|
||||
['getpagesize'],
|
||||
['mmap'],
|
||||
['isatty'],
|
||||
['uselocale'],
|
||||
['newlocale'],
|
||||
['atexit', {'prefix': '#include <stdlib.h>'}],
|
||||
['mprotect', {'prefix': '#include <sys/mman.h>'}],
|
||||
['sysconf', {'prefix': '#include <unistd.h>'}],
|
||||
['getpagesize', {'prefix': '#include <unistd.h>'}],
|
||||
['mmap', {'prefix': '#include <sys/mman.h>'}],
|
||||
['isatty', {'prefix': '#include <unistd.h>'}],
|
||||
['uselocale', {'prefix': '#include <locale.h>'}],
|
||||
['newlocale', {'prefix': '#include <locale.h>'}],
|
||||
['sincosf', {'prefix': '#define _GNU_SOURCE\n#include <math.h>'}],
|
||||
]
|
||||
|
||||
m_dep = cpp.find_library('m', required: false)
|
||||
|
||||
|
||||
# Try pkgconfig name
|
||||
freetype_dep = dependency('freetype2', required: false)
|
||||
if not freetype_dep.found()
|
||||
# Try cmake name
|
||||
freetype_dep = dependency('freetype', required: false)
|
||||
endif
|
||||
if not freetype_dep.found()
|
||||
# Subproject fallback, `allow_fallback: true` means the fallback will be
|
||||
# tried even if the freetype option is set to `auto`.
|
||||
if meson.version().version_compare('>=0.60.0')
|
||||
# Sadly, FreeType's versioning schemes are different between pkg-config and CMake
|
||||
# pkg-config: freetype2, cmake: Freetype
|
||||
freetype_dep = dependency('freetype2',
|
||||
required: get_option('freetype'),
|
||||
default_options: ['harfbuzz=disabled'],
|
||||
version: freetype_min_version,
|
||||
method: 'pkg-config',
|
||||
required: false,
|
||||
allow_fallback: false)
|
||||
if not freetype_dep.found()
|
||||
freetype_dep = dependency('FreeType',
|
||||
version: freetype_min_version_actual,
|
||||
method: 'cmake',
|
||||
required: get_option('freetype'),
|
||||
default_options: ['harfbuzz=disabled'],
|
||||
allow_fallback: true)
|
||||
endif
|
||||
else
|
||||
# painful hack to handle multiple dependencies but also respect options
|
||||
freetype_opt = get_option('freetype')
|
||||
# we want to handle enabled manually after fallbacks, but also handle disabled normally
|
||||
if freetype_opt.enabled()
|
||||
freetype_opt = false
|
||||
endif
|
||||
# try pkg-config name
|
||||
freetype_dep = dependency('freetype2', version: freetype_min_version, method: 'pkg-config', required: freetype_opt)
|
||||
# when disabled, leave it not-found
|
||||
if not freetype_dep.found() and not get_option('freetype').disabled()
|
||||
# Try cmake name
|
||||
freetype_dep = dependency('Freetype', version: freetype_min_version_actual, method: 'cmake', required: false)
|
||||
# Subproject fallback, `allow_fallback: true` means the fallback will be
|
||||
# tried even if the freetype option is set to `auto`.
|
||||
if not freetype_dep.found()
|
||||
freetype_dep = dependency('freetype2',
|
||||
version: freetype_min_version,
|
||||
method: 'pkg-config',
|
||||
required: get_option('freetype'),
|
||||
default_options: ['harfbuzz=disabled'],
|
||||
allow_fallback: true)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
glib_dep = dependency('glib-2.0', version: glib_min_version, required: get_option('glib'))
|
||||
gobject_dep = dependency('gobject-2.0', version: glib_min_version, required: get_option('gobject'))
|
||||
graphite2_dep = dependency('graphite2', version: graphite2_min_version, required: get_option('graphite2'))
|
||||
graphite_dep = dependency('graphite2', version: graphite2_min_version, required: get_option('graphite'))
|
||||
wasm_dep = cpp.find_library('iwasm', required: get_option('wasm'))
|
||||
# How to check whether iwasm was built, and hence requires, LLVM?
|
||||
#llvm_dep = cpp.find_library('LLVM-15', required: get_option('wasm'))
|
||||
|
||||
if meson.version().version_compare('>=0.60.0')
|
||||
# pkg-config: icu-uc, cmake: ICU but with components
|
||||
icu_dep = dependency('icu-uc', 'ICU',
|
||||
version: icu_min_version,
|
||||
components: 'uc',
|
||||
required: get_option('icu'),
|
||||
allow_fallback: true)
|
||||
else
|
||||
# painful hack to handle multiple dependencies but also respect options
|
||||
icu_opt = get_option('icu')
|
||||
# we want to handle enabled manually after fallbacks, but also handle disabled normally
|
||||
if icu_opt.enabled()
|
||||
icu_opt = false
|
||||
endif
|
||||
# try pkg-config name
|
||||
icu_dep = dependency('icu-uc', version: icu_min_version, method: 'pkg-config', required: icu_opt)
|
||||
# when disabled, leave it not-found
|
||||
if not icu_dep.found() and not get_option('icu').disabled()
|
||||
# Try cmake name
|
||||
icu_dep = dependency('ICU', version: icu_min_version, method: 'cmake', components: 'uc', required: false)
|
||||
# Try again with subproject fallback. `allow_fallback: true` means the
|
||||
# fallback will be tried even if the icu option is set to `auto`, but
|
||||
# we cannot pass this option until Meson 0.59.0, because no wrap file
|
||||
# is checked into git.
|
||||
if not icu_dep.found()
|
||||
icu_dep = dependency('icu-uc',
|
||||
version: icu_min_version,
|
||||
method: 'pkg-config',
|
||||
required: get_option('icu'))
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
glib_dep = dependency('glib-2.0', required: get_option('glib'))
|
||||
gobject_dep = dependency('gobject-2.0', required: get_option('gobject'))
|
||||
graphite2_dep = dependency('graphite2', required: get_option('graphite2'))
|
||||
graphite_dep = dependency('graphite2', required: get_option('graphite'))
|
||||
|
||||
# Try pkgconfig name
|
||||
icu_dep = dependency('icu-uc', required: false)
|
||||
if not icu_dep.found()
|
||||
# Try cmake name
|
||||
icu_dep = dependency('ICU',
|
||||
required: false,
|
||||
components: 'uc',
|
||||
method: 'cmake')
|
||||
endif
|
||||
if not icu_dep.found()
|
||||
# Subproject fallback if icu option is enabled
|
||||
icu_dep = dependency('icu-uc', required: get_option('icu'))
|
||||
if icu_dep.found() and icu_dep.version().version_compare('>=75.1') and (get_option('cpp_std') == 'c++11' or get_option('cpp_std') == 'c++14')
|
||||
cpp17_arg = cpp.get_argument_syntax() == 'msvc' ? '/std:c++17' : '-std=c++17'
|
||||
add_project_arguments(cpp17_arg, language: 'cpp')
|
||||
endif
|
||||
|
||||
if icu_dep.found() and icu_dep.type_name() == 'pkgconfig'
|
||||
@@ -128,8 +200,8 @@ endif
|
||||
cairo_dep = null_dep
|
||||
cairo_ft_dep = null_dep
|
||||
if not get_option('cairo').disabled()
|
||||
cairo_dep = dependency('cairo', required: false)
|
||||
cairo_ft_dep = dependency('cairo-ft', required: false)
|
||||
cairo_dep = dependency('cairo', version: cairo_min_version, required: false)
|
||||
cairo_ft_dep = dependency('cairo-ft', version: cairo_min_version, required: false)
|
||||
|
||||
if (not cairo_dep.found() and
|
||||
cpp.get_argument_syntax() == 'msvc' and
|
||||
@@ -147,12 +219,13 @@ if not get_option('cairo').disabled()
|
||||
# dependency cycle here because we have configured freetype2 above with
|
||||
# harfbuzz support disabled, so when cairo will lookup freetype2 dependency
|
||||
# it will be forced to use that one.
|
||||
cairo_dep = dependency('cairo', required: get_option('cairo'))
|
||||
cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo'))
|
||||
cairo_dep = dependency('cairo', version: cairo_min_version, required: get_option('cairo'))
|
||||
cairo_ft_required = get_option('cairo').enabled() and get_option('freetype').enabled()
|
||||
cairo_ft_dep = dependency('cairo-ft', version: cairo_min_version, required: cairo_ft_required)
|
||||
endif
|
||||
endif
|
||||
|
||||
chafa_dep = dependency('chafa', version: '>= 1.6.0', required: get_option('chafa'))
|
||||
chafa_dep = dependency('chafa', version: chafa_min_version, required: get_option('chafa'))
|
||||
|
||||
conf = configuration_data()
|
||||
incconfig = include_directories('.')
|
||||
@@ -175,10 +248,19 @@ endif
|
||||
|
||||
if cairo_dep.found()
|
||||
conf.set('HAVE_CAIRO', 1)
|
||||
check_cairo_funcs = [
|
||||
['cairo_user_font_face_set_render_color_glyph_func', {'deps': cairo_dep}],
|
||||
['cairo_font_options_get_custom_palette_color', {'deps': cairo_dep}],
|
||||
['cairo_user_scaled_font_get_foreground_source', {'deps': cairo_dep}],
|
||||
]
|
||||
|
||||
if cairo_dep.type_name() == 'internal'
|
||||
conf.set('HAVE_CAIRO_USER_FONT_FACE_SET_RENDER_COLOR_GLYPH_FUNC', 1)
|
||||
foreach func: check_cairo_funcs
|
||||
name = func[0]
|
||||
conf.set('HAVE_@0@'.format(name.to_upper()), 1)
|
||||
endforeach
|
||||
else
|
||||
check_funcs += [['cairo_user_font_face_set_render_color_glyph_func', {'deps': cairo_dep}]]
|
||||
check_funcs += check_cairo_funcs
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -190,6 +272,11 @@ if chafa_dep.found()
|
||||
conf.set('HAVE_CHAFA', 1)
|
||||
endif
|
||||
|
||||
if wasm_dep.found()
|
||||
conf.set('HAVE_WASM', 1)
|
||||
conf.set('HB_WASM_MODULE_DIR', '"'+get_option('prefix')+'/'+get_option('libdir')+'/harfbuzz/wasm"')
|
||||
endif
|
||||
|
||||
if graphite2_dep.found() or graphite_dep.found()
|
||||
conf.set('HAVE_GRAPHITE2', 1)
|
||||
endif
|
||||
@@ -304,11 +391,12 @@ foreach check : check_funcs
|
||||
opts = check.get(1, {})
|
||||
link_withs = opts.get('link_with', [])
|
||||
check_deps = opts.get('deps', [])
|
||||
check_prefix = opts.get('prefix', '')
|
||||
extra_deps = []
|
||||
found = true
|
||||
|
||||
# First try without linking
|
||||
found = cpp.has_function(name, dependencies: check_deps)
|
||||
found = cpp.has_function(name, prefix: check_prefix, dependencies: check_deps)
|
||||
|
||||
if not found and link_withs.length() > 0
|
||||
found = true
|
||||
@@ -323,7 +411,7 @@ foreach check : check_funcs
|
||||
endforeach
|
||||
|
||||
if found
|
||||
found = cpp.has_function(name, dependencies: check_deps + extra_deps)
|
||||
found = cpp.has_function(name, prefix: check_prefix, dependencies: check_deps + extra_deps)
|
||||
endif
|
||||
endif
|
||||
|
||||
@@ -333,8 +421,31 @@ foreach check : check_funcs
|
||||
endif
|
||||
endforeach
|
||||
|
||||
# CMake support (package install dir)
|
||||
|
||||
# Equivalent to configure_package_config_file(INSTALL_DESTINATION ...), see
|
||||
# https://cmake.org/cmake/help/latest/module/CMakePackageConfigHelpers.html#command:configure_package_config_file.
|
||||
# In certain unusual packaging layouts such as Nixpkgs, the Harfbuzz package
|
||||
# is installed into two Nix store paths, "out" and "dev", where "out" contains
|
||||
# libraries only (i.e. lib/libharfbuzz.so) and "dev" contains development
|
||||
# files, i.e. include and lib/cmake. If CMake package files are installed to
|
||||
# "out", Nixpkgs will move them to "dev", which breaks assumptions about
|
||||
# our file paths. Since we need to figure out relative install paths here
|
||||
# to make a relocatable package, we do need to know the final path of our
|
||||
# CMake files to calculate the correct relative paths.
|
||||
# Of course, this still defaults to $libdir/cmake if unset, which works for
|
||||
# most packaging layouts.
|
||||
cmake_package_install_dir = get_option('cmakepackagedir')
|
||||
|
||||
if cmake_package_install_dir == ''
|
||||
cmake_package_install_dir = get_option('libdir') / 'cmake'
|
||||
endif
|
||||
|
||||
subdir('src')
|
||||
subdir('util')
|
||||
|
||||
if not get_option('utilities').disabled()
|
||||
subdir('util')
|
||||
endif
|
||||
|
||||
if not get_option('tests').disabled()
|
||||
subdir('test')
|
||||
@@ -350,6 +461,9 @@ endif
|
||||
|
||||
configure_file(output: 'config.h', configuration: conf)
|
||||
|
||||
alias_target('lib', libharfbuzz)
|
||||
alias_target('libs', libharfbuzz, libharfbuzz_subset)
|
||||
|
||||
build_summary = {
|
||||
'Directories':
|
||||
{'prefix': get_option('prefix'),
|
||||
@@ -357,6 +471,7 @@ build_summary = {
|
||||
'libdir': get_option('libdir'),
|
||||
'includedir': get_option('includedir'),
|
||||
'datadir': get_option('datadir'),
|
||||
'cmakepackagedir': cmake_package_install_dir
|
||||
},
|
||||
'Unicode callbacks (you want at least one)':
|
||||
{'Builtin': true,
|
||||
@@ -364,7 +479,8 @@ build_summary = {
|
||||
'ICU': conf.get('HAVE_ICU', 0) == 1,
|
||||
},
|
||||
'Font callbacks (the more the merrier)':
|
||||
{'FreeType': conf.get('HAVE_FREETYPE', 0) == 1,
|
||||
{'Builtin' : true,
|
||||
'FreeType': conf.get('HAVE_FREETYPE', 0) == 1,
|
||||
},
|
||||
'Dependencies used for command-line utilities':
|
||||
{'Cairo': conf.get('HAVE_CAIRO', 0) == 1,
|
||||
@@ -372,15 +488,17 @@ build_summary = {
|
||||
},
|
||||
'Additional shapers':
|
||||
{'Graphite2': conf.get('HAVE_GRAPHITE2', 0) == 1,
|
||||
'WebAssembly (experimental)': conf.get('HAVE_WASM', 0) == 1,
|
||||
},
|
||||
'Platform shapers (not normally needed)':
|
||||
{'CoreText': conf.get('HAVE_CORETEXT', 0) == 1,
|
||||
'DirectWrite': conf.get('HAVE_DIRECTWRITE', 0) == 1,
|
||||
'DirectWrite (experimental)': conf.get('HAVE_DIRECTWRITE', 0) == 1,
|
||||
'GDI/Uniscribe': (conf.get('HAVE_GDI', 0) == 1) and (conf.get('HAVE_UNISCRIBE', 0) == 1),
|
||||
},
|
||||
'Other features':
|
||||
{'Documentation': conf.get('HAVE_GTK_DOC', 0) == 1,
|
||||
'GObject bindings': conf.get('HAVE_GOBJECT', 0) == 1,
|
||||
'Cairo integration': conf.get('HAVE_CAIRO', 0) == 1,
|
||||
'Introspection': conf.get('HAVE_INTROSPECTION', 0) == 1,
|
||||
'Experimental APIs': conf.get('HB_EXPERIMENTAL_API', 0) == 1,
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user