Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for Meson build system #1437

Merged
merged 34 commits into from
Mar 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d63a788
Add Meson build definitions
MathieuDuponchelle May 16, 2018
c6e823f
meson: add subproject wraps for dependencies
MathieuDuponchelle May 17, 2018
b678341
meson: refactor fuzzing test
MathieuDuponchelle May 17, 2018
244c6e4
meson: more windows fixes
MathieuDuponchelle May 17, 2018
09398ea
meson: all tests passing on Windows / MSVC
MathieuDuponchelle May 17, 2018
a6b4eae
meson: install
MathieuDuponchelle Jun 5, 2018
f5b038a
meson: pass subdirs to pkgconfig.generate()
MathieuDuponchelle Jun 5, 2018
1baeed2
meson: misc fixes
MathieuDuponchelle Jun 5, 2018
1bce7d3
meson: update minimum meson version
MathieuDuponchelle Jun 18, 2018
3a6c090
meson: remove debug message
MathieuDuponchelle Jul 4, 2018
caf447a
meson: Declare dependencies for use as a subproject
nirbheek Oct 12, 2018
34ca567
meson: fix glib git url
tp-m Nov 12, 2018
6b3bdba
meson: use proxy-libintl from frida
tp-m Nov 12, 2018
ab7d2f8
meson: add options to enable/disable various features
tp-m Nov 12, 2018
7c9b9ef
meson: add feature option for internal ucdn lib
tp-m Nov 12, 2018
c56374f
meson: add option and build system plumbing for uniscribe on Windows
tp-m Nov 12, 2018
1434896
meson: add option and build system plumbing for DirectWrite on Windows
tp-m Nov 12, 2018
32a3e72
meson: add option and build system plumbing for CoreText on macOS/iOS
tp-m Nov 12, 2018
49fc96b
meson: generate .def file for MSVC symbol export on the fly
tp-m Nov 12, 2018
05b173c
meson: add option to disable tests
tp-m Nov 14, 2018
466cb47
meson: add g-i introspection
tp-m Nov 14, 2018
4445259
meson: Fix include directory when used as subproject
khaledhosny Nov 14, 2018
eb7a561
meson: rename incbase to incconfig
tp-m Nov 14, 2018
f6ff493
meson: Update build files after rebase
khaledhosny Nov 14, 2018
e142d68
meson: update for changes in master
tp-m Nov 16, 2018
ff25ffa
meson: suppress some spurious compiler warnings with MSVC
tp-m Dec 1, 2018
0f127d9
meson: fix linking on MSVC
tp-m Dec 1, 2018
4764bf8
meson: pin glib wrap to 2.58.1 release
tp-m Dec 1, 2018
0631000
meson: tests: subset: no need to check for 'which' command any more
tp-m Dec 1, 2018
27d1f3a
meson: tests: shaping: add missing in-house tests
tp-m Dec 2, 2018
77d234f
meson: tests: shaping: add aots tests
tp-m Dec 2, 2018
16f7652
meson: update harfbuzz version
tp-m Dec 2, 2018
6d6976e
meson: provide a harfbuzz-config for use from CMake
tp-m Dec 3, 2018
4289b88
meson: update to latest master
aaron-boxer Jul 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions meson-cc-tests/intel-atomic-primitives-test.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
void memory_barrier (void) { __sync_synchronize (); }
int atomic_add (int *i) { return __sync_fetch_and_add (i, 1); }
int mutex_trylock (int *m) { return __sync_lock_test_and_set (m, 1); }
void mutex_unlock (int *m) { __sync_lock_release (m); }

int main(void) { return 0;}
8 changes: 8 additions & 0 deletions meson-cc-tests/solaris-atomic-operations.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#include <atomic.h>
/* This requires Solaris Studio 12.2 or newer: */
#include <mbarrier.h>
void memory_barrier (void) { __machine_rw_barrier (); }
int atomic_add (volatile unsigned *i) { return atomic_add_int_nv (i, 1); }
void *atomic_ptr_cmpxchg (volatile void **target, void *cmp, void *newval) { return atomic_cas_ptr (target, cmp, newval); }

int main(void) { return 0; }
281 changes: 281 additions & 0 deletions meson.build
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
project('harfbuzz', 'c', 'cpp',
meson_version: '>= 0.47.0',
version: '2.2.0')

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
if hb_version_minor % 2 == 1
hb_libtool_revision = 0 # for unstable releases
else
hb_libtool_revision = hb_version_micro # for stable releases
endif
hb_libtool_age = hb_version_int - hb_libtool_revision
hb_libtool_current = hb_libtool_age
hb_libtool_version_info = '@0@:@1@:@2@'.format(hb_libtool_current, hb_libtool_revision, hb_libtool_age)

pkgmod = import('pkgconfig')
tp-m marked this conversation as resolved.
Show resolved Hide resolved
cpp = meson.get_compiler('cpp')

if cpp.get_id() == '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)
cpp.get_supported_arguments(['/utf-8']), # set the input encoding to utf-8
'-DHB_DLL_EXPORT', # FIXME: shouldn't this be set only on the lib targets?
]
add_project_arguments(msvc_args, language : 'c')
add_project_arguments(msvc_args, language : 'cpp')
# Disable SAFESEH with MSVC for libs that use external deps that are built with MinGW
# noseh_link_args = ['/SAFESEH:NO']
endif

python3 = import('python').find_installation('python3')

check_headers = [
['unistd.h'],
['sys/mman.h'],
['xlocale.h'],
['stdbool.h'],
]

check_funcs = [
['atexit'],
['mprotect'],
['sysconf'],
['getpagesize'],
['mmap'],
['isatty'],
['newlocale'],
['strtod_l'],
['round'],
]

freetype_dep = dependency('freetype2', required: get_option('freetype'),
fallback: ['freetype2', 'freetype_dep'])
glib_dep = dependency('glib-2.0', required: get_option('glib'),
fallback: ['glib', 'libglib_dep'])
gobject_dep = dependency('gobject-2.0', required: get_option('gobject'),
fallback: ['glib', 'libgobject_dep'])
cairo_dep = dependency('cairo', required: get_option('cairo'),
fallback: ['cairo', 'libcairo_dep'])
fontconfig_dep = dependency('fontconfig', required: get_option('fontconfig'),
fallback: ['fontconfig', 'fontconfig_dep'])
graphite2_dep = dependency('graphite2', required: get_option('graphite'))
icu_dep = dependency('icu-uc', required: get_option('icu'))
m_dep = cpp.find_library('m', required: false)

# Ensure that cairo-ft is fetched from the same library as cairo itself
if cairo_dep.found()
if cairo_dep.type_name() == 'pkgconfig'
cairo_ft_dep = dependency('cairo-ft', required: get_option('cairo'))
else
cairo_ft_dep = cairo_dep
endif
else
# Not-found dependency
cairo_ft_dep = dependency('', required: false)
endif

deps = []

conf = configuration_data()
incconfig = include_directories('.')
cpp_args = ['-DHAVE_CONFIG_H']

warn_cflags = [
'-Wno-non-virtual-dtor',
]

cpp_args += cpp.get_supported_arguments(warn_cflags)

if m_dep.found()
deps += [m_dep]
endif

if glib_dep.found()
conf.set('HAVE_GLIB', 1)
deps += [glib_dep]
endif

if gobject_dep.found()
conf.set('HAVE_GOBJECT', 1)
deps += [gobject_dep]
endif

if cairo_dep.found()
conf.set('HAVE_CAIRO', 1)
deps += [cairo_dep]
endif

if cairo_ft_dep.found()
conf.set('HAVE_CAIRO_FT', 1)
deps += [cairo_ft_dep]
endif

if graphite2_dep.found()
conf.set('HAVE_GRAPHITE2', 1)
deps += [graphite2_dep]
endif

if icu_dep.found()
conf.set('HAVE_ICU', 1)
conf.set('HAVE_ICU_BUILTIN', 1)
deps += [icu_dep]
endif

if freetype_dep.found()
conf.set('HAVE_FREETYPE', 1)
deps += [freetype_dep]
check_freetype_funcs = [
['FT_Get_Var_Blend_Coordinates', {'deps': freetype_dep}],
['FT_Set_Var_Blend_Coordinates', {'deps': freetype_dep}],
['FT_Done_MM_Var', {'deps': freetype_dep}],
]

if freetype_dep.type_name() == 'internal'
foreach func: check_freetype_funcs
name = func[0]
conf.set('HAVE_@0@'.format(name.to_upper()), 1)
endforeach
else
check_funcs += check_freetype_funcs
endif
endif

if fontconfig_dep.found()
conf.set('HAVE_FONTCONFIG', 1)
deps += [fontconfig_dep]
endif

# uniscribe (windows) - FIXME: untested
if host_machine.system() == 'windows' and not get_option('uniscribe').disabled()
# TODO: make nicer once we have https://github.com/mesonbuild/meson/issues/3940
if cpp.has_header('usp10.h') and cpp.has_header('windows.h')
foreach usplib : ['usp10', 'gdi32', 'rpcrt4']
deps += [cpp.find_library(usplib, required: true)]
endforeach
conf.set('HAVE_UNISCRIBE', 1)
elif get_option('uniscribe').enabled()
error('uniscribe was enabled explicitly, but some required headers are missing.')
endif
endif

# DirectWrite (windows) - FIXME: untested
if host_machine.system() == 'windows' and not get_option('directwrite').disabled()
if cpp.has_header('dwrite.h')
deps += [cpp.find_library('dwrite', required: true)]
conf.set('HAVE_DIRECTWRITE', 1)
elif get_option('directwrite').enabled()
error('DirectWrite was enabled explicitly, but required header is missing.')
endif
endif

# CoreText (macOS) - FIXME: untested
if host_machine.system() == 'darwin' and not get_option('coretext').disabled()
app_services_dep = dependency('appleframeworks', modules : ['ApplicationServices'], required: false)
if cpp.has_type('CTFontRef', prefix: '#include <ApplicationServices/ApplicationServices.h>', dependencies: app_services_dep)
deps += [app_services_dep]
conf.set('HAVE_CORETEXT', 1)
# On iOS CoreText and CoreGraphics are stand-alone frameworks
# Check for a different symbol to avoid getting cached result
else
coretext_dep = dependency('appleframeworks', modules : ['CoreText'], required: false)
coregraphics_dep = dependency('appleframeworks', modules : ['CoreGraphics'], required: false)
corefoundation_dep = dependency('appleframeworks', modules : ['CoreFoundation'], required: false)
if cpp.has_type('CTRunRef', prefix: '#include <CoreText/CoreText.h>', dependencies: [coretext_dep, coregraphics_dep, corefoundation_dep])
deps += [coretext_dep, coregraphics_dep, corefoundation_dep]
conf.set('HAVE_CORETEXT', 1)
elif get_option('coretext').enabled()
error('CoreText was enabled explicitly, but required headers or frameworks are missing.')
endif
endif
endif

# threads
if host_machine.system() != 'windows'
thread_dep = dependency('threads', required: false)

if thread_dep.found()
conf.set('HAVE_PTHREAD', 1)
deps += [thread_dep]
else
check_headers += ['sched.h']
check_funcs += ['sched_yield', {'link_with': 'rt'}]
endif
endif

conf.set('HAVE_OT', 1)
conf.set('HAVE_FALLBACK', 1)
conf.set_quoted('PACKAGE_NAME', 'HarfBuzz')
conf.set_quoted('PACKAGE_VERSION', meson.project_version())

foreach check : check_headers
name = check[0]

if cpp.has_header(name)
conf.set('HAVE_@0@'.format(name.to_upper().underscorify()), 1)
endif
endforeach

foreach check : check_funcs
name = check[0]
opts = check.get(1, {})
link_withs = opts.get('link_with', [])
check_deps = opts.get('deps', [])
extra_deps = []
found = true

# First try without linking

found = cpp.has_function(name, dependencies: check_deps)

if not found and link_withs.length() > 0
found = true

foreach link_with : link_withs
dep = cpp.find_library(link_with, required: false)
if dep.found()
extra_deps += dep
else
found = false
endif
endforeach

if found
found = cpp.has_function(name, dependencies: check_deps + extra_deps)
endif
endif

if found
deps += extra_deps
conf.set('HAVE_@0@'.format(name.to_upper()), 1)
endif
endforeach

if cpp.links(files('meson-cc-tests/intel-atomic-primitives-test.c'), name: 'Intel atomics')
conf.set('HAVE_INTEL_ATOMIC_PRIMITIVES', 1)
endif

if cpp.links(files('meson-cc-tests/solaris-atomic-operations.c'), name: 'Solaris atomic ops')
conf.set('HAVE_SOLARIS_ATOMIC_OPS', 1)
endif

subdir('src')
subdir('util')

if not get_option('tests').disabled()
subdir('test')
endif

configure_file(output: 'config.h', configuration: conf)
27 changes: 27 additions & 0 deletions meson_options.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# HarfBuzz feature options
option('glib', type: 'feature', value: 'auto',
description: 'Enable GLib unicode functions')
option('gobject', type: 'feature', value: 'disabled',
description: 'Enable GObject bindings')
option('cairo', type: 'feature', value: 'auto',
description: 'Use Cairo graphics library')
option('fontconfig', type: 'feature', value: 'auto',
description: 'Use fontconfig')
option('icu', type: 'feature', value: 'auto',
description: 'Enable ICU library unicode functions')
option('graphite', type: 'feature', value: 'disabled',
description: 'Enable Graphite2 complementary shaper')
option('freetype', type: 'feature', value: 'auto',
description: 'Enable freetype interop helpers')
option('uniscribe', type: 'feature', value: 'disabled',
description: 'Enable Uniscribe shaper backend (Windows only)')
option('directwrite', type: 'feature', value: 'disabled',
description: 'Enable DirectWrite shaper backend on Windows (experimental)')
option('coretext', type: 'feature', value: 'disabled',
description: 'Enable CoreText shaper backend on macOS')

# Common feature options
option('tests', type : 'feature', value : 'auto', yield : true,
description: 'Enable or disable unit tests')
option('introspection', type : 'feature', value : 'disabled', yield : true,
description : 'Generate gobject-introspection bindings (.gir/.typelib files)')
15 changes: 15 additions & 0 deletions src/fix_get_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import re
import argparse

if __name__=='__main__':
parser = argparse.ArgumentParser()
parser.add_argument('input')
parser.add_argument('output')
args = parser.parse_args()

with open(args.input, 'r') as inp:
with open(args.output, 'w') as out:
for l in inp.readlines():
l = re.sub('_t_get_type', '_get_type', l)
l = re.sub('_T \(', ' (', l)
out.write(l)
2 changes: 1 addition & 1 deletion src/gen-def.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@

result = symbols if os.environ.get('PLAIN_LIST', '') else """EXPORTS
%s
LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('.def', ''))
LIBRARY lib%s-0.dll""" % (symbols, output_file.replace ('src/', '').replace ('.def', ''))

with open (output_file, "w") as f: f.write (result)
Loading