1
0
mirror of https://gitlab.gnome.org/GNOME/libxml2.git synced 2024-12-23 17:33:50 +03:00

meson: Implement option dependencies

This also removes the FreeBSD hack.
This commit is contained in:
Nick Wellnhofer 2024-06-21 22:45:15 +02:00
parent f9c33a5519
commit c2ccbc0fed
4 changed files with 204 additions and 288 deletions

View File

@ -9,12 +9,12 @@ xmlversion_h.set10('WITH_CATALOG', want_catalog)
xmlversion_h.set10('WITH_DEBUG', want_debug)
xmlversion_h.set10('WITH_HTML', want_html)
xmlversion_h.set10('WITH_HTTP', want_http)
xmlversion_h.set10('WITH_ICONV', iconv_dep.found())
xmlversion_h.set10('WITH_ICU', icu_dep.found())
xmlversion_h.set10('WITH_ICONV', want_iconv)
xmlversion_h.set10('WITH_ICU', want_icu)
xmlversion_h.set10('WITH_ISO8859X', want_iso8859x)
xmlversion_h.set10('WITH_LEGACY', want_legacy)
xmlversion_h.set10('WITH_LZMA', lzma_dep.found())
xmlversion_h.set10('WITH_MODULES', dl_dep.found())
xmlversion_h.set10('WITH_LZMA', want_lzma)
xmlversion_h.set10('WITH_MODULES', want_modules)
xmlversion_h.set('MODULE_EXTENSION', module_extension)
xmlversion_h.set10('WITH_OUTPUT', want_output)
xmlversion_h.set10('WITH_PATTERN', want_pattern)
@ -24,14 +24,14 @@ xmlversion_h.set10('WITH_REGEXPS', want_regexps)
xmlversion_h.set10('WITH_SAX1', want_sax1)
xmlversion_h.set10('WITH_SCHEMAS', want_schemas)
xmlversion_h.set10('WITH_SCHEMATRON', want_schematron)
xmlversion_h.set10('WITH_THREADS', threads_dep.found())
xmlversion_h.set10('WITH_THREADS', want_threads)
xmlversion_h.set10('WITH_THREAD_ALLOC', want_thread_alloc)
xmlversion_h.set10('WITH_VALID', want_valid)
xmlversion_h.set10('WITH_WRITER', want_writer)
xmlversion_h.set10('WITH_XINCLUDE', want_xinclude)
xmlversion_h.set10('WITH_XPATH', want_xpath)
xmlversion_h.set10('WITH_XPTR', want_xptr)
xmlversion_h.set10('WITH_ZLIB', zlib_dep.found())
xmlversion_h.set10('WITH_ZLIB', want_zlib)
configure_file(
input: 'xmlversion.h.in',

View File

@ -32,10 +32,8 @@ dir_locale = dir_prefix / get_option('localedir')
host_os = host_machine.system()
bsd = ['freebsd', 'dragonfly']
cygwin = 'cygwin'
windows = 'windows'
sys_bsd = bsd.contains(host_os)
sys_cygwin = cygwin.contains(host_os)
sys_windows = windows.contains(host_os)
@ -55,152 +53,133 @@ endif
cc = meson.get_compiler('c')
# options
want_c14n = get_option('c14n')
want_catalog = get_option('catalog')
want_debug = get_option('debuging')
want_html = get_option('html')
want_http = get_option('http')
want_ipv6 = get_option('ipv6')
want_iso8859x = get_option('iso8859x')
want_legacy = get_option('legacy')
want_output = get_option('output')
want_pattern = get_option('pattern')
want_push = get_option('push')
want_python = get_option('python')
want_reader = get_option('reader')
want_regexps = get_option('regexps')
want_sax1 = get_option('sax1')
want_schemas = get_option('schemas')
want_schematron = get_option('schematron')
want_thread_alloc = get_option('thread-alloc')
want_tls = get_option('tls')
want_valid = get_option('valid')
want_writer = get_option('writer')
want_xinclude = get_option('xinclude')
want_xpath = get_option('xpath')
want_xptr = get_option('xptr')
# TODO: Options should be three-valued: "yes", "no", default
# disabled by default
want_icu = get_option('icu').enabled()
want_legacy = get_option('legacy').enabled()
want_thread_alloc = get_option('thread-alloc').enabled()
want_tls = get_option('tls').enabled()
# TODO: Legacy defaults
# default depends on minimum option
# hard dependencies on options
want_minimum = get_option('minimum')
if want_c14n == true
if want_output == false
message('-Dc14n=true overrides -Doutput')
endif
want_output = true
if want_xpath == false
message('-Dc14n=true overrides -Dxpath')
endif
want_xpath = true
endif
feature = get_option('catalog')
want_catalog = want_minimum ? feature.enabled() : feature.allowed()
if want_schemas == true
if want_pattern == false
message('-Dschemas=true overrides -Dpattern')
endif
want_pattern = true
if want_regexps == false
message('-Dschemas=true overrides -Dregexps')
endif
want_regexps = true
endif
feature = get_option('debugging')
want_debug = want_minimum ? feature.enabled() : feature.allowed()
if want_schematron == true
if want_pattern == false
message('-Dschematron=true overrides -Dpattern')
endif
want_pattern = true
if want_xpath == false
message('-Dschematron=true overrides -Dxpath')
endif
want_xpath = true
endif
feature = get_option('html')
want_html = want_minimum ? feature.enabled() : feature.allowed()
if want_reader == true
if want_push == false
message('-Dreader=true overrides -Dpush')
endif
want_push = true
endif
feature = get_option('iconv')
want_iconv = want_minimum ? feature.enabled() : feature.allowed()
if want_writer == true
if want_output == false
message('-Dwriter=true overrides -Doutput')
endif
want_output = true
if want_push == false
message('-Dwriter=true overrides -Dpush')
endif
want_push = true
endif
feature = get_option('ipv6')
want_ipv6 = want_minimum ? feature.enabled() : feature.allowed()
if want_xinclude == true
if want_xpath == false
message('-Dxinclude=true overrides -Dxpath')
endif
want_xpath = true
endif
feature = get_option('iso8859x')
want_iso8859x = want_minimum ? feature.enabled() : feature.allowed()
if want_xptr == true
if want_xpath == false
message('-Dxptr=true overrides -Dxpath')
endif
want_xpath = true
endif
feature = get_option('iso8859x')
want_python = want_minimum ? feature.enabled() : feature.allowed()
# minimum dependencies
feature = get_option('modules')
want_modules = want_minimum ? feature.enabled() : feature.allowed()
if get_option('minimum')
# TODO: This is should allow other options
want_c14n = false
want_catalog = false
want_debug = false
want_html = false
want_http = false
want_ipv6 = false
want_iso8859x = false
want_output = false
want_pattern = false
want_push = false
want_python = false
want_reader = false
want_regexps = false
want_sax1 = false
want_schemas = false
want_schematron = false
want_thread_alloc = false
want_valid = false
want_writer = false
want_xinclude = false
want_xpath = false
want_xptr = false
else
# Disable dependent modules
if want_output == false
want_c14n = false
want_writer = false
endif
if want_pattern == false
want_schemas = false
want_schematron = false
endif
if want_push == false
want_reader = false
want_writer = false
endif
if want_regexps == false
want_schemas = false
endif
if want_xpath == false
want_c14n = false
want_schematron = false
want_xinclude = false
want_xptr = false
endif
endif
feature = get_option('sax1')
want_sax1 = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('threads')
want_threads = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('valid')
want_valid = want_minimum ? feature.enabled() : feature.allowed()
# default depends on legacy option
feature = get_option('http')
want_http = want_legacy ? feature.allowed() : feature.enabled()
feature = get_option('lzma')
want_lzma = want_legacy ? feature.allowed() : feature.enabled()
feature = get_option('zlib')
want_zlib = want_legacy ? feature.allowed() : feature.enabled()
# dependencies
feature = get_option('output')
want_output = not want_minimum \
or get_option('c14n').enabled() \
or get_option('writer').enabled() ? \
feature.allowed() : feature.enabled()
feature = get_option('pattern')
want_pattern = not want_minimum \
or get_option('schemas').enabled() \
or get_option('schematron').enabled() ? \
feature.allowed() : feature.enabled()
feature = get_option('regexps')
want_regexps = not want_minimum \
or get_option('schemas').enabled() ? \
feature.allowed() : feature.enabled()
feature = get_option('push')
want_push = not want_minimum \
or get_option('reader').enabled() \
or get_option('writer').enabled() ? \
feature.allowed() : feature.enabled()
feature = get_option('readline')
want_readline = get_option('history').enabled() ? \
feature.allowed() : feature.enabled()
feature = get_option('xpath')
want_xpath = not want_minimum \
or get_option('c14n').enabled() \
or get_option('schematron').enabled() \
or get_option('xinclude').enabled() \
or get_option('xptr').enabled() ? \
feature.allowed() : feature.enabled()
feature = get_option('c14n') \
.require(want_output, error_message: 'c14n requires output') \
.require(want_xpath, error_message: 'c14n requires xpath')
want_c14n = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('history') \
.require(want_readline, error_message: 'history requires readline')
want_history = feature.enabled()
feature = get_option('reader') \
.require(want_push, error_message: 'reader requires push')
want_reader = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('schemas') \
.require(want_pattern, error_message: 'schemas requires pattern') \
.require(want_regexps, error_message: 'schemas requires regexps')
want_schemas = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('schematron') \
.require(want_pattern, error_message: 'schematron requires pattern') \
.require(want_xpath, error_message: 'schematron requires xpath')
want_schematron = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('writer') \
.require(want_output, error_message: 'writer requires output') \
.require(want_push, error_message: 'writer requires push')
want_writer = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('xinclude') \
.require(want_xpath, error_message: 'xinclude requires xpath')
want_xinclude = want_minimum ? feature.enabled() : feature.allowed()
feature = get_option('xptr') \
.require(want_xpath, error_message: 'xptr requires xpath')
want_xptr = want_minimum ? feature.enabled() : feature.allowed()
cflags_try = []
@ -314,7 +293,7 @@ if sys_windows == false
endif
### thread local storage
if want_tls == true
if want_tls
tls_src = '''
#include <threads.h>
int main()
@ -370,59 +349,42 @@ else
module_extension = '.so'
endif
dl_dep = dependency('', required: false)
if not get_option('minimum')
if host_machine.system() != 'windows'
if meson.version().version_compare('>=0.62')
dl_dep = dependency('dl', required: get_option('modules'))
else
dl_dep = cc.find_library('dl', required: get_option('modules'))
endif
if dl_dep.found()
config_h.set10('HAVE_DLOPEN', true)
xml_deps += dl_dep
endif
elif get_option('modules').allowed()
dl_dep = declare_dependency()
if want_modules and host_machine.system() != 'windows'
if meson.version().version_compare('>=0.62')
dl_dep = dependency('dl', required: false)
else
dl_dep = cc.find_library('dl', required: false)
endif
if dl_dep.found()
config_h.set10('HAVE_DLOPEN', true)
xml_deps += dl_dep
endif
endif
### threads
threads_dep = dependency('', required: false)
if not get_option('minimum')
if host_machine.system() != 'windows'
threads_dep = dependency('threads', required: get_option('threads'))
if threads_dep.found()
config_h.set10('HAVE_PTHREAD_H', true)
xml_deps += threads_dep
endif
elif get_option('threads').allowed()
threads_dep = declare_dependency()
endif
if want_threads
threads_dep = dependency('threads')
config_h.set10('HAVE_PTHREAD_H', true)
xml_deps += threads_dep
else
threads_dep = dependency('', required: false)
endif
want_thread_alloc = threads_dep.found()
### xmllint shell history
xmllint_deps = []
if not get_option('minimum')
readline_dep = dependency('readline', required: get_option('readline'))
else
readline_dep = dependency('', required: false)
if want_readline
readline_dep = dependency('readline')
config_h.set('HAVE_LIBREADLINE', true)
xmllint_deps += readline_dep
endif
config_h.set('HAVE_LIBREADLINE', readline_dep.found())
xmllint_deps += readline_dep
if not get_option('minimum') and readline_dep.found()
history_dep = dependency('history', required: get_option('history'))
else
history_dep = dependency('', required: false)
if want_history
history_dep = dependency('history')
config_h.set('HAVE_LIBHISTORY', true)
xmllint_deps += history_dep
endif
config_h.set('HAVE_LIBHISTORY', history_dep.found())
xmllint_deps += history_dep
### crypto
if sys_windows == true
bcrypt_dep = cc.find_library('bcrypt', required: true)
@ -529,48 +491,28 @@ int main()
endif
### zlib
if not get_option('minimum')
zlib_dep = dependency('zlib', required: get_option('zlib'))
else
zlib_dep = dependency('', required: false)
if want_zlib
xml_deps += dependency('zlib')
endif
xml_deps += zlib_dep
### lzma
if not get_option('minimum')
lzma_dep = dependency('liblzma', required: get_option('lzma'))
else
lzma_dep = dependency('', required: false)
if want_lzma
xml_deps += dependency('liblzma')
endif
xml_deps += lzma_dep
# icu
icu_dep = dependency('icu-i18n', method: 'pkg-config', required: get_option('icu'))
if icu_dep.found()
if want_icu
icu_dep = dependency('icu-i18n', method: 'pkg-config')
defs = icu_dep.get_variable(pkgconfig: 'DEFS')
if cc.has_argument(defs)
libxml2_cflags += defs
endif
xml_deps += icu_dep
endif
xml_deps += icu_dep
### iconv
if not get_option('minimum')
# this is a hack for the BSDs. The iconv dependency works as long as libiconv is not in the include path.
if sys_bsd and icu_dep.found()
iconv_dep = cc.find_library('iconv', dirs: icu_dep.get_variable(pkgconfig: 'libdir'), required: get_option('iconv'))
else
iconv_dep = dependency('iconv', required: get_option('iconv'))
endif
else
iconv_dep = dependency('', required: false)
endif
xml_deps += iconv_dep
if not iconv_dep.found() and want_iso8859x == false
want_iso8859x = false
else
want_iso8859x = true
if want_iconv
xml_deps += dependency('iconv')
endif
subdir('include/libxml')
@ -610,8 +552,8 @@ xml_opt_src = [
[want_html, ['HTMLparser.c', 'HTMLtree.c']],
[want_http, ['nanohttp.c']],
[want_legacy, ['legacy.c']],
[lzma_dep.found(), ['xzlib.c']],
[dl_dep.found(), ['xmlmodule.c']],
[want_lzma, ['xzlib.c']],
[want_modules, ['xmlmodule.c']],
[want_output, ['xmlsave.c']],
[want_pattern, ['pattern.c']],
[want_reader, ['xmlreader.c']],
@ -729,7 +671,7 @@ pkgmod.generate(
filebase: 'libxml-2.0',
name: 'libXML',
subdirs: [meson.project_name()],
variables: 'modules=' + dl_dep.found().to_string('1', '0'),
variables: 'modules=' + want_modules.to_string('1', '0'),
)
## libxml2-config.cmake file
@ -739,12 +681,12 @@ config_cmake.set('LIBXML_MAJOR_VERSION', v_maj)
config_cmake.set('LIBXML_MINOR_VERSION', v_min)
config_cmake.set('LIBXML_MICRO_VERSION', v_mic)
config_cmake.set('VERSION', meson.project_version())
config_cmake.set('WITH_ICONV', iconv_dep.found().to_int().to_string())
config_cmake.set('WITH_ICU', icu_dep.found().to_int().to_string())
config_cmake.set('WITH_LZMA', lzma_dep.found().to_int().to_string())
config_cmake.set('WITH_MODULES', dl_dep.found().to_int().to_string())
config_cmake.set('WITH_THREADS', threads_dep.found().to_int().to_string())
config_cmake.set('WITH_ZLIB', zlib_dep.found().to_int().to_string())
config_cmake.set('WITH_ICONV', want_iconv.to_int().to_string())
config_cmake.set('WITH_ICU', want_icu.to_int().to_string())
config_cmake.set('WITH_LZMA', want_lzma.to_int().to_string())
config_cmake.set('WITH_MODULES', want_modules.to_int().to_string())
config_cmake.set('WITH_THREADS', want_threads.to_int().to_string())
config_cmake.set('WITH_ZLIB', want_zlib.to_int().to_string())
config_cmake.set('XML_CFLAGS', xml_cflags)
configure_file(
input: 'libxml2-config.cmake.in',
@ -761,27 +703,27 @@ summary(
'c14n': want_c14n,
'catalog': want_catalog,
'debug': want_debug,
'history': history_dep.found(),
'history': want_history,
'html': want_html,
'http': want_http,
'iconv': iconv_dep.found(),
'icu': icu_dep.found(),
'iconv': want_iconv,
'icu': want_icu,
'ipv6': want_ipv6,
'iso8859x': want_iso8859x,
'legacy': want_legacy,
'lzma': lzma_dep.found(),
'modules': dl_dep.found(),
'lzma': want_lzma,
'modules': want_modules,
'output': want_output,
'pattern': want_pattern,
'push': want_push,
'python': want_python,
'reader': want_reader,
'readline': readline_dep.found(),
'readline': want_readline,
'regexps': want_regexps,
'sax1': want_sax1,
'schemas': want_schemas,
'schematron': want_schematron,
'threads': threads_dep.found(),
'threads': want_threads,
'thread-alloc': want_thread_alloc,
'tls': want_tls,
'valid': want_valid,
@ -789,7 +731,7 @@ summary(
'xinclude': want_xinclude,
'xpath': want_xpath,
'xptr': want_xptr,
'zlib': zlib_dep.found(),
'zlib': want_zlib,
},
section: 'Configuration Options Summary:',
)

View File

@ -36,23 +36,18 @@
# [X] minimum
# [X] ipv6
# TODO: Options should be three-valued: "yes", "no", default
option('c14n',
type: 'boolean',
value: true,
type: 'feature',
description: 'Canonical XML 1.0 support'
)
option('catalog',
type: 'boolean',
value: true,
type: 'feature',
description: 'XML Catalogs support'
)
option('debuging',
type: 'boolean',
value: true,
option('debugging',
type: 'feature',
description: 'Debugging module and shell'
)
@ -62,14 +57,12 @@ option('history',
)
option('html',
type: 'boolean',
value: true,
type: 'feature',
description: 'HTML parser'
)
option('http',
type: 'boolean',
value: false,
type: 'feature',
description: 'HTTP support'
)
@ -85,20 +78,17 @@ option('icu',
)
option('ipv6',
type: 'boolean',
value: true,
type: 'feature',
description: 'Compilation of IPv6 code'
)
option('iso8859x',
type: 'boolean',
value: true,
type: 'feature',
description: 'ISO-8859-X support if no iconv'
)
option('legacy',
type: 'boolean',
value: false,
type: 'feature',
description: 'Maximum ABI compatibility'
)
@ -113,61 +103,52 @@ option('modules',
)
option('output',
type: 'boolean',
value: true,
type: 'feature',
description: 'Serialization support'
)
option('pattern',
type: 'boolean',
value: true,
type: 'feature',
description: 'xmlPattern selection interface'
)
option('push',
type: 'boolean',
value: true,
type: 'feature',
description: 'push parser interfaces'
)
option('python',
type: 'boolean',
value: true,
type: 'feature',
description: 'Python bindings'
)
option('reader',
type: 'boolean',
value: true,
type: 'feature',
description: 'xmlReader parsing interface'
)
option('readline',
type: 'feature',
description: 'use readline in DIR (for shell history)'
description: 'use readline for shell history'
)
option('regexps',
type: 'boolean',
value: true,
type: 'feature',
description: 'Regular expressions support'
)
option('sax1',
type: 'boolean',
value: true,
type: 'feature',
description: 'Older SAX1 interface'
)
option('schemas',
type: 'boolean',
value: true,
type: 'feature',
description: 'XML Schemas 1.0 and RELAX NG support'
)
option('schematron',
type: 'boolean',
value: true,
type: 'feature',
description: 'Schematron support'
)
@ -177,44 +158,37 @@ option('threads',
)
option('thread-alloc',
type: 'boolean',
value: false,
type: 'feature',
description: 'per-thread malloc hooks'
)
option('tls',
type: 'boolean',
value: false,
type: 'feature',
description: 'thread-local storage'
)
option('valid',
type: 'boolean',
value: true,
type: 'feature',
description: 'DTD validation support'
)
option('writer',
type: 'boolean',
value: true,
type: 'feature',
description: 'xmlWriter serialization interface'
)
option('xinclude',
type: 'boolean',
value: true,
type: 'feature',
description: 'XInclude 1.0 support'
)
option('xpath',
type: 'boolean',
value: true,
type: 'feature',
description: 'XPath 1.0 support'
)
option('xptr',
type: 'boolean',
value: true,
type: 'feature',
description: 'XPointer support'
)
@ -226,5 +200,5 @@ option('zlib',
option('minimum',
type: 'boolean',
value: false,
description: 'build a minimally sized library (default=false)'
description: 'build a minimally sized library'
)

View File

@ -20,11 +20,11 @@ if py.found() == true
setup_py = configuration_data()
setup_py.set('prefix', get_option('prefix'))
setup_py.set('LIBXML_VERSION', meson.project_version())
setup_py.set('WITH_ICONV', iconv_dep.found().to_int())
setup_py.set('WITH_ICU', icu_dep.found().to_int())
setup_py.set('WITH_LZMA', lzma_dep.found().to_int())
setup_py.set('WITH_ZLIB', zlib_dep.found().to_int())
setup_py.set('WITH_THREADS', threads_dep.found().to_int())
setup_py.set('WITH_ICONV', want_iconv.to_int())
setup_py.set('WITH_ICU', want_icu.to_int())
setup_py.set('WITH_LZMA', want_lzma.to_int())
setup_py.set('WITH_ZLIB', want_zlib.to_int())
setup_py.set('WITH_THREADS', want_threads.to_int())
configure_file(
input: 'setup.py.in',
output: 'setup.py',